]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
A router with a lifetime of zero is no longer a default router.
authorRoy Marples <roy@marples.name>
Fri, 7 Mar 2014 13:01:20 +0000 (13:01 +0000)
committerRoy Marples <roy@marples.name>
Fri, 7 Mar 2014 13:01:20 +0000 (13:01 +0000)
However, the options it passes do have lifetimes which we should still
respect according to RFC4861 section 4.2.

ipv6.c
ipv6nd.c

diff --git a/ipv6.c b/ipv6.c
index ed5882e0bcc7e78831df43bd4beb6d4c2985ab00..30b6c05648f044381bfc6cf2505e6b0a6958e726 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -942,14 +942,15 @@ ipv6_build_ra_routes(struct ipv6_ctx *ctx, struct rt6_head *dnr, int expired)
                        continue;
                if (rap->iface->options->options & DHCPCD_IPV6RA_OWN) {
                        TAILQ_FOREACH(addr, &rap->addrs, next) {
-                               if ((addr->flags & IPV6_AF_ONLINK) == 0)
+                               if (addr->prefix_vltime == 0 ||
+                                   (addr->flags & IPV6_AF_ONLINK) == 0)
                                        continue;
                                rt = make_prefix(rap->iface, rap, addr);
                                if (rt)
                                        TAILQ_INSERT_TAIL(dnr, rt, next);
                        }
                }
-               if (rap->iface->options->options &
+               if (rap->lifetime && rap->iface->options->options &
                    (DHCPCD_IPV6RA_OWN | DHCPCD_IPV6RA_OWN_DEFAULT))
                {
                        rt = make_router(rap);
index 7eccdad78134c7bb935baad9eeec214c05663dec..22c5e2c10be6db7a0d75d5e22876819017a6da49 100644 (file)
--- a/ipv6nd.c
+++ b/ipv6nd.c
@@ -588,7 +588,7 @@ ipv6nd_dadcallback(void *arg)
                                        found = 1;
                        }
 
-                       if (wascompleted && found && rap->lifetime) {
+                       if (wascompleted && found) {
                                syslog(LOG_DEBUG,
                                    "%s: Router Advertisement DAD completed",
                                    rap->iface->name);
@@ -664,11 +664,6 @@ ipv6nd_handlera(struct ipv6_ctx *ctx, struct interface *ifp,
        }
 
        nd_ra = (struct nd_router_advert *)icp;
-       /* Don't bother doing anything if we don't know about a router
-        * expiring */
-       if ((rap == NULL || rap->lifetime == 0)
-           && nd_ra->nd_ra_router_lifetime == 0)
-               return;
 
        /* We don't want to spam the log with the fact we got an RA every
         * 30 seconds or so, so only spam the log if it's different. */
@@ -980,12 +975,8 @@ ipv6nd_handlera(struct ipv6_ctx *ctx, struct interface *ifp,
        }
        ipv6_addaddrs(&rap->addrs);
        ipv6_buildroutes(ifp->ctx);
-
-       /* We will get run by the expire function */
-       if (rap->lifetime) {
-               if (ipv6nd_scriptrun(rap))
-                       return;
-       }
+       if (ipv6nd_scriptrun(rap))
+               return;
 
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
        eloop_timeout_delete(ifp->ctx->eloop, NULL, rap); /* reachable timer */
@@ -1002,15 +993,13 @@ ipv6nd_handlera(struct ipv6_ctx *ctx, struct interface *ifp,
 
 handle_flag:
        if (rap->flags & ND_RA_FLAG_MANAGED) {
-               if (rap->lifetime && new_data &&
-                   dhcp6_start(ifp, DH6S_INIT) == -1)
+               if (new_data && dhcp6_start(ifp, DH6S_INIT) == -1)
                        syslog(LOG_ERR, "dhcp6_start: %s: %m", ifp->name);
        } else if (rap->flags & ND_RA_FLAG_OTHER) {
-               if (rap->lifetime && new_data &&
-                   dhcp6_start(ifp, DH6S_INFORM) == -1)
+               if (new_data && dhcp6_start(ifp, DH6S_INFORM) == -1)
                        syslog(LOG_ERR, "dhcp6_start: %s: %m", ifp->name);
        } else {
-               if (rap->lifetime && new_data)
+               if (new_data)
                        syslog(LOG_DEBUG, "%s: No DHCPv6 instruction in RA",
                            ifp->name);
                if (ifp->ctx->options & DHCPCD_TEST) {
@@ -1180,23 +1169,26 @@ ipv6nd_expirera(void *arg)
        TAILQ_FOREACH_SAFE(rap, ifp->ctx->ipv6->ra_routers, next, ran) {
                if (rap->iface != ifp)
                        continue;
-               lt.tv_sec = rap->lifetime;
-               lt.tv_usec = 0;
-               timeradd(&rap->received, &lt, &expire);
-               if (rap->lifetime == 0 || timercmp(&now, &expire, >)) {
-                       valid = 0;
-                       if (!rap->expired) {
-                               syslog(LOG_WARNING,
-                                   "%s: %s: router expired",
-                                   ifp->name, rap->sfrom);
-                               rap->expired = expired = 1;
-                               ipv6nd_cancelproberouter(rap);
+               valid = 0;
+               if (rap->lifetime) {
+                       lt.tv_sec = rap->lifetime;
+                       lt.tv_usec = 0;
+                       timeradd(&rap->received, &lt, &expire);
+                       if (rap->lifetime == 0 || timercmp(&now, &expire, >)) {
+                               if (!rap->expired) {
+                                       syslog(LOG_WARNING,
+                                           "%s: %s: router expired",
+                                           ifp->name, rap->sfrom);
+                                       rap->expired = expired = 1;
+                                       ipv6nd_cancelproberouter(rap);
+                               }
+                       } else {
+                               valid = 1;
+                               timersub(&expire, &now, &lt);
+                               if (!timerisset(&next) ||
+                                   timercmp(&next, &lt, >))
+                                       next = lt;
                        }
-               } else {
-                       valid = 1;
-                       timersub(&expire, &now, &lt);
-                       if (!timerisset(&next) || timercmp(&next, &lt, >))
-                               next = lt;
                }
 
                /* Addresses are expired in ipv6_addaddrs