]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
OpenBSD: When attaching INET6 set IFF_UP
authorRoy Marples <roy@marples.name>
Wed, 26 Apr 2023 10:52:17 +0000 (11:52 +0100)
committerRoy Marples <roy@marples.name>
Wed, 26 Apr 2023 10:52:17 +0000 (11:52 +0100)
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.

src/if-bsd.c
src/if-linux.c
src/if-sun.c
src/if.h

index eb3a4380de18e386592e9f45f262b6c10cdb67c3..f6f0902d72be88034dcec0a9f97d1edf17da0516 100644 (file)
@@ -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
index 3ca967055d5d6cda2f228efd38dc564daecfb33d..ea47f0d67f5fa95f55a8f32937d11f4a848dc016 100644 (file)
@@ -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;
index 0a60368edb5e63287c5398b9570ea28bb5584913..9e152c747963996565472244cc338a5f34916917 100644 (file)
@@ -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)
 {
 
 }
index df5f921e63987562c2f3ba0268940d8a2ac21dab..6ae22d610bd55138654638fc5b3eee3d18a74d54 100644 (file)
--- 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;