Christian PERRIER wrote: > To Robert: thanks for the patches and the finally fruitful discussion > with Matthew (it started a little bit hot but you guys managed to > handle it. That deserves applauses).
here is a new version of the patch. this one makes the reachability test conditional on !is_wireless_iface(), since wireless interfaces don't have the 802.1d forwarding delay problem. -- Robert Edmonds edmo...@debian.org
diff -Npru netcfg-1.60.orig/netcfg-common.c netcfg-1.60/netcfg-common.c --- netcfg-1.60.orig/netcfg-common.c 2011-02-05 20:42:06.000000000 -0500 +++ netcfg-1.60/netcfg-common.c 2011-02-08 21:14:29.855940300 -0500 @@ -1035,23 +1035,40 @@ void netcfg_update_entropy (void) */ int netcfg_detect_link(struct debconfclient *client, const char *if_name) { - int wait_count, rv = 0; + char arping[256]; + char s_gateway[INET_ADDRSTRLEN]; + int count, rv = 0; + int link_waits = NETCFG_LINK_WAIT_TIME * 4; + int gw_tries = NETCFG_GATEWAY_REACHABILITY_TRIES; + + if (gateway.s_addr) { + inet_ntop(AF_INET, &gateway, s_gateway, sizeof(s_gateway)); + sprintf(arping, "arping -c 1 -w 1 -f -I %s %s", if_name, s_gateway); + } debconf_capb(client, "progresscancel"); debconf_subst(client, "netcfg/link_detect_progress", "interface", if_name); - debconf_progress_start(client, 0, NETCFG_LINK_WAIT_TIME * 4, "netcfg/link_detect_progress"); - for (wait_count = 0; wait_count < NETCFG_LINK_WAIT_TIME * 4; wait_count++) { + debconf_progress_start(client, 0, 100, "netcfg/link_detect_progress"); + for (count = 0; count < link_waits; count++) { usleep(250000); - if (debconf_progress_step(client, 1) == 30) { + if (debconf_progress_set(client, 50 * count / link_waits) == 30) { /* User cancelled on us... bugger */ rv = 0; break; } - if (ethtool_lite (if_name) == 1) /* ethtool-lite's CONNECTED */ { - debconf_progress_set(client, NETCFG_LINK_WAIT_TIME * 4); + if (ethtool_lite(if_name) == 1) /* ethtool-lite's CONNECTED */ { + if (gateway.s_addr && !is_wireless_iface(if_name)) { + for (count = 0; count < gw_tries; count++) { + if (di_exec_shell_log(arping) == 0) + break; + if (debconf_progress_set(client, 50 + 50 * count / gw_tries) == 30) + break; + } + } rv = 1; break; } + debconf_progress_set(client, 100); } debconf_progress_stop(client); diff -Npru netcfg-1.60.orig/netcfg.h netcfg-1.60/netcfg.h --- netcfg-1.60.orig/netcfg.h 2011-02-05 20:42:06.000000000 -0500 +++ netcfg-1.60/netcfg.h 2011-02-07 01:32:02.895935476 -0500 @@ -47,6 +47,11 @@ */ #define NETCFG_LINK_WAIT_TIME 3 +/* The number of times to attempt to verify gateway reachability. + * Each try invokes arping with a one second timeout. + */ +#define NETCFG_GATEWAY_REACHABILITY_TRIES 50 + #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 63 #endif