From 0ec91eea07f1a7807d87ffb131ee211df2ca1a62 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Fri, 27 Apr 2018 10:34:52 +0200 Subject: [PATCH] 40network: Add wicked as an alternative to arping --- modules.d/40network/dhclient-script.sh | 19 ++++++++++++++----- modules.d/40network/ifup.sh | 26 +++++++++++++++++--------- modules.d/40network/module-setup.sh | 7 ++++--- modules.d/40network/net-lib.sh | 10 +++++++--- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh index fc6ed0a36..9cf991f9c 100755 --- a/modules.d/40network/dhclient-script.sh +++ b/modules.d/40network/dhclient-script.sh @@ -168,15 +168,24 @@ case $reason in read layer2 < /sys/class/net/$netif/device/layer2 fi if [ "$layer2" != "0" ]; then - if command -v arping2 >/dev/null; then - if arping2 -q -C 1 -c 2 -I $netif -0 $new_ip_address ; then + + if command -v wicked >/dev/null; then + wicked arp verify $netif $new_ip_address 2>/dev/null + if [ $? -eq 4 ]; 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 + if command -v arping2 >/dev/null; then + if arping2 -q -C 1 -c 2 -I $netif -0 $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 fi diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh index 0db3c0213..e1366d0a7 100755 --- a/modules.d/40network/ifup.sh +++ b/modules.d/40network/ifup.sh @@ -114,20 +114,28 @@ do_static() { wait_for_ipv6_dad $netif else if [ -z "$srv" ]; then - if command -v arping2 >/dev/null; then - if arping2 -q -C 1 -c 2 -I $netif -0 $ip ; then - warn "Duplicate address detected for $ip for interface $netif." - return 1 + if command -v wicked >/dev/null; then + wicked arp verify $netif $ip 2>/dev/null + if [ $? -eq 4 ]; then + warn "Duplicate address detected for $ip while doing dhcp. retrying" + exit 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 + if command -v arping2 >/dev/null; then + if arping2 -q -C 1 -c 2 -I $netif -0 $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 fi + ip addr flush dev $netif + ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif fi - ip addr flush dev $netif - ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif fi [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh index a10109115..b6828e97b 100755 --- a/modules.d/40network/module-setup.sh +++ b/modules.d/40network/module-setup.sh @@ -4,8 +4,9 @@ check() { local _program - require_binaries ip dhclient sed awk grep || return 1 - require_any_binary arping arping2 || return 1 + require_binaries ip sed awk grep || return 1 + require_any_binary arping arping2 wicked || return 1 + require_any_binary dhclient wicked || return 1 return 255 } @@ -28,7 +29,7 @@ install() { inst_multiple -o arping arping2 strstr "$(arping 2>&1)" "ARPing 2" && mv "$initdir/bin/arping" "$initdir/bin/arping2" - + inst_multiple -o wicked inst_multiple -o ping ping6 inst_multiple -o teamd teamdctl teamnl inst_simple /etc/libnl/classid diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh index 71a665cdf..efea81587 100755 --- a/modules.d/40network/net-lib.sh +++ b/modules.d/40network/net-lib.sh @@ -171,10 +171,14 @@ setup_net() { fi if [ "$layer2" != "0" ] && [ -n "$dest" ] && ! strstr "$dest" ":"; then - if command -v arping2 >/dev/null; then - arping2 -q -C 1 -c 60 -I $netif $dest || info "Resolving $dest via ARP on $netif failed" + if command -v wicked >/dev/null; then + wicked arp ping --interval 3000 --replies 1 --timeout 60000 --quiet $netif $dest 2>/dev/null || 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" + 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 -- 2.47.3