Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix IP broadcast + checksum offload problem.



details:   https://anonhg.NetBSD.org/src/rev/62c59d407ddf
branches:  trunk
changeset: 966680:62c59d407ddf
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Mon Nov 11 08:12:35 2019 +0000

description:
Fix IP broadcast + checksum offload problem.

 When a machine sends a IP broadcast packet to an Ethernet interface that the
checksum offload flags are set, the packet goes through ether_output() ->
looutput() and the offload flags is cleard without calculating the checksum.
And then, ip_input() calculate the packet's checksum because it's csum_flags is
zero. It regard as bad checksum and it's dropped because the packet's ifp
is s not lo0's. Fixes this bug by passing csum_flags as "calculated and good"
when IN_LOOPBACK_NEED_CHECKSUM() is false. Adviced by ryo@.

 This problem was seen when "routed -s" was used and the machine's interface's
offload flags were set. bad checksum field of "netstat -s" was increased every
30 minutes.

diffstat:

 sys/net/if_loop.c |  18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diffs (48 lines):

diff -r c1a79a2e1ce6 -r 62c59d407ddf sys/net/if_loop.c
--- a/sys/net/if_loop.c Mon Nov 11 07:27:48 2019 +0000
+++ b/sys/net/if_loop.c Mon Nov 11 08:12:35 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_loop.c,v 1.107 2019/04/26 08:38:25 pgoyette Exp $   */
+/*     $NetBSD: if_loop.c,v 1.108 2019/11/11 08:12:35 msaitoh Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.107 2019/04/26 08:38:25 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.108 2019/11/11 08:12:35 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -321,8 +321,13 @@
                KASSERT((csum_flags & ~(M_CSUM_IPv4|M_CSUM_UDPv4)) == 0);
                if (csum_flags != 0 && IN_LOOPBACK_NEED_CHECKSUM(csum_flags)) {
                        in_undefer_cksum(m, 0, csum_flags);
+                       m->m_pkthdr.csum_flags = 0;
+               } else {
+                       /*
+                        * Do nothing. Pass M_CSUM_IPv4 and M_CSUM_UDPv4 as
+                        * they are to tell those are calculated and good.
+                        */
                }
-               m->m_pkthdr.csum_flags = 0;
                pktq = ip_pktq;
                break;
 #endif
@@ -333,8 +338,13 @@
                if (csum_flags != 0 &&
                    IN6_LOOPBACK_NEED_CHECKSUM(csum_flags)) {
                        in6_undefer_cksum(m, 0, csum_flags);
+                       m->m_pkthdr.csum_flags = 0;
+               } else {
+                       /*
+                        * Do nothing. Pass M_CSUM_IPv4 and M_CSUM_UDPv4 as
+                        * they are to tell those are calculated and good.
+                        */
                }
-               m->m_pkthdr.csum_flags = 0;
                m->m_flags |= M_LOOP;
                pktq = ip6_pktq;
                break;



Home | Main Index | Thread Index | Old Index