Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipconfig: add informative timeout messages while waiting for carrier

Commit 3fb72f1e6e6165c5f495e8dc11c5bbd14c73385c ("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>

authored by

Paul Gortmaker and committed by
David S. Miller
5e404cd6 f7f22874

+12 -1
+12 -1
net/ipv4/ipconfig.c
··· 206 206 struct ic_device *d, **last; 207 207 struct net_device *dev; 208 208 unsigned short oflags; 209 - unsigned long start; 209 + unsigned long start, next_msg; 210 210 211 211 last = &ic_first_dev; 212 212 rtnl_lock(); ··· 263 263 264 264 /* wait for a carrier on at least one device */ 265 265 start = jiffies; 266 + next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); 266 267 while (jiffies - start < msecs_to_jiffies(CONF_CARRIER_TIMEOUT)) { 268 + int wait, elapsed; 269 + 267 270 for_each_netdev(&init_net, dev) 268 271 if (ic_is_init_dev(dev) && netif_carrier_ok(dev)) 269 272 goto have_carrier; 270 273 271 274 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); 272 283 } 273 284 have_carrier: 274 285 rtnl_unlock();