diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-04-13 08:52:52 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-04-13 08:52:52 +0000 |
commit | 9d892957c57d97c5a097161e70589da31bb34ad5 (patch) | |
tree | e42c7199b3c785b8c956e4e5988d1ee2152a44ff /sys/net/if_bridge.c | |
parent | 6519c8e60e1f060fbf796f09849009a73dc50960 (diff) |
Move one "#ifdef NVLAN" chunk needed only if you're running bridge(4) on
to of vlan(4) from ether_input() to bridge_input().
One of the goal of the if_input() plumbing is to stop doing all possible
pseudo-drivers checks on every packets. There's no reason that even if
you're not running a bridge(4) you've to run this code.
This change also will also makes it easier to convert vlan(4) to if_input().
Reviewed by Rafael Zalamena and mikeb@, ok markus@
Diffstat (limited to 'sys/net/if_bridge.c')
-rw-r--r-- | sys/net/if_bridge.c | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 2f5d11b7200..3b5651e6261 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.233 2015/04/07 10:46:20 mpi Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.234 2015/04/13 08:52:51 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -117,6 +117,8 @@ void bridge_localbroadcast(struct bridge_softc *, struct ifnet *, struct ether_header *, struct mbuf *); void bridge_span(struct bridge_softc *, struct ether_header *, struct mbuf *); +struct mbuf *bridge_dispatch(struct bridge_iflist *, struct ifnet *, + struct ether_header *, struct mbuf *); void bridge_stop(struct bridge_softc *); void bridge_init(struct bridge_softc *); int bridge_bifconf(struct bridge_softc *, struct ifbifconf *); @@ -1299,10 +1301,10 @@ struct mbuf * bridge_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) { struct bridge_softc *sc; - int s; - struct bridge_iflist *ifl, *srcifl; - struct arpcom *ac; - struct mbuf *mc; + struct bridge_iflist *ifl; +#if NVLAN > 0 + uint16_t etype = ntohs(eh->ether_type); +#endif /* NVLAN > 0 */ /* * Make sure this interface is a bridge member. @@ -1328,6 +1330,31 @@ bridge_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m) bridge_span(sc, eh, m); + m = bridge_dispatch(ifl, ifp, eh, m); + +#if NVLAN > 0 + if ((m != NULL) && ((m->m_flags & M_VLANTAG) || + etype == ETHERTYPE_VLAN || etype == ETHERTYPE_QINQ)) { + /* The bridge did not want the vlan frame either, drop it. */ + ifp->if_noproto++; + m_freem(m); + m = NULL; + } +#endif /* NVLAN > 0 */ + + return (m); +} + +struct mbuf * +bridge_dispatch(struct bridge_iflist *ifl, struct ifnet *ifp, + struct ether_header *eh, struct mbuf *m) +{ + struct bridge_softc *sc = ifl->bridge_sc; + struct bridge_iflist *srcifl; + struct arpcom *ac; + struct mbuf *mc; + int s; + if (m->m_flags & (M_BCAST | M_MCAST)) { /* * Reserved destination MAC addresses (01:80:C2:00:00:0x) |