diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-05 21:48:58 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-05 21:48:58 +0000 |
commit | 52f635294dc2220b27898d3db1703c9464b92fb1 (patch) | |
tree | 5c2d6cca90a4bcc953c4c704201e7c2d7c08188e /sys/netinet6/in6.c | |
parent | 84fa77ca902d7934ca42a7fdd806497b643a8421 (diff) |
Use more queue macros rather than doing it by hand; ok otto@ krw@
Diffstat (limited to 'sys/netinet6/in6.c')
-rw-r--r-- | sys/netinet6/in6.c | 69 |
1 files changed, 26 insertions, 43 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 61fb740b1f2..70700fa9a62 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.63 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: in6.c,v 1.64 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -1252,7 +1252,8 @@ in6_purgeaddr(ifa) /* * leave from multicast groups we have joined for the interface */ - while ((imm = ia->ia6_memberships.lh_first) != NULL) { + while (!LIST_EMPTY(&ia->ia6_memberships)) { + imm = LIST_FIRST(&ia->ia6_memberships); LIST_REMOVE(imm, i6mm_chain); in6_leavegroup(imm); } @@ -1284,7 +1285,7 @@ in6_unlink_ifa(ia, ifp) } } - if (oia->ia6_multiaddrs.lh_first != NULL) { + if (!LIST_EMPTY(&oia->ia6_multiaddrs)) { in6_savemkludge(oia); } @@ -1510,10 +1511,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, p) } } - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (!cmp) @@ -1596,9 +1594,7 @@ in6_ifinit(ifp, ia, sin6, newhost) * if this is its first address, * and to validate the address if necessary. */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -1661,8 +1657,9 @@ in6_savemkludge(oia) IFP_TO_IA6(oia->ia_ifp, ia); if (ia) { /* there is another address */ - for (in6m = oia->ia6_multiaddrs.lh_first; in6m; in6m = next){ - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&oia->ia6_multiaddrs); + in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); IFAFREE(&in6m->in6m_ia->ia_ifa); ia->ia_ifa.ifa_refcnt++; in6m->in6m_ia = ia; @@ -1671,15 +1668,16 @@ in6_savemkludge(oia) } else { /* last address on this if deleted, save */ struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp == oia->ia_ifp) break; } if (mk == NULL) /* this should not happen! */ panic("in6_savemkludge: no kludge space"); - for (in6m = oia->ia6_multiaddrs.lh_first; in6m; in6m = next){ - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&oia->ia6_multiaddrs); + in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); IFAFREE(&in6m->in6m_ia->ia_ifa); /* release reference */ in6m->in6m_ia = NULL; LIST_INSERT_HEAD(&mk->mk_head, in6m, in6m_entry); @@ -1699,12 +1697,14 @@ in6_restoremkludge(ia, ifp) { struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp == ifp) { struct in6_multi *in6m, *next; - for (in6m = mk->mk_head.lh_first; in6m; in6m = next) { - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&ia->ia6_multiaddrs); + in6m != LIST_END(&ia->ia6_multiaddrs); + in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); in6m->in6m_ia = ia; ia->ia_ifa.ifa_refcnt++; LIST_INSERT_HEAD(&ia->ia6_multiaddrs, @@ -1733,7 +1733,7 @@ in6_createmkludge(ifp) { struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { /* If we've already had one, do not allocate. */ if (mk->mk_ifp == ifp) return; @@ -1754,7 +1754,7 @@ in6_purgemkludge(ifp) struct multi6_kludge *mk; struct in6_multi *in6m; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp != ifp) continue; @@ -1931,10 +1931,7 @@ in6ifa_ifpforlinklocal(ifp, ignoreflags) { struct ifaddr *ifa; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -1961,10 +1958,7 @@ in6ifa_ifpwithaddr(ifp, addr) { struct ifaddr *ifa; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -2243,9 +2237,7 @@ in6_ifawithscope(oifp, dst) if (in6_addr2scopeid(ifp, dst) != in6_addr2scopeid(oifp, dst)) continue; - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { int tlen = -1, dscopecmp, bscopecmp, matchcmp; if (ifa->ifa_addr->sa_family != AF_INET6) @@ -2481,10 +2473,7 @@ in6_ifawithifp(ifp, dst) * If two or more, return one which matches the dst longest. * If none, return one of global addresses assigned other ifs. */ - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -2518,10 +2507,7 @@ in6_ifawithifp(ifp, dst) if (besta) return (besta); - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -2565,10 +2551,7 @@ in6_if_up(ifp) in6_ifattach(ifp, NULL); dad_delay = 0; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; |