Module Name:    src
Committed By:   martin
Date:           Mon Oct 10 16:09:13 UTC 2022

Modified Files:
        src/sys/net [netbsd-8]: if_ethersubr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #1770):

        sys/net/if_ethersubr.c: revision 1.254

Fix a bug in the VLAN path: there's an inverted logic, the mbuf needs to
be bigger than struct ether_vlan_header, not smaller.

Meanwhile add a KASSERT in the LLC path.


To generate a diff of this commit:
cvs rdiff -u -r1.242.6.9 -r1.242.6.10 src/sys/net/if_ethersubr.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_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.242.6.9 src/sys/net/if_ethersubr.c:1.242.6.10
--- src/sys/net/if_ethersubr.c:1.242.6.9	Wed Oct 27 18:52:51 2021
+++ src/sys/net/if_ethersubr.c	Mon Oct 10 16:09:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.242.6.9 2021/10/27 18:52:51 martin Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.242.6.10 2022/10/10 16:09:12 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242.6.9 2021/10/27 18:52:51 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242.6.10 2022/10/10 16:09:12 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -706,7 +706,7 @@ ether_input(struct ifnet *ifp, struct mb
 		 * just being used to store the priority.  Extract the ether
 		 * type, and if IP or IPV6, let them deal with it.
 		 */
-		if (m->m_len <= sizeof(*evl)
+		if (m->m_len >= sizeof(*evl)
 		    && EVL_VLANOFTAG((ntohs(evl->evl_tag))) == 0) {
 			etype = ntohs(evl->evl_proto);
 			ehlen = sizeof(*evl);
@@ -841,11 +841,13 @@ ether_input(struct ifnet *ifp, struct mb
 			return;
 		}
 	} else {
+		KASSERT(ehlen == sizeof(*eh));
 #if defined (LLC) || defined (NETATALK)
-		if (m->m_len < ehlen + sizeof(struct llc)) {
+		if (m->m_len < sizeof(*eh) + sizeof(struct llc)) {
 			goto dropanyway;
 		}
 		l = (struct llc *)(eh+1);
+
 		switch (l->llc_dsap) {
 #ifdef NETATALK
 		case LLC_SNAP_LSAP:
@@ -871,10 +873,10 @@ ether_input(struct ifnet *ifp, struct mb
 				    sizeof(aarp_org_code)) == 0 &&
 				    ntohs(l->llc_snap_ether_type) ==
 				    ETHERTYPE_AARP) {
-					m_adj( m, sizeof(struct ether_header)
+					m_adj(m, sizeof(struct ether_header)
 					    + sizeof(struct llc));
 					aarpinput(ifp, m); /* XXX */
-				    return;
+					return;
 				}
 
 			default:

Reply via email to