Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/linux/addrs: fix point-to-point peer address bug #1239

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/net/linux/addrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static bool parse_msg_addr(struct nlmsghdr *msg, ssize_t len,
for (nlh = msg; NLMSG_OK(nlh, len); nlh = NLMSG_NEXT(nlh, len)) {
struct sa sa;
uint32_t flags;
void *addr;
char if_name[IF_NAMESIZE];

if (nlh->nlmsg_type == NLMSG_DONE) {
Expand Down Expand Up @@ -109,13 +110,19 @@ static bool parse_msg_addr(struct nlmsghdr *msg, ssize_t len,
continue;
}

if (rta_tb[IFA_LOCAL])
/* looks like point-to-point network, use local
* address, instead of peer */
addr = RTA_DATA(rta_tb[IFA_LOCAL]);
else
addr = RTA_DATA(rta_tb[IFA_ADDRESS]);

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]);
sa.u.in.sin_addr.s_addr = *(uint32_t *)addr;
}
else if (ifa->ifa_family == AF_INET6) {
sa_set_in6(&sa, RTA_DATA(rta_tb[IFA_ADDRESS]), 0);
sa_set_in6(&sa, addr, 0);
sa_set_scopeid(&sa, ifa->ifa_index);
}
else
Expand Down
Loading