[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#403706: allow-hotplug and udev



Another option would be to make netcfg always add an auto line, so it
has:

allow-hotplug eth0
auto eth0

This avoids any problems caused by udev running ifup too early or too
late, for interfaces that arn't really that hotpluggable, or that are
cold-plugged. /etc/init.d/networking will (generally) start the
interface first, then udev will try to start it again, which is
harmless, and does not even generate any ugly messages. In some rare
cases, udev might manage to start the interface first, if so,
/etc/init.d/networking will output "ifup: interface eth0 already configured"

If the interface is an actual hotpluggable interface, such as a USB
nic, and it's not present at boot, then /etc/init.d/networking might
complain: "eth0: ERROR file getting interface flags: No such device".
In any case, when it gets plugged in, udev will handle it as usual.

The only downside seems to be the potential for these error messages.
The upside: No need to worry about obscure races in udev breakin
networking; no need to worry about asynchronycity issues for the primary
interface.

Here's a patch to netcfg, to do that:

Index: debian/changelog
===================================================================
--- debian/changelog	(revision 43410)
+++ debian/changelog	(working copy)
@@ -1,3 +1,14 @@
+netcfg (1.33) UNRELEASED; urgency=low
+
+  * Add "auto" lines even for hotpluggable interfaces. This can result in
+    udev trying to ifup an interface that /etc/network/interfaces has already
+    upped, but it avoids problems with bugs and races in udev's handling of
+    coldplugged primary network interfaces, and it ensures that the primary
+    interface is always up by the time /etc/network/interfaces completes.
+    Closes: #403706
+
+ -- Joey Hess <joeyh@debian.org>  Tue, 19 Dec 2006 16:57:54 -0500
+
 netcfg (1.32) unstable; urgency=low
 
   [ Colin Watson ]
Index: dhcp.c
===================================================================
--- dhcp.c	(revision 43410)
+++ dhcp.c	(working copy)
@@ -35,9 +35,9 @@
     
     if ((fp = file_open(INTERFACES_FILE, "a"))) {
         fprintf(fp, "\n# The primary network interface\n");
-        if (!iface_is_hotpluggable(iface) && !find_in_stab(iface))
+        if (!find_in_stab(iface))
             fprintf(fp, "auto %s\n", iface);
-        else
+        if (iface_is_hotpluggable(iface))
             fprintf(fp, "allow-hotplug %s\n", iface);
         fprintf(fp, "iface %s inet dhcp\n", iface);
         if (dhostname) {
Index: static.c
===================================================================
--- static.c	(revision 43410)
+++ static.c	(working copy)
@@ -178,9 +178,9 @@
     
     if ((fp = file_open(INTERFACES_FILE, "a"))) {
         fprintf(fp, "\n# The primary network interface\n");
-        if (!iface_is_hotpluggable(interface) && !find_in_stab(interface))
+        if (!find_in_stab(interface))
             fprintf(fp, "auto %s\n", interface);
-        else
+        if (iface_is_hotpluggable(interface))
             fprintf(fp, "allow-hotplug %s\n", interface);
         fprintf(fp, "iface %s inet static\n", interface);
         fprintf(fp, "\taddress %s\n", inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)));

-- 
see shy jo

Attachment: signature.asc
Description: Digital signature


Reply to: