From: Roy Marples Date: Fri, 24 Mar 2017 21:34:12 +0000 (+0000) Subject: Remove ipv6ra_own and ipv6ra_own_default options. X-Git-Tag: v7.0.0-beta1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdf4387ec19a64b218e0ad8aeec393dd17184d9d;p=thirdparty%2Fdhcpcd.git Remove ipv6ra_own and ipv6ra_own_default options. This is controllable via noipv6 and noipv6rs options. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index 0e8720e6..6d5f9801 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -441,10 +441,6 @@ configure_interface1(struct interface *ifp) ifo->options &= ~(DHCPCD_IPV6RS | DHCPCD_DHCP6 | DHCPCD_WAITIP6); - if (ifo->options & DHCPCD_SLAACPRIVATE && - !(ifp->ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))) - ifo->options |= DHCPCD_IPV6RA_OWN; - /* We want to disable kernel interface RA as early as possible. */ if (ifo->options & DHCPCD_IPV6 && !(ifp->ctx->options & DHCPCD_DUMPLEASE)) @@ -452,15 +448,10 @@ configure_interface1(struct interface *ifp) /* If not doing any DHCP, disable the RDNSS requirement. */ if (!(ifo->options & (DHCPCD_DHCP | DHCPCD_DHCP6))) ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; - ra_global = if_checkipv6(ifp->ctx, NULL, - ifp->ctx->options & DHCPCD_IPV6RA_OWN ? 1 : 0); - ra_iface = if_checkipv6(ifp->ctx, ifp, - ifp->options->options & DHCPCD_IPV6RA_OWN ? 1 : 0); + ra_global = if_checkipv6(ifp->ctx, NULL); + ra_iface = if_checkipv6(ifp->ctx, ifp); if (ra_global == -1 || ra_iface == -1) ifo->options &= ~DHCPCD_IPV6RS; - else if (ra_iface == 0 && - !(ifp->ctx->options & DHCPCD_TEST)) - ifo->options |= DHCPCD_IPV6RA_OWN; } if (!(ifo->options & DHCPCD_IAID)) { @@ -759,8 +750,7 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags, ipv6nd_expire(ifp, RTR_CARRIER_EXPIRE); #endif /* RFC4941 Section 3.5 */ - if (ifp->options->options & DHCPCD_IPV6RA_OWN) - ipv6_gentempifid(ifp); + ipv6_gentempifid(ifp); dhcpcd_startinterface(ifp); } } diff --git a/src/dhcpcd.conf.5.in b/src/dhcpcd.conf.5.in index 10846276..7e3db0ff 100644 --- a/src/dhcpcd.conf.5.in +++ b/src/dhcpcd.conf.5.in @@ -406,14 +406,6 @@ RDNSS option and a valid prefix or no DHCPv6 instruction. Set this option so to make .Nm dhcpcd always fork on an RA. -.It Ic ipv6ra_own -Disables kernel IPv6 Router Advertisement processing so dhcpcd can manage -addresses and routes. -.It Ic ipv6ra_own_default -Each time dhcpcd receives an IPv6 Router Adveristment, dhcpcd will manage -the default route only. -This allows dhcpcd to prefer an interface for outbound traffic based on metric -and/or user selection rather than the kernel. .It Ic ipv6rs Enables IPv6 Router Advertisement solicitation. This is on by default, but is documented here in the case where it is disabled diff --git a/src/if-bsd.c b/src/if-bsd.c index ed3ba2f1..e3c6b889 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -1299,7 +1299,7 @@ set_ifxflags(int s, const struct interface *ifp, int own) #endif int -if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) +if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp) { struct priv *priv; int s, ra; @@ -1318,7 +1318,9 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) flags = (int)nd.ndi.flags; #ifdef ND6_IFF_AUTO_LINKLOCAL - if (own && flags & ND6_IFF_AUTO_LINKLOCAL) { + if (!(ctx->options & DHCPCD_TEST) && + flags & ND6_IFF_AUTO_LINKLOCAL) + { syslog(LOG_DEBUG, "%s: disabling Kernel IPv6 auto link-local support", ifp->name); @@ -1334,14 +1336,17 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) #endif #ifdef ND6_IFF_ACCEPT_RTADV - if (own && flags & ND6_IFF_ACCEPT_RTADV) { + if (!(ctx->options & DHCPCD_TEST) && + flags & ND6_IFF_ACCEPT_RTADV) + { syslog(LOG_DEBUG, "%s: disabling Kernel IPv6 RA support", ifp->name); flags &= ~ND6_IFF_ACCEPT_RTADV; } #ifdef ND6_IFF_OVERRIDE_RTADV - if (own && flags & ND6_IFF_OVERRIDE_RTADV) + if (!(ctx->options & DHCPCD_TEST) && + flags & ND6_IFF_OVERRIDE_RTADV) flags &= ~ND6_IFF_OVERRIDE_RTADV; #endif #endif @@ -1351,6 +1356,12 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) #endif if (nd.ndi.flags != (uint32_t)flags) { + if (ctx->options & DHCPCD_TEST) { + syslog(LOG_WARNING, + "%s: interface not IPv6 enabled", + ifp->name); + return -1; + } nd.ndi.flags = (uint32_t)flags; if (ioctl(s, SIOCSIFINFO_FLAGS, &nd) == -1) { syslog(LOG_ERR, "%s: SIOCSIFINFO_FLAGS: %m", @@ -1401,7 +1412,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) * error as such so just log it and continue */ syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, "IPV6CTL_ACCEPT_RTADV: %m"); - else if (ra != 0 && own) { + else if (ra != 0 && !(ctx->options & DHCPCD_TEST)) { syslog(LOG_DEBUG, "disabling Kernel IPv6 RA support"); if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1) { syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m"); @@ -1410,7 +1421,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) ra = 0; #else ra = 0; - if (own) { + if (!(ctx->options & DHCPCD_TEST)) { #endif /* Flush the kernel knowledge of advertised routers * and prefixes so the kernel does not expire prefixes diff --git a/src/if-linux.c b/src/if-linux.c index 48547253..4f70583b 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -1634,7 +1634,7 @@ if_disable_autolinklocal(struct dhcpcd_ctx *ctx, unsigned int ifindex) static const char *prefix = "/proc/sys/net/ipv6/conf"; int -if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) +if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp) { const char *ifname; int ra; @@ -1642,7 +1642,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) if (ifp == NULL) ifname = "all"; - else if (own) { + else if (!(ctx->options & DHCPCD_TEST)) { if (if_disable_autolinklocal(ctx, ifp->index) == -1) syslog(LOG_DEBUG, "%s: if_disable_autolinklocal: %m", ifp->name); @@ -1653,10 +1653,10 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) snprintf(path, sizeof(path), "%s/%s/autoconf", prefix, ifname); ra = check_proc_int(path); if (ra != 1) { - if (!own) + if (ctx->options & DHCPCD_TEST) syslog(LOG_WARNING, "%s: IPv6 kernel autoconf disabled", ifname); - } else if (ra != -1 && own) { + } else if (ra != -1 && !(ctx->options & DHCPCD_TEST)) { if (write_path(path, "0") == -1) { syslog(LOG_ERR, "write_path: %s: %m", path); return -1; @@ -1669,7 +1669,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *ifp, int own) /* The sysctl probably doesn't exist, but this isn't an * error as such so just log it and continue */ syslog(errno == ENOENT ? LOG_DEBUG:LOG_WARNING, "%s: %m", path); - else if (ra != 0 && own) { + else if (ra != 0 && !(ctx->options & DHCPCD_TEST)) { syslog(LOG_DEBUG, "%s: disabling kernel IPv6 RA support", ifname); if (write_path(path, "0") == -1) { diff --git a/src/if-options.c b/src/if-options.c index ca755f3a..7f171486 100644 --- a/src/if-options.c +++ b/src/if-options.c @@ -64,8 +64,8 @@ #define O_IPV6RS O_BASE + 4 #define O_NOIPV6RS O_BASE + 5 #define O_IPV6RA_FORK O_BASE + 6 -#define O_IPV6RA_OWN O_BASE + 7 -#define O_IPV6RA_OWN_D O_BASE + 8 +// unused O_BASE + 7 +// unused O_BASE + 8 #define O_NOALIAS O_BASE + 9 #define O_IA_NA O_BASE + 10 #define O_IA_TA O_BASE + 11 @@ -167,8 +167,6 @@ const struct option cf_options[] = { {"ipv6ra_autoconf", no_argument, NULL, O_IPV6RA_AUTOCONF}, {"ipv6ra_noautoconf", no_argument, NULL, O_IPV6RA_NOAUTOCONF}, {"ipv6ra_fork", no_argument, NULL, O_IPV6RA_FORK}, - {"ipv6ra_own", no_argument, NULL, O_IPV6RA_OWN}, - {"ipv6ra_own_default", no_argument, NULL, O_IPV6RA_OWN_D}, {"ipv4", no_argument, NULL, O_IPV4}, {"noipv4", no_argument, NULL, O_NOIPV4}, {"ipv6", no_argument, NULL, O_IPV6}, @@ -1279,12 +1277,6 @@ parse_option(struct dhcpcd_ctx *ctx, const char *ifname, struct if_options *ifo, case O_IPV6RA_FORK: ifo->options &= ~DHCPCD_IPV6RA_REQRDNSS; break; - case O_IPV6RA_OWN: - ifo->options |= DHCPCD_IPV6RA_OWN; - break; - case O_IPV6RA_OWN_D: - ifo->options |= DHCPCD_IPV6RA_OWN_DEFAULT; - break; case O_IPV6RA_AUTOCONF: ifo->options |= DHCPCD_IPV6RA_AUTOCONF; break; diff --git a/src/if-options.h b/src/if-options.h index 3ecc36b9..be1325b7 100644 --- a/src/if-options.h +++ b/src/if-options.h @@ -89,8 +89,8 @@ #define DHCPCD_DUMPLEASE (1ULL << 30) #define DHCPCD_IPV6RS (1ULL << 31) #define DHCPCD_IPV6RA_REQRDNSS (1ULL << 32) -#define DHCPCD_IPV6RA_OWN (1ULL << 33) -#define DHCPCD_IPV6RA_OWN_DEFAULT (1ULL << 34) +// unused (1ULL << 33) +// unused (1ULL << 34) #define DHCPCD_IPV4 (1ULL << 35) #define DHCPCD_FORKED (1ULL << 36) #define DHCPCD_IPV6 (1ULL << 37) diff --git a/src/if-sun.c b/src/if-sun.c index b53a41a3..5def7b0e 100644 --- a/src/if-sun.c +++ b/src/if-sun.c @@ -1409,7 +1409,7 @@ if_getlifetime6(struct ipv6_addr *addr) int if_checkipv6(__unused struct dhcpcd_ctx *ctx, - __unused const struct interface *ifp, int __unused own) + __unused const struct interface *ifp) { return 0; diff --git a/src/if.h b/src/if.h index f1303c90..7c0cc402 100644 --- a/src/if.h +++ b/src/if.h @@ -180,7 +180,7 @@ int if_initrt(struct dhcpcd_ctx *, int); #endif #ifdef INET6 -int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *, int); +int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *); #ifdef IPV6_MANAGETEMPADDR int ip6_use_tempaddr(const char *ifname); int ip6_temp_preferred_lifetime(const char *ifname); diff --git a/src/ipv6.c b/src/ipv6.c index 296ad227..9befa1ee 100644 --- a/src/ipv6.c +++ b/src/ipv6.c @@ -710,7 +710,6 @@ ipv6_addaddr1(struct ipv6_addr *ap, const struct timespec *now) if (ap->flags & IPV6_AF_TEMPORARY && ap->prefix_pltime && ap->prefix_vltime && - ap->iface->options->options & DHCPCD_IPV6RA_OWN && ip6_use_tempaddr(ap->iface->name)) eloop_timeout_add_sec(ap->iface->ctx->eloop, (time_t)ap->prefix_pltime - REGEN_ADVANCE, @@ -1032,7 +1031,6 @@ ipv6_getstate(struct interface *ifp) /* Regenerate new ids */ if (ifp->options && - ifp->options->options & DHCPCD_IPV6RA_OWN && ip6_use_tempaddr(ifp->name)) ipv6_regentempifid(ifp); } @@ -1610,8 +1608,7 @@ ipv6_start(struct interface *ifp) if (IPV6_CSTATE(ifp)) { /* Regenerate new ids */ - if (ifp->options->options & DHCPCD_IPV6RA_OWN && - ip6_use_tempaddr(ifp->name)) + if (ip6_use_tempaddr(ifp->name)) ipv6_regentempifid(ifp); } @@ -2205,20 +2202,16 @@ inet6_raroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx, int expired, TAILQ_FOREACH(rap, ctx->ra_routers, next) { if (rap->expired != expired) continue; - if (rap->iface->options->options & DHCPCD_IPV6RA_OWN) { - TAILQ_FOREACH(addr, &rap->addrs, next) { - if (addr->prefix_vltime == 0) - continue; - rt = inet6_makeprefix(rap->iface, rap, addr); - if (rt) { - TAILQ_INSERT_TAIL(routes, rt, rt_next); - n++; - } + TAILQ_FOREACH(addr, &rap->addrs, next) { + if (addr->prefix_vltime == 0) + continue; + rt = inet6_makeprefix(rap->iface, rap, addr); + if (rt) { + TAILQ_INSERT_TAIL(routes, rt, rt_next); + n++; } } - if (rap->lifetime && rap->iface->options->options & - (DHCPCD_IPV6RA_OWN | DHCPCD_IPV6RA_OWN_DEFAULT)) - { + if (rap->lifetime) { rt = inet6_makerouter(rap); if (rt) { TAILQ_INSERT_TAIL(routes, rt, rt_next); diff --git a/src/route.c b/src/route.c index bafc260c..c91c224d 100644 --- a/src/route.c +++ b/src/route.c @@ -516,8 +516,6 @@ rt_build(struct dhcpcd_ctx *ctx, int af) ctx->options; #ifdef INET6 if (!have_default && - (o & DHCPCD_IPV6RA_OWN_DEFAULT) && - !(o & DHCPCD_IPV6RA_OWN) && rt->rt_dest.sa_family == AF_INET6 && sa_is_unspecified(&rt->rt_dest)) have_default = true;