Module Name:    src
Committed By:   martin
Date:           Wed Oct  3 17:57:39 UTC 2018

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

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

        sys/net/if_bridge.c: revision 1.157
        sys/net/if_bridge.c: revision 1.158
        sys/net/if_bridge.c: revision 1.159

  Fix a bug that bridge_enqueue() incorrectly cleared outgoing packet's offload
flags. bridge_enqueue() is called from bridge_output() when a packet is
spontaneous. Clear csum_flags before calling brige_enqueue() in
bridge_forward() or bridge_broadcast() instead of in the beginning of
bridge_enqueue().

Note that this change doesn't fix a problem on the following configuration:

        A bridge has two or more interfaces.
        An address is assigned to an bridge member interface and
        some offload flags are set.
        Another interface has no address and has no any offload flag.

XXX pullup-[78]

- Fix bridge_enqueue() which was broken by last commit. Use correct mbuf
   pointer.
- Modify comment.

Micro optimization. m_copym(M_COPYALL) -> m_copypacket().


To generate a diff of this commit:
cvs rdiff -u -r1.134.6.11 -r1.134.6.12 src/sys/net/if_bridge.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_bridge.c
diff -u src/sys/net/if_bridge.c:1.134.6.11 src/sys/net/if_bridge.c:1.134.6.12
--- src/sys/net/if_bridge.c:1.134.6.11	Thu Jun  7 17:42:25 2018
+++ src/sys/net/if_bridge.c	Wed Oct  3 17:57:39 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bridge.c,v 1.134.6.11 2018/06/07 17:42:25 martin Exp $	*/
+/*	$NetBSD: if_bridge.c,v 1.134.6.12 2018/10/03 17:57:39 martin Exp $	*/
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.134.6.11 2018/06/07 17:42:25 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.134.6.12 2018/10/03 17:57:39 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -1395,11 +1395,6 @@ bridge_enqueue(struct bridge_softc *sc, 
 	int len, error;
 	short mflags;
 
-	/*
-	 * Clear any in-bound checksum flags for this packet.
-	 */
-	m->m_pkthdr.csum_flags = 0;
-
 	if (runfilt) {
 		if (pfil_run_hooks(sc->sc_if.if_pfil, &m,
 		    dst_ifp, PFIL_OUT) != 0) {
@@ -1545,7 +1540,7 @@ bridge_output(struct ifnet *ifp, struct 
 				used = true;
 				mc = m;
 			} else {
-				mc = m_copym(m, 0, M_COPYALL, M_NOWAIT);
+				mc = m_copypacket(m, M_DONTWAIT);
 				if (mc == NULL) {
 					sc->sc_if.if_oerrors++;
 					goto next;
@@ -1563,8 +1558,7 @@ bridge_output(struct ifnet *ifp, struct 
 					used = true;
 					mc = m;
 				} else {
-					mc = m_copym(m, 0, M_COPYALL,
-					    M_DONTWAIT);
+					mc = m_copypacket(m, M_DONTWAIT);
 					if (mc == NULL) {
 						sc->sc_if.if_oerrors++;
 						goto next;
@@ -1768,6 +1762,13 @@ bridge_forward(struct bridge_softc *sc, 
 
 	bridge_release_member(sc, bif, &psref);
 
+	/*
+	 * Before enqueueing this packet to the destination interface,
+	 * clear any in-bound checksum flags to prevent them from being
+	 * misused as out-bound flags.
+	 */
+	m->m_pkthdr.csum_flags = 0;
+
 	ACQUIRE_GLOBAL_LOCKS();
 	bridge_enqueue(sc, dst_if, m, 1);
 	RELEASE_GLOBAL_LOCKS();
@@ -1973,18 +1974,25 @@ bridge_broadcast(struct bridge_softc *sc
 			goto next;
 
 		if (dst_if != src_if) {
-			mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
+			mc = m_copypacket(m, M_DONTWAIT);
 			if (mc == NULL) {
 				sc->sc_if.if_oerrors++;
 				goto next;
 			}
+			/*
+			 * Before enqueueing this packet to the destination
+			 * interface, clear any in-bound checksum flags to
+			 * prevent them from being misused as out-bound flags.
+			 */
+			mc->m_pkthdr.csum_flags = 0;
+
 			ACQUIRE_GLOBAL_LOCKS();
 			bridge_enqueue(sc, dst_if, mc, 1);
 			RELEASE_GLOBAL_LOCKS();
 		}
 
 		if (bmcast) {
-			mc = m_copym(m, 0, M_COPYALL, M_DONTWAIT);
+			mc = m_copypacket(m, M_DONTWAIT);
 			if (mc == NULL) {
 				sc->sc_if.if_oerrors++;
 				goto next;

Reply via email to