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;
#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)
{
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
#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);