summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kepplinger <martin.kepplinger@ginzinger.com>2019-01-31 05:14:18 -0500
committerDavid S. Miller <davem@davemloft.net>2019-02-01 18:24:13 -0500
commit3fc46fc9f68c71e21afde62984444b2ffdd1ea90 (patch)
treedde61921c95851ae913466e90d645e2968d17f31
parent1f533ba6d50d0e7a104d1a2c1e1a28ee0b919a90 (diff)
ipconfig: add carrier_timeout kernel parameter
commit 3fb72f1e6e61 ("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 5e404cd65860 ("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>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt5
-rw-r--r--net/ipv4/ipconfig.c27
2 files changed, 27 insertions, 5 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index b799bcf67d7b..7afb2fedde0a 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -461,6 +461,11 @@
461 possible to determine what the correct size should be. 461 possible to determine what the correct size should be.
462 This option provides an override for these situations. 462 This option provides an override for these situations.
463 463
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
464 ca_keys= [KEYS] This parameter identifies a specific key(s) on 469 ca_keys= [KEYS] This parameter identifies a specific key(s) on
465 the system trusted keyring to be used for certificate 470 the system trusted keyring to be used for certificate
466 trust validation. 471 trust validation.
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index b9a9873c25c6..9bcca08efec9 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -85,7 +85,6 @@
85 85
86/* Define the friendly delay before and after opening net devices */ 86/* Define the friendly delay before and after opening net devices */
87#define CONF_POST_OPEN 10 /* After opening: 10 msecs */ 87#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
88#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
89 88
90/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */ 89/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
91#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */ 90#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -101,6 +100,9 @@
101#define NONE cpu_to_be32(INADDR_NONE) 100#define NONE cpu_to_be32(INADDR_NONE)
102#define ANY cpu_to_be32(INADDR_ANY) 101#define ANY cpu_to_be32(INADDR_ANY)
103 102
103/* Wait for carrier timeout default in seconds */
104static unsigned int carrier_timeout = 120;
105
104/* 106/*
105 * Public IP configuration 107 * Public IP configuration
106 */ 108 */
@@ -268,9 +270,9 @@ static int __init ic_open_devs(void)
268 270
269 /* wait for a carrier on at least one device */ 271 /* wait for a carrier on at least one device */
270 start = jiffies; 272 start = jiffies;
271 next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12); 273 next_msg = start + msecs_to_jiffies(20000);
272 while (time_before(jiffies, start + 274 while (time_before(jiffies, start +
273 msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) { 275 msecs_to_jiffies(carrier_timeout * 1000))) {
274 int wait, elapsed; 276 int wait, elapsed;
275 277
276 for_each_netdev(&init_net, dev) 278 for_each_netdev(&init_net, dev)
@@ -283,9 +285,9 @@ static int __init ic_open_devs(void)
283 continue; 285 continue;
284 286
285 elapsed = jiffies_to_msecs(jiffies - start); 287 elapsed = jiffies_to_msecs(jiffies - start);
286 wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000; 288 wait = (carrier_timeout * 1000 - elapsed + 500) / 1000;
287 pr_info("Waiting up to %d more seconds for network.\n", wait); 289 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);
289 } 291 }
290have_carrier: 292have_carrier:
291 rtnl_unlock(); 293 rtnl_unlock();
@@ -1780,3 +1782,18 @@ static int __init vendor_class_identifier_setup(char *addrs)
1780 return 1; 1782 return 1;
1781} 1783}
1782__setup("dhcpclass=", vendor_class_identifier_setup); 1784__setup("dhcpclass=", vendor_class_identifier_setup);
1785
1786static 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);