From d87740bb963b915a9b194ee0f89a64b250674121 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Tue, 2 Jan 2018 20:38:36 +0100 Subject: [PATCH] mdns: Fix multicast destination check for IPv6 This broke when IPv6 got scopes added. Scopes/zones are checked even if none of the compared addresses are link local. Result of the bug was that IPv6 replies were always sent unicast to the source instead of to the multicast address. Add ip-generic version that ignores IP zone info, since the v6 group address is not tied to any netif. --- src/apps/mdns/mdns.c | 2 +- src/include/lwip/ip_addr.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/apps/mdns/mdns.c b/src/apps/mdns/mdns.c index 61061f70..ca614e01 100644 --- a/src/apps/mdns/mdns.c +++ b/src/apps/mdns/mdns.c @@ -1814,7 +1814,7 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, #if LWIP_IPV6 if (IP_IS_V6(ip_current_dest_addr())) { - if (!ip_addr_cmp(ip_current_dest_addr(), &v6group)) { + if (!ip_addr_cmp_zoneless(ip_current_dest_addr(), &v6group)) { packet.recv_unicast = 1; } } diff --git a/src/include/lwip/ip_addr.h b/src/include/lwip/ip_addr.h index 8b0056b4..df5fd503 100644 --- a/src/include/lwip/ip_addr.h +++ b/src/include/lwip/ip_addr.h @@ -201,6 +201,10 @@ extern const ip_addr_t ip_addr_any_type; ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) /** @ingroup ipaddr */ +#define ip_addr_cmp_zoneless(addr1, addr2) ((IP_GET_TYPE(addr1) != IP_GET_TYPE(addr2)) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \ + ip6_addr_cmp_zoneless(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \ + ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2)))) +/** @ingroup ipaddr */ #define ip_addr_isany(ipaddr) (((ipaddr) == NULL) ? 1 : ((IP_IS_V6(ipaddr)) ? \ ip6_addr_isany(ip_2_ip6(ipaddr)) : \ ip4_addr_isany(ip_2_ip4(ipaddr))))