]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
ip6: Install not on link routes with a gateway of the router
authorRoy Marples <roy@marples.name>
Sun, 6 Jan 2019 10:10:59 +0000 (10:10 +0000)
committerRoy Marples <roy@marples.name>
Sun, 6 Jan 2019 10:10:59 +0000 (10:10 +0000)
This allows a secondary router to broadcast prefixes it controls
without being a default router itself.

src/ipv6.c
src/ipv6nd.c

index 38cb06d85c8e4002a5432bdffb0e389919eb97f0..1f1e36c0cf1246e273569a8ae7bf534785c3cb93 100644 (file)
@@ -2151,13 +2151,11 @@ inet6_makeprefix(struct interface *ifp, const struct ra *rap,
        }
 
        /* There is no point in trying to manage a /128 prefix,
-        * ones without a lifetime or ones not on link or delegated */
-       if (addr->prefix_len == 128 ||
-           addr->prefix_vltime == 0 ||
-           !(addr->flags & (IPV6_AF_ONLINK | IPV6_AF_DELEGATEDPFX)))
+        * ones without a lifetime.  */
+       if (addr->prefix_len == 128 || addr->prefix_vltime == 0)
                return NULL;
 
-       /* Don't install a reject route when not creating bigger prefixes */
+       /* Don't install a reject route when not creating bigger prefixes. */
        if (addr->flags & IPV6_AF_NOREJECT)
                return NULL;
 
@@ -2189,7 +2187,9 @@ inet6_makeprefix(struct interface *ifp, const struct ra *rap,
 #ifndef __linux__
                sa_in6_init(&rt->rt_gateway, &in6addr_loopback);
 #endif
-       } else
+       } else if (!(addr->flags & IPV6_AF_ONLINK))
+               sa_in6_init(&rt->rt_gateway, &rap->from);
+       else
                rt->rt_gateway.sa_family = AF_UNSPEC;
        sa_in6_init(&rt->rt_ifa, &addr->addr);
        return rt;
index d6dc749df4b14b163fb6d73d3a4a538a0baa32e0..9a53fc92f42c10cc52419badf11ba5b6b7752aa8 100644 (file)
@@ -1096,12 +1096,6 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                        if (ap == NULL) {
                                unsigned int flags;
 
-                               if (!(pi.nd_opt_pi_flags_reserved &
-                                   ND_OPT_PI_FLAG_AUTO) &&
-                                   !(pi.nd_opt_pi_flags_reserved &
-                                   ND_OPT_PI_FLAG_ONLINK))
-                                       continue;
-
                                flags = IPV6_AF_RAPFX;
                                if (pi.nd_opt_pi_flags_reserved &
                                    ND_OPT_PI_FLAG_AUTO &&
@@ -1114,7 +1108,8 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                                if (ap == NULL)
                                        break;
                                ap->prefix = pi_prefix;
-                               ap->dadcallback = ipv6nd_dadcallback;
+                               if (flags & IPV6_AF_AUTOCONF)
+                                       ap->dadcallback = ipv6nd_dadcallback;
                                ap->created = ap->acquired = rap->acquired;
                                TAILQ_INSERT_TAIL(&rap->addrs, ap, next);
 
@@ -1124,7 +1119,8 @@ ipv6nd_handlera(struct dhcpcd_ctx *ctx, struct interface *ifp,
                                 * temporary address also exists then
                                 * extend the existing one rather than
                                 * create a new one */
-                               if (ipv6_iffindaddr(ifp, &ap->addr,
+                               if (flags & IPV6_AF_AUTOCONF &&
+                                   ipv6_iffindaddr(ifp, &ap->addr,
                                    IN6_IFF_NOTUSEABLE) &&
                                    ipv6_settemptime(ap, 0))
                                        new_ap = 0;