From: Roy Marples Date: Tue, 3 Sep 2019 20:20:57 +0000 (+0300) Subject: Solaris: plumb interface at init if does not exist X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=388f4ae696de9495e9711f5fe4931ff66f8d6f74;p=thirdparty%2Fdhcpcd.git Solaris: plumb interface at init if does not exist 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. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index d2b8bd91..6d361e49 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -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); diff --git a/src/if-sun.c b/src/if-sun.c index f0968c54..c7d8a078 100644 --- a/src/if-sun.c +++ b/src/if-sun.c @@ -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)