Commit 98ce8298 authored by Matthieu Boutier's avatar Matthieu Boutier Committed by Juliusz Chroboczek

Fix: ignore peer address of point-to-point interfaces.

Point-to-point interfaces are bound to two link-local addresses: the
local address and the peer address [1].  The former is advertised with
an IFA_LOCAL TLV and the latter with an IFA_ADDRESS TLV.

[1] $ip addr show [...]
    inet6 fe80::1234 peer fe80::5678/128 scope link
parent 40503ba5
...@@ -1312,10 +1312,13 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res) ...@@ -1312,10 +1312,13 @@ 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
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;
case IFA_ADDRESS: case IFA_ADDRESS:
switch(addr->ifa_family) { switch(addr->ifa_family) {
case AF_INET: case AF_INET:
...@@ -1332,6 +1335,8 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res) ...@@ -1332,6 +1335,8 @@ parse_addr_rta(struct ifaddrmsg *addr, int len, struct in6_addr *res)
return -1; return -1;
break; break;
} }
if(has_local)
return 0;
break; break;
default: default:
break; break;
......
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