From: Roy Marples Date: Thu, 5 Jun 2014 11:38:04 +0000 (+0000) Subject: Ensure OWN is set by SLAAC private before initing. X-Git-Tag: v6.4.0~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2612c7f005dc37b16a4645a4bf61a4631509ae56;p=thirdparty%2Fdhcpcd.git Ensure OWN is set by SLAAC private before initing. Add a link-local address before running any PREINIT script as well as at start incase a 3rd party removed it. Move kernel tweaks to RA to DEBUG messages. --- diff --git a/dhcpcd.c b/dhcpcd.c index 51607657..23895a91 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -348,6 +348,9 @@ configure_interface1(struct interface *ifp) if (!(ifo->options & DHCPCD_IPV6)) ifo->options &= ~DHCPCD_IPV6RS; + if (ifo->options & DHCPCD_SLAACPRIVATE) + ifo->options |= DHCPCD_IPV6RA_OWN; + /* We want to disable kernel interface RA as early as possible. */ if (ifo->options & DHCPCD_IPV6RS) { ra_global = if_checkipv6(ifp->ctx, NULL, @@ -446,9 +449,6 @@ configure_interface1(struct interface *ifp) /* If we are not sending an authentication option, don't require it */ if (!(ifo->auth.options & DHCPCD_AUTH_SEND)) ifo->auth.options &= ~DHCPCD_AUTH_REQUIRE; - - if (ifo->options & DHCPCD_SLAACPRIVATE) - ifo->options |= DHCPCD_IPV6RA_OWN; } int @@ -570,7 +570,9 @@ dhcpcd_startinterface(void *arg) char buf[DUID_LEN * 3]; /* Add our link-local address before upping the interface - * so our RFC7217 address beats the hwaddr based one */ + * so our RFC7217 address beats the hwaddr based one. + * This is also a safety check incase it was ripped out + * from under us. */ if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) { syslog(LOG_ERR, "%s: ipv6_start: %m", ifp->name); ifo->options &= DHCPCD_IPV6; @@ -686,6 +688,15 @@ init_state(struct interface *ifp, int argc, char **argv) ifo->options &= ~DHCPCD_IPV6RS; } + /* Add our link-local address before upping the interface + * so our RFC7217 address beats the hwaddr based one. + * This needs to happen before PREINIT incase a hook script + * inadvertently ups the interface. */ + if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) { + syslog(LOG_ERR, "%s: ipv6_start: %m", ifp->name); + ifo->options &= DHCPCD_IPV6; + } + reason = NULL; /* appease gcc */ if (ifo->options & DHCPCD_LINK) { switch (if_carrier(ifp)) { diff --git a/if-bsd.c b/if-bsd.c index c4892c8b..51786481 100644 --- a/if-bsd.c +++ b/if-bsd.c @@ -1029,7 +1029,8 @@ if_rarestore(struct dhcpcd_ctx *ctx) for (; ctx->ra_restore_len > 0; ctx->ra_restore_len--) { #ifdef ND6_IFF_ACCEPT_RTADV if (!(ctx->options & DHCPCD_FORKED)) { - syslog(LOG_INFO, "%s: restoring kernel IPv6 RA support", + syslog(LOG_DEBUG, + "%s: restoring kernel IPv6 RA support", ctx->ra_restore[ctx->ra_restore_len - 1]); if (set_if_nd6_flag( ctx->ra_restore[ctx->ra_restore_len -1], @@ -1051,7 +1052,7 @@ if_rarestore(struct dhcpcd_ctx *ctx) ctx->ra_restore = NULL; if (ctx->ra_kernel_set) { - syslog(LOG_INFO, "restoring kernel IPv6 RA support"); + syslog(LOG_DEBUG, "restoring kernel IPv6 RA support"); if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 1) == -1) syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m"); } @@ -1107,15 +1108,6 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) } #endif -#ifdef ND_IFF_AUTO_LINKLOCAL - if (set_if_nd6_flag(ifname, ND6_IFF_AUTO_LINKLOCAL) == -1) { - syslog(LOG_ERR, - "%s: set_if_nd6_flag: ND6_IFF_AUTO_LINKLOCAL: %m", - ifname); - return -1; - } -#endif - #ifdef ND6_IFF_OVERRIDE_RTADV override = get_if_nd6_flag(ifname, ND6_IFF_OVERRIDE_RTADV); if (override == -1) @@ -1133,7 +1125,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) "%s: get_if_nd6_flag: ND6_IFF_ACCEPT_RTADV: %m", ifname); else if (ra != 0 && own) { - syslog(LOG_INFO, + syslog(LOG_DEBUG, "%s: disabling Kernel IPv6 RA support", ifname); if (del_if_nd6_flag(ifname, ND6_IFF_ACCEPT_RTADV) @@ -1191,7 +1183,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, "IPV6CTL_ACCEPT_RTADV: %m"); else if (ra != 0 && own) { - syslog(LOG_INFO, "disabling Kernel IPv6 RA support"); + syslog(LOG_DEBUG, "disabling Kernel IPv6 RA support"); if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1) { syslog(LOG_ERR, "IPV6CTL_ACCEPT_RTADV: %m"); return ra; diff --git a/if-linux.c b/if-linux.c index 2eb64945..c00304dc 100644 --- a/if-linux.c +++ b/if-linux.c @@ -1230,7 +1230,8 @@ if_rarestore(struct dhcpcd_ctx *ctx) for (; ctx->ra_restore_len > 0; ctx->ra_restore_len--) { if (!(ctx->options & DHCPCD_FORKED)) { - syslog(LOG_INFO, "%s: restoring kernel IPv6 RA support", + syslog(LOG_DEBUG, + "%s: restoring kernel IPv6 RA support", ctx->ra_restore[ctx->ra_restore_len - 1]); snprintf(path, sizeof(path), "%s/%s/accept_ra", prefix, ctx->ra_restore[ctx->ra_restore_len - 1]); @@ -1276,7 +1277,7 @@ if_checkipv6(struct dhcpcd_ctx *ctx, const char *ifname, int own) syslog(errno == ENOENT ? LOG_DEBUG : LOG_WARNING, "%s: %m", path); else if (ra != 0 && own) { - syslog(LOG_INFO, "%s: disabling kernel IPv6 RA support", + syslog(LOG_DEBUG, "%s: disabling kernel IPv6 RA support", ifname); if (write_path(path, "0") == -1) { syslog(LOG_ERR, "write_path: %s: %m", path);