]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Some drivers report ENODEV when bring the interface up if their kill switch is on.
authorRoy Marples <roy@marples.name>
Wed, 5 Aug 2009 21:16:09 +0000 (21:16 +0000)
committerRoy Marples <roy@marples.name>
Wed, 5 Aug 2009 21:16:09 +0000 (21:16 +0000)
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.

net.c

diff --git a/net.c b/net.c
index 4c8be2fe3a61315582eaf2c4f7a3f2ec6c918a87..3b30cf5efd5e89bf40bb0e6618254cc5bf13cdb0 100644 (file)
--- 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