--- embedaddon/dnsmasq/src/netlink.c 2013/07/29 19:37:40 1.1 +++ embedaddon/dnsmasq/src/netlink.c 2014/06/15 16:31:38 1.1.1.2 @@ -1,4 +1,4 @@ -/* dnsmasq is Copyright (c) 2000-2013 Simon Kelley +/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -39,7 +39,6 @@ static struct iovec iov; static u32 netlink_pid; static int nl_async(struct nlmsghdr *h); -static void nl_newaddress(time_t now); void netlink_init(void) { @@ -193,14 +192,17 @@ int iface_enumerate(int family, void *parm, int (*call { /* May be multicast arriving async */ if (nl_async(h)) - newaddr = 1; + { + newaddr = 1; + enumerate_interfaces(1); /* reset */ + } } else if (h->nlmsg_type == NLMSG_DONE) { /* handle async new interface address arrivals, these have to be done after we complete as we're not re-entrant */ if (newaddr) - nl_newaddress(dnsmasq_time()); + newaddress(dnsmasq_time()); return callback_ok; } @@ -215,7 +217,8 @@ int iface_enumerate(int family, void *parm, int (*call if (ifa->ifa_family == AF_INET) { struct in_addr netmask, addr, broadcast; - + char *label = NULL; + netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen)); addr.s_addr = 0; broadcast.s_addr = 0; @@ -226,12 +229,14 @@ int iface_enumerate(int family, void *parm, int (*call addr = *((struct in_addr *)(rta+1)); else if (rta->rta_type == IFA_BROADCAST) broadcast = *((struct in_addr *)(rta+1)); + else if (rta->rta_type == IFA_LABEL) + label = RTA_DATA(rta); rta = RTA_NEXT(rta, len1); } if (addr.s_addr && callback_ok) - if (!((*callback)(addr, ifa->ifa_index, netmask, broadcast, parm))) + if (!((*callback)(addr, ifa->ifa_index, label, netmask, broadcast, parm))) callback_ok = 0; } #ifdef HAVE_IPV6 @@ -260,6 +265,9 @@ int iface_enumerate(int family, void *parm, int (*call if (ifa->ifa_flags & IFA_F_DEPRECATED) flags |= IFACE_DEPRECATED; + if (!(ifa->ifa_flags & IFA_F_TEMPORARY)) + flags |= IFACE_PERMANENT; + if (addrp && callback_ok) if (!((*callback)(addrp, (int)(ifa->ifa_prefixlen), (int)(ifa->ifa_scope), (int)(ifa->ifa_index), flags, @@ -342,7 +350,7 @@ void netlink_multicast(time_t now) fcntl(daemon->netlinkfd, F_SETFL, flags); if (newaddr) - nl_newaddress(now); + newaddress(now); } static int nl_async(struct nlmsghdr *h) @@ -390,28 +398,6 @@ static int nl_async(struct nlmsghdr *h) return 0; } - -static void nl_newaddress(time_t now) -{ - if (option_bool(OPT_CLEVERBIND) || daemon->doing_dhcp6 || daemon->doing_ra) - enumerate_interfaces(); - - if (option_bool(OPT_CLEVERBIND)) - create_bound_listeners(0); - -#ifdef HAVE_DHCP6 - if (daemon->doing_dhcp6 || daemon->doing_ra) - { - join_multicast(0); - dhcp_construct_contexts(now); - } - - if (daemon->doing_dhcp6) - lease_find_interfaces(now); -#endif -} - - #endif