diff --git a/src/net/linux/addrs.c b/src/net/linux/addrs.c index c8a904eda..24bed62e5 100644 --- a/src/net/linux/addrs.c +++ b/src/net/linux/addrs.c @@ -111,8 +111,17 @@ static bool parse_msg_addr(struct nlmsghdr *msg, ssize_t len, if (ifa->ifa_family == AF_INET) { sa_init(&sa, AF_INET); - sa.u.in.sin_addr.s_addr = - *(uint32_t *)RTA_DATA(rta_tb[IFA_ADDRESS]); + if (rta_tb[IFA_LOCAL]) { + /* looks like point-to-point network, use local + * address, instead of peer */ + sa.u.in.sin_addr.s_addr = *( + uint32_t *)RTA_DATA(rta_tb[IFA_LOCAL]); + } + else { + sa.u.in.sin_addr.s_addr = + *(uint32_t *)RTA_DATA( + rta_tb[IFA_ADDRESS]); + } } else if (ifa->ifa_family == AF_INET6) { sa_set_in6(&sa, RTA_DATA(rta_tb[IFA_ADDRESS]), 0);