From d292d54e9032ab27ba68f66010c20707cf5925c4 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 6 Jan 2019 10:10:59 +0000 Subject: [PATCH] ip6: Install not on link routes with a gateway of the router This allows a secondary router to broadcast prefixes it controls without being a default router itself. --- src/ipv6.c | 12 ++++++------ src/ipv6nd.c | 12 ++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/ipv6.c b/src/ipv6.c index 38cb06d8..1f1e36c0 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -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; diff --git a/src/ipv6nd.c b/src/ipv6nd.c index d6dc749d..9a53fc92 100644 --- a/src/ipv6nd.c +++ b/src/ipv6nd.c @@ -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; -- 2.47.2