Commit e4c0e82b authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Clarify IFA_LOCAL code in kernel_netlink.

parent e10eadef
...@@ -1334,13 +1334,16 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res) ...@@ -1334,13 +1334,16 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
struct rtattr *rta; struct rtattr *rta;
len -= NLMSG_ALIGN(sizeof(*addr)); len -= NLMSG_ALIGN(sizeof(*addr));
rta = IFA_RTA(addr); rta = IFA_RTA(addr);
int has_local = 0; /* A _LOCAL TLV may be bound with a _ADDRESS' which int is_local = 0;
represents the peer's address. In this case, ignore _ADDRESS. */
while(RTA_OK(rta, len)) { while(RTA_OK(rta, len)) {
switch(rta->rta_type) { switch(rta->rta_type) {
case IFA_LOCAL: case IFA_LOCAL:
has_local = 1; /* On some point-to-point technologies, there's both _LOCAL
and _ADDRESS, and _ADDRESS is apparently the peer address
while _LOCAL is the one we want. */
is_local = 1;
/* fallthrough */
case IFA_ADDRESS: case IFA_ADDRESS:
switch(addr->ifa_family) { switch(addr->ifa_family) {
case AF_INET: case AF_INET:
...@@ -1357,7 +1360,7 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res) ...@@ -1357,7 +1360,7 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
return -1; return -1;
break; break;
} }
if(has_local) if(is_local)
return 0; return 0;
break; break;
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment