diff options
author | 2017-03-03 08:01:41 +0000 | |
---|---|---|
committer | 2017-03-03 08:01:41 +0000 | |
commit | b3605584c82b70b5969ec99bfcfdc447a33a4579 (patch) | |
tree | 8b314ec66733acf1191d8574d89081ecf929e078 | |
parent | Remove non longer needed splsoftnet()/splx() dances. (diff) | |
download | wireguard-openbsd-b3605584c82b70b5969ec99bfcfdc447a33a4579.tar.xz wireguard-openbsd-b3605584c82b70b5969ec99bfcfdc447a33a4579.zip |
Iterate over the global list of interfaces instead of using the global
list of IPv6 addresses.
ok bluhm@
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 8dd1a2ed0e9..9747dde93e7 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.155 2017/02/09 15:23:35 jca Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.156 2017/03/03 08:01:41 mpi Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -1519,8 +1519,10 @@ find_pfxlist_reachable_router(struct nd_prefix *pr) void pfxlist_onlink_check(void) { + struct ifnet *ifp; + struct ifaddr *ifa; struct nd_prefix *pr; - struct in6_ifaddr *ia6; + struct in6_ifaddr *ia6, *pia6 = NULL; char addr[INET6_ADDRSTRLEN]; /* @@ -1624,42 +1626,54 @@ pfxlist_onlink_check(void) * always be attached. * The precise detection logic is same as the one for prefixes. */ - TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) { - if (!(ia6->ia6_flags & IN6_IFF_AUTOCONF)) - continue; + TAILQ_FOREACH(ifp, &ifnet, if_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + if (ifa->ifa_addr->sa_family != AF_INET6) + continue; + + ia6 = ifatoia6(ifa); + if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0) + continue; - if (ia6->ia6_ndpr == NULL) { /* * This can happen when we first configure the address * (i.e. the address exists, but the prefix does not). * XXX: complicated relationships... */ - continue; + if (ia6->ia6_ndpr == NULL) + continue; + + if (find_pfxlist_reachable_router(ia6->ia6_ndpr)) { + pia6 = ia6; + break; + } } - if (find_pfxlist_reachable_router(ia6->ia6_ndpr)) + if (pia6 != NULL) break; } - if (ia6) { - TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) { - if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0) - continue; - if (ia6->ia6_ndpr == NULL) /* XXX: see above. */ + TAILQ_FOREACH(ifp, &ifnet, if_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + if (ifa->ifa_addr->sa_family != AF_INET6) continue; - if (find_pfxlist_reachable_router(ia6->ia6_ndpr)) - ia6->ia6_flags &= ~IN6_IFF_DETACHED; - else - ia6->ia6_flags |= IN6_IFF_DETACHED; - } - } - else { - TAILQ_FOREACH(ia6, &in6_ifaddr, ia_list) { + ia6 = ifatoia6(ifa); if ((ia6->ia6_flags & IN6_IFF_AUTOCONF) == 0) continue; - ia6->ia6_flags &= ~IN6_IFF_DETACHED; + if (pia6 != NULL) { + /* XXX: see above. */ + if (ia6->ia6_ndpr == NULL) + continue; + + if (find_pfxlist_reachable_router(ia6->ia6_ndpr)) + ia6->ia6_flags &= ~IN6_IFF_DETACHED; + else + ia6->ia6_flags |= IN6_IFF_DETACHED; + } else { + ia6->ia6_flags &= ~IN6_IFF_DETACHED; + } } } } |