pure ipv6 interface not accepted by samba (3 & 4)
Matthieu Patou
mat at samba.org
Fri Oct 14 12:41:47 MDT 2011
Hello,
I tried today to start samba4 on one of my computer it has a 6to4 IPv6
interface and samba was not binding.
Most of the problem is in lib/socket/interfaces.c, in this code:
if (ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) {
make_bcast(&ifaces[total].bcast,
&ifaces[total].ip,
&ifaces[total].netmask);
} else if ((ifaces[total].flags & IFF_POINTOPOINT) &&
ifptr->ifa_dstaddr ) {
memcpy(&ifaces[total].bcast,
ifptr->ifa_dstaddr,
copy_size);
}
The 6to4 interface has the flags IFF_POINTTOPOINT interface but no
ifa_dstaddr as it's not at the IPv6 level a point to point interface (at
least from my understanding), as we don't have a IFF_BROADCAST flag set
(I have the impression that this flag is only set on a interface that
has also an IPv4 address) the first test is not valid also, which result
in a skipped interface.
I made the following patch in my repo: http://bit.ly/rl0DCs, it's
basically this:
memcpy(&ifaces[total].bcast,
ifptr->ifa_dstaddr,
copy_size);
+#if defined(HAVE_IPV6)
+ } else if (ifptr->ifa_addr->sa_family == AF_INET6) {
+ const struct sockaddr_in6 *sin6 = (const struct
sockaddr_in6*)(ifptr->ifa_addr);
+ const struct in6_addr *in6 = (const struct
in6_addr *)&sin6->sin6_addr;
+
+ if (IN6_IS_ADDR_LINKLOCAL(in6) ||
IN6_IS_ADDR_V4COMPAT(in6)) {
+ continue;
+ }
+ /* IPv6 do not have broadcast bydefault there is
special broadcast address for it*/
+ memset(&ifaces[total].bcast, 0, copy_size);
+#endif
} else {
continue;
}
My idea is to say we don't care about broadcast when we do IPv6 because
this exact notion do not exists, and in order not to have the local link
nor the V4compat address we skip this kind of addresses.
The result: on my computer I'm now able to start samba4 and have it
running as a domain controller and listenning on my 6to4 interface.
Matthieu
--
Matthieu Patou
Samba Team
http://samba.org
More information about the samba-technical
mailing list