From: Roy Marples Date: Wed, 26 Apr 2023 10:52:17 +0000 (+0100) Subject: OpenBSD: When attaching INET6 set IFF_UP X-Git-Tag: v10.0.2~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=985aa759da7b8b1c47d5e90c5a6e835ec17855e8;p=thirdparty%2Fdhcpcd.git OpenBSD: When attaching INET6 set IFF_UP Because some, if not all, OpenBSD interface drivers do this. https://github.com/openbsd/src/blob/master/sys/dev/pv/if_vio.c#L856 With this hack, dhcpcd can now operate at boot time without any manual interface setup. --- diff --git a/src/if-bsd.c b/src/if-bsd.c index eb3a4380..f6f0902d 100644 --- a/src/if-bsd.c +++ b/src/if-bsd.c @@ -1758,10 +1758,9 @@ ip6_forwarding(__unused const char *ifname) static int if_af_attach(const struct interface *ifp, int af) { - struct if_afreq ifar; + struct if_afreq ifar = { .ifar_af = af }; strlcpy(ifar.ifar_name, ifp->name, sizeof(ifar.ifar_name)); - ifar.ifar_af = af; return if_ioctl6(ifp->ctx, SIOCIFAFATTACH, &ifar, sizeof(ifar)); } #endif @@ -1833,7 +1832,7 @@ if_disable_rtadv(void) } void -if_setup_inet6(const struct interface *ifp) +if_setup_inet6(struct interface *ifp) { #ifdef ND6_NDI_FLAGS struct priv *priv; @@ -1892,6 +1891,14 @@ if_setup_inet6(const struct interface *ifp) #ifdef SIOCIFAFATTACH if (if_af_attach(ifp, AF_INET6) == -1) logerr("%s: if_af_attach", ifp->name); +#ifdef __OpenBSD__ + /* Adding any address to any interface *will* force the interface + * UP without sending a notification via route(4). + * Attaching INET6 will add a LL address. + * This truely sucks balls, but is what it is. */ + else + ifp->flags |= IFF_UP; +#endif #endif #ifdef SIOCGIFXFLAGS diff --git a/src/if-linux.c b/src/if-linux.c index 3ca96705..ea47f0d6 100644 --- a/src/if-linux.c +++ b/src/if-linux.c @@ -2117,7 +2117,7 @@ static const char *p_conf = "/proc/sys/net/ipv6/conf"; static const char *p_neigh = "/proc/sys/net/ipv6/neigh"; void -if_setup_inet6(const struct interface *ifp) +if_setup_inet6(struct interface *ifp) { struct dhcpcd_ctx *ctx = ifp->ctx; int ra; diff --git a/src/if-sun.c b/src/if-sun.c index 0a60368e..9e152c74 100644 --- a/src/if-sun.c +++ b/src/if-sun.c @@ -1741,7 +1741,7 @@ if_applyra(const struct ra *rap) } void -if_setup_inet6(__unused const struct interface *ifp) +if_setup_inet6(__unused struct interface *ifp) { } diff --git a/src/if.h b/src/if.h index df5f921e..6ae22d61 100644 --- a/src/if.h +++ b/src/if.h @@ -266,7 +266,7 @@ int if_addrflags(const struct interface *, const struct in_addr *, #ifdef INET6 void if_disable_rtadv(void); -void if_setup_inet6(const struct interface *); +void if_setup_inet6(struct interface *); int ip6_forwarding(const char *ifname); struct ra;