]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network: use arping2, if available
authorHarald Hoyer <harald@redhat.com>
Thu, 14 Jul 2016 12:24:31 +0000 (14:24 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 14 Jul 2016 12:36:04 +0000 (14:36 +0200)
fixes https://github.com/dracutdevs/dracut/issues/135

modules.d/40network/dhclient-script.sh
modules.d/40network/ifup.sh
modules.d/40network/module-setup.sh
modules.d/40network/net-lib.sh

index 94ee9d1e7ac300aa6c70e2621cfa300c1ad5b275..2eade353d8c628fc3b03d151ff5820427a82db96 100755 (executable)
@@ -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
index 41282e7d01fe9fe3849d8460236753dbc05a5e67..1461b916704b77249233db6893bfc7ee228761b2 100755 (executable)
@@ -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
index 53b4b60b31cd48c91ea3f7ebb59d6063aca38ecb..0501ffe7d1fd90891abaca441ef8c07f2d86521d 100755 (executable)
@@ -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
index 9c1448d61345ea99d54b6487be60689a85944888..92225c57be8e02dc4e60e5b2d3a3c9f2182740cd 100755 (executable)
@@ -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