diff options
| author | Roy Marples <roy@marples.name> | 2009-08-05 21:16:09 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-08-05 21:16:09 +0000 |
| commit | 4e58d0605458479d53bb9a86e566394c9995c1f3 (patch) | |
| tree | 5496997c6fc833c42ee7a3fb73bff403cc5163f9 /net.c | |
| parent | 69ee64a66eac1d99dcc7009baec89295758c4cc4 (diff) | |
| download | dhcpcd-4e58d0605458479d53bb9a86e566394c9995c1f3.tar.xz | |
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.
Diffstat (limited to 'net.c')
| -rw-r--r-- | net.c | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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 |
