NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/56263: mdnsd advertises link-local addresses in non-standard KAME format
>Number: 56263
>Category: bin
>Synopsis: mdnsd advertises link-local addresses in non-standard KAME format
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Jun 20 13:40:00 +0000 2021
>Originator: Andrew Stevenson
>Release: 9.99.83
>Organization:
>Environment:
NetBSD 3dp 9.99.83 NetBSD 9.99.83 (RPI) #0: Sun Jun 6 18:37:20 UTC 2021 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/evbarm/compile/RPI evbarm
>Description:
mdnsd advertises the link local address obtained from getifaddrs() however this is in the non-standard KAME format where the scope ID is embedded in bytes 3 & 4.
I'm not sure getifaddrs() should be returning it in that format but as it does it is important that mdnsd regularises it (i.e. sets these bytes to 0) before putting it on the wire. In my limited testing BSD based systems seem to handle it (zeroing the bytes themselves) but Linux machines using systems-resolved do not. They are therefore unable to contact NetBSD machines using the IPv6 link local address.
mdnsd is contributed code from Apple but IIUC the fix needs to be in mDNSBSD.c which I don't see in the upstream distribution.
>How-To-Repeat:
Run mdnsd on NetBSD.
Look at the mdns packets on the wire and see the AAAA address advertised does not match that you see with ifconfig.
OR
>From a linux machine using systems-resolved try ping -6 "netbsd.local". The address used will have bits set in the 4th byte and won't match what you see with ifconfig on the NetBSD machine. The ping will timeout.
>Fix:
--- external/apache2/mDNSResponder/dist/mDNSPosix/mDNSBSD.c.orig 2021-06-20 13:32:59.522315787 +0000
+++ external/apache2/mDNSResponder/dist/mDNSPosix/mDNSBSD.c 2021-06-20 13:33:37.814346492 +0000
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
+#include <netinet6/in6.h>
#include <net/if_dl.h>
static int
@@ -112,6 +113,17 @@
if (!copyaddr(&ifi->ifi_netmask, ifa->ifa_netmask, sa->sa_len))
goto gotError;
+ if (sa->sa_family == AF_INET6) {
+ struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *)(ifi->ifi_addr);
+ if (IN6_IS_ADDR_LINKLOCAL(&(sa6->sin6_addr))) {
+ // KAME encodes the zone ID in the 3rd and 4th byte of a link
+ // local address but we musn't leak that to the outside world.
+ // BSD derived systems will cope but e.g. systemd systems will
+ // not
+ sa6->sin6_addr.__u6_addr.__u6_addr16[1] = 0;
+ }
+ }
+
if ((flags & IFF_BROADCAST) && !copyaddr(&ifi->ifi_brdaddr,
ifa->ifa_broadaddr, sa->sa_len))
goto gotError;
Home |
Main Index |
Thread Index |
Old Index