[PATCH] ipconfig: make the wait for carrier timeout configurable

From: Martin Kepplinger
Date: Mon Jan 28 2019 - 06:30:18 EST


From: Manfred Schlaegl <manfred.schlaegl@xxxxxxxxxxxxx>

commit 3fb72f1e6e61 ("ipconfig wait for carrier") added a
"wait for carrier" policy, with a fixed worst case maximum wait
of two minutes.

This makes the wait for carrier timeout configurable (0 - 240 seconds).

The informative timeout messages introduced with
commit 5e404cd65860 ("ipconfig: add informative timeout messages while
waiting for carrier") were adapted. Message output is done in a fixed
interval of 20 seconds, just like before (240/12).

Signed-off-by: Manfred Schlaegl <manfred.schlaegl@xxxxxxxxxxxxx>
Signed-off-by: Martin Kepplinger <martin.kepplinger@xxxxxxxxxxxxx>
---

This is really just something we always set shorter on embedded devices
and don't understand why it isn't configurable :)

thanks

martin



net/ipv4/Kconfig | 11 +++++++++++
net/ipv4/ipconfig.c | 7 ++++---
2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
index 32cae39cdff6..299c5dbbea97 100644
--- a/net/ipv4/Kconfig
+++ b/net/ipv4/Kconfig
@@ -113,6 +113,17 @@ config IP_PNP
on NFS" as well), because all other machines configure the network
in their startup scripts.

+config IP_PNP_CARRIER_TIMEOUT
+ int "Wait for carrier timeout (in seconds)"
+ default 120
+ range 0 240
+ depends on IP_PNP
+ help
+ This defines the timeout waiting for carrier in seconds before
+ continuing kernel startup.
+
+ Use the default if unsure.
+
config IP_PNP_DHCP
bool "IP: DHCP support"
depends on IP_PNP
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index b9a9873c25c6..e8041c0c2b97 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -85,7 +85,8 @@

/* Define the friendly delay before and after opening net devices */
#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
-#define CONF_CARRIER_TIMEOUT 120000 /* Wait for carrier timeout */
+/* Wait for carrier timeout */
+#define CONF_CARRIER_TIMEOUT (CONFIG_IP_PNP_CARRIER_TIMEOUT*1000)

/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
@@ -268,7 +269,7 @@ static int __init ic_open_devs(void)

/* wait for a carrier on at least one device */
start = jiffies;
- next_msg = start + msecs_to_jiffies(CONF_CARRIER_TIMEOUT/12);
+ next_msg = start + msecs_to_jiffies(20000);
while (time_before(jiffies, start +
msecs_to_jiffies(CONF_CARRIER_TIMEOUT))) {
int wait, elapsed;
@@ -285,7 +286,7 @@ static int __init ic_open_devs(void)
elapsed = jiffies_to_msecs(jiffies - start);
wait = (CONF_CARRIER_TIMEOUT - elapsed + 500)/1000;
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:
rtnl_unlock();
--
2.20.1