Module Name:    src
Committed By:   martin
Date:           Mon Dec  7 20:01:02 UTC 2020

Modified Files:
        src/sys/netinet [netbsd-8]: ip_mroute.c

Log Message:
Pull up following revision(s) (requested by kardel in ticket #1632):

        sys/netinet/ip_mroute.c: revision 1.164 (patch)

PR kern/55779:

restore non-desctructive guarantee of ip_mforward() mbuf
argument. This avoids generation invalid UDP checksums
on multicast packets in ip_output().

XXX the root cause of the misguided fix in 2008 should be
XXX investigated


To generate a diff of this commit:
cvs rdiff -u -r1.146.6.4 -r1.146.6.5 src/sys/netinet/ip_mroute.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/netinet/ip_mroute.c
diff -u src/sys/netinet/ip_mroute.c:1.146.6.4 src/sys/netinet/ip_mroute.c:1.146.6.5
--- src/sys/netinet/ip_mroute.c:1.146.6.4	Fri Jul 13 14:26:47 2018
+++ src/sys/netinet/ip_mroute.c	Mon Dec  7 20:01:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $	*/
+/*	$NetBSD: ip_mroute.c,v 1.146.6.5 2020/12/07 20:01:01 martin Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.4 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.146.6.5 2020/12/07 20:01:01 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -239,6 +239,8 @@ static int tbf_dq_sel(struct vif *, stru
 static void tbf_send_packet(struct vif *, struct mbuf *);
 static void tbf_update_tokens(struct vif *);
 static int priority(struct vif *, struct ip *);
+static int ip_mforward_real(struct mbuf *, struct ifnet *);
+
 
 /*
  * Bandwidth monitoring
@@ -1309,6 +1311,34 @@ ip_mforward(struct mbuf *m, struct ifnet
 ip_mforward(struct mbuf *m, struct ifnet *ifp)
 #endif /* RSVP_ISI */
 {
+	int rc;
+	/*
+	 * save csum_flags to uphold the 
+	 * "unscathed" guarantee.
+	 * ip_output() relies on that and
+	 * without it we send out
+	 * multicast packets with an invalid
+	 * checksum
+	 *
+	 * see PR kern/55779
+	 */
+	int csum_flags = m->m_pkthdr.csum_flags;
+
+	/*
+	 * Temporarily clear any in-bound checksum flags for this packet.
+	 */
+	m->m_pkthdr.csum_flags = 0;
+
+	rc = ip_mforward_real(m, ifp);
+
+	m->m_pkthdr.csum_flags = csum_flags;
+
+	return rc;
+}
+
+static int
+ip_mforward_real(struct mbuf *m, struct ifnet *ifp)
+{
 	struct ip *ip = mtod(m, struct ip *);
 	struct mfc *rt;
 	static int srctun = 0;
@@ -1340,11 +1370,6 @@ ip_mforward(struct mbuf *m, struct ifnet
 		return (1);
 	}
 
-	/*
-	 * Clear any in-bound checksum flags for this packet.
-	 */
-	m->m_pkthdr.csum_flags = 0;
-
 #ifdef RSVP_ISI
 	if (imo && ((vifi = imo->imo_multicast_vif) < numvifs)) {
 		if (ip->ip_ttl < MAXTTL)

Reply via email to