The branch stable/14 has been updated by tuexen:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=1b8d19dea4624cba3c96fb4fdcf05f681562ee0b

commit 1b8d19dea4624cba3c96fb4fdcf05f681562ee0b
Author:     Michael Tuexen <[email protected]>
AuthorDate: 2026-08-06 14:54:45 +0000
Commit:     Michael Tuexen <[email protected]>
CommitDate: 2026-08-06 14:54:45 +0000

    Revert "loopback: improve checksum offloading"
    
    This reverts commit d6c4cea7740d5c5c673a06ba37e4f1bdcddb2ece.
    It is done because this change interferes with the ipfilter
    NAT functionality. So Back it out until ipfilter has been fixed.
---
 share/man/man4/lo.4 | 23 +++++++++++++----------
 sys/net/if_loop.c   | 42 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 16 deletions(-)

diff --git a/share/man/man4/lo.4 b/share/man/man4/lo.4
index 5b808153559a..f1ac67c7d7db 100644
--- a/share/man/man4/lo.4
+++ b/share/man/man4/lo.4
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)lo.4       8.1 (Berkeley) 6/5/93
 .\"
-.Dd June 28, 2026
+.Dd June 23, 2024
 .Dt LO 4
 .Os
 .Sh NAME
@@ -56,16 +56,19 @@ The loopback should
 be configured first unless no hardware
 interfaces exist.
 .Pp
-If the transmit checksum offload capability is enabled on a loopback interface,
-checksums will not be generated by IP, UDP, TCP, or SCTP for packets sent on 
the
-interface.
-By default, this capability is enabled to avoid the overhead of checksumming 
for
-local communication where data corruption is unlikely.
+If the transmit checksum offload capability flag is enabled on a loopback
+interface, checksums will not be generated by IP, UDP, TCP, or SCTP for packets
+sent on the interface.
 .Pp
-If the receive checksum offload capability is disabled on a loopback interface,
-the flags that indicate a valid checksum will be unset if set previously.
-By default, this capability is enabled to avoid another checksum validation if
-it has already been validated.
+If the receive checksum offload capability flag is enabled on a loopback
+interface, checksums will not be validated by IP, UDP, TCP, or SCTP for packets
+received on the interface.
+.Pp
+By default, both receive and transmit checksum flags will be enabled, in
+order to avoid the overhead of checksumming for local communication where
+data corruption is unlikely.
+If transmit checksum generation is disabled, then validation should also be
+disabled in order to avoid packets being dropped due to invalid checksums.
 .Sh DIAGNOSTICS
 .Bl -diag
 .It lo%d: can't handle af%d.
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 97a534e43212..92740bfb6cfb 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -230,22 +230,38 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct 
sockaddr *dst,
        else
                af = RO_GET_FAMILY(ro, dst);
 
+#if 1  /* XXX */
        switch (af) {
        case AF_INET:
-               if ((ifp->if_capenable & IFCAP_RXCSUM) == 0) {
-                       m->m_pkthdr.csum_flags &= ~LO_CSUM_SET;
+               if (ifp->if_capenable & IFCAP_RXCSUM) {
+                       m->m_pkthdr.csum_data = 0xffff;
+                       m->m_pkthdr.csum_flags = LO_CSUM_SET;
                }
+               m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES;
                break;
        case AF_INET6:
-               if ((ifp->if_capenable & IFCAP_RXCSUM_IPV6) == 0) {
-                       m->m_pkthdr.csum_flags &= ~LO_CSUM_SET;
+#if 0
+               /*
+                * XXX-BZ for now always claim the checksum is good despite
+                * any interface flags.   This is a workaround for 9.1-R and
+                * a proper solution ought to be sought later.
+                */
+               if (ifp->if_capenable & IFCAP_RXCSUM_IPV6) {
+                       m->m_pkthdr.csum_data = 0xffff;
+                       m->m_pkthdr.csum_flags = LO_CSUM_SET;
                }
+#else
+               m->m_pkthdr.csum_data = 0xffff;
+               m->m_pkthdr.csum_flags = LO_CSUM_SET;
+#endif
+               m->m_pkthdr.csum_flags &= ~LO_CSUM_FEATURES6;
                break;
        default:
                printf("looutput: af=%d unexpected\n", af);
                m_freem(m);
                return (EAFNOSUPPORT);
        }
+#endif
        return (if_simloop(ifp, m, af, 0));
 }
 
@@ -399,15 +415,29 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
                        ifp->if_capenable ^= IFCAP_RXCSUM;
                if ((mask & IFCAP_TXCSUM) != 0)
                        ifp->if_capenable ^= IFCAP_TXCSUM;
-               if ((mask & IFCAP_RXCSUM_IPV6) != 0)
+               if ((mask & IFCAP_RXCSUM_IPV6) != 0) {
+#if 0
                        ifp->if_capenable ^= IFCAP_RXCSUM_IPV6;
-               if ((mask & IFCAP_TXCSUM_IPV6) != 0)
+#else
+                       error = EOPNOTSUPP;
+                       break;
+#endif
+               }
+               if ((mask & IFCAP_TXCSUM_IPV6) != 0) {
+#if 0
                        ifp->if_capenable ^= IFCAP_TXCSUM_IPV6;
+#else
+                       error = EOPNOTSUPP;
+                       break;
+#endif
+               }
                ifp->if_hwassist = 0;
                if (ifp->if_capenable & IFCAP_TXCSUM)
                        ifp->if_hwassist = LO_CSUM_FEATURES;
+#if 0
                if (ifp->if_capenable & IFCAP_TXCSUM_IPV6)
                        ifp->if_hwassist |= LO_CSUM_FEATURES6;
+#endif
                break;
 
        default:

Reply via email to