Module Name: src Committed By: msaitoh Date: Mon Nov 11 08:12:35 UTC 2019
Modified Files: src/sys/net: if_loop.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 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.108 --- src/sys/net/if_loop.c:1.107 Fri Apr 26 08:38:25 2019 +++ src/sys/net/if_loop.c Mon Nov 11 08:12: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.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 @@ 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_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;