From 9bb6cf50511db35643ce029fbc6c199992c5b0fe Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Tue, 16 Jan 2018 17:12:20 -0800 Subject: [PATCH] minissdp: Re-add SSDP filtering Add back SSDP filtering. Relying on the kernel to filter out multicast traffic from non-member interfaces simply doesn't work the way many people think it does, so we need to re-introduce manual filtering. But this time we will use in_pktinfo's ifindex for comparison rather than a netmask comparison, so SSDP packets from other subnets should still work. --- minissdp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/minissdp.c b/minissdp.c index 2c7d037..79f53c4 100644 --- a/minissdp.c +++ b/minissdp.c @@ -671,6 +671,11 @@ ProcessSSDPRequest(struct event *ev) pi = (struct in_pktinfo *)CMSG_DATA(cmsg); addr = pi->ipi_spec_dst; inet_ntop(AF_INET, &addr, host, sizeof(host)); + for (i = 0; i < n_lan_addr; i++) + { + if (pi->ipi_ifindex == lan_addr[i].ifindex) + break; + } } #else const char *host; @@ -685,14 +690,14 @@ ProcessSSDPRequest(struct event *ev) break; } } + host = lan_addr[iface].str; +#endif if (n_lan_addr == i) { DPRINTF(E_DEBUG, L_SSDP, "Ignoring SSDP M-SEARCH on other interface [%s]\n", inet_ntoa(sendername.sin_addr)); return; } - host = lan_addr[iface].str; -#endif DPRINTF(E_DEBUG, L_SSDP, "SSDP M-SEARCH from %s:%d ST: %.*s, MX: %.*s, MAN: %.*s\n", inet_ntoa(sendername.sin_addr), ntohs(sendername.sin_port),