tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bridge diffs



There are several PRs open on bridge(4).

I have been using the following diffs for a while now, they add bpf(4)
support as well as adding a static address cache entry for each
member interface.

Being able to use bpf on the bridge as well as any members may help
people to work out what is going on in their usage.

I would commit it in two parts. Any comments ?

Robert Swindells

Index: if_bridge.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_bridge.c,v
retrieving revision 1.76
diff -u -r1.76 if_bridge.c
--- if_bridge.c 22 Mar 2012 12:59:33 -0000      1.76
+++ if_bridge.c 22 May 2012 16:37:53 -0000
@@ -385,6 +385,8 @@
 
        if_alloc_sadl(ifp);
 
+       bpf_attach(ifp, DLT_EN10MB, sizeof(struct ether_header));
+
        s = splnet();
        LIST_INSERT_HEAD(&bridge_list, sc, sc_list);
        splx(s);
@@ -406,6 +408,8 @@
 
        s = splnet();
 
+       bpf_detach(ifp);
+
        bridge_stop(ifp, 1);
 
        while ((bif = LIST_FIRST(&sc->sc_iflist)) != NULL)
@@ -669,6 +673,10 @@
        ifs->if_bridge = sc;
        LIST_INSERT_HEAD(&sc->sc_iflist, bif, bif_next);
 
+       error = bridge_rtupdate(sc, CLLADDR(ifs->if_sadl), ifs, 1, 
IFBAF_STATIC);
+       if (error)
+               goto out;
+
        if (sc->sc_if.if_flags & IFF_RUNNING)
                bstp_initialization(sc);
        else
@@ -1232,6 +1240,8 @@
        eh = mtod(m, struct ether_header *);
        sc = ifp->if_bridge;
 
+       bpf_mtap(&sc->sc_if, m);
+
        s = splnet();
 
        /*
@@ -1561,6 +1571,7 @@
                                (void) bridge_rtupdate(sc,
                                    eh->ether_shost, ifp, 0, IFBAF_DYNAMIC);
                        m->m_pkthdr.rcvif = bif->bif_ifp;
+                       bpf_mtap(&sc->sc_if, m);
                        return (m);
                }
 
@@ -1583,6 +1594,9 @@
                m_freem(m);
                return (NULL);
        }
+
+       bpf_mtap(&sc->sc_if, m);
+
        IF_ENQUEUE(&sc->sc_if.if_snd, m);
        softint_schedule(sc->sc_softintr);
 


Home | Main Index | Thread Index | Old Index