summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2015-04-13 08:52:52 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2015-04-13 08:52:52 +0000
commit9d892957c57d97c5a097161e70589da31bb34ad5 (patch)
treee42c7199b3c785b8c956e4e5988d1ee2152a44ff /sys
parent6519c8e60e1f060fbf796f09849009a73dc50960 (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')
-rw-r--r--sys/net/if_bridge.c37
-rw-r--r--sys/net/if_ethersubr.c12
-rw-r--r--sys/net/if_vlan.c18
3 files changed, 48 insertions, 19 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)
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index f5e3a63a393..fb013aef29e 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.193 2015/04/10 13:58:20 dlg Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.194 2015/04/13 08:52:51 mpi Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -563,16 +563,6 @@ ether_input(struct mbuf *m, void *hdr)
}
#endif
-#if NVLAN > 0
- if ((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);
- return (1);
- }
-#endif /* NVLAN > 0 */
-
#if NCARP > 0
if (ifp->if_carp) {
if (ifp->if_type != IFT_CARP && (carp_input(ifp, eh, m) == 0))
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 072b28be3dd..83482bbbdd1 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vlan.c,v 1.115 2015/04/10 02:08:08 dlg Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.116 2015/04/13 08:52:51 mpi Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
@@ -305,8 +305,20 @@ vlan_input(struct ether_header *eh, struct mbuf *m)
etype == ifv->ifv_type)
break;
}
- if (ifv == NULL)
- return (1);
+
+ if (ifv == NULL) {
+#if NBRIDGE > 0
+ /*
+ * If the packet hasn't been through its bridge(4) give
+ * it a chance.
+ */
+ if (ifp->if_bridgeport && (m->m_flags & M_PROTO1) == 0)
+ return (1);
+#endif
+ ifp->if_noproto++;
+ m_freem(m);
+ return (0);
+ }
if ((ifv->ifv_if.if_flags & (IFF_UP|IFF_RUNNING)) !=
(IFF_UP|IFF_RUNNING)) {