diff options
| author | Roy Marples <roy@marples.name> | 2016-07-27 15:39:29 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2016-07-27 15:39:29 +0000 |
| commit | 8c15388073d54f9bf85b53342269fcd0a002e805 (patch) | |
| tree | 5c5ca019d6c4e6ff5c89b5c87a71409e19ef50bb /ipv6.c | |
| parent | 8b5c7a9ab001ef0e8e344f234a6d2784fc0ea231 (diff) | |
| download | dhcpcd-8c15388073d54f9bf85b53342269fcd0a002e805.tar.xz | |
When aliasing to an existing address, check it is already aliased.
Add debug to say which alias will use the address.
Fixes Solaris.
Diffstat (limited to 'ipv6.c')
| -rw-r--r-- | ipv6.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -790,14 +790,15 @@ ipv6_aliasaddr(struct ipv6_addr *ia, struct ipv6_addr **repl) if (ia->alias[0] != '\0') return 0; - state = IPV6_STATE(ia->iface); /* First find an existng address. * This can happen when dhcpcd restarts as ND and DHCPv6 * maintain their own lists of addresses. */ TAILQ_FOREACH(iap, &state->addrs, next) { - if (IN6_ARE_ADDR_EQUAL(&iap->addr, &ia->addr)) { + if (iap->alias[0] != '\0' && + IN6_ARE_ADDR_EQUAL(&iap->addr, &ia->addr)) + { strlcpy(ia->alias, iap->alias, sizeof(ia->alias)); return 0; } @@ -810,6 +811,8 @@ find_unit: else snprintf(alias, sizeof(alias), "%s:%u", ia->iface->name, unit); TAILQ_FOREACH(iap, &state->addrs, next) { + if (iap->alias[0] == '\0') + continue; if (IN6_IS_ADDR_UNSPECIFIED(&iap->addr)) { /* No address assigned? Lets use it. */ strlcpy(ia->alias, iap->alias, sizeof(ia->alias)); @@ -840,11 +843,15 @@ ipv6_addaddr(struct ipv6_addr *ia, const struct timespec *now) { int r; #ifdef ALIAS_ADDR - int replaced; + int replaced, blank; struct ipv6_addr *replaced_ia; + blank = (ia->alias[0] == '\0'); if ((replaced = ipv6_aliasaddr(ia, &replaced_ia)) == -1) return -1; + if (blank) + logger(ia->iface->ctx, LOG_DEBUG, "%s: aliased %s", + ia->alias, ia->saddr); #endif if ((r = ipv6_addaddr1(ia, now)) == 0) { |
