Hi, The call to in_proto_cksum_out() is only needed before the packet is passed to ifp->if_output(). The fragment code has its own checksum calculation and the other paths end in goto bad.
My TSO tcp_copper() will also do its own checksum handling, so I have to move the call to in_proto_cksum_out() to avoid calculating it twice. ok? bluhm Index: net/pf.c =================================================================== RCS file: /cvs/src/sys/net/pf.c,v retrieving revision 1.1176 diff -u -p -r1.1176 pf.c --- net/pf.c 7 May 2023 16:23:23 -0000 1.1176 +++ net/pf.c 8 May 2023 12:15:33 -0000 @@ -6548,8 +6548,6 @@ pf_route(struct pf_pdesc *pd, struct pf_ ip = mtod(m0, struct ip *); } - in_proto_cksum_out(m0, ifp); - if (ntohs(ip->ip_len) <= ifp->if_mtu) { ip->ip_sum = 0; if (ifp->if_capabilities & IFCAP_CSUM_IPv4) @@ -6558,6 +6556,7 @@ pf_route(struct pf_pdesc *pd, struct pf_ ipstat_inc(ips_outswcsum); ip->ip_sum = in_cksum(m0, ip->ip_hl << 2); } + in_proto_cksum_out(m0, ifp); ifp->if_output(ifp, m0, sintosa(dst), rt); goto done; } @@ -6677,8 +6676,6 @@ pf_route6(struct pf_pdesc *pd, struct pf } } - in6_proto_cksum_out(m0, ifp); - /* * If packet has been reassembled by PF earlier, we have to * use pf_refragment6() here to turn it back to fragments. @@ -6689,6 +6686,7 @@ pf_route6(struct pf_pdesc *pd, struct pf } if ((u_long)m0->m_pkthdr.len <= ifp->if_mtu) { + in6_proto_cksum_out(m0, ifp); ifp->if_output(ifp, m0, sin6tosa(dst), rt); goto done; } Index: netinet/ip_output.c =================================================================== RCS file: /cvs/src/sys/netinet/ip_output.c,v retrieving revision 1.383 diff -u -p -r1.383 ip_output.c --- netinet/ip_output.c 7 May 2023 16:23:23 -0000 1.383 +++ netinet/ip_output.c 8 May 2023 12:15:33 -0000 @@ -443,7 +443,6 @@ sendit: goto reroute; } #endif - in_proto_cksum_out(m, ifp); #ifdef IPSEC if (ipsec_in_use && (flags & IP_FORWARDING) && (ipforwarding == 2) && @@ -464,7 +463,7 @@ sendit: ipstat_inc(ips_outswcsum); ip->ip_sum = in_cksum(m, hlen); } - + in_proto_cksum_out(m, ifp); error = ifp->if_output(ifp, m, sintosa(dst), ro->ro_rt); goto done; } Index: netinet6/ip6_output.c =================================================================== RCS file: /cvs/src/sys/netinet6/ip6_output.c,v retrieving revision 1.273 diff -u -p -r1.273 ip6_output.c --- netinet6/ip6_output.c 7 May 2023 16:23:24 -0000 1.273 +++ netinet6/ip6_output.c 8 May 2023 12:15:33 -0000 @@ -664,8 +664,6 @@ reroute: ip6->ip6_dst.s6_addr16[1] = dst_scope; } - in6_proto_cksum_out(m, ifp); - /* * Send the packet to the outgoing interface. * If necessary, do IPv6 fragmentation before sending. @@ -701,6 +699,7 @@ reroute: * transmit packet without fragmentation */ if (dontfrag || (tlen <= mtu)) { /* case 1-a and 2-a */ + in6_proto_cksum_out(m, ifp); error = ifp->if_output(ifp, m, sin6tosa(dst), ro->ro_rt); goto done; }