On 28/05/15(Thu) 11:23, Martin Pieuchot wrote:
> Let's use if_input() rather than ether_input_mbuf(). This simplifies
> the bpf(4) bits and removes some duplicate "rcvif" assignments.
>
> Once ether_input_mbuf() is no more my plan is to start merging various
> ifp counters and put an interface index in the packet header.
>
> ok?
Anybody?
>
> Index: net/if_bridge.c
> ===================================================================
> RCS file: /cvs/src/sys/net/if_bridge.c,v
> retrieving revision 1.239
> diff -u -p -r1.239 if_bridge.c
> --- net/if_bridge.c 18 May 2015 11:43:57 -0000 1.239
> +++ net/if_bridge.c 22 May 2015 13:39:16 -0000
> @@ -1364,6 +1364,7 @@ bridge_dispatch(struct bridge_iflist *if
> struct bridge_iflist *srcifl;
> struct ether_header *eh;
> struct arpcom *ac;
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *mc;
> int s;
>
> @@ -1411,21 +1412,14 @@ bridge_dispatch(struct bridge_iflist *if
> schednetisr(NETISR_BRIDGE);
> if (ifp->if_type == IFT_GIF) {
> TAILQ_FOREACH(ifl, &sc->sc_iflist, next) {
> - if (ifl->ifp->if_type == IFT_ETHER)
> - break;
> - }
> - if (ifl != NULL) {
> - m->m_pkthdr.rcvif = ifl->ifp;
> - m->m_pkthdr.ph_rtableid = ifl->ifp->if_rdomain;
> -#if NBPFILTER > 0
> - if (ifl->ifp->if_bpf)
> - bpf_mtap_ether(ifl->ifp->if_bpf, m,
> - BPF_DIRECTION_IN);
> -#endif
> + if (ifl->ifp->if_type != IFT_ETHER)
> + continue;
> +
> m->m_flags |= M_PROTO1;
> - ether_input_mbuf(ifl->ifp, m);
> + ml_enqueue(&ml, m);
> + if_input(ifl->ifp, &ml);
> ifl->ifp->if_ipackets++;
> - m = NULL;
> + return (NULL);
> }
> }
> return (m);
> @@ -1462,24 +1456,14 @@ bridge_dispatch(struct bridge_iflist *if
> return (NULL);
> }
>
> - /* Make sure the real incoming interface
> - * is aware */
> -#if NBPFILTER > 0
> - if (ifl->ifp->if_bpf)
> - bpf_mtap_ether(ifl->ifp->if_bpf, m,
> - BPF_DIRECTION_IN);
> -#endif
> - /* Count for the interface we are going to */
> - ifl->ifp->if_ipackets++;
> -
> /* Count for the bridge */
> sc->sc_if.if_ipackets++;
> sc->sc_if.if_ibytes += m->m_pkthdr.len;
>
> - m->m_pkthdr.rcvif = ifl->ifp;
> - m->m_pkthdr.ph_rtableid = ifl->ifp->if_rdomain;
> m->m_flags |= M_PROTO1;
> - ether_input_mbuf(ifl->ifp, m);
> + ml_enqueue(&ml, m);
> + if_input(ifl->ifp, &ml);
> + ifl->ifp->if_ipackets++;
> return (NULL);
> }
> if (bcmp(ac->ac_enaddr, eh->ether_shost, ETHER_ADDR_LEN) == 0
> @@ -1615,8 +1599,10 @@ void
> bridge_localbroadcast(struct bridge_softc *sc, struct ifnet *ifp,
> struct ether_header *eh, struct mbuf *m)
> {
> + struct mbuf_list ml = MBUF_LIST_INITIALIZER();
> struct mbuf *m1;
> u_int16_t etype;
> + int s;
>
> /*
> * quick optimisation, don't send packets up the stack if no
> @@ -1638,18 +1624,11 @@ bridge_localbroadcast(struct bridge_soft
> sc->sc_if.if_oerrors++;
> return;
> }
> - /* fixup header a bit */
> - m1->m_pkthdr.rcvif = ifp;
> - m1->m_pkthdr.ph_rtableid = ifp->if_rdomain;
> m1->m_flags |= M_PROTO1;
> -
> -#if NBPFILTER > 0
> - if (ifp->if_bpf)
> - bpf_mtap(ifp->if_bpf, m1,
> - BPF_DIRECTION_IN);
> -#endif
> -
> - ether_input_mbuf(ifp, m1);
> + ml_enqueue(&ml, m1);
> + s = splnet();
> + if_input(ifp, &ml);
> + splx(s);
> ifp->if_ipackets++;
> }
>
>