From f38352f1afe52faa7f4d44bdb9df88d5d06b015a Mon Sep 17 00:00:00 2001 From: sg Date: Tue, 9 Dec 2014 20:56:39 +0100 Subject: [PATCH] fixed bug #43596 IGMP queries from 0.0.0.0 are discarded --- CHANGELOG | 3 +++ src/core/ipv4/ip4.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1f4b80da..f49d444d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -139,6 +139,9 @@ HISTORY ++ Bugfixes: + 2014-12-09: Simon Goldschmidt + * ip4.c: fixed bug #43596 IGMP queries from 0.0.0.0 are discarded + 2014-10-21: Simon Goldschmidt (patch by Joel Cunningham and Albert Huitsing) * sockts.c: fixed bugs #41495 Possible threading issue in select() and #43278 event_callback() handle context switch when calling sys_sem_signal() diff --git a/src/core/ipv4/ip4.c b/src/core/ipv4/ip4.c index 9b360652..f838c37a 100644 --- a/src/core/ipv4/ip4.c +++ b/src/core/ipv4/ip4.c @@ -301,9 +301,9 @@ ip_input(struct pbuf *p, struct netif *inp) struct netif *netif; u16_t iphdr_hlen; u16_t iphdr_len; -#if IP_ACCEPT_LINK_LAYER_ADDRESSING - int check_ip_src=1; -#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ +#if IP_ACCEPT_LINK_LAYER_ADDRESSING || LWIP_IGMP + int check_ip_src = 1; +#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING || LWIP_IGMP */ IP_STATS_INC(ip.recv); snmp_inc_ipinreceives(); @@ -381,6 +381,13 @@ ip_input(struct pbuf *p, struct netif *inp) #if LWIP_IGMP if (ip_addr_ismulticast(ip_current_dest_addr())) { if ((inp->flags & NETIF_FLAG_IGMP) && (igmp_lookfor_group(inp, ip_current_dest_addr()))) { + /* IGMP snooping switches need 0.0.0.0 to be allowed as source address (RFC 4541) */ + ip_addr_t allsystems; + IP4_ADDR(&allsystems, 224, 0, 0, 1); + if (ip_addr_cmp(ip_current_dest_addr(), &allsystems) && + ip_addr_isany(ip_current_src_addr())) { + check_ip_src = 0; + } netif = inp; } else { netif = NULL; @@ -461,10 +468,14 @@ ip_input(struct pbuf *p, struct netif *inp) #endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ /* broadcast or multicast packet source address? Compliant with RFC 1122: 3.2.1.3 */ +#if LWIP_IGMP || IP_ACCEPT_LINK_LAYER_ADDRESSING + if (check_ip_src #if IP_ACCEPT_LINK_LAYER_ADDRESSING /* DHCP servers need 0.0.0.0 to be allowed as source address (RFC 1.1.2.2: 3.2.1.3/a) */ - if (check_ip_src && !ip_addr_isany(ip_current_src_addr())) + && !ip_addr_isany(ip_current_src_addr()) #endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */ + ) +#endif /* LWIP_IGMP || IP_ACCEPT_LINK_LAYER_ADDRESSING */ { if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) || (ip_addr_ismulticast(ip_current_src_addr()))) { /* packet source is not valid */