Skip to content

Commit 3fc46fc

Browse files
mergedavem330
authored andcommitted
ipconfig: add carrier_timeout kernel parameter
commit 3fb72f1 ("ipconfig wait for carrier") added a "wait for carrier" policy, with a fixed worst case maximum wait of two minutes. Now make the wait for carrier timeout configurable on the kernel commandline and use the 120s as the default. The timeout messages introduced with commit 5e404cd ("ipconfig: add informative timeout messages while waiting for carrier") are done in a fixed interval of 20 seconds, just like they were before (240/12). Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1f533ba commit 3fc46fc

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,11 @@
461461
possible to determine what the correct size should be.
462462
This option provides an override for these situations.
463463

464+
carrier_timeout=
465+
[NET] Specifies amount of time (in seconds) that
466+
the kernel should wait for a network carrier. By default
467+
it waits 120 seconds.
468+
464469
ca_keys= [KEYS] This parameter identifies a specific key(s) on
465470
the system trusted keyring to be used for certificate
466471
trust validation.

net/ipv4/ipconfig.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585

8686
/* Define the friendly delay before and after opening net devices */
8787
#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
88-
#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
8988

9089
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
9190
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -101,6 +100,9 @@
101100
#define NONE cpu_to_be32(INADDR_NONE)
102101
#define ANY cpu_to_be32(INADDR_ANY)
103102

103+
/* Wait for carrier timeout default in seconds */
104+
static unsigned int carrier_timeout = 120;
105+
104106
/*
105107
* Public IP configuration
106108
*/
@@ -268,9 +270,9 @@ static int __init ic_open_devs(void)
268270

269271
/* wait for a carrier on at least one device */
270272
start = jiffies;
271-
next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
273+
next_msg = start + msecs_to_jiffies(20000);
272274
while (time_before(jiffies, start +
273-
msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) {
275+
msecs_to_jiffies(carrier_timeout * 1000))) {
274276
int wait, elapsed;
275277

276278
for_each_netdev(&init_net, dev)
@@ -283,9 +285,9 @@ static int __init ic_open_devs(void)
283285
continue;
284286

285287
elapsed = jiffies_to_msecs(jiffies - start);
286-
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
288+
wait = (carrier_timeout * 1000 - elapsed + 500) / 1000;
287289
pr_info("Waiting up to %d more seconds for network.\n", wait);
288-
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
290+
next_msg = jiffies + msecs_to_jiffies(20000);
289291
}
290292
have_carrier:
291293
rtnl_unlock();
@@ -1780,3 +1782,18 @@ static int __init vendor_class_identifier_setup(char *addrs)
17801782
return 1;
17811783
}
17821784
__setup("dhcpclass=", vendor_class_identifier_setup);
1785+
1786+
static int __init set_carrier_timeout(char *str)
1787+
{
1788+
ssize_t ret;
1789+
1790+
if (!str)
1791+
return 0;
1792+
1793+
ret = kstrtouint(str, 0, &carrier_timeout);
1794+
if (ret)
1795+
return 0;
1796+
1797+
return 1;
1798+
}
1799+
__setup("carrier_timeout=", set_carrier_timeout);

0 commit comments

Comments
 (0)