diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-06-24 21:00:25 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-06-24 21:00:25 +0000 |
commit | 9c4380a8eea873952968c44b6e2567cd55ba5011 (patch) | |
tree | d5254cdd84bc71793efc3d8e4ce92756811f0fc7 /sys/netinet6/in6.c | |
parent | cb4def77ea11a26ecabee87b4221b746f96d689d (diff) | |
download | FreeBSD-src-9c4380a8eea873952968c44b6e2567cd55ba5011.zip FreeBSD-src-9c4380a8eea873952968c44b6e2567cd55ba5011.tar.gz |
Convert netinet6 to using queue(9) rather than hand-crafted linked lists
for the global IPv6 address list (in6_ifaddr -> in6_ifaddrhead). Adopt
the code styles and conventions present in netinet where possible.
Reviewed by: gnn, bz
MFC after: 6 weeks (possibly not MFCable?)
Diffstat (limited to 'sys/netinet6/in6.c')
-rw-r--r-- | sys/netinet6/in6.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 243fd21..9ad447e 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -684,7 +684,6 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, { INIT_VNET_INET6(ifp->if_vnet); int error = 0, hostIsNew = 0, plen = -1; - struct in6_ifaddr *oia; struct sockaddr_in6 dst6; struct in6_addrlifetime *lt; struct in6_multi_mship *imm; @@ -826,19 +825,13 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, ia->ia_ifa.ifa_dstaddr = NULL; } ia->ia_ifa.ifa_netmask = (struct sockaddr *)&ia->ia_prefixmask; - ia->ia_ifp = ifp; - if ((oia = V_in6_ifaddr) != NULL) { - for ( ; oia->ia_next; oia = oia->ia_next) - continue; - oia->ia_next = ia; - } else - V_in6_ifaddr = ia; - ifa_ref(&ia->ia_ifa); /* if_addrhead */ IF_ADDR_LOCK(ifp); TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_link); IF_ADDR_UNLOCK(ifp); + + TAILQ_INSERT_TAIL(&V_in6_ifaddrhead, ia, ia_link); } /* update timestamp */ @@ -1375,7 +1368,6 @@ static void in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) { INIT_VNET_INET6(ifp->if_vnet); - struct in6_ifaddr *oia; int s = splnet(); IF_ADDR_LOCK(ifp); @@ -1383,31 +1375,19 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) IF_ADDR_UNLOCK(ifp); ifa_free(&ia->ia_ifa); /* if_addrhead */ - oia = ia; - if (oia == (ia = V_in6_ifaddr)) - V_in6_ifaddr = ia->ia_next; - else { - while (ia->ia_next && (ia->ia_next != oia)) - ia = ia->ia_next; - if (ia->ia_next) - ia->ia_next = oia->ia_next; - else { - /* search failed */ - printf("Couldn't unlink in6_ifaddr from in6_ifaddr\n"); - } - } + TAILQ_REMOVE(&V_in6_ifaddrhead, ia, ia_link); /* * Release the reference to the base prefix. There should be a * positive reference. */ - if (oia->ia6_ndpr == NULL) { + if (ia->ia6_ndpr == NULL) { nd6log((LOG_NOTICE, "in6_unlink_ifa: autoconf'ed address " - "%p has no prefix\n", oia)); + "%p has no prefix\n", ia)); } else { - oia->ia6_ndpr->ndpr_refcnt--; - oia->ia6_ndpr = NULL; + ia->ia6_ndpr->ndpr_refcnt--; + ia->ia6_ndpr = NULL; } /* @@ -1415,7 +1395,7 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) * pfxlist_onlink_check() since the release might affect the status of * other (detached) addresses. */ - if ((oia->ia6_flags & IN6_IFF_AUTOCONF)) { + if ((ia->ia6_flags & IN6_IFF_AUTOCONF)) { pfxlist_onlink_check(); } @@ -1423,7 +1403,7 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) * release another refcnt for the link from in6_ifaddr. * Note that we should decrement the refcnt at least once for all *BSD. */ - ifa_free(&oia->ia_ifa); + ifa_free(&ia->ia_ifa); splx(s); } @@ -1941,7 +1921,7 @@ in6_localaddr(struct in6_addr *in6) if (IN6_IS_ADDR_LOOPBACK(in6) || IN6_IS_ADDR_LINKLOCAL(in6)) return 1; - for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) { + TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { if (IN6_ARE_MASKED_ADDR_EQUAL(in6, &ia->ia_addr.sin6_addr, &ia->ia_prefixmask.sin6_addr)) { return 1; @@ -1957,7 +1937,7 @@ in6_is_addr_deprecated(struct sockaddr_in6 *sa6) INIT_VNET_INET6(curvnet); struct in6_ifaddr *ia; - for (ia = V_in6_ifaddr; ia; ia = ia->ia_next) { + TAILQ_FOREACH(ia, &V_in6_ifaddrhead, ia_link) { if (IN6_ARE_ADDR_EQUAL(&ia->ia_addr.sin6_addr, &sa6->sin6_addr) && (ia->ia6_flags & IN6_IFF_DEPRECATED) != 0) |