dracut/0103-network-use-arping2-if-available.patch

102 lines
4.0 KiB
Diff
Raw Normal View History

2016-08-18 11:30:10 +00:00
From 9853791d376bee4a658d624424b32f7deae6ac79 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 14 Jul 2016 14:24:31 +0200
Subject: [PATCH] network: use arping2, if available
fixes https://github.com/dracutdevs/dracut/issues/135
---
modules.d/40network/dhclient-script.sh | 13 ++++++++++---
modules.d/40network/ifup.sh | 13 ++++++++++---
modules.d/40network/module-setup.sh | 5 +++--
modules.d/40network/net-lib.sh | 6 +++++-
4 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
index 94ee9d1..2eade35 100755
--- a/modules.d/40network/dhclient-script.sh
+++ b/modules.d/40network/dhclient-script.sh
@@ -159,9 +159,16 @@ case $reason in
read layer2 < /sys/class/net/$netif/device/layer2
fi
if [ "$layer2" != "0" ]; then
- if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then
- warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
- exit 1
+ if command -v arping2 >/dev/null; then
+ if arping2 -q -C 1 -c 2 -I $netif $new_ip_address ; then
+ warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
+ exit 1
+ fi
+ else
+ if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then
+ warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying"
+ exit 1
+ fi
fi
fi
unset layer2
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 41282e7..1461b91 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -110,9 +110,16 @@ do_static() {
ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
wait_for_ipv6_dad $netif
else
- if ! arping -f -q -D -c 2 -I $netif $ip; then
- warn "Duplicate address detected for $ip for interface $netif."
- return 1
+ if command -v arping2 >/dev/null; then
+ if arping2 -q -C 1 -c 2 -I $netif $ip ; then
+ warn "Duplicate address detected for $ip for interface $netif."
+ return 1
+ fi
+ else
+ if ! arping -f -q -D -c 2 -I $netif $ip ; then
+ warn "Duplicate address detected for $ip for interface $netif."
+ return 1
+ fi
fi
ip addr flush dev $netif
ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index 53b4b60..0501ffe 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -4,7 +4,8 @@
check() {
local _program
- require_binaries ip arping dhclient || return 1
+ require_binaries ip dhclient || return 1
+ require_any_binaries arping arping2 || return 1
return 255
}
@@ -23,7 +24,7 @@ installkernel() {
# called by dracut
install() {
local _arch _i _dir
- inst_multiple ip arping dhclient sed awk
+ inst_multiple ip arping arping2 dhclient sed awk
inst_multiple -o ping ping6
inst_multiple -o brctl
inst_multiple -o teamd teamdctl teamnl
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index 9c1448d..92225c5 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -169,7 +169,11 @@ setup_net() {
fi
if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then
- arping -q -f -w 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
+ if command -v arping2 >/dev/null; then
+ arping2 -q -C 1 -c 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
+ else
+ arping -q -f -w 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed"
+ fi
fi
unset layer2