]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 715] libisc Linux IPv6 interface iteration drops multicast flags.
authorDave Hart <hart@ntp.org>
Tue, 8 Jun 2010 13:15:32 +0000 (13:15 +0000)
committerDave Hart <hart@ntp.org>
Tue, 8 Jun 2010 13:15:32 +0000 (13:15 +0000)
bk: 4c0e4274Pcu01sWMa7syhkNo5W8jVA

ChangeLog
lib/isc/unix/interfaceiter.c

index 7fc15664943488a1208f418d3339e63392134668..c69708cd27bdcecabdb6637469dea41990423d17 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+
+* [Bug 715] libisc Linux IPv6 interface iteration drops multicast flags.
+
 ---
 (4.2.6p2-RC5) 2010/06/03 Released by Harlan Stenn <stenn@ntp.org>
 
index 4cfc82179e68d8712d95fe9b50f2f9635223a2fc..87af69e99f48b0dccec14989a8b8803935980102 100644 (file)
@@ -185,8 +185,10 @@ static isc_result_t
 linux_if_inet6_current(isc_interfaceiter_t *iter) {
        char address[33];
        char name[IF_NAMESIZE+1];
+       char strbuf[ISC_STRERRORSIZE];
        struct in6_addr addr6;
-       int ifindex, prefix, flag3, flag4;
+       int ifindex, prefix, scope, flags;
+       struct ifreq ifreq;
        int res;
        unsigned int i;
 
@@ -200,7 +202,7 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) {
        }
 
        res = sscanf(iter->entry, "%32[a-f0-9] %x %x %x %x %16s\n",
-                    address, &ifindex, &prefix, &flag3, &flag4, name);
+                    address, &ifindex, &prefix, &scope, &flags, name);
        if (res != 6) {
                isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
                              ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR,
@@ -222,7 +224,34 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) {
                addr6.s6_addr[i] = byte;
        }
        iter->current.af = AF_INET6;
-       iter->current.flags = INTERFACE_F_UP;
+       iter->current.flags = 0;
+       memset(&ifreq, 0, sizeof(ifreq));
+       INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name));
+       strncpy(ifreq.ifr_name, name, sizeof(ifreq.ifr_name));
+
+       if (ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               "%s: getting interface flags: %s",
+                               ifreq.ifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+
+       if ((ifreq.ifr_flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+#ifdef IFF_POINTOPOINT
+       if ((ifreq.ifr_flags & IFF_POINTOPOINT) != 0)
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+#endif
+       if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+       if ((ifreq.ifr_flags & IFF_BROADCAST) != 0)
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+#ifdef IFF_MULTICAST
+       if ((ifreq.ifr_flags & IFF_MULTICAST) != 0)
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+#endif
+
        isc_netaddr_fromin6(&iter->current.address, &addr6);
        if (isc_netaddr_islinklocal(&iter->current.address)) {
                isc_netaddr_setzone(&iter->current.address,