Mercurial > hg > dhcpcd
changeset 2489:a7bd17a62fde draft
If a DHCPv6 lease expires as well as all IPv6 routers who want DHCPv6, don't restart discover.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 19 May 2014 00:49:14 +0000 |
| parents | c2fe62e8d4e1 |
| children | 19b7947d234c |
| files | dhcp6.c dhcpcd.c ipv6nd.c ipv6nd.h script.c |
| diffstat | 5 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/dhcp6.c Mon May 19 00:32:04 2014 +0000 +++ b/dhcp6.c Mon May 19 00:49:14 2014 +0000 @@ -1142,7 +1142,12 @@ dhcp6_freedrop_addrs(ifp, 1, NULL); dhcp6_delete_delegates(ifp); script_runreason(ifp, "EXPIRE6"); - dhcp6_startdiscover(ifp); + if (ipv6nd_hasradhcp(ifp)) + dhcp6_startdiscover(ifp); + else + syslog(LOG_WARNING, + "%s: no advertising IPv6 router wants DHCP", + ifp->name); } static void
--- a/dhcpcd.c Mon May 19 00:32:04 2014 +0000 +++ b/dhcpcd.c Mon May 19 00:49:14 2014 +0000 @@ -1001,7 +1001,7 @@ len++; if (D6_STATE_RUNNING(ifp)) len++; - if (ipv6nd_has_ra(ifp)) + if (ipv6nd_hasra(ifp)) len++; } if (write(fd->fd, &len, sizeof(len)) != @@ -1024,7 +1024,7 @@ len++; if (D6_STATE_RUNNING(ifp)) len++; - if (ipv6nd_has_ra(ifp)) + if (ipv6nd_hasra(ifp)) len++; } }
--- a/ipv6nd.c Mon May 19 00:32:04 2014 +0000 +++ b/ipv6nd.c Mon May 19 00:49:14 2014 +0000 @@ -1022,18 +1022,34 @@ } int -ipv6nd_has_ra(const struct interface *ifp) +ipv6nd_hasra(const struct interface *ifp) { const struct ra *rap; if (ifp->ctx->ipv6) { TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) - if (rap->iface == ifp) + if (rap->iface == ifp && !rap->expired) return 1; } return 0; } +int +ipv6nd_hasradhcp(const struct interface *ifp) +{ + const struct ra *rap; + + if (ifp->ctx->ipv6) { + TAILQ_FOREACH(rap, ifp->ctx->ipv6->ra_routers, next) { + if (rap->iface == ifp && + !rap->expired && + (rap->flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER))) + return 1; + } + } + return 0; +} + ssize_t ipv6nd_env(char **env, const char *prefix, const struct interface *ifp) {
--- a/ipv6nd.h Mon May 19 00:32:04 2014 +0000 +++ b/ipv6nd.h Mon May 19 00:49:14 2014 +0000 @@ -90,7 +90,8 @@ #define ipv6nd_drop_ra(ra) ipv6nd_freedrop_ra((ra), 1) ssize_t ipv6nd_free(struct interface *); void ipv6nd_expirera(void *arg); -int ipv6nd_has_ra(const struct interface *); +int ipv6nd_hasra(const struct interface *); +int ipv6nd_hasradhcp(const struct interface *); void ipv6nd_handleifa(struct dhcpcd_ctx *, int, const char *, const struct in6_addr *, int); void ipv6nd_drop(struct interface *);
--- a/script.c Mon May 19 00:32:04 2014 +0000 +++ b/script.c Mon May 19 00:49:14 2014 +0000 @@ -249,7 +249,7 @@ #ifdef INET6 else if (d6_state && d6_state->new) dhcp6 = 1; - else if (ipv6nd_has_ra(ifp)) + else if (ipv6nd_hasra(ifp)) ra = 1; #endif #ifdef INET @@ -336,7 +336,7 @@ #endif #ifdef INET6 || (dhcp6 && d6_state && d6_state->new) - || (ra && ipv6nd_has_ra(ifp)) + || (ra && ipv6nd_hasra(ifp)) #endif ) { @@ -557,7 +557,7 @@ #endif #ifdef INET6 - if (ipv6nd_has_ra(ifp)) { + if (ipv6nd_hasra(ifp)) { if (send_interface1(fd, ifp, "ROUTERADVERT") == -1) retval = -1; }
