From f7b48b9214404c6e2ef827e74672354d085000de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Str=C3=B6m?= Date: Fri, 19 Nov 2021 22:47:54 +0100 Subject: [PATCH] Fix IGMP timer (#3476) LWIP_RAND() return type is int, value returned is sometimes negative. This causes timer to sometimes (often) go outside of max_time, which in turn causes IGMP snoopers or IGMP routers to drop the subscription --- app/lwip/core/ipv4/igmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lwip/core/ipv4/igmp.c b/app/lwip/core/ipv4/igmp.c index 8e35ecd4..e2c81f2f 100644 --- a/app/lwip/core/ipv4/igmp.c +++ b/app/lwip/core/ipv4/igmp.c @@ -731,7 +731,7 @@ igmp_start_timer(struct igmp_group *group, u8_t max_time) if(max_time == 1) group->timer = 1; else - group->timer = (LWIP_RAND() % (max_time - 1)) + 1; + group->timer = (u16_t) ((unsigned int)LWIP_RAND() % (max_time - 1)) + 1; } /**