Index: head/sys/net/if_bridge.c =================================================================== --- head/sys/net/if_bridge.c +++ head/sys/net/if_bridge.c @@ -229,7 +229,7 @@ * Bridge interface list entry. */ struct bridge_iflist { - LIST_ENTRY(bridge_iflist) bif_next; + CK_LIST_ENTRY(bridge_iflist) bif_next; struct ifnet *bif_ifp; /* member if */ struct bstp_port bif_stp; /* STP state */ uint32_t bif_flags; /* member if flags */ @@ -243,8 +243,8 @@ * Bridge route node. */ struct bridge_rtnode { - LIST_ENTRY(bridge_rtnode) brt_hash; /* hash table linkage */ - LIST_ENTRY(bridge_rtnode) brt_list; /* list linkage */ + CK_LIST_ENTRY(bridge_rtnode) brt_hash; /* hash table linkage */ + CK_LIST_ENTRY(bridge_rtnode) brt_list; /* list linkage */ struct bridge_iflist *brt_dst; /* destination if */ unsigned long brt_expire; /* expiration time */ uint8_t brt_flags; /* address flags */ @@ -267,11 +267,11 @@ struct callout sc_brcallout; /* bridge callout */ uint32_t sc_iflist_ref; /* refcount for sc_iflist */ uint32_t sc_iflist_xcnt; /* refcount for sc_iflist */ - LIST_HEAD(, bridge_iflist) sc_iflist; /* member interface list */ - LIST_HEAD(, bridge_rtnode) *sc_rthash; /* our forwarding table */ - LIST_HEAD(, bridge_rtnode) sc_rtlist; /* list version of above */ + CK_LIST_HEAD(, bridge_iflist) sc_iflist; /* member interface list */ + CK_LIST_HEAD(, bridge_rtnode) *sc_rthash; /* our forwarding table */ + CK_LIST_HEAD(, bridge_rtnode) sc_rtlist; /* list version of above */ uint32_t sc_rthash_key; /* key for hash */ - LIST_HEAD(, bridge_iflist) sc_spanlist; /* span ports list */ + CK_LIST_HEAD(, bridge_iflist) sc_spanlist; /* span ports list */ struct bstp_state sc_stp; /* STP state */ uint32_t sc_brtexceeded; /* # of cache drops */ struct ifnet *sc_ifaddr; /* member mac copied from */ @@ -697,8 +697,8 @@ callout_init_mtx(&sc->sc_brcallout, &sc->sc_mtx, 0); - LIST_INIT(&sc->sc_iflist); - LIST_INIT(&sc->sc_spanlist); + CK_LIST_INIT(&sc->sc_iflist); + CK_LIST_INIT(&sc->sc_spanlist); ifp->if_softc = sc; if_initname(ifp, bridge_name, unit); @@ -774,10 +774,10 @@ bridge_stop(ifp, 1); ifp->if_flags &= ~IFF_UP; - while ((bif = LIST_FIRST(&sc->sc_iflist)) != NULL) + while ((bif = CK_LIST_FIRST(&sc->sc_iflist)) != NULL) bridge_delete_member(sc, bif, 0); - while ((bif = LIST_FIRST(&sc->sc_spanlist)) != NULL) { + while ((bif = CK_LIST_FIRST(&sc->sc_spanlist)) != NULL) { bridge_delete_span(sc, bif); } @@ -916,12 +916,12 @@ error = EINVAL; break; } - if (LIST_EMPTY(&sc->sc_iflist)) { + if (CK_LIST_EMPTY(&sc->sc_iflist)) { sc->sc_ifp->if_mtu = ifr->ifr_mtu; break; } BRIDGE_LOCK(sc); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp->if_mtu != ifr->ifr_mtu) { log(LOG_NOTICE, "%s: invalid MTU: %u(%s)" " != %d\n", sc->sc_ifp->if_xname, @@ -961,13 +961,13 @@ /* Initial bitmask of capabilities to test */ mask = BRIDGE_IFCAPS_MASK; - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { /* Every member must support it or its disabled */ mask &= bif->bif_savedcaps; } BRIDGE_XLOCK(sc); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { enabled = bif->bif_ifp->if_capenable; enabled &= ~BRIDGE_IFCAPS_STRIP; /* strip off mask bits and enable them again if allowed */ @@ -1021,7 +1021,7 @@ BRIDGE_LOCK_ASSERT(sc); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { ifp = bif->bif_ifp; if (strcmp(ifp->if_xname, name) == 0) return (bif); @@ -1042,7 +1042,7 @@ BRIDGE_LOCK_ASSERT(sc); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp == member_ifp) return (bif); } @@ -1061,6 +1061,7 @@ { struct ifnet *ifs = bif->bif_ifp; struct ifnet *fif = NULL; + struct bridge_iflist *bifl; BRIDGE_LOCK_ASSERT(sc); @@ -1069,7 +1070,7 @@ ifs->if_bridge = NULL; BRIDGE_XLOCK(sc); - LIST_REMOVE(bif, bif_next); + CK_LIST_REMOVE(bif, bif_next); BRIDGE_XDROP(sc); /* @@ -1078,12 +1079,13 @@ * to its default address if no members are left. */ if (V_bridge_inherit_mac && sc->sc_ifaddr == ifs) { - if (LIST_EMPTY(&sc->sc_iflist)) { + if (CK_LIST_EMPTY(&sc->sc_iflist)) { bcopy(&sc->sc_defaddr, IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN); sc->sc_ifaddr = NULL; } else { - fif = LIST_FIRST(&sc->sc_iflist)->bif_ifp; + bifl = CK_LIST_FIRST(&sc->sc_iflist); + fif = bifl->bif_ifp; bcopy(IF_LLADDR(fif), IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN); sc->sc_ifaddr = fif; @@ -1144,7 +1146,7 @@ KASSERT(bif->bif_ifp->if_bridge == NULL, ("%s: not a span interface", __func__)); - LIST_REMOVE(bif, bif_next); + CK_LIST_REMOVE(bif, bif_next); free(bif, M_DEVBUF); } @@ -1163,7 +1165,7 @@ return (EINVAL); /* If it's in the span list, it can't be a member. */ - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) if (ifs == bif->bif_ifp) return (EBUSY); @@ -1202,7 +1204,7 @@ * interfaces. */ BRIDGE_XLOCK(sc); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (in6ifa_llaonifp(bif->bif_ifp)) { BRIDGE_UNLOCK(sc); in6_ifdetach(bif->bif_ifp); @@ -1228,7 +1230,7 @@ } #endif /* Allow the first Ethernet member to define the MTU */ - if (LIST_EMPTY(&sc->sc_iflist)) + if (CK_LIST_EMPTY(&sc->sc_iflist)) sc->sc_ifp->if_mtu = ifs->if_mtu; else if (sc->sc_ifp->if_mtu != ifs->if_mtu) { if_printf(sc->sc_ifp, "invalid MTU: %u(%s) != %u\n", @@ -1249,7 +1251,7 @@ * member and the MAC address of the bridge has not been changed from * the default randomly generated one. */ - if (V_bridge_inherit_mac && LIST_EMPTY(&sc->sc_iflist) && + if (V_bridge_inherit_mac && CK_LIST_EMPTY(&sc->sc_iflist) && !memcmp(IF_LLADDR(sc->sc_ifp), sc->sc_defaddr.octet, ETHER_ADDR_LEN)) { bcopy(IF_LLADDR(ifs), IF_LLADDR(sc->sc_ifp), ETHER_ADDR_LEN); sc->sc_ifaddr = ifs; @@ -1266,7 +1268,7 @@ * * NOTE: insert_***HEAD*** should be safe for the traversals. */ - LIST_INSERT_HEAD(&sc->sc_iflist, bif, bif_next); + CK_LIST_INSERT_HEAD(&sc->sc_iflist, bif, bif_next); /* Set interface capabilities to the intersection set of all members */ bridge_mutecaps(sc); @@ -1413,9 +1415,9 @@ int count, buflen, len, error = 0; count = 0; - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) count++; - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) count++; buflen = sizeof(breq) * count; @@ -1431,7 +1433,7 @@ buf = outbuf; len = min(bifc->ifbic_len, buflen); bzero(&breq, sizeof(breq)); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (len < sizeof(breq)) break; @@ -1446,7 +1448,7 @@ buf += sizeof(breq); len -= sizeof(breq); } - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) { if (len < sizeof(breq)) break; @@ -1481,7 +1483,7 @@ return (0); count = 0; - LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) + CK_LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) count++; buflen = sizeof(bareq) * count; @@ -1493,7 +1495,7 @@ buf = outbuf; len = min(bac->ifbac_len, buflen); bzero(&bareq, sizeof(bareq)); - LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { + CK_LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { if (len < sizeof(bareq)) goto out; strlcpy(bareq.ifba_ifsname, brt->brt_ifp->if_xname, @@ -1696,7 +1698,7 @@ if (ifs == NULL) return (ENOENT); - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) if (ifs == bif->bif_ifp) return (EBUSY); @@ -1719,7 +1721,7 @@ bif->bif_ifp = ifs; bif->bif_flags = IFBIF_SPAN; - LIST_INSERT_HEAD(&sc->sc_spanlist, bif, bif_next); + CK_LIST_INSERT_HEAD(&sc->sc_spanlist, bif, bif_next); return (0); } @@ -1735,7 +1737,7 @@ if (ifs == NULL) return (ENOENT); - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) if (ifs == bif->bif_ifp) break; @@ -1797,7 +1799,7 @@ int count, buflen, len, error = 0; count = 0; - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if ((bif->bif_flags & IFBIF_STP) != 0) count++; } @@ -1816,7 +1818,7 @@ buf = outbuf; len = min(bifstp->ifbpstp_len, buflen); bzero(&bpreq, sizeof(bpreq)); - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (len < sizeof(bpreq)) break; @@ -1898,7 +1900,7 @@ BRIDGE_LIST_LOCK(); LIST_FOREACH(sc, &V_bridge_list, sc_list) { BRIDGE_LOCK(sc); - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) if (ifp == bif->bif_ifp) { bridge_delete_span(sc, bif); break; @@ -2113,7 +2115,7 @@ return (0); } - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { dst_if = bif->bif_ifp; if (dst_if->if_type == IFT_GIF) @@ -2131,7 +2133,7 @@ bif->bif_stp.bp_state == BSTP_IFSTATE_DISCARDING) continue; - if (LIST_NEXT(bif, bif_next) == NULL) { + if (CK_LIST_NEXT(bif, bif_next) == NULL) { used = 1; mc = m; } else { @@ -2546,7 +2548,7 @@ do { GRAB_OUR_PACKETS(ifp) } while (0); /* Now check the all bridge members. */ - LIST_FOREACH(bif2, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif2, &sc->sc_iflist, bif_next) { GRAB_OUR_PACKETS(bif2->bif_ifp) } @@ -2599,7 +2601,7 @@ goto out; } - LIST_FOREACH(dbif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(dbif, &sc->sc_iflist, bif_next) { dst_if = dbif->bif_ifp; if (dst_if == src_if) continue; @@ -2619,7 +2621,7 @@ if ((dst_if->if_drv_flags & IFF_DRV_RUNNING) == 0) continue; - if (LIST_NEXT(dbif, bif_next) == NULL) { + if (CK_LIST_NEXT(dbif, bif_next) == NULL) { mc = m; used = 1; } else { @@ -2677,10 +2679,10 @@ struct ifnet *dst_if; struct mbuf *mc; - if (LIST_EMPTY(&sc->sc_spanlist)) + if (CK_LIST_EMPTY(&sc->sc_spanlist)) return; - LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_spanlist, bif_next) { dst_if = bif->bif_ifp; if ((dst_if->if_drv_flags & IFF_DRV_RUNNING) == 0) @@ -2816,7 +2818,7 @@ if (sc->sc_brtcnt <= sc->sc_brtmax) return; - LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { + CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) { bridge_rtnode_destroy(sc, brt); if (sc->sc_brtcnt <= sc->sc_brtmax) @@ -2859,7 +2861,7 @@ BRIDGE_LOCK_ASSERT(sc); - LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { + CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if ((brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) { if (time_uptime >= brt->brt_expire) bridge_rtnode_destroy(sc, brt); @@ -2879,7 +2881,7 @@ BRIDGE_LOCK_ASSERT(sc); - LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { + CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if (full || (brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) bridge_rtnode_destroy(sc, brt); } @@ -2922,7 +2924,7 @@ BRIDGE_LOCK_ASSERT(sc); - LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { + CK_LIST_FOREACH_SAFE(brt, &sc->sc_rtlist, brt_list, nbrt) { if (brt->brt_ifp == ifp && (full || (brt->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC)) bridge_rtnode_destroy(sc, brt); @@ -2943,10 +2945,10 @@ M_DEVBUF, M_WAITOK); for (i = 0; i < BRIDGE_RTHASH_SIZE; i++) - LIST_INIT(&sc->sc_rthash[i]); + CK_LIST_INIT(&sc->sc_rthash[i]); sc->sc_rthash_key = arc4random(); - LIST_INIT(&sc->sc_rtlist); + CK_LIST_INIT(&sc->sc_rtlist); } /* @@ -3027,7 +3029,7 @@ BRIDGE_LOCK_ASSERT(sc); hash = bridge_rthash(sc, addr); - LIST_FOREACH(brt, &sc->sc_rthash[hash], brt_hash) { + CK_LIST_FOREACH(brt, &sc->sc_rthash[hash], brt_hash) { dir = bridge_rtnode_addr_cmp(addr, brt->brt_addr); if (dir == 0 && (brt->brt_vlan == vlan || vlan == 0)) return (brt); @@ -3055,9 +3057,9 @@ hash = bridge_rthash(sc, brt->brt_addr); - lbrt = LIST_FIRST(&sc->sc_rthash[hash]); + lbrt = CK_LIST_FIRST(&sc->sc_rthash[hash]); if (lbrt == NULL) { - LIST_INSERT_HEAD(&sc->sc_rthash[hash], brt, brt_hash); + CK_LIST_INSERT_HEAD(&sc->sc_rthash[hash], brt, brt_hash); goto out; } @@ -3066,14 +3068,14 @@ if (dir == 0 && brt->brt_vlan == lbrt->brt_vlan) return (EEXIST); if (dir > 0) { - LIST_INSERT_BEFORE(lbrt, brt, brt_hash); + CK_LIST_INSERT_BEFORE(lbrt, brt, brt_hash); goto out; } - if (LIST_NEXT(lbrt, brt_hash) == NULL) { - LIST_INSERT_AFTER(lbrt, brt, brt_hash); + if (CK_LIST_NEXT(lbrt, brt_hash) == NULL) { + CK_LIST_INSERT_AFTER(lbrt, brt, brt_hash); goto out; } - lbrt = LIST_NEXT(lbrt, brt_hash); + lbrt = CK_LIST_NEXT(lbrt, brt_hash); } while (lbrt != NULL); #ifdef DIAGNOSTIC @@ -3081,7 +3083,7 @@ #endif out: - LIST_INSERT_HEAD(&sc->sc_rtlist, brt, brt_list); + CK_LIST_INSERT_HEAD(&sc->sc_rtlist, brt, brt_list); sc->sc_brtcnt++; return (0); @@ -3097,9 +3099,9 @@ { BRIDGE_LOCK_ASSERT(sc); - LIST_REMOVE(brt, brt_hash); + CK_LIST_REMOVE(brt, brt_hash); - LIST_REMOVE(brt, brt_list); + CK_LIST_REMOVE(brt, brt_list); sc->sc_brtcnt--; brt->brt_dst->bif_addrcnt--; uma_zfree(V_bridge_rtnode_zone, brt); @@ -3126,7 +3128,7 @@ if (age == 0) bridge_rtdelete(sc, ifp, IFBF_FLUSHDYN); else { - LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { + CK_LIST_FOREACH(brt, &sc->sc_rtlist, brt_list) { /* Cap the expiry time to 'age' */ if (brt->brt_ifp == ifp && brt->brt_expire > time_uptime + age && @@ -3664,7 +3666,7 @@ new_link = LINK_STATE_DOWN; hasls = 0; /* Our link is considered up if at least one of our ports is active */ - LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { + CK_LIST_FOREACH(bif, &sc->sc_iflist, bif_next) { if (bif->bif_ifp->if_capabilities & IFCAP_LINKSTATE) hasls++; if (bif->bif_ifp->if_link_state == LINK_STATE_UP) { @@ -3672,7 +3674,7 @@ break; } } - if (!LIST_EMPTY(&sc->sc_iflist) && !hasls) { + if (!CK_LIST_EMPTY(&sc->sc_iflist) && !hasls) { /* If no interfaces support link-state then we default to up */ new_link = LINK_STATE_UP; }