]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If a DHCPv6 lease expires as well as all IPv6 routers who want DHCPv6, don't restart...
authorRoy Marples <roy@marples.name>
Mon, 19 May 2014 00:49:14 +0000 (00:49 +0000)
committerRoy Marples <roy@marples.name>
Mon, 19 May 2014 00:49:14 +0000 (00:49 +0000)
dhcp6.c
dhcpcd.c
ipv6nd.c
ipv6nd.h
script.c

diff --git a/dhcp6.c b/dhcp6.c
index 8c27bcc47e65d7fa17b29d14aaedaf37ca69f107..d18da6ed24521d1cf2355812399b16398b9e7708 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -1142,7 +1142,12 @@ dhcp6_startexpire(void *arg)
        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
index fe869c119c464e9c0f133496de917343a43d1541..5e142009b6a5bb6a2475dab762d10bf33a95a1e5 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1001,7 +1001,7 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd,
                                                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 @@ dhcpcd_handleargs(struct dhcpcd_ctx *ctx, struct fd_list *fd,
                                                        len++;
                                                if (D6_STATE_RUNNING(ifp))
                                                        len++;
-                                               if (ipv6nd_has_ra(ifp))
+                                               if (ipv6nd_hasra(ifp))
                                                        len++;
                                        }
                                }
index da3817b62f251c64a14dcd40d6844b3d461ba9b8..9977fd06e60923fa13fe443db7bf1cf0b7704aef 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -1022,18 +1022,34 @@ handle_flag:
 }
 
 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)
 {
index 9dbbdf63495d82b17cf8a04721f2b26425b4435f..6c52c1fde2a1b314ce8ce4dd0d48633a9571ed24 100644 (file)
--- a/ipv6nd.h
+++ b/ipv6nd.h
@@ -90,7 +90,8 @@ void ipv6nd_freedrop_ra(struct ra *, int);
 #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 *);
index bbc9006a26d04c1cfbede743a495155e777458cb..e3f3405093fac0d19f8723a4794e164b0d29b558 100644 (file)
--- a/script.c
+++ b/script.c
@@ -249,7 +249,7 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
 #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 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
 #endif
 #ifdef INET6
            || (dhcp6 && d6_state && d6_state->new)
-           || (ra && ipv6nd_has_ra(ifp))
+           || (ra && ipv6nd_hasra(ifp))
 #endif
            )
        {
@@ -557,7 +557,7 @@ send_interface(int fd, const struct interface *ifp)
 #endif
 
 #ifdef INET6
-       if (ipv6nd_has_ra(ifp)) {
+       if (ipv6nd_hasra(ifp)) {
                if (send_interface1(fd, ifp, "ROUTERADVERT") == -1)
                        retval = -1;
        }