This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 8a0f354ac62 net/igmp: fix checksum validation that always dropped
valid IGMP packets
8a0f354ac62 is described below
commit 8a0f354ac62032bbcd5d7010a61f9bd3bc30c750
Author: zhekunren <[email protected]>
AuthorDate: Thu Aug 6 21:32:30 2026 +0800
net/igmp: fix checksum validation that always dropped valid IGMP packets
igmp_input() validated the IGMP checksum with:
if (net_chksum((FAR uint16_t *)igmp, IGMP_HDRLEN) != 0)
but net_chksum() returns the raw one's complement sum of the 16-bit
words (it does NOT take the one's complement of that sum). For a valid
IGMP packet whose checksum field holds ~S (as written by igmp_send()),
the sum of all 16-bit words is S + ~S = 0xffff, never 0.
So the existing check `!= 0` was always true for any well-formed IGMP
message, sending every valid packet down the "Checksum error" path to
be silently dropped and breaking IGMP membership query/report processing.
Compare against 0xffff instead, matching the convention used by the
other transport input handlers:
- ipv4_input.c: (ipv4_chksum(IPv4BUF) != 0xffff)
- tcp_input.c: (tcp_chksum(dev) != 0xffff)
This is also consistent with the sender side in igmp_send.c, which
stores `igmp->chksum = ~igmp_chksum(...)`.
Signed-off-by: zhekunren <[email protected]>
Assisted-by: GLM-5.2 <[email protected]>
---
net/igmp/igmp_input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/igmp/igmp_input.c b/net/igmp/igmp_input.c
index e107c3db02d..4d10e5c9c71 100644
--- a/net/igmp/igmp_input.c
+++ b/net/igmp/igmp_input.c
@@ -141,7 +141,7 @@ void igmp_input(struct net_driver_s *dev)
#ifdef CONFIG_NET_IGMP_CHECKSUMS
/* Calculate and check the IGMP checksum */
- if (net_chksum((FAR uint16_t *)igmp, IGMP_HDRLEN) != 0)
+ if (net_chksum((FAR uint16_t *)igmp, IGMP_HDRLEN) != 0xffff)
{
IGMP_STATINCR(g_netstats.igmp.chksum_errors);
nwarn("WARNING: Checksum error\n");