summaryrefslogtreecommitdiffstats
path: root/ipv6nd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-10-09 18:59:30 +0000
committerRoy Marples <roy@marples.name>2014-10-09 18:59:30 +0000
commitf30470407c46975440dee1b524ef01d798ae9274 (patch)
tree17912fb90ff65fdbfb89d4b6a1f16bf9e8e336b9 /ipv6nd.c
parent3446ccb56bc6fedba78161e2fa94cf88f9cfbdb8 (diff)
downloaddhcpcd-f30470407c46975440dee1b524ef01d798ae9274.tar.xz
Allow the same IP address to be leased for different interfaces.
The interface with the lowest metric gets the address. When that interfaces loses the address, the next valid interface with the lowest metric gets it.
Diffstat (limited to 'ipv6nd.c')
-rw-r--r--ipv6nd.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ipv6nd.c b/ipv6nd.c
index 0cf15780..66223439 100644
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -391,14 +391,15 @@ ipv6nd_free_opts(struct ra *rap)
}
}
-int
-ipv6nd_addrexists(struct dhcpcd_ctx *ctx, const struct ipv6_addr *addr)
+struct ipv6_addr *
+ipv6nd_findaddr(struct dhcpcd_ctx *ctx, const struct in6_addr *addr,
+ short flags)
{
struct ra *rap;
struct ipv6_addr *ap;
if (ctx->ipv6 == NULL)
- return 0;
+ return NULL;
TAILQ_FOREACH(rap, ctx->ipv6->ra_routers, next) {
TAILQ_FOREACH(ap, &rap->addrs, next) {
@@ -406,12 +407,14 @@ ipv6nd_addrexists(struct dhcpcd_ctx *ctx, const struct ipv6_addr *addr)
if ((ap->flags &
(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED)) ==
(IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED))
- return 1;
- } else if (IN6_ARE_ADDR_EQUAL(&ap->addr, &addr->addr))
- return 1;
+ return ap;
+ } else if (ap->prefix_vltime &&
+ IN6_ARE_ADDR_EQUAL(&ap->addr, addr) &&
+ (!flags || ap->flags & flags))
+ return ap;
}
}
- return 0;
+ return NULL;
}
void ipv6nd_freedrop_ra(struct ra *rap, int drop)
@@ -525,7 +528,7 @@ ipv6nd_scriptrun(struct ra *rap)
{
hasaddress = 1;
if (!(ap->flags & IPV6_AF_DADCOMPLETED) &&
- ipv6_findaddr(ap->iface, &ap->addr))
+ ipv6_iffindaddr(ap->iface, &ap->addr))
ap->flags |= IPV6_AF_DADCOMPLETED;
if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0) {
syslog(LOG_DEBUG,