On Sun, 23 Sep 2012, Stefan Sperling wrote:

> On Thu, Sep 20, 2012 at 10:11:20AM +0200, Camiel Dobbelaar wrote:
> > I need help testing this bridge diff, as I cannot test (or even imagine) 
> > all the possible bridge setups.
> > 
> > It brings a nice speed improvement and simplifies the code.
> > 
> > Testing especially appreciated with gif, tun and vether interfaces in the 
> > bridge.
> > 
> > I can provide i386 and amd64 kernels to make it convenient.  :-)
> > 
> > Thanks!
> 
> The diff reads fine. I like the idea, storing a pointer to the bridge
> port itself makes much more sense than having everyone and their uncle
> loop over the iflist in the bridge softc to find the port.
> 
> I'll note that apart from making the output path more efficient this
> diff also hides the bridge iflist internals inside the bridge core code.
> Are you planning on changing the list to e.g. a tree going forward?

I think the list is ok as long as it's for simple bridge maintenance.  Not 
for lookups.

There is one performance killer still there that loops over the list to 
compare MAC addresses to see if the packet is for the machine itself.  I 
think it may be possible to use the bridge routecache for this.  So that 
MAC addresses of bridgeports point to "self".  There is also a carp 
check in there unfortunately, which may make this a bit harder.
 
> I'm gonna test this on my firewalls. Let's see if it runs as well
> as it looks :)
> 
> There are two small changes buried in the diff which are unrelated
> to the overall change you're making to the bridge code, see below.

Yes, the mbuf.h change as well.  I'll commit those seperately.

And a new diff,  A misplaced bracket in in_arpinput() caused make release 
to fail (as you noticed).


Index: dev/isa/if_ie.c
===================================================================
RCS file: /cvs/src/sys/dev/isa/if_ie.c,v
retrieving revision 1.35
diff -u -p -r1.35 if_ie.c
--- dev/isa/if_ie.c     28 Nov 2008 02:44:17 -0000      1.35
+++ dev/isa/if_ie.c     24 Sep 2012 15:14:52 -0000
@@ -1054,16 +1054,16 @@ check_eh(sc, eh, to_bpf)
                 */
 #if NBPFILTER > 0
                *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0) ||
-                   (sc->sc_arpcom.ac_if.if_bridge != NULL);
+                   (sc->sc_arpcom.ac_if.if_bridgeport != NULL);
 #else
-               *to_bpf = (sc->sc_arpcom.ac_if.if_bridge != NULL);
+               *to_bpf = (sc->sc_arpcom.ac_if.if_bridgeport != NULL);
 #endif
                /* If for us, accept and hand up to BPF */
                if (ether_equal(eh->ether_dhost, sc->sc_arpcom.ac_enaddr))
                        return 1;
 
 #if NBPFILTER > 0
-               if (*to_bpf && sc->sc_arpcom.ac_if.if_bridge == NULL)
+               if (*to_bpf && sc->sc_arpcom.ac_if.if_bridgeport == NULL)
                        *to_bpf = 2; /* we don't need to see it */
 #endif
 
@@ -1095,9 +1095,9 @@ check_eh(sc, eh, to_bpf)
                 */
 #if NBPFILTER > 0
                *to_bpf = (sc->sc_arpcom.ac_if.if_bpf != 0) ||
-                   (sc->sc_arpcom.ac_if.if_bridge != NULL);
+                   (sc->sc_arpcom.ac_if.if_bridgeport != NULL);
 #else
-               *to_bpf = (sc->sc_arpcom.ac_if.if_bridge != NULL);
+               *to_bpf = (sc->sc_arpcom.ac_if.if_bridgeport != NULL);
 #endif
                /* We want to see multicasts. */
                if (eh->ether_dhost[0] & 1)
@@ -1109,7 +1109,7 @@ check_eh(sc, eh, to_bpf)
 
                /* Anything else goes to BPF but nothing else. */
 #if NBPFILTER > 0
-               if (*to_bpf && sc->sc_arpcom.ac_if.if_bridge == NULL)
+               if (*to_bpf && sc->sc_arpcom.ac_if.if_bridgeport == NULL)
                        *to_bpf = 2;
 #endif
                return 1;
Index: net/bridgestp.c
===================================================================
RCS file: /cvs/src/sys/net/bridgestp.c,v
retrieving revision 1.41
diff -u -p -r1.41 bridgestp.c
--- net/bridgestp.c     20 Sep 2012 14:10:18 -0000      1.41
+++ net/bridgestp.c     24 Sep 2012 15:14:52 -0000
@@ -1641,7 +1641,6 @@ void
 bstp_ifstate(void *arg)
 {
        struct ifnet *ifp = (struct ifnet *)arg;
-       struct bridge_softc *sc;
        struct bridge_iflist *p;
        struct bstp_port *bp;
        struct bstp_state *bs;
@@ -1649,16 +1648,11 @@ bstp_ifstate(void *arg)
 
        if (ifp->if_type == IFT_BRIDGE)
                return;
-       sc = (struct bridge_softc *)ifp->if_bridge;
 
        s = splnet();
-       LIST_FOREACH(p, &sc->sc_iflist, next) {
-               if ((p->bif_flags & IFBIF_STP) == 0)
-                       continue;
-               if (p->ifp == ifp)
-                       break;
-       }
-       if (p == LIST_END(&sc->sc_iflist))
+       if ((p = (struct bridge_iflist *)ifp->if_bridgeport) == NULL)
+               goto done;
+       if ((p->bif_flags & IFBIF_STP) == 0)
                goto done;
        if ((bp = p->bif_stp) == NULL)
                goto done;
@@ -2121,7 +2115,7 @@ bstp_ifsflags(struct bstp_port *bp, u_in
 int
 bstp_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
-       struct bridge_softc *sc = (struct bridge_softc *)ifp;
+       struct bridge_softc *sc = (struct bridge_softc *)ifp->if_softc;
        struct bstp_state *bs = sc->sc_stp;
        struct ifbrparam *ifbp = (struct ifbrparam *)data;
        struct ifbreq *ifbr = (struct ifbreq *)data;
@@ -2138,15 +2132,8 @@ bstp_ioctl(struct ifnet *ifp, u_long cmd
                        err = ENOENT;
                        break;
                }
-               if ((caddr_t)sc != ifs->if_bridge) {
-                       err = ESRCH;
-                       break;
-               }
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (p->ifp == ifs)
-                               break;
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        err = ESRCH;
                        break;
                }
Index: net/if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.244
diff -u -p -r1.244 if.c
--- net/if.c    19 Sep 2012 16:14:01 -0000      1.244
+++ net/if.c    24 Sep 2012 15:14:52 -0000
@@ -531,7 +531,7 @@ if_detach(struct ifnet *ifp)
 
 #if NBRIDGE > 0
        /* Remove the interface from any bridge it is part of.  */
-       if (ifp->if_bridge)
+       if (ifp->if_bridgeport)
                bridge_ifdetach(ifp);
 #endif
 
@@ -1094,7 +1094,7 @@ if_down(struct ifnet *ifp)
                carp_carpdev_state(ifp);
 #endif
 #if NBRIDGE > 0
-       if (ifp->if_bridge)
+       if (ifp->if_bridgeport)
                bstp_ifstate(ifp);
 #endif
        rt_ifmsg(ifp);
@@ -1130,7 +1130,7 @@ if_up(struct ifnet *ifp)
                carp_carpdev_state(ifp);
 #endif
 #if NBRIDGE > 0
-       if (ifp->if_bridge)
+       if (ifp->if_bridgeport)
                bstp_ifstate(ifp);
 #endif
        rt_ifmsg(ifp);
Index: net/if.h
===================================================================
RCS file: /cvs/src/sys/net/if.h,v
retrieving revision 1.134
diff -u -p -r1.134 if.h
--- net/if.h    19 Sep 2012 15:29:53 -0000      1.134
+++ net/if.h    24 Sep 2012 15:14:52 -0000
@@ -270,7 +270,7 @@ struct ifnet {                              /* and the 
entries */
        char    if_xname[IFNAMSIZ];     /* external name (name + unit) */
        int     if_pcount;              /* number of promiscuous listeners */
        caddr_t if_bpf;                 /* packet filter structure */
-       caddr_t if_bridge;              /* bridge structure */
+       caddr_t if_bridgeport;          /* used by bridge ports */
        caddr_t if_tp;                  /* used by trunk ports */
        caddr_t if_pf_kif;              /* pf interface abstraction */
        union {
Index: net/if_bridge.c
===================================================================
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.196
diff -u -p -r1.196 if_bridge.c
--- net/if_bridge.c     20 Sep 2012 14:10:18 -0000      1.196
+++ net/if_bridge.c     24 Sep 2012 15:14:52 -0000
@@ -273,7 +273,7 @@ bridge_delete(struct bridge_softc *sc, s
        if (p->bif_flags & IFBIF_STP)
                bstp_delete(p->bif_stp);
 
-       p->ifp->if_bridge = NULL;
+       p->ifp->if_bridgeport = NULL;
        error = ifpromisc(p->ifp, 0);
 
        LIST_REMOVE(p, next);
@@ -310,11 +310,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if (ifs->if_bridge == (caddr_t)sc) {
-                       error = EEXIST;
-                       break;
-               }
-               if (ifs->if_bridge != NULL) {
+               if (ifs->if_bridgeport != NULL) {
                        error = EBUSY;
                        break;
                }
@@ -384,28 +380,28 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        break;
                }
 
+               p->bridge_sc = sc;
                p->ifp = ifs;
                p->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
                SIMPLEQ_INIT(&p->bif_brlin);
                SIMPLEQ_INIT(&p->bif_brlout);
-               ifs->if_bridge = (caddr_t)sc;
+               ifs->if_bridgeport = (caddr_t)p;
                LIST_INSERT_HEAD(&sc->sc_iflist, p, next);
                break;
        case SIOCBRDGDEL:
                if ((error = suser(curproc, 0)) != 0)
                        break;
-
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (strncmp(p->ifp->if_xname, req->ifbr_ifsname,
-                           sizeof(p->ifp->if_xname)) == 0) {
-                               error = bridge_delete(sc, p);
-                               break;
-                       }
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               ifs = ifunit(req->ifbr_ifsname);
+               if (ifs == NULL) {
                        error = ENOENT;
                        break;
                }
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
+                       error = ESRCH;
+                       break;
+               }
+               error = bridge_delete(sc, p);
                break;
        case SIOCBRDGIFS:
                error = bridge_bifconf(sc, (struct ifbifconf *)data);
@@ -418,11 +414,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if (ifs->if_bridge == (caddr_t)sc) {
-                       error = EEXIST;
-                       break;
-               }
-               if (ifs->if_bridge != NULL) {
+               if (ifs->if_bridgeport != NULL) {
                        error = EBUSY;
                        break;
                }
@@ -467,15 +459,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if ((caddr_t)sc != ifs->if_bridge) {
-                       error = ESRCH;
-                       break;
-               }
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (p->ifp == ifs)
-                               break;
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        error = ESRCH;
                        break;
                }
@@ -515,15 +500,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if ((caddr_t)sc != ifs->if_bridge) {
-                       error = ESRCH;
-                       break;
-               }
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (p->ifp == ifs)
-                               break;
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        error = ESRCH;
                        break;
                }
@@ -561,15 +539,13 @@ bridge_ioctl(struct ifnet *ifp, u_long c
        case SIOCBRDGSADDR:
                if ((error = suser(curproc, 0)) != 0)
                        break;
-
                ifs = ifunit(bareq->ifba_ifsname);
                if (ifs == NULL) {                      /* no such interface */
                        error = ENOENT;
                        break;
                }
-
-               if (ifs->if_bridge == NULL ||
-                   ifs->if_bridge != (caddr_t)sc) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        error = ESRCH;
                        break;
                }
@@ -626,16 +602,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if (ifs->if_bridge == NULL ||
-                   ifs->if_bridge != (caddr_t)sc) {
-                       error = ESRCH;
-                       break;
-               }
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (p->ifp == ifs)
-                               break;
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        error = ESRCH;
                        break;
                }
@@ -664,16 +632,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
                        error = ENOENT;
                        break;
                }
-               if (ifs->if_bridge == NULL ||
-                   ifs->if_bridge != (caddr_t)sc) {
-                       error = ESRCH;
-                       break;
-               }
-               LIST_FOREACH(p, &sc->sc_iflist, next) {
-                       if (p->ifp == ifs)
-                               break;
-               }
-               if (p == LIST_END(&sc->sc_iflist)) {
+               p = (struct bridge_iflist *)ifs->if_bridgeport;
+               if (p == NULL || p->bridge_sc != sc) {
                        error = ESRCH;
                        break;
                }
@@ -731,51 +691,49 @@ bridge_ioctl(struct ifnet *ifp, u_long c
 void
 bridge_ifdetach(struct ifnet *ifp)
 {
-       struct bridge_softc *sc = (struct bridge_softc *)ifp->if_bridge;
+       struct bridge_softc *sc;
        struct bridge_iflist *bif;
 
-       LIST_FOREACH(bif, &sc->sc_iflist, next)
-               if (bif->ifp == ifp) {
-                       bridge_delete(sc, bif);
-                       break;
-               }
+       bif = (struct bridge_iflist *)ifp->if_bridgeport;
+       sc = bif->bridge_sc;
+
+       bridge_delete(sc, bif);
 }
 
 void
 bridge_update(struct ifnet *ifp, struct ether_addr *ea, int delete)
 {
-       struct bridge_softc *sc = (struct bridge_softc *)ifp->if_bridge;
+       struct bridge_softc *sc;
        struct bridge_iflist *bif;
        u_int8_t *addr;
 
        addr = (u_int8_t *)ea;
 
-       LIST_FOREACH(bif, &sc->sc_iflist, next)
-               if (bif->ifp == ifp) {
-                       /*
-                        * Update the bridge interface if it is in
-                        * the learning state.
-                        */
-                       if ((bif->bif_flags & IFBIF_LEARNING) &&
-                           (ETHER_IS_MULTICAST(addr) == 0) &&
-                           !(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 &&
-                           addr[3] == 0 && addr[4] == 0 && addr[5] == 0)) {
-                               /* Care must be taken with spanning tree */
-                               if ((bif->bif_flags & IFBIF_STP) &&
-                                   (bif->bif_state == BSTP_IFSTATE_DISCARDING))
-                                       return;
-
-                               /* Delete the address from the bridge */
-                               bridge_rtdaddr(sc, ea);
+       bif = (struct bridge_iflist *)ifp->if_bridgeport;
+       sc = bif->bridge_sc;
 
-                               if (!delete) {
-                                       /* Update the bridge table */
-                                       bridge_rtupdate(sc, ea, ifp, 0,
-                                           IFBAF_DYNAMIC);
-                               }
-                       }
+       /*
+        * Update the bridge interface if it is in
+        * the learning state.
+        */
+       if ((bif->bif_flags & IFBIF_LEARNING) &&
+           (ETHER_IS_MULTICAST(addr) == 0) &&
+           !(addr[0] == 0 && addr[1] == 0 && addr[2] == 0 &&
+           addr[3] == 0 && addr[4] == 0 && addr[5] == 0)) {
+               /* Care must be taken with spanning tree */
+               if ((bif->bif_flags & IFBIF_STP) &&
+                   (bif->bif_state == BSTP_IFSTATE_DISCARDING))
                        return;
+
+               /* Delete the address from the bridge */
+               bridge_rtdaddr(sc, ea);
+
+               if (!delete) {
+                       /* Update the bridge table */
+                       bridge_rtupdate(sc, ea, ifp, 0, IFBAF_DYNAMIC);
                }
+       }
+       return;
 }
 
 int
@@ -879,13 +837,8 @@ bridge_brlconf(struct bridge_softc *sc, 
        ifp = ifunit(bc->ifbrl_ifsname);
        if (ifp == NULL)
                return (ENOENT);
-       if (ifp->if_bridge == NULL || ifp->if_bridge != (caddr_t)sc)
-               return (ESRCH);
-       LIST_FOREACH(ifl, &sc->sc_iflist, next) {
-               if (ifl->ifp == ifp)
-                       break;
-       }
-       if (ifl == LIST_END(&sc->sc_iflist))
+       ifl = (struct bridge_iflist *)ifp->if_bridgeport;
+       if (ifl == NULL || ifl->bridge_sc != sc)
                return (ESRCH);
 
        SIMPLEQ_FOREACH(n, &ifl->bif_brlin, brl_next) {
@@ -1005,11 +958,11 @@ bridge_output(struct ifnet *ifp, struct 
 #endif /* IPSEC */
 
        /* ifp must be a member interface of the bridge. */ 
-       sc = (struct bridge_softc *)ifp->if_bridge;
-       if (sc == NULL) {
+       if (ifp->if_bridgeport == NULL) {
                m_freem(m);
                return (EINVAL);
        }
+       sc = ((struct bridge_iflist *)ifp->if_bridgeport)->bridge_sc;
 
        if (m->m_len < sizeof(*eh)) {
                m = m_pullup(m, sizeof(*eh));
@@ -1207,11 +1160,8 @@ bridgeintr_frame(struct bridge_softc *sc
        sc->sc_if.if_ipackets++;
        sc->sc_if.if_ibytes += m->m_pkthdr.len;
 
-       LIST_FOREACH(ifl, &sc->sc_iflist, next)
-               if (ifl->ifp == src_if)
-                       break;
-
-       if (ifl == LIST_END(&sc->sc_iflist)) {
+       ifl = (struct bridge_iflist *)src_if->if_bridgeport;
+       if (ifl == NULL) {
                m_freem(m);
                return;
        }
@@ -1327,14 +1277,7 @@ bridgeintr_frame(struct bridge_softc *sc
                m_freem(m);
                return;
        }
-       LIST_FOREACH(ifl, &sc->sc_iflist, next) {
-               if (ifl->ifp == dst_if)
-                       break;
-       }
-       if (ifl == LIST_END(&sc->sc_iflist)) {
-               m_freem(m);
-               return;
-       }
+       ifl = (struct bridge_iflist *)dst_if->if_bridgeport;
        if ((ifl->bif_flags & IFBIF_STP) &&
            (ifl->bif_state == BSTP_IFSTATE_DISCARDING)) {
                m_freem(m);
@@ -1379,7 +1322,7 @@ bridge_input(struct ifnet *ifp, struct e
        /*
         * Make sure this interface is a bridge member.
         */
-       if (ifp == NULL || ifp->if_bridge == NULL || m == NULL)
+       if (ifp == NULL || ifp->if_bridgeport == NULL || m == NULL)
                return (m);
 
        if ((m->m_flags & M_PKTHDR) == 0)
@@ -1387,17 +1330,11 @@ bridge_input(struct ifnet *ifp, struct e
 
        m->m_flags &= ~M_PROTO1;        /* Loop prevention */
 
-       sc = (struct bridge_softc *)ifp->if_bridge;
+       ifl = (struct bridge_iflist *)ifp->if_bridgeport;
+       sc = ifl->bridge_sc;
        if ((sc->sc_if.if_flags & IFF_RUNNING) == 0)
                return (m);
 
-       LIST_FOREACH(ifl, &sc->sc_iflist, next) {
-               if (ifl->ifp == ifp)
-                       break;
-       }
-       if (ifl == LIST_END(&sc->sc_iflist))
-               return (m);
-
 #if NBPFILTER > 0
        if (sc->sc_if.if_bpf)
                bpf_mtap_hdr(sc->sc_if.if_bpf, (caddr_t)eh,
@@ -2000,10 +1937,11 @@ bridge_rtage(struct bridge_softc *sc)
 void
 bridge_rtagenode(struct ifnet *ifp, int age)
 {
-       struct bridge_softc *sc = (struct bridge_softc *)ifp->if_bridge;
+       struct bridge_softc *sc;
        struct bridge_rtnode *n;
        int i;
 
+       sc = ((struct bridge_iflist *)ifp->if_bridgeport)->bridge_sc;
        if (sc == NULL)
                return;
 
Index: net/if_bridge.h
===================================================================
RCS file: /cvs/src/sys/net/if_bridge.h,v
retrieving revision 1.35
diff -u -p -r1.35 if_bridge.h
--- net/if_bridge.h     20 Sep 2012 14:10:18 -0000      1.35
+++ net/if_bridge.h     24 Sep 2012 15:14:52 -0000
@@ -384,6 +384,7 @@ struct bstp_state {
  */
 struct bridge_iflist {
        LIST_ENTRY(bridge_iflist)       next;           /* next in list */
+       struct bridge_softc             *bridge_sc;
        struct bstp_port                *bif_stp;       /* STP port state */
        struct brl_head                 bif_brlin;      /* input rules */
        struct brl_head                 bif_brlout;     /* output rules */
@@ -391,6 +392,10 @@ struct bridge_iflist {
        u_int32_t                       bif_flags;      /* member flags */
 };
 #define bif_state                      bif_stp->bp_state
+
+#define SAME_BRIDGE(_bp1, _bp2)                                                
\
+       (_bp1 && _bp2 && ((struct bridge_iflist *)_bp1)->bridge_sc ==   \
+           ((struct bridge_iflist *)_bp2)->bridge_sc)
 
 /*
  * Bridge route node
Index: net/if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.151
diff -u -p -r1.151 if_ethersubr.c
--- net/if_ethersubr.c  9 Jul 2011 00:47:18 -0000       1.151
+++ net/if_ethersubr.c  24 Sep 2012 15:14:52 -0000
@@ -379,15 +379,14 @@ ether_output(ifp0, m0, dst, rt0)
 
 #if NBRIDGE > 0
        /*
-        * Interfaces that are bridge members need special handling
-        * for output.
+        * Interfaces that are bridgeports need special handling for output.
         */
-       if (ifp->if_bridge) {
+       if (ifp->if_bridgeport) {
                struct m_tag *mtag;
 
                /*
                 * Check if this packet has already been sent out through
-                * this bridge, in which case we simply send it out
+                * this bridgeport, in which case we simply send it out
                 * without further bridge processing.
                 */
                for (mtag = m_tag_find(m, PACKET_TAG_BRIDGE, NULL); mtag;
@@ -399,7 +398,7 @@ ether_output(ifp0, m0, dst, rt0)
                                goto bad;
                        }
 #endif
-                       if (!bcmp(&ifp->if_bridge, mtag + 1, sizeof(caddr_t)))
+                       if (!bcmp(&ifp->if_bridgeport, mtag + 1, 
sizeof(caddr_t)))
                                break;
                }
                if (mtag == NULL) {
@@ -410,7 +409,7 @@ ether_output(ifp0, m0, dst, rt0)
                                error = ENOBUFS;
                                goto bad;
                        }
-                       bcopy(&ifp->if_bridge, mtag + 1, sizeof(caddr_t));
+                       bcopy(&ifp->if_bridgeport, mtag + 1, sizeof(caddr_t));
                        m_tag_prepend(m, mtag);
                        error = bridge_output(ifp, m, NULL, NULL);
                        return (error);
@@ -560,7 +559,7 @@ ether_input(ifp0, eh, m)
         * NULL if it has consumed the packet, otherwise, it
         * gets processed as normal.
         */
-       if (ifp->if_bridge) {
+       if (ifp->if_bridgeport) {
                if (m->m_flags & M_PROTO1)
                        m->m_flags &= ~M_PROTO1;
                else {
Index: net/if_gif.c
===================================================================
RCS file: /cvs/src/sys/net/if_gif.c,v
retrieving revision 1.57
diff -u -p -r1.57 if_gif.c
--- net/if_gif.c        12 May 2012 12:58:16 -0000      1.57
+++ net/if_gif.c        24 Sep 2012 15:14:52 -0000
@@ -176,7 +176,7 @@ gif_start(struct ifnet *ifp)
                 * the start function and bypasses the if_output function
                 * so we need to do the encap here.
                 */
-               if (ifp->if_bridge && (m->m_flags & M_PROTO1)) {
+               if (ifp->if_bridgeport && (m->m_flags & M_PROTO1)) {
                        int error = 0;
                        /*
                         * Remove multicast and broadcast flags or encapsulated
Index: net/pfvar.h
===================================================================
RCS file: /cvs/src/sys/net/pfvar.h,v
retrieving revision 1.369
diff -u -p -r1.369 pfvar.h
--- net/pfvar.h 20 Sep 2012 09:43:49 -0000      1.369
+++ net/pfvar.h 24 Sep 2012 15:14:52 -0000
@@ -35,6 +35,7 @@
 #define _NET_PFVAR_H_
 
 #include <sys/param.h>
+#include <sys/mbuf.h>
 #include <sys/types.h>
 #include <sys/queue.h>
 #include <sys/tree.h>
Index: net80211/ieee80211_node.c
===================================================================
RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
retrieving revision 1.74
diff -u -p -r1.74 ieee80211_node.c
--- net80211/ieee80211_node.c   20 Sep 2012 17:21:13 -0000      1.74
+++ net80211/ieee80211_node.c   24 Sep 2012 15:14:52 -0000
@@ -1474,10 +1474,10 @@ ieee80211_node_join(struct ieee80211com 
 
 #if NBRIDGE > 0
        /*
-        * If the parent interface belongs to a bridge, learn
+        * If the parent interface is a bridgeport, learn
         * the node's address dynamically on this interface.
         */
-       if (ic->ic_if.if_bridge != NULL)
+       if (ic->ic_if.if_bridgeport != NULL)
                bridge_update(&ic->ic_if,
                    (struct ether_addr *)ni->ni_macaddr, 0);
 #endif
@@ -1627,10 +1627,10 @@ ieee80211_node_leave(struct ieee80211com
 
 #if NBRIDGE > 0
        /*
-        * If the parent interface belongs to a bridge, delete
+        * If the parent interface is a bridgeport, delete
         * any dynamically learned address for this node.
         */
-       if (ic->ic_if.if_bridge != NULL)
+       if (ic->ic_if.if_bridgeport != NULL)
                bridge_update(&ic->ic_if,
                    (struct ether_addr *)ni->ni_macaddr, 1);
 #endif
Index: netinet/if_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/if_ether.c,v
retrieving revision 1.93
diff -u -p -r1.93 if_ether.c
--- netinet/if_ether.c  18 Sep 2011 11:17:58 -0000      1.93
+++ netinet/if_ether.c  24 Sep 2012 15:14:52 -0000
@@ -63,6 +63,9 @@
 #if NCARP > 0
 #include <netinet/ip_carp.h>
 #endif
+#if NBRIDGE > 0
+#include <net/if_bridge.h>
+#endif
 
 #define SIN(s) ((struct sockaddr_in *)s)
 #define SDL(s) ((struct sockaddr_dl *)s)
@@ -671,7 +674,9 @@ in_arpinput(struct mbuf *m)
                                   ac->ac_if.if_xname);
                                goto out;
                        } else if (rt->rt_ifp != &ac->ac_if) {
+#if NCARP > 0
                                if (ac->ac_if.if_type != IFT_CARP)
+#endif
                                        log(LOG_WARNING,
                                           "arp: attempt to overwrite entry for"
                                           " %s on %s by %s on %s\n",
@@ -689,19 +694,25 @@ in_arpinput(struct mbuf *m)
                                rt->rt_expire = 1; /* no longer static */
                        }
                    }
-               } else if (rt->rt_ifp != &ac->ac_if && !(ac->ac_if.if_bridge &&
-                   (rt->rt_ifp->if_bridge == ac->ac_if.if_bridge)) &&
+               } else if (rt->rt_ifp != &ac->ac_if &&
+#if NBRIDGE > 0
+                   !SAME_BRIDGE(ac->ac_if.if_bridgeport,
+                   rt->rt_ifp->if_bridgeport) &&
+#endif
+#if NCARP > 0
                    !(rt->rt_ifp->if_type == IFT_CARP &&
                    rt->rt_ifp->if_carpdev == &ac->ac_if) &&
                    !(ac->ac_if.if_type == IFT_CARP &&
-                   ac->ac_if.if_carpdev == rt->rt_ifp)) {
-                   log(LOG_WARNING,
-                       "arp: attempt to add entry for %s "
-                       "on %s by %s on %s\n",
-                       inet_ntoa(isaddr), rt->rt_ifp->if_xname,
-                       ether_sprintf(ea->arp_sha),
-                       ac->ac_if.if_xname);
-                   goto out;
+                   ac->ac_if.if_carpdev == rt->rt_ifp) &&
+#endif
+                   1) {
+                       log(LOG_WARNING,
+                           "arp: attempt to add entry for %s "
+                           "on %s by %s on %s\n",
+                           inet_ntoa(isaddr), rt->rt_ifp->if_xname,
+                           ether_sprintf(ea->arp_sha),
+                           ac->ac_if.if_xname);
+                       goto out;
                }
                bcopy(ea->arp_sha, LLADDR(sdl),
                    sdl->sdl_alen = sizeof(ea->arp_sha));
Index: netinet/ip_ether.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_ether.c,v
retrieving revision 1.58
diff -u -p -r1.58 ip_ether.c
--- netinet/ip_ether.c  4 Jul 2011 20:42:15 -0000       1.58
+++ netinet/ip_ether.c  24 Sep 2012 15:14:52 -0000
@@ -60,6 +60,9 @@
 #ifdef MPLS
 #include <netmpls/mpls.h>
 #endif
+#if NPF > 0
+#include <net/pfvar.h>
+#endif
 
 #include "bpfilter.h"
 
@@ -230,7 +233,7 @@ etherip_decap(struct mbuf *m, int iphlen
        sc = etherip_getgif(m);
        if (sc == NULL)
                return;
-       if (sc->gif_if.if_bridge == NULL) {
+       if (sc->gif_if.if_bridgeport == NULL) {
                DPRINTF(("etherip_input(): interface not part of bridge\n"));
                etheripstat.etherip_noifdrops++;
                m_freem(m);
Index: netinet/ip_output.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.231
diff -u -p -r1.231 ip_output.c
--- netinet/ip_output.c 20 Sep 2012 10:25:03 -0000      1.231
+++ netinet/ip_output.c 24 Sep 2012 15:14:52 -0000
@@ -740,7 +740,7 @@ sendit:
        if (ntohs(ip->ip_len) <= mtu) {
                ip->ip_sum = 0;
                if ((ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
-                   (ifp->if_bridge == NULL)) {
+                   (ifp->if_bridgeport == NULL)) {
                        m->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
                        ipstat.ips_outhwcsum++;
                } else
@@ -887,7 +887,7 @@ ip_fragment(struct mbuf *m, struct ifnet
                mhip->ip_sum = 0;
                if ((ifp != NULL) &&
                    (ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
-                   (ifp->if_bridge == NULL)) {
+                   (ifp->if_bridgeport == NULL)) {
                        m->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
                        ipstat.ips_outhwcsum++;
                } else
@@ -907,7 +907,7 @@ ip_fragment(struct mbuf *m, struct ifnet
        ip->ip_sum = 0;
        if ((ifp != NULL) &&
            (ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
-           (ifp->if_bridge == NULL)) {
+           (ifp->if_bridgeport == NULL)) {
                m->m_pkthdr.csum_flags |= M_IPV4_CSUM_OUT;
                ipstat.ips_outhwcsum++;
        } else
@@ -2150,13 +2150,13 @@ in_proto_cksum_out(struct mbuf *m, struc
 {
        if (m->m_pkthdr.csum_flags & M_TCP_CSUM_OUT) {
                if (!ifp || !(ifp->if_capabilities & IFCAP_CSUM_TCPv4) ||
-                   ifp->if_bridge != NULL) {
+                   ifp->if_bridgeport != NULL) {
                        in_delayed_cksum(m);
                        m->m_pkthdr.csum_flags &= ~M_TCP_CSUM_OUT; /* Clear */
                }
        } else if (m->m_pkthdr.csum_flags & M_UDP_CSUM_OUT) {
                if (!ifp || !(ifp->if_capabilities & IFCAP_CSUM_UDPv4) ||
-                   ifp->if_bridge != NULL) {
+                   ifp->if_bridgeport != NULL) {
                        in_delayed_cksum(m);
                        m->m_pkthdr.csum_flags &= ~M_UDP_CSUM_OUT; /* Clear */
                }
Index: netinet6/in6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.99
diff -u -p -r1.99 in6.c
--- netinet6/in6.c      19 Sep 2012 09:47:25 -0000      1.99
+++ netinet6/in6.c      24 Sep 2012 15:14:52 -0000
@@ -85,6 +85,9 @@
 #include <netinet/in.h>
 #include <netinet/in_var.h>
 #include <netinet/if_ether.h>
+#if NBRIDGE > 0
+#include <net/if_bridge.h>
+#endif
 
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
@@ -1907,8 +1910,7 @@ in6_ifpprefix(const struct ifnet *ifp, c
        if ((rt->rt_flags & (RTF_CLONING | RTF_CLONED)) == 0 ||
            (rt->rt_ifp != ifp &&
 #if NBRIDGE > 0
-           (rt->rt_ifp->if_bridge == NULL || ifp->if_bridge == NULL ||
-           rt->rt_ifp->if_bridge != ifp->if_bridge) &&
+           !SAME_BRIDGE(rt->rt_ifp->if_bridgeport, ifp->if_bridgeport) &&
 #endif
 #if NCARP > 0
            (ifp->if_type != IFT_CARP || rt->rt_ifp != ifp->if_carpdev) &&
Index: sys/mbuf.h
===================================================================
RCS file: /cvs/src/sys/sys/mbuf.h,v
retrieving revision 1.157
diff -u -p -r1.157 mbuf.h
--- sys/mbuf.h  19 Sep 2012 17:50:17 -0000      1.157
+++ sys/mbuf.h  24 Sep 2012 15:14:52 -0000
@@ -32,6 +32,9 @@
  *     @(#)mbuf.h      8.5 (Berkeley) 2/19/95
  */
 
+#ifndef _SYS_MBUF_H_
+#define _SYS_MBUF_H_
+
 #include <sys/malloc.h>
 #include <sys/pool.h>
 #include <sys/queue.h>
@@ -448,4 +451,5 @@ struct m_tag *m_tag_next(struct mbuf *, 
 #define PACKET_TAG_PIPEX               0x0400 /* pipex session cache */
 #define PACKET_TAG_PF_REASSEMBLED      0x0800 /* pf reassembled ipv6 packet */
 
-#endif
+#endif /* _KERNEL */
+#endif /* _SYS_MBUF_H_ */

Reply via email to