diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-04-20 21:05:37 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-04-20 21:05:37 +0000 |
commit | 084ce14c28bf83c651c7963eacdea97f7f32d914 (patch) | |
tree | 162325e49cec3a202b9dc1058c809a24759ab1b5 | |
parent | dd96787bc78284b906ccfb55f8cd2228da7bfaf9 (diff) | |
download | FreeBSD-src-084ce14c28bf83c651c7963eacdea97f7f32d914.zip FreeBSD-src-084ce14c28bf83c651c7963eacdea97f7f32d914.tar.gz |
Use TAILQ_FOREACH() and TAILQ_FOREACH_SAFE() rather than manually
accessing queue(9) structure fields for if_addrhead.
Prefer FreeBSD field name if_addrhead to compatibility macro
if_addrlist.
MFC after: 2 weeks
-rw-r--r-- | sys/netinet6/icmp6.c | 5 | ||||
-rw-r--r-- | sys/netinet6/in6.c | 21 | ||||
-rw-r--r-- | sys/netinet6/in6_ifattach.c | 13 | ||||
-rw-r--r-- | sys/netinet6/in6_var.h | 2 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 3 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 6 |
6 files changed, 21 insertions, 29 deletions
diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 0472139..2f4dc3e 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1689,7 +1689,7 @@ ni6_addrs(struct icmp6_nodeinfo *ni6, struct mbuf *m, struct ifnet **ifpp, for (ifp = TAILQ_FIRST(&V_ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) { addrsofif = 0; IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifa6 = (struct in6_ifaddr *)ifa; @@ -1776,8 +1776,7 @@ ni6_store_addrs(struct icmp6_nodeinfo *ni6, struct icmp6_nodeinfo *nni6, for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) { IF_ADDR_LOCK(ifp); - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifa6 = (struct in6_ifaddr *)ifa; diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index d997057..662cdc5 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -816,7 +816,7 @@ in6_update_ifa(struct ifnet *ifp, struct in6_aliasreq *ifra, ia->ia_ifa.ifa_refcnt = 1; IF_ADDR_LOCK(ifp); - TAILQ_INSERT_TAIL(&ifp->if_addrlist, &ia->ia_ifa, ifa_list); + TAILQ_INSERT_TAIL(&ifp->if_addrhead, &ia->ia_ifa, ifa_list); IF_ADDR_UNLOCK(ifp); } @@ -1178,7 +1178,7 @@ in6_unlink_ifa(struct in6_ifaddr *ia, struct ifnet *ifp) int s = splnet(); IF_ADDR_LOCK(ifp); - TAILQ_REMOVE(&ifp->if_addrlist, &ia->ia_ifa, ifa_list); + TAILQ_REMOVE(&ifp->if_addrhead, &ia->ia_ifa, ifa_list); IF_ADDR_UNLOCK(ifp); oia = ia; @@ -1231,8 +1231,7 @@ in6_purgeif(struct ifnet *ifp) { struct ifaddr *ifa, *nifa; - for (ifa = TAILQ_FIRST(&ifp->if_addrlist); ifa != NULL; ifa = nifa) { - nifa = TAILQ_NEXT(ifa, ifa_list); + TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_list, nifa) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; in6_purgeaddr(ifa); @@ -1415,7 +1414,7 @@ in6_lifaddr_ioctl(struct socket *so, u_long cmd, caddr_t data, } IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (!cmp) @@ -1514,7 +1513,7 @@ in6_ifinit(struct ifnet *ifp, struct in6_ifaddr *ia, * and to validate the address if necessary. */ IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifacount++; @@ -1630,7 +1629,7 @@ in6ifa_ifpforlinklocal(struct ifnet *ifp, int ignoreflags) struct ifaddr *ifa; IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (IN6_IS_ADDR_LINKLOCAL(IFA_IN6(ifa))) { @@ -1654,7 +1653,7 @@ in6ifa_ifpwithaddr(struct ifnet *ifp, struct in6_addr *addr) { struct ifaddr *ifa; - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (IN6_ARE_ADDR_EQUAL(addr, IFA_IN6(ifa))) @@ -1859,7 +1858,7 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst) * If none, return one of global addresses assigned other ifs. */ IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -1895,7 +1894,7 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst) return (besta); } - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -1934,7 +1933,7 @@ in6_if_up(struct ifnet *ifp) struct in6_ifaddr *ia; IF_ADDR_LOCK(ifp); - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 68b3542..4cf4862 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -233,9 +233,7 @@ in6_get_hw_ifid(struct ifnet *ifp, struct in6_addr *in6) static u_int8_t allone[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family != AF_LINK) continue; sdl = (struct sockaddr_dl *)ifa->ifa_addr; @@ -750,17 +748,14 @@ in6_ifdetach(struct ifnet *ifp) nd6_purge(ifp); /* nuke any of IPv6 addresses we have */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = next) { - next = ifa->ifa_list.tqe_next; + TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_list, next) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; in6_purgeaddr(ifa); } /* undo everything done by in6_ifattach(), just in case */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = next) { - next = ifa->ifa_list.tqe_next; - + TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_list, next) { if (ifa->ifa_addr->sa_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&satosin6(&ifa->ifa_addr)->sin6_addr)) { continue; @@ -788,7 +783,7 @@ in6_ifdetach(struct ifnet *ifp) } /* remove from the linked list */ - TAILQ_REMOVE(&ifp->if_addrlist, (struct ifaddr *)ia, ifa_list); + TAILQ_REMOVE(&ifp->if_addrhead, (struct ifaddr *)ia, ifa_list); IFAFREE(&ia->ia_ifa); /* also remove from the IPv6 address chain(itojun&jinmei) */ diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index b5dba5e..e18f740 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -503,7 +503,7 @@ MALLOC_DECLARE(M_IP6MADDR); /* struct in6_ifaddr *ia; */ \ do { \ struct ifaddr *ifa; \ - TAILQ_FOREACH(ifa, &(ifp)->if_addrlist, ifa_list) { \ + TAILQ_FOREACH(ifa, &(ifp)->if_addrhead, ifa_list) { \ if (ifa->ifa_addr->sa_family == AF_INET6) \ break; \ } \ diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index ef0c825..a6b7974 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -727,8 +727,7 @@ regen_tmpaddr(struct in6_ifaddr *ia6) struct in6_ifaddr *public_ifa6 = NULL; ifp = ia6->ia_ifa.ifa_ifp; - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { struct in6_ifaddr *it6; if (ifa->ifa_addr->sa_family != AF_INET6) diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 1b59db7..525bfba 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -442,7 +442,7 @@ nd6_rtmsg(int cmd, struct rtentry *rt) info.rti_info[RTAX_NETMASK] = rt_mask(rt); if (rt->rt_ifp) { info.rti_info[RTAX_IFP] = - TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; + TAILQ_FIRST(&rt->rt_ifp->if_addrhead)->ifa_addr; info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; } @@ -1120,7 +1120,7 @@ prelist_update(struct nd_prefixctl *new, struct nd_defrouter *dr, * consider autoconfigured addresses while RFC2462 simply said * "address". */ - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { struct in6_ifaddr *ifa6; u_int32_t remaininglifetime; @@ -1592,7 +1592,7 @@ nd6_prefix_onlink(struct nd_prefix *pr) IN6_IFF_NOTREADY | IN6_IFF_ANYCAST); if (ifa == NULL) { /* XXX: freebsd does not have ifa_ifwithaf */ - TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_list) { if (ifa->ifa_addr->sa_family == AF_INET6) break; } |