Module Name:    src
Committed By:   yamaguchi
Date:           Thu Jul 15 04:05:47 UTC 2021

Modified Files:
        src/sys/net: if_vlan.c

Log Message:
vlan: drop tagged outgoing packets

vlan(4) doesn't support Q-in-Q yet.


To generate a diff of this commit:
cvs rdiff -u -r1.159 -r1.160 src/sys/net/if_vlan.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_vlan.c
diff -u src/sys/net/if_vlan.c:1.159 src/sys/net/if_vlan.c:1.160
--- src/sys/net/if_vlan.c:1.159	Wed Jul 14 06:50:22 2021
+++ src/sys/net/if_vlan.c	Thu Jul 15 04:05:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $	*/
+/*	$NetBSD: if_vlan.c,v 1.160 2021/07/15 04:05:47 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.159 2021/07/14 06:50:22 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.160 2021/07/15 04:05:47 yamaguchi Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1321,6 +1321,7 @@ vlan_start(struct ifnet *ifp)
 	struct mbuf *m;
 	struct ifvlan_linkmib *mib;
 	struct psref psref;
+	struct ether_header *eh;
 	int error;
 
 	mib = vlan_getref_linkmib(ifv, &psref);
@@ -1342,6 +1343,21 @@ vlan_start(struct ifnet *ifp)
 		if (m == NULL)
 			break;
 
+		if (m->m_len < sizeof(*eh)) {
+			m = m_pullup(m, sizeof(*eh));
+			if (m == NULL) {
+				if_statinc(ifp, if_oerrors);
+				continue;
+			}
+		}
+
+		eh = mtod(m, struct ether_header *);
+		if (ntohs(eh->ether_type) == ETHERTYPE_VLAN) {
+			m_freem(m);
+			if_statinc(ifp, if_noproto);
+			continue;
+		}
+
 #ifdef ALTQ
 		/*
 		 * KERNEL_LOCK is required for ALTQ even if NET_MPSAFE is
@@ -1465,10 +1481,26 @@ vlan_transmit(struct ifnet *ifp, struct 
 	struct ethercom *ec;
 	struct ifvlan_linkmib *mib;
 	struct psref psref;
+	struct ether_header *eh;
 	int error;
 	size_t pktlen = m->m_pkthdr.len;
 	bool mcast = (m->m_flags & M_MCAST) != 0;
 
+	if (m->m_len < sizeof(*eh)) {
+		m = m_pullup(m, sizeof(*eh));
+		if (m == NULL) {
+			if_statinc(ifp, if_oerrors);
+			return ENOBUFS;
+		}
+	}
+
+	eh = mtod(m, struct ether_header *);
+	if (ntohs(eh->ether_type) == ETHERTYPE_VLAN) {
+		m_freem(m);
+		if_statinc(ifp, if_noproto);
+		return EPROTONOSUPPORT;
+	}
+
 	mib = vlan_getref_linkmib(ifv, &psref);
 	if (mib == NULL) {
 		m_freem(m);

Reply via email to