net/igmp: drop the invalid packet

igmp message storm occurs if multiple nuttx devices works on same network.

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-04-14 20:56:38 +08:00 committed by Xiang Xiao
parent 692856a626
commit b96fc3fe84

View File

@ -140,7 +140,7 @@ void igmp_input(struct net_driver_s *dev)
{ {
IGMP_STATINCR(g_netstats.igmp.length_errors); IGMP_STATINCR(g_netstats.igmp.length_errors);
nwarn("WARNING: Length error\n"); nwarn("WARNING: Length error\n");
return; goto drop;
} }
/* Calculate and check the IGMP checksum */ /* Calculate and check the IGMP checksum */
@ -149,7 +149,7 @@ void igmp_input(struct net_driver_s *dev)
{ {
IGMP_STATINCR(g_netstats.igmp.chksum_errors); IGMP_STATINCR(g_netstats.igmp.chksum_errors);
nwarn("WARNING: Checksum error\n"); nwarn("WARNING: Checksum error\n");
return; goto drop;
} }
/* Find the group (or create a new one) using the incoming IP address. */ /* Find the group (or create a new one) using the incoming IP address. */
@ -161,7 +161,7 @@ void igmp_input(struct net_driver_s *dev)
{ {
nerr("ERROR: Failed to find/allocate group: %08" PRIx32 "\n", nerr("ERROR: Failed to find/allocate group: %08" PRIx32 "\n",
(uint32_t)destipaddr); (uint32_t)destipaddr);
return; goto drop;
} }
/* Now handle the message based on the IGMP message type */ /* Now handle the message based on the IGMP message type */
@ -302,6 +302,7 @@ void igmp_input(struct net_driver_s *dev)
break; break;
} }
drop:
dev->d_len = 0; dev->d_len = 0;
return; return;
} }