File 0563-40network-collapse-arping-and-dhcp-calls-into-wicked.patch of Package dracut.10369
From abb2c4123658ec5e9f7b21d92c80e1af7e879180 Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <dmolkentin@suse.com>
Date: Fri, 16 Feb 2018 11:51:18 +0100
Subject: [PATCH] 40network: collapse arping and dhcp calls into wicked binary
References: bsc#1078245
---
modules.d/40network/dhclient-script.sh | 6 ++----
modules.d/40network/ifup.sh | 25 ++++++++++++++++---------
modules.d/40network/module-setup.sh | 8 +++-----
modules.d/40network/net-lib.sh | 14 +++++++++-----
4 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/modules.d/40network/dhclient-script.sh b/modules.d/40network/dhclient-script.sh
index f8a558c7..fb9f5858 100755
--- a/modules.d/40network/dhclient-script.sh
+++ b/modules.d/40network/dhclient-script.sh
@@ -113,11 +113,9 @@ case $reason in
if [ -f /sys/class/net/$netif/device/layer2 ]; then
read layer2 < /sys/class/net/$netif/device/layer2
fi
- if ! which arping > /dev/null 2>&1 ; then
- layer2=0
- fi
if [ "$layer2" != "0" ]; then
- if ! arping -f -q -D -c 2 -I $netif $new_ip_address ; 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
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 9775084e..a51b6a30 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -214,9 +214,9 @@ do_dhcp() {
else
ipv6_mode="managed"
fi
- dhclient="wickedd-dhcp6 --test --test-mode $ipv6_mode"
+ dhclient="wicked test dhcp6"
else
- dhclient="wickedd-dhcp4 --test"
+ dhclient="wicked test dhcp4"
fi
if ! linkup $netif; then
@@ -229,9 +229,8 @@ do_dhcp() {
[ -n "$mtu" ] && ip $1 link set mtu $mtu dev $netif
fi
- $dhclient --test-format leaseinfo --test-output /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} --test-request - $netif << EOF
-<request type="lease"/>
-EOF
+ echo '<request type="lease"/>' > /tmp/request.${netif}.dhcp.ipv${1:1:1}
+ $dhclient --format leaseinfo --output /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1} --request /tmp/request.${netif}.dhcp.ipv${1:1:1} $netif
dhcp_apply $1 || return $?
if [ "$1" = "-6" ] ; then
@@ -329,10 +328,18 @@ if strglobin $ip '*:*:*'; then
wait_for_ipv6_dad $netif
[ "$gw" = "::" ] && gw=""
else
- if which arping > /dev/null 2>&1 -a ! arping -f -q -D -c 2 -I $netif $ip; then
- warn "Duplicate address detected for $ip for interface $netif."
- return 1
- fi
+ wicked arp verify --quiet $netif $ip 2>/dev/null
+ case "$?" in
+ 1)
+ info "$netif does not support ARP, cannot attempt to resolve $dest."
+ ;;
+ 4)
+ warn "Duplicate address detected for $ip for interface $netif."
+ return 1
+ ;;
+ *)
+ ;;
+ esac
# Assume /24 prefix for IPv4
[ -z "$prefix" ] && prefix=24
ip addr add $ip/$prefix ${srv:+peer $srv} brd + dev $netif
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index 2dd3630c..023400ac 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -1,13 +1,12 @@
#!/bin/bash
-WICKEDD_DHCP_PATH="/usr/lib/wicked/bin"
WICKED_EXT_PATH="/etc/wicked/extensions"
# called by dracut
check() {
local _program
- require_binaries ip $WICKEDD_DHCP_PATH/wickedd-dhcp4 $WICKEDD_DHCP_PATH/wickedd-dhcp6 || return 1
+ require_binaries ip wicked || return 1
return 255
}
@@ -34,11 +33,10 @@ installkernel() {
install() {
local _arch _i _dir
inst_multiple ip hostname sed
- inst_multiple -o arping ping ping6
+ inst_multiple ping ping6
inst_multiple -o teamd teamdctl teamnl
+ inst_multiple wicked
inst_simple /etc/libnl/classid
- inst_simple "$WICKEDD_DHCP_PATH/wickedd-dhcp4" "/usr/sbin/wickedd-dhcp4"
- inst_simple "$WICKEDD_DHCP_PATH/wickedd-dhcp6" "/usr/sbin/wickedd-dhcp6"
inst_libdir_file "libwicked*.so.*"
inst_libdir_file "libdbus-1.so.*"
inst_script "$moddir/ifup.sh" "/sbin/ifup"
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index c8ab84d0..b491f8e1 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -199,12 +199,16 @@ setup_net() {
read layer2 < /sys/class/net/$netif/device/layer2
fi
- if ! which arping > /dev/null 2>&1 ; then
- layer2=0
- 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"
+ wicked arp ping --interval 3000 --replies 1 --timeout 60000 --quiet $netif $dest 2>/dev/null
+ case "$?" in
+ 0)
+ # Everything is ok
+ ;;
+ *)
+ info "Resolving $dest via ARP on $netif failed"
+ ;;
+ esac
fi
unset layer2
--
2.13.6