You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
6.5 KiB
197 lines
6.5 KiB
From d8ad687e1a4c0343eb076902b11aff2b2b2c4b85 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. |
|
--- |
|
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 c7e3bd40..5f3dead1 100644 |
|
--- a/dracut.cmdline.7.asc |
|
+++ b/dracut.cmdline.7.asc |
|
@@ -572,6 +572,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 3cff725c..2f51e6d5 100755 |
|
--- a/modules.d/40network/ifup.sh |
|
+++ b/modules.d/40network/ifup.sh |
|
@@ -98,15 +98,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 1f77a154..de5273ca 100755 |
|
--- a/modules.d/40network/net-lib.sh |
|
+++ b/modules.d/40network/net-lib.sh |
|
@@ -486,7 +486,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 |
|
@@ -498,7 +502,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 |
|
@@ -509,7 +517,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 |
|
@@ -521,7 +533,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 |
|
@@ -533,7 +549,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 |
|
@@ -561,8 +581,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))
|
|
|