network: use arping2, if available

fixes https://github.com/dracutdevs/dracut/issues/135
master
Harald Hoyer 2016-07-14 14:24:31 +02:00
parent 5a3773dbe6
commit 9853791d37
4 changed files with 28 additions and 9 deletions

View File

@ -159,9 +159,16 @@ case $reason in
read layer2 < /sys/class/net/$netif/device/layer2 read layer2 < /sys/class/net/$netif/device/layer2
fi fi
if [ "$layer2" != "0" ]; then if [ "$layer2" != "0" ]; then
if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; then if command -v arping2 >/dev/null; then
warn "Duplicate address detected for $new_ip_address while doing dhcp. retrying" if arping2 -q -C 1 -c 2 -I $netif $new_ip_address ; then
exit 1 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
fi fi
unset layer2 unset layer2

View File

@ -110,9 +110,16 @@ do_static() {
ip addr add $ip/$mask ${srv:+peer $srv} dev $netif ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
wait_for_ipv6_dad $netif wait_for_ipv6_dad $netif
else else
if ! arping -f -q -D -c 2 -I $netif $ip; then if command -v arping2 >/dev/null; then
warn "Duplicate address detected for $ip for interface $netif." if arping2 -q -C 1 -c 2 -I $netif $ip ; then
return 1 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 fi
ip addr flush dev $netif ip addr flush dev $netif
ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif

View File

@ -4,7 +4,8 @@
check() { check() {
local _program local _program


require_binaries ip arping dhclient || return 1 require_binaries ip dhclient || return 1
require_any_binaries arping arping2 || return 1


return 255 return 255
} }
@ -23,7 +24,7 @@ installkernel() {
# called by dracut # called by dracut
install() { install() {
local _arch _i _dir 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 ping ping6
inst_multiple -o brctl inst_multiple -o brctl
inst_multiple -o teamd teamdctl teamnl inst_multiple -o teamd teamdctl teamnl

View File

@ -169,7 +169,11 @@ setup_net() {
fi fi


if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then 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 fi
unset layer2 unset layer2