]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure OWN is set by SLAAC private before initing.
authorRoy Marples <roy@marples.name>
Thu, 5 Jun 2014 11:38:04 +0000 (11:38 +0000)
committerRoy Marples <roy@marples.name>
Thu, 5 Jun 2014 11:38:04 +0000 (11:38 +0000)
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.

dhcpcd.c
if-bsd.c
if-linux.c

index 516076577fb9587930dd8399f0459b65c5138c9f..23895a91e0e730203569e2e4a8ffd258910329a4 100644 (file)
--- 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)) {
index c4892c8bc8299ed41a1fb91d2f27f6f277876f09..517864816702a173e3d0b9ba06ab4295420388b6 100644 (file)
--- 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;
index 2eb64945520386328e8edea69b15dadb054301d0..c00304dc3f277a9c9bbeee7be607f05e6c5da11c 100644 (file)
@@ -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);