Skip to contentSkip to conversation

net/dhcp: Don't start dhclient when wicked is running

PATCH New Petr Vorel 1 participant 2 messages Oct 22, 2019 – Oct 31, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

PATCH 1/1 net/dhcp: Don't start dhclient when wicked is running

This is a rework of wicked workaround. Commit f5b28dbb0 stopped wicked (if running) as it's conflicting with dhclient. But for systems which use wicked is better to actually test wicked as client side, because dhclient is not actually used.

Fixes f5b28dbb0 ("net/dhcp: Add support for wicked")

---

NOTE: I actually had also idea to use -sf (dhclient-script) and maybe -cf (config file) parameter from running dhclient instance. NetworkManager is using it's own dhclient-script and config file, so it'd have more sense to test them (for the same reasons as this commit). But it does not work (either using just -sf or using both -sf and -cf - the latter isn't surprising).

Kind regards,
Petr

 testcases/network/dhcp/dhcp_lib.sh | 33 ++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)
testcases/network/dhcp/dhcp_lib.sh +22 -11
index f731eed24..634d6ab43 100755
@@ -108,7 +108,8 @@ print_dhcp_log()
 
 test01()
 {
-	local wicked
+	local wicked_cfg="/etc/sysconfig/network/ifcfg-$iface1"
+	local wicked_cleanup
 
 	tst_res TINFO "testing DHCP server $dhcp_name: $(print_dhcp_version)"
 	tst_res TINFO "using DHCP client: $(dhclient --version 2>&1)"
@@ -130,15 +131,28 @@ test01()
 
 	if [ $HAVE_SYSTEMCTL -eq 1 ] && \
 		systemctl --no-pager -p Id show network.service | grep -q Id=wicked.service; then
-		tst_res TINFO "temporarily disabling wicked"
-		wicked=1
-		systemctl disable wicked
+		tst_res TINFO "wicked is running, don't start dhclient"
+		if [ ! -f "$wicked_cfg" ]; then
+			cat <<EOF > $wicked_cfg
+BOOTPROTO='dhcp'
+NAME='LTP card'
+STARTMODE='auto'
+USERCONTROL='no'
+EOF
+			wicked_cleanup=1
+		else
+			tst_res TINFO "wicked config file $wicked_cfg already exist"
+		fi
+
+		tst_res TINFO "restarting wicked"
+		systemctl restart wicked
+	else
+		tst_res TINFO "starting dhclient -$TST_IPVER $iface1"
+		dhclient -$TST_IPVER $iface1 || tst_brk TBROK "dhclient failed"
 	fi
-	tst_res TINFO "starting dhclient -$TST_IPVER $iface1"
-	dhclient -$TST_IPVER $iface1 || tst_brk TBROK "dhclient failed"
 
 	# check that we get configured ip address
-	ip addr show $iface1 | grep $ip_addr_check > /dev/null
+	ip addr show $iface1 | grep -q $ip_addr_check
 	if [ $? -eq 0 ]; then
 		tst_res TPASS "'$ip_addr_check' configured by DHCPv$TST_IPVER"
 	else
@@ -151,10 +165,7 @@ test01()
 		fi
 	fi
 
-	if [ "$wicked" ]; then
-		tst_res TINFO "reenabling wicked"
-		systemctl enable wicked
-	fi
+	[ "$wicked_cleanup" ] && rm -f $wicked_cfg
 
 	stop_dhcp
 }
Signature · 1 line
2.23.0
author
#1 lore raw

PATCH 1/1 net/dhcp: Don't start dhclient when wicked is running

Hi,

Quoted 8 lines

This is a rework of wicked workaround. Commit f5b28dbb0 stopped wicked (if running) as it's conflicting with dhclient. But for systems which use wicked is better to actually test wicked as client side, because dhclient is not actually used.

Fixes f5b28dbb0 ("net/dhcp: Add support for wicked")

Merged.

Kind regards,
Petr