Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet PR kern/55779:



details:   https://anonhg.NetBSD.org/src/rev/5861e24cb52c
branches:  trunk
changeset: 945977:5861e24cb52c
user:      kardel <kardel%NetBSD.org@localhost>
date:      Thu Nov 12 13:13:45 2020 +0000

description:
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

diffstat:

 sys/netinet/ip_mroute.c |  39 ++++++++++++++++++++++++++++++++-------
 1 files changed, 32 insertions(+), 7 deletions(-)

diffs (74 lines):

diff -r 2b30eb53927f -r 5861e24cb52c sys/netinet/ip_mroute.c
--- a/sys/netinet/ip_mroute.c   Thu Nov 12 12:19:46 2020 +0000
+++ b/sys/netinet/ip_mroute.c   Thu Nov 12 13:13:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_mroute.c,v 1.163 2018/09/14 05:09:51 maxv Exp $     */
+/*     $NetBSD: ip_mroute.c,v 1.164 2020/11/12 13:13:45 kardel Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.163 2018/09/14 05:09:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.164 2020/11/12 13:13:45 kardel Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -225,6 +225,8 @@
 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
@@ -1268,6 +1270,34 @@
 int
 ip_mforward(struct mbuf *m, struct ifnet *ifp)
 {
+       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;
@@ -1305,11 +1335,6 @@
        }
 
        /*
-        * Clear any in-bound checksum flags for this packet.
-        */
-       m->m_pkthdr.csum_flags = 0;
-
-       /*
         * Don't forward a packet with time-to-live of zero or one,
         * or a packet destined to a local-only group.
         */



Home | Main Index | Thread Index | Old Index