]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
RA: expire whole RA on carrier up
authorRoy Marples <roy@marples.name>
Fri, 14 Jun 2019 16:05:24 +0000 (17:05 +0100)
committerRoy Marples <roy@marples.name>
Fri, 14 Jun 2019 16:05:24 +0000 (17:05 +0100)
If preserving IP, we need to expire the whole RA now that we care
about RDNSS and DNSSL lifetimes. Cheat by setting the aquired time
to something very low so it all expires.

src/dhcpcd.c
src/ipv6nd.c
src/ipv6nd.h

index 981134b456a9da09ea95b8b081318381b7c790a3..fc5003531a7c14e382e101327f72c7909357a9d8 100644 (file)
@@ -782,7 +782,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
                        /* Set any IPv6 Routers we remembered to expire
                         * faster than they would normally as we
                         * maybe on a new network. */
-                       ipv6nd_expire(ifp, RTR_CARRIER_EXPIRE);
+                       ipv6nd_startexpire(ifp);
 #endif
                        /* RFC4941 Section 3.5 */
                        ipv6_gentempifid(ifp);
index 1adb5e16a4a92a19d8e450cc6754f553cc0eaa1a..5ece711e5d5c201ff0467df262ec162d9cb90b48 100644 (file)
@@ -526,46 +526,34 @@ ipv6nd_advertise(struct ipv6_addr *ia)
        ipv6nd_sendadvertisement(iaf);
 }
 
-void
-ipv6nd_expire(struct interface *ifp, uint32_t seconds)
+static void
+ipv6nd_expire(void *arg)
 {
+       struct interface *ifp = arg;
        struct ra *rap;
-       struct timespec now;
-       uint32_t vltime = seconds;
-       uint32_t pltime = seconds / 2;
+       struct ipv6_addr *ia;
+       struct timespec now = { .tv_sec = 1 };
 
        if (ifp->ctx->ra_routers == NULL)
                return;
 
-       clock_gettime(CLOCK_MONOTONIC, &now);
-
        TAILQ_FOREACH(rap, ifp->ctx->ra_routers, next) {
-               if (rap->iface == ifp) {
-                       rap->acquired = now;
-                       rap->expired = seconds ? 0 : 1;
-                       if (seconds) {
-                               struct ipv6_addr *ia;
-
-                               rap->lifetime = seconds;
-                               TAILQ_FOREACH(ia, &rap->addrs, next) {
-                                       if (ia->prefix_pltime > pltime ||
-                                           ia->prefix_vltime > vltime)
-                                       {
-                                               ia->acquired = now;
-                                               if (ia->prefix_pltime != 0)
-                                                       ia->prefix_pltime =
-                                                           pltime;
-                                               ia->prefix_vltime = vltime;
-                                       }
-                               }
-                               ipv6_addaddrs(&rap->addrs);
-                       }
+               if (rap->iface == ifp)
+                       continue;
+               rap->acquired = now;
+               TAILQ_FOREACH(ia, &rap->addrs, next) {
+                       ia->acquired = now;
                }
        }
-       if (seconds)
-               ipv6nd_expirera(ifp);
-       else
-               rt_build(ifp->ctx, AF_INET6);
+       ipv6nd_expirera(ifp);
+}
+
+void
+ipv6nd_startexpire(struct interface *ifp)
+{
+
+       eloop_timeout_add_sec(ifp->ctx->eloop, RTR_CARRIER_EXPIRE,
+           ipv6nd_expire, ifp);
 }
 
 static void
index 7b9598148701062ceaf444cb2a8e4c33eb7c1078..2727e51446a47b731e38b564a8933d1334971688 100644 (file)
@@ -107,7 +107,7 @@ int ipv6nd_hasradhcp(const struct interface *);
 void ipv6nd_handleifa(int, struct ipv6_addr *, pid_t);
 int ipv6nd_dadcompleted(const struct interface *);
 void ipv6nd_advertise(struct ipv6_addr *);
-void ipv6nd_expire(struct interface *, uint32_t);
+void ipv6nd_startexpire(struct interface *);
 void ipv6nd_drop(struct interface *);
 void ipv6nd_neighbour(struct dhcpcd_ctx *, struct in6_addr *, int);
 #endif /* INET6 */