]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Solaris: plumb interface at init if does not exist
authorRoy Marples <roy@marples.name>
Tue, 3 Sep 2019 20:20:57 +0000 (23:20 +0300)
committerRoy Marples <roy@marples.name>
Tue, 3 Sep 2019 20:23:04 +0000 (23:23 +0300)
This makes dhcpcd go so much easier.
The only downside is that you always get an unspecified address
on the default LUN for each compiled protocol regardless of
if you use it or not.

src/dhcpcd.c
src/if-sun.c

index d2b8bd91293ed6728c79ff46cb7d89d6a2c7ddd8..6d361e49a3760deb34331b465a3d56e502a41b21 100644 (file)
@@ -950,12 +950,7 @@ dhcpcd_prestartinterface(void *arg)
 
        if ((!(ifp->ctx->options & DHCPCD_MASTER) ||
            ifp->options->options & DHCPCD_IF_UP) &&
-           if_up(ifp) == -1
-#ifdef __sun
-           /* Interface could not yet be plumbed. */
-           && errno != ENXIO
-#endif
-           )
+           if_up(ifp) == -1)
                logerr("%s: %s", __func__, ifp->name);
 
        dhcpcd_startinterface(ifp);
index f0968c54698ce8ac0b5d91e84d50972d32a7ad0c..c7d8a0786cd73916dd67df8411ce3a1de58106c1 100644 (file)
@@ -106,10 +106,27 @@ struct rtm
        char buffer[sizeof(struct sockaddr_storage) * RTAX_MAX];
 };
 
+static int if_plumb(int, const struct dhcpcd_ctx *, int, const char *);
+
 int
-if_init(__unused struct interface *ifp)
+if_init(struct interface *ifp)
 {
 
+#ifdef INET
+       if (if_plumb(RTM_NEWADDR, ifp->ctx, AF_INET, ifp->name) == -1 &&
+           errno != EEXIST)
+               return -1;
+#endif
+
+#ifdef INET6
+       if (if_plumb(RTM_NEWADDR, ifp->ctx, AF_INET6, ifp->name) == -1 &&
+           errno != EEXIST)
+               return -1;
+#endif
+
+       if (ifp->index == 0)
+               ifp->index = if_nametoindex(ifp->name);
+
        return 0;
 }
 
@@ -1575,7 +1592,8 @@ if_address(unsigned char cmd, const struct ipv4_addr *ia)
        } addr, mask, brd;
 
        /* Either remove the alias or ensure it exists. */
-       if (if_plumb(cmd, ia->iface->ctx, AF_INET, ia->alias) == -1)
+       if (if_plumb(cmd, ia->iface->ctx, AF_INET, ia->alias) == -1 &&
+           errno != EEXIST)
                return -1;
 
        if (cmd == RTM_DELADDR)
@@ -1629,7 +1647,8 @@ if_address6(unsigned char cmd, const struct ipv6_addr *ia)
        int                     r;
 
        /* Either remove the alias or ensure it exists. */
-       if (if_plumb(cmd, ia->iface->ctx, AF_INET6, ia->alias) == -1)
+       if (if_plumb(cmd, ia->iface->ctx, AF_INET6, ia->alias) == -1 &&
+           errno != EEXIST)
                return -1;
 
        if (cmd == RTM_DELADDR)