dracut/0104-network-add-options-to-tweak-timeouts.patch

200 lines
6.6 KiB
Diff
Raw Normal View History

From 2448fbf17b8deb28046b9721503cab15721716ca Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Fri, 3 Jul 2015 13:30:40 +0200
Subject: [PATCH] network: add options to tweak timeouts
rd.net.dhcp.retry=<cnt>
If this option is set, dracut will try to connect via dhcp
<cnt> times before failing. Default is 1.
rd.net.timeout.dhcp=<arg>
If this option is set, dhclient is called with "-timeout <arg>".
rd.net.timeout.iflink=<seconds>
Wait <seconds> until link shows up. Default is 60 seconds.
rd.net.timeout.ifup=<seconds>
Wait <seconds> until link has state "UP". Default is 20 seconds.
rd.net.timeout.route=<seconds>
Wait <seconds> until route shows up. Default is 20 seconds.
rd.net.timeout.ipv6dad=<seconds>
Wait <seconds> until IPv6 DAD is finished. Default is 50 seconds.
rd.net.timeout.ipv6auto=<seconds>
Wait <seconds> until IPv6 automatic addresses are assigned.
Default is 40 seconds.
rd.net.timeout.carrier=<seconds>
Wait <seconds> until carrier is recognized. Default is 5 seconds.
(cherry picked from commit d8ad687e1a4c0343eb076902b11aff2b2b2c4b85)
---
dracut.cmdline.7.asc | 25 +++++++++++++++++++++++++
modules.d/40network/ifup.sh | 26 ++++++++++++++++++++++----
modules.d/40network/net-lib.sh | 36 ++++++++++++++++++++++++++++++------
3 files changed, 77 insertions(+), 10 deletions(-)
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index 8c7e965..d790afd 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -606,6 +606,31 @@ NFS
**rd.nfs.domain=**__<NFSv4 domain name>__::
Set the NFSv4 domain name. Will overwrite the settings in _/etc/idmap.conf_.
+**rd.net.dhcp.retry=**__<cnt>__::
+ If this option is set, dracut will try to connect via dhcp <cnt> times before failing.
+ Default is 1.
+
+**rd.net.timeout.dhcp=**__<arg>__::
+ If this option is set, dhclient is called with "-timeout <arg>".
+
+**rd.net.timeout.iflink=**__<seconds>__::
+ Wait <seconds> until link shows up. Default is 60 seconds.
+
+**rd.net.timeout.ifup=**__<seconds>__::
+ Wait <seconds> until link has state "UP". Default is 20 seconds.
+
+**rd.net.timeout.route=**__<seconds>__::
+ Wait <seconds> until route shows up. Default is 20 seconds.
+
+**rd.net.timeout.ipv6dad=**__<seconds>__::
+ Wait <seconds> until IPv6 DAD is finished. Default is 50 seconds.
+
+**rd.net.timeout.ipv6auto=**__<seconds>__::
+ Wait <seconds> until IPv6 automatic addresses are assigned. Default is 40 seconds.
+
+**rd.net.timeout.carrier=**__<seconds>__::
+ Wait <seconds> until carrier is recognized. Default is 5 seconds.
+
CIFS
~~~
**root=**cifs://[__<username>__[:__<password>__]@]__<server-ip>__:__<root-dir>__::
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 0138e01..bb20afe 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -93,15 +93,33 @@ do_dhcp() {
# event for nfsroot
# XXX add -V vendor class and option parsing per kernel
+ local _COUNT=0
+ local _timeout=$(getargs rd.net.timeout.dhcp=)
+ local _DHCPRETRY=$(getargs rd.net.dhcp.retry=)
+ _DHCPRETRY=${_DHCPRETRY:-1}
+
[ -e /tmp/dhclient.$netif.pid ] && return 0
if ! iface_has_link $netif; then
- echo "No carrier detected"
+ warn "No carrier detected on interface $netif"
return 1
fi
- echo "Starting dhcp for interface $netif"
- dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \
- || echo "dhcp failed"
+
+ while [ $_COUNT -lt $_DHCPRETRY ]; do
+ info "Starting dhcp for interface $netif"
+ dhclient "$@" \
+ ${_timeout:+-timeout $_timeout} \
+ -1 -q \
+ -cf /etc/dhclient.conf \
+ -pf /tmp/dhclient.$netif.pid \
+ -lf /tmp/dhclient.$netif.lease \
+ $netif \
+ && return 0
+ _COUNT=$(($_COUNT+1))
+ [ $_COUNT -lt $_DHCPRETRY ] && sleep 1
+ done
+ warn "dhcp for interface $netif failed"
+ return 1
}
load_ipv6() {
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index 2e79619..2f25de7 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -504,7 +504,11 @@ parse_ifname_opts() {
wait_for_if_link() {
local cnt=0
local li
- while [ $cnt -lt 600 ]; do
+ local timeout="$(getargs rd.net.timeout.iflink=)"
+ timeout=${timeout:-60}
+ timeout=$(($timeout*10))
+
+ while [ $cnt -lt $timeout ]; do
li=$(ip -o link show dev $1 2>/dev/null)
[ -n "$li" ] && return 0
sleep 0.1
@@ -516,7 +520,11 @@ wait_for_if_link() {
wait_for_if_up() {
local cnt=0
local li
- while [ $cnt -lt 200 ]; do
+ local timeout="$(getargs rd.net.timeout.ifup=)"
+ timeout=${timeout:-20}
+ timeout=$(($timeout*10))
+
+ while [ $cnt -lt $timeout ]; do
li=$(ip -o link show up dev $1)
[ -n "$li" ] && [ -z "${li##*state UP*}" ] && return 0
sleep 0.1
@@ -527,7 +535,11 @@ wait_for_if_up() {
wait_for_route_ok() {
local cnt=0
- while [ $cnt -lt 200 ]; do
+ local timeout="$(getargs rd.net.timeout.route=)"
+ timeout=${timeout:-20}
+ timeout=$(($timeout*10))
+
+ while [ $cnt -lt $timeout ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
@@ -539,7 +551,11 @@ wait_for_route_ok() {
wait_for_ipv6_dad() {
local cnt=0
local li
- while [ $cnt -lt 500 ]; do
+ local timeout="$(getargs rd.net.timeout.ipv6dad=)"
+ timeout=${timeout:-50}
+ timeout=$(($timeout*10))
+
+ while [ $cnt -lt $timeout ]; do
li=$(ip -6 addr show dev $1 scope link)
strstr "$li" "tentative" || return 0
sleep 0.1
@@ -551,7 +567,11 @@ wait_for_ipv6_dad() {
wait_for_ipv6_auto() {
local cnt=0
local li
- while [ $cnt -lt 400 ]; do
+ local timeout="$(getargs rd.net.timeout.ipv6auto=)"
+ timeout=${timeout:-40}
+ timeout=$(($timeout*10))
+
+ while [ $cnt -lt $timeout ]; do
li=$(ip -6 addr show dev $1)
if ! strstr "$li" "tentative"; then
strstr "$li" "dynamic" && return 0
@@ -579,8 +599,12 @@ iface_has_link() {
[ -n "$interface" ] || return 2
interface="/sys/class/net/$interface"
[ -d "$interface" ] || return 2
+ local timeout="$(getargs rd.net.timeout.carrier=)"
+ timeout=${timeout:-5}
+ timeout=$(($timeout*10))
+
linkup "$1"
- while [ $cnt -lt 50 ]; do
+ while [ $cnt -lt $timeout ]; do
[ "$(cat $interface/carrier)" = 1 ] && return 0
sleep 0.1
cnt=$(($cnt+1))