Module Name: src Committed By: martin Date: Thu Nov 14 15:34:35 UTC 2019
Modified Files: src/sys/net [netbsd-9]: if_loop.c Log Message: Pull up following revision(s) (requested by msaitoh in ticket #424): sys/net/if_loop.c: revision 1.108 sys/net/if_loop.c: revision 1.109 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 cleared 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. Advised 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 seconds. Fix comment. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.107.2.1 src/sys/net/if_loop.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_loop.c diff -u src/sys/net/if_loop.c:1.107 src/sys/net/if_loop.c:1.107.2.1 --- src/sys/net/if_loop.c:1.107 Fri Apr 26 08:38:25 2019 +++ src/sys/net/if_loop.c Thu Nov 14 15:34:35 2019 @@ -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.107.2.1 2019/11/14 15:34:35 martin 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.107.2.1 2019/11/14 15:34:35 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -321,8 +321,13 @@ looutput(struct ifnet *ifp, struct mbuf 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 @@ looutput(struct ifnet *ifp, struct mbuf 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_UDPv6 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;