summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-11-14 10:16:30 +0000
committerRoy Marples <roy@marples.name>2012-11-14 10:16:30 +0000
commitc42cbb3c3b54b31598b0f19e8d8d6882c85c5f8d (patch)
tree79fdd91fef4b0a46d6068892f337482f3f29f653
parent323b06a0d3fb5ce1050cfe2079ea42adfe20cbf3 (diff)
downloaddhcpcd-c42cbb3c3b54b31598b0f19e8d8d6882c85c5f8d.tar.xz
Only remove IPv6 addresses when no RA's have them configured.
-rw-r--r--ipv6rs.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/ipv6rs.c b/ipv6rs.c
index 3737d91c..31a52309 100644
--- a/ipv6rs.c
+++ b/ipv6rs.c
@@ -262,6 +262,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)
{
@@ -269,7 +284,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)