Bug#606515: Preseed installation does not wait for network to be ready
Hi,
Attached a patch to netcfg that waits for the link to come up before
proceeding.
It times out after 10 seconds, so if link detection is broken for some reason
it doesn't affect the install.
--
Yours sincerely,
Floris Bos
diff -ur netcfg.orig/Makefile netcfg/Makefile
--- netcfg.orig/Makefile 2009-10-28 21:37:37.000000000 +0100
+++ netcfg/Makefile 2010-12-11 20:51:10.362642461 +0100
@@ -26,7 +26,7 @@
all: $(TARGETS)
-netcfg-static: netcfg-static.o static.o
+netcfg-static: netcfg-static.o static.o ethtool-lite.o
netcfg: netcfg.o dhcp.o static.o ethtool-lite.o
$(TARGETS): $(COMMON_OBJS)
diff -ur netcfg.orig/netcfg.h netcfg/netcfg.h
--- netcfg.orig/netcfg.h 2010-09-06 23:53:19.000000000 +0200
+++ netcfg/netcfg.h 2010-12-11 20:10:50.761351395 +0100
@@ -41,6 +41,9 @@
"ff02::1 ip6-allnodes\n" \
"ff02::2 ip6-allrouters\n"
+/* Maximum number of seconds to wait for network link to come up */
+#define LINK_TIMEOUT 10
+
typedef enum { NOT_ASKED = 30, GO_BACK } response_t;
typedef enum { DHCP, STATIC, DUNNO } method_t;
typedef enum { ADHOC = 1, MANAGED = 2 } wifimode_t;
diff -ur netcfg.orig/static.c netcfg/static.c
--- netcfg.orig/static.c 2010-12-11 20:03:12.091975462 +0100
+++ netcfg/static.c 2010-12-11 20:49:30.851349894 +0100
@@ -269,10 +269,10 @@
int netcfg_activate_static(struct debconfclient *client)
{
- int rv = 0, masksize;
+ int rv = 0, masksize, tries = 0;
char buf[256];
char ptr1[INET_ADDRSTRLEN];
-
+
#ifdef __GNU__
snprintf(buf, sizeof(buf),
"settrans -fgap /servers/socket/2 /hurd/pfinet --interface=%s --address=%s",
@@ -381,6 +381,16 @@
debconf_capb(client, "backup");
return -1;
}
+
+ di_info("Waiting for the link of interface %s to come up", interface);
+
+ do {
+ usleep(100000); /* sleep a tenth of a second */
+ if (++tries > LINK_TIMEOUT*10) {
+ di_info("Link did not come up, but timeout expired, continuing...");
+ break;
+ }
+ } while ( ethtool_lite(interface) == 2 /*DISCONNECTED*/ );
return 0;
}
Reply to: