From: Roy Marples Date: Wed, 31 Oct 2012 13:58:36 +0000 (+0000) Subject: Only remove IPv6 addresses when no RA's have them configured. X-Git-Tag: v5.99.3~46 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=376e8b8055eda6a7458182997e7984f8b37ae309;p=thirdparty%2Fdhcpcd.git Only remove IPv6 addresses when no RA's have them configured. --- diff --git a/ipv6rs.c b/ipv6rs.c index aaa5c717..155391e9 100644 --- a/ipv6rs.c +++ b/ipv6rs.c @@ -269,6 +269,21 @@ ipv6rs_free_opts(struct ra *rap) } } +static int +ipv6rs_addrexists(struct ipv6_addr *a) +{ + struct ra *rap; + struct ipv6_addr *ap; + + TAILQ_FOREACH(rap, &ipv6_routers, next) { + TAILQ_FOREACH(ap, &rap->addrs, next) { + if (memcmp(&ap->addr, &a->addr, sizeof(a->addr)) == 0) + return 1; + } + } + return 0; +} + static void ipv6rs_freedrop_addrs(struct ra *rap, int drop) { @@ -276,7 +291,12 @@ ipv6rs_freedrop_addrs(struct ra *rap, int drop) while ((ap = TAILQ_FIRST(&rap->addrs))) { TAILQ_REMOVE(&rap->addrs, ap, next); - if (drop && (options & DHCPCD_IPV6RA_OWN)) { + /* Only drop the address if no other RAs have assigned it. + * This is safe because the RA is removed from the list + * before we are called. */ + if (drop && (options & DHCPCD_IPV6RA_OWN) && + !ipv6rs_addrexists(ap)) + { syslog(LOG_INFO, "%s: deleting address %s", rap->iface->name, ap->saddr); if (del_address6(rap->iface, ap) == -1)