git: d5f5193e2db9 - main - rtwn: don't treat UDP/TCP checksum failure as permanent failure

From: Adrian Chadd <adrian_at_FreeBSD.org>
Date: Wed, 23 Apr 2025 02:04:09 UTC
The branch main has been updated by adrian:

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

commit d5f5193e2db974576120b5e5f559970a6c15247d
Author:     Adrian Chadd <adrian@FreeBSD.org>
AuthorDate: 2025-04-01 23:57:41 +0000
Commit:     Adrian Chadd <adrian@FreeBSD.org>
CommitDate: 2025-04-23 02:02:47 +0000

    rtwn: don't treat UDP/TCP checksum failure as permanent failure
    
    jrtc27@freebsd.org reported that DHCP wasn't working on some
    networks.  She dug into it and found that the RTL8812AU/RTL8812AU
    NICs seem to be failing UDP frames w/ a zero checksum, which is
    a valid "there's no checksum" checksum.
    
    So, just pass those frames up the stack and let the IP stack
    deal with it.  If the hardware claims the frames did pass TCP/UDP
    checksum then still mark those frames with the checksum offload
    bits.
    
    PR:     kern/285387
    Differential Revision:  https://reviews.freebsd.org/D49628
---
 sys/dev/rtwn/rtl8812a/r12a_rx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/sys/dev/rtwn/rtl8812a/r12a_rx.c b/sys/dev/rtwn/rtl8812a/r12a_rx.c
index 805775033fd1..b2e02998de49 100644
--- a/sys/dev/rtwn/rtl8812a/r12a_rx.c
+++ b/sys/dev/rtwn/rtl8812a/r12a_rx.c
@@ -190,8 +190,16 @@ r12a_check_frame_checksum(struct rtwn_softc *sc, struct mbuf *m)
 		    (rxdw1 & R12A_RXDW1_IPV6) ? "IPv6" : "IP",
 		    (rxdw1 & R12A_RXDW1_CKSUM_ERR) ? "invalid" : "valid");
 
+		/*
+		 * There seems to be a problem with UDP checksum processing
+		 * with the checksum value = 0 (ie, no checksum.)
+		 * So, don't treat it as a permament failure; just let
+		 * the IP stack take a crack at validating frames.
+		 *
+		 * See kern/285837 for more details.
+		 */
 		if (rxdw1 & R12A_RXDW1_CKSUM_ERR)
-			return (-1);
+			return (0);
 
 		if ((rxdw1 & R12A_RXDW1_IPV6) ?
 		    (rs->rs_flags & R12A_RXCKSUM6_EN) :