Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net vlan: drop tagged outgoing packets
details: https://anonhg.NetBSD.org/src/rev/91e10a9e2fab
branches: trunk
changeset: 1022376:91e10a9e2fab
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Thu Jul 15 04:05:47 2021 +0000
description:
vlan: drop tagged outgoing packets
vlan(4) doesn't support Q-in-Q yet.
diffstat:
sys/net/if_vlan.c | 36 ++++++++++++++++++++++++++++++++++--
1 files changed, 34 insertions(+), 2 deletions(-)
diffs (75 lines):
diff -r e5b6098e0321 -r 91e10a9e2fab sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Thu Jul 15 03:25:50 2021 +0000
+++ b/sys/net/if_vlan.c Thu Jul 15 04:05:47 2021 +0000
@@ -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 @@
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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index