summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-05-30 12:56:16 +0000
committermpi <mpi@openbsd.org>2016-05-30 12:56:16 +0000
commite87b0f2a1421d69f3f47aa4465258c72ab78d6cc (patch)
tree47d5ab655a10241e0b8de075832818276b69704d
parentDo not forward declare an enum, makes gcc3 happy. (diff)
downloadwireguard-openbsd-e87b0f2a1421d69f3f47aa4465258c72ab78d6cc.tar.xz
wireguard-openbsd-e87b0f2a1421d69f3f47aa4465258c72ab78d6cc.zip
Insert a hack to deal with interfaces removing the VLAN header before
the packet has been feed to the pseudo-interfaces input handlers. To fix that without introducing a layer violation we should be able to disable HW-vlan on parent when in use with different pseudo-interfaces. In the case of bridge(4) for example it makes no sense to let the interface remove the VLAN header if the kernel has to add it back for every packet. Fix issues reported by sebastia@ and markus@ From dlg@, ok claudio@
-rw-r--r--sys/net/if_bridge.c14
-rw-r--r--sys/netinet/ip_carp.c15
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index e880e793e5d..bc87a19f1e2 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bridge.c,v 1.278 2016/04/12 06:20:30 mpi Exp $ */
+/* $OpenBSD: if_bridge.c,v 1.279 2016/05/30 12:56:16 mpi Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -1063,6 +1063,18 @@ bridge_process(struct ifnet *ifp, struct mbuf *m)
if ((sc->sc_if.if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
goto reenqueue;
+#if NVLAN > 0
+ /*
+ * If the underlying interface removed the VLAN header itself,
+ * add it back.
+ */
+ if (ISSET(m->m_flags, M_VLANTAG)) {
+ m = vlan_inject(m, ETHERTYPE_VLAN, m->m_pkthdr.ether_vtag);
+ if (m == NULL)
+ return;
+ }
+#endif
+
#if NBPFILTER > 0
if (sc->sc_if.if_bpf)
bpf_mtap_ether(sc->sc_if.if_bpf, m, BPF_DIRECTION_IN);
diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c
index 954c227d210..d9fff8835ca 100644
--- a/sys/netinet/ip_carp.c
+++ b/sys/netinet/ip_carp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_carp.c,v 1.289 2016/05/18 03:46:03 dlg Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.290 2016/05/30 12:56:16 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -80,6 +80,10 @@
#include <net/bpf.h>
#endif
+#if NVLAN > 0
+#include <net/if_vlan_var.h>
+#endif
+
#include <netinet/ip_carp.h>
struct carp_mc_entry {
@@ -1399,6 +1403,15 @@ carp_input(struct ifnet *ifp0, struct mbuf *m, void *cookie)
struct carp_softc *sc;
struct srp_ref sr;
+#if NVLAN > 0
+ /*
+ * If the underlying interface removed the VLAN header itself,
+ * it's not for us.
+ */
+ if (ISSET(m->m_flags, M_VLANTAG))
+ return (0);
+#endif
+
eh = mtod(m, struct ether_header *);
cif = (struct carp_if *)cookie;
KASSERT(cif == (struct carp_if *)ifp0->if_carp);