From 9d892957c57d97c5a097161e70589da31bb34ad5 Mon Sep 17 00:00:00 2001 From: Martin Pieuchot Date: Mon, 13 Apr 2015 08:52:52 +0000 Subject: 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@ --- sys/net/if_bridge.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'sys/net/if_bridge.c') 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) -- cgit v1.2.3