From: Roy Marples Date: Wed, 5 Aug 2009 21:16:09 +0000 (+0000) Subject: Some drivers report ENODEV when bring the interface up if their kill switch is on. X-Git-Tag: v5.1.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4e58d0605458479d53bb9a86e566394c9995c1f3;p=thirdparty%2Fdhcpcd.git Some drivers report ENODEV when bring the interface up if their kill switch is on. This stops dhcpcd from using the interface, so we now just blunder on and await a carrier up event. IMO, ENODEV is the wrong error code as the device IS present, it's just disabled. But the patch here still makes sense. --- diff --git a/net.c b/net.c index 4c8be2fe..3b30cf5e 100644 --- a/net.c +++ b/net.c @@ -218,21 +218,20 @@ init_interface(const char *ifname) goto eexit; } - if (up_interface(ifname) != 0) - goto eexit; snprintf(iface->leasefile, sizeof(iface->leasefile), LEASEFILE, ifname); /* 0 is a valid fd, so init to -1 */ iface->raw_fd = -1; iface->udp_fd = -1; iface->arp_fd = -1; - close(s); - return iface; + goto exit; eexit: free(iface); + iface = NULL; +exit: close(s); - return NULL; + return iface; } void @@ -322,6 +321,15 @@ discover_interfaces(int argc, char * const *argv) } if ((ifp = init_interface(p)) == NULL) continue; + + /* Bring the interface up */ + if (!(ifp->flags & IFF_UP) && up_interface(p) != 0) + /* Some drivers return ENODEV here when they are disabled by a switch. + * We just blunder on as the carrier will be down anyway. + * When the switch is enabled, it should bring the interface up. + * Then we'll spot the carrier and start working. */ + syslog(LOG_ERR, "%s: up_interface: %m", p); + /* Don't allow loopback unless explicit */ if (ifp->flags & IFF_LOOPBACK) { if (argc == 0 && ifac == 0) { @@ -364,6 +372,7 @@ discover_interfaces(int argc, char * const *argv) syslog(LOG_WARNING, "%s: unknown hardware family", p); } } + if (ifl) ifl->next = ifp; else