Commit 3fc46fc9 authored by Martin Kepplinger's avatar Martin Kepplinger Committed by David S. Miller

ipconfig: add carrier_timeout kernel parameter

commit 3fb72f1e ("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 5e404cd6 ("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: default avatarMartin Kepplinger <martin.kepplinger@ginzinger.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1f533ba6
...@@ -461,6 +461,11 @@ ...@@ -461,6 +461,11 @@
possible to determine what the correct size should be. possible to determine what the correct size should be.
This option provides an override for these situations. This option provides an override for these situations.
carrier_timeout=
[NET] Specifies amount of time (in seconds) that
the kernel should wait for a network carrier. By default
it waits 120 seconds.
ca_keys= [KEYS] This parameter identifies a specific key(s) on ca_keys= [KEYS] This parameter identifies a specific key(s) on
the system trusted keyring to be used for certificate the system trusted keyring to be used for certificate
trust validation. trust validation.
......
...@@ -85,7 +85,6 @@ ...@@ -85,7 +85,6 @@
/* Define the friendly delay before and after opening net devices */ /* Define the friendly delay before and after opening net devices */
#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ #define CONF_POST_OPEN 10 /* After opening: 10 msecs */
#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ /* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ #define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
...@@ -101,6 +100,9 @@ ...@@ -101,6 +100,9 @@
#define NONE cpu_to_be32(INADDR_NONE) #define NONE cpu_to_be32(INADDR_NONE)
#define ANY cpu_to_be32(INADDR_ANY) #define ANY cpu_to_be32(INADDR_ANY)
/* Wait for carrier timeout default in seconds */
static unsigned int carrier_timeout = 120;
/* /*
* Public IP configuration * Public IP configuration
*/ */
...@@ -268,9 +270,9 @@ static int __init ic_open_devs(void) ...@@ -268,9 +270,9 @@ static int __init ic_open_devs(void)
/* wait for a carrier on at least one device */ /* wait for a carrier on at least one device */
start = jiffies; start = jiffies;
next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); next_msg = start + msecs_to_jiffies(20000);
while (time_before(jiffies, start + while (time_before(jiffies, start +
msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) { msecs_to_jiffies(carrier_timeout * 1000))) {
int wait, elapsed; int wait, elapsed;
for_each_netdev(&init_net, dev) for_each_netdev(&init_net, dev)
...@@ -283,9 +285,9 @@ static int __init ic_open_devs(void) ...@@ -283,9 +285,9 @@ static int __init ic_open_devs(void)
continue; continue;
elapsed = jiffies_to_msecs(jiffies - start); elapsed = jiffies_to_msecs(jiffies - start);
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000; wait = (carrier_timeout * 1000 - elapsed + 500) / 1000;
pr_info("Waiting up to %d more seconds for network.\n", wait); pr_info("Waiting up to %d more seconds for network.\n", wait);
next_msg = jiffies + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); next_msg = jiffies + msecs_to_jiffies(20000);
} }
have_carrier: have_carrier:
rtnl_unlock(); rtnl_unlock();
...@@ -1780,3 +1782,18 @@ static int __init vendor_class_identifier_setup(char *addrs) ...@@ -1780,3 +1782,18 @@ static int __init vendor_class_identifier_setup(char *addrs)
return 1; return 1;
} }
__setup("dhcpclass=", vendor_class_identifier_setup); __setup("dhcpclass=", vendor_class_identifier_setup);
static int __init set_carrier_timeout(char *str)
{
ssize_t ret;
if (!str)
return 0;
ret = kstrtouint(str, 0, &carrier_timeout);
if (ret)
return 0;
return 1;
}
__setup("carrier_timeout=", set_carrier_timeout);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment