Skip to content

Commit 5e404cd

Browse files
Paul Gortmakerdavem330
authored andcommitted
ipconfig: add informative timeout messages while waiting for carrier
Commit 3fb72f1 ("ipconfig wait for carrier") added a "wait for carrier on at least one interface" policy, with a worst case maximum wait of two minutes. However, if you encounter this, you won't get any feedback from the console as to the nature of what is going on. You just see the booting process hang for two minutes and then continue. Here we add a message so the user knows what is going on, and hence can take action to rectify the situation (e.g. fix network cable or whatever.) After the 1st 10s pause, output now begins that looks like this: Waiting up to 110 more seconds for network. Waiting up to 100 more seconds for network. Waiting up to 90 more seconds for network. Waiting up to 80 more seconds for network. ... Since most systems will have no problem getting link/carrier in the 1st 10s, the only people who will see these messages are people with genuine issues that need to be resolved. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f7f2287 commit 5e404cd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

net/ipv4/ipconfig.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int __init ic_open_devs(void)
206206
struct ic_device *d, **last;
207207
struct net_device *dev;
208208
unsigned short oflags;
209-
unsigned long start;
209+
unsigned long start, next_msg;
210210

211211
last = &ic_first_dev;
212212
rtnl_lock();
@@ -263,12 +263,23 @@ static int __init ic_open_devs(void)
263263

264264
/* wait for a carrier on at least one device */
265265
start = jiffies;
266+
next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
266267
while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) {
268+
int wait, elapsed;
269+
267270
for_each_netdev(&init_net, dev)
268271
if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
269272
goto have_carrier;
270273

271274
msleep(1);
275+
276+
if time_before(jiffies, next_msg)
277+
continue;
278+
279+
elapsed = jiffies_to_msecs(jiffies - start);
280+
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
281+
pr_info("Waiting up to %d more seconds for network.\n", wait);
282+
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
272283
}
273284
have_carrier:
274285
rtnl_unlock();

0 commit comments

Comments
 (0)