]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
BSD: Disable kernel RTADV sysctl earlier
authorRoy Marples <roy@marples.name>
Mon, 4 Nov 2019 17:21:33 +0000 (17:21 +0000)
committerRoy Marples <roy@marples.name>
Mon, 4 Nov 2019 17:21:33 +0000 (17:21 +0000)
Just makes life a bit easier.

src/dhcpcd.c
src/if-bsd.c
src/if.h

index 2b04bb3e65f23422fc0d2709a01885499116dc91..474b6abea3e53ece0a8a1bfdbf7b37ac248c7a6c 100644 (file)
@@ -1995,6 +1995,12 @@ printpidfile:
            ctx.options & DHCPCD_IPV4 ? " [ip4]" : "",
            ctx.options & DHCPCD_IPV6 ? " [ip6]" : "");
 
+#ifdef BSD
+       /* Disable the kernel RTADV sysctl as early as possible. */
+       if (ctx.options & DHCPCD_IPV6 && ctx.options & DHCPCD_IPV6RS)
+               if_disable_rtadv();
+#endif
+
        if (if_opensockets(&ctx) == -1) {
                logerr("%s: if_opensockets", __func__);
                goto exit_failure;
index a2c613edcb307a33ab315003e7018d7b94ff8546..d2e910ef74d2b473c9213cd5eb7be33da02a7945 100644 (file)
@@ -1619,6 +1619,22 @@ set_ifxflags(int s, const struct interface *ifp)
 #define        ND6_NDI_FLAGS
 #endif
 
+void
+if_disable_rtadv(void)
+{
+#if defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)
+       int ra = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV);
+
+       if (ra == -1) {
+               if (errno != ENOENT)
+                       logerr("IPV6CTL_ACCEPT_RTADV");
+       else if (ra != 0)
+               if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1)
+                       logerr("IPV6CTL_ACCEPT_RTADV");
+       }
+#endif
+}
+
 void
 if_setup_inet6(const struct interface *ifp)
 {
@@ -1690,21 +1706,6 @@ if_setup_inet6(const struct interface *ifp)
                logerr("%s: set_ifxflags", ifp->name);
 #endif
 
-#if defined(IPV6CTL_ACCEPT_RTADV) && !defined(ND6_IFF_ACCEPT_RTADV)
-       /* If we cannot control ra per interface, disable it globally. */
-       if (ifp->options->options & DHCPCD_IPV6RS) {
-               int ra = get_inet6_sysctl(IPV6CTL_ACCEPT_RTADV);
-
-               if (ra == -1) {
-                       if (errno != ENOENT)
-                               logerr("IPV6CTL_ACCEPT_RTADV");
-               else if (ra != 0)
-                       if (set_inet6_sysctl(IPV6CTL_ACCEPT_RTADV, 0) == -1)
-                               logerr("IPV6CTL_ACCEPT_RTADV");
-               }
-       }
-#endif
-
 #if defined(IPV6CTL_ACCEPT_RTADV) || defined(ND6_IFF_ACCEPT_RTADV)
        /* Flush the kernel knowledge of advertised routers
         * and prefixes so the kernel does not expire prefixes
index 19b6b2fe1b9780b59afff4a23a53cb2d3d4bbd0a..ecfdb1027d7cbaf36506db5510f459203423e1b1 100644 (file)
--- a/src/if.h
+++ b/src/if.h
@@ -195,6 +195,7 @@ int if_addrflags(const struct interface *, const struct in_addr *,
 #endif
 
 #ifdef INET6
+void if_disable_rtadv(void);
 void if_setup_inet6(const struct interface *);
 #ifdef IPV6_MANAGETEMPADDR
 int ip6_use_tempaddr(const char *ifname);