public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: passt-dev@passt.top
Subject: [PATCH 3/5] Tweak dhclient arguments for readability
Date: Fri, 10 Jun 2022 12:32:43 +1000	[thread overview]
Message-ID: <20220610023245.845652-4-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220610023245.845652-1-david@gibson.dropbear.id.au>

[-- Attachment #1: Type: text/plain, Size: 7476 bytes --]

A number of tests and examples use dhclient in both IPv4 and IPv6 modes.
We use "dhclient -6" for IPv6, but usually just "dhclient" for IPv4.  Add
an explicit "-4" argument to make it more clear and explicit.

In addition, when dhclient is run from within pasta it usually won't be
"real" root, and so will not have access to write the default global pid
file.  This results in a mostly harmless but irritating error:
    Can't create /var/run/dhclient.pid: Permission denied
We can avoid that by using the --no-pid flag to dhclient.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 passt.1               | 4 ++--
 test/demo/passt       | 6 +++---
 test/demo/pasta       | 6 +++---
 test/dhcp/passt       | 2 +-
 test/dhcp/pasta       | 2 +-
 test/distro/ubuntu    | 4 ++--
 test/lib/setup        | 2 +-
 test/perf/passt_tcp   | 2 +-
 test/perf/passt_udp   | 2 +-
 test/two_guests/basic | 4 ++--
 10 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/passt.1 b/passt.1
index d3af916..28704e9 100644
--- a/passt.1
+++ b/passt.1
@@ -484,7 +484,7 @@ udhcpc: started, v1.30.1
 udhcpc: sending discover
 udhcpc: sending select for 192.168.1.118
 udhcpc: lease of 192.168.1.118 obtained, lease time 4294967295
-# dhclient -6
+# dhclient -6 --no-pid
 # ip address show
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
@@ -581,7 +581,7 @@ udhcpc: started, v1.30.1
 udhcpc: sending discover
 udhcpc: sending select for 192.168.1.118
 udhcpc: lease of 192.168.1.118 obtained, lease time 4294967295
-# dhclient -6
+# dhclient -6 --no-pid
 # ip address show
 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
diff --git a/test/demo/passt b/test/demo/passt
index d394a08..ee4e7c2 100644
--- a/test/demo/passt
+++ b/test/demo/passt
@@ -73,9 +73,9 @@ sleep	3
 passt	cd __TEMPDIR__/passt
 passtb	./pasta
 sleep	3
-passt	/sbin/dhclient
+passt	/sbin/dhclient -4 --no-pid
 sleep	2
-passt	/sbin/dhclient -6
+passt	/sbin/dhclient -6 --no-pid
 sleep	2
 
 nl
@@ -112,7 +112,7 @@ guest	ip link show
 sleep	3
 say	Guest is up. Let's configure IPv4 first...
 sleep	2
-guest	dhclient
+guest	dhclient -4
 sleep	2
 guest	ip addr show
 sleep	5
diff --git a/test/demo/pasta b/test/demo/pasta
index 8b13b5e..e2517ed 100644
--- a/test/demo/pasta
+++ b/test/demo/pasta
@@ -77,7 +77,7 @@ ns	ip link show
 sleep	3
 say	Let's configure IPv4 first...
 sleep	2
-ns	dhclient
+ns	dhclient -4 --no-pid
 sleep	2
 ns	ip addr show
 sleep	5
@@ -87,7 +87,7 @@ say	  SLAAC is already done, but we can also
 nl
 say	  get another address via DHCPv6.
 sleep	3
-ns	dhclient -6
+ns	dhclient -6 --no-pid
 sleep	3
 
 nl
@@ -146,7 +146,7 @@ temp	TEMP
 passtb	./pasta -p __TEMP__.pcap
 sleep	2
 passt	
-passt	/sbin/dhclient
+passt	/sbin/dhclient -4 --no-pid
 sleep	2
 hostb	tshark -r __TEMP__.pcap
 sleep	5
diff --git a/test/dhcp/passt b/test/dhcp/passt
index ca76846..4648821 100644
--- a/test/dhcp/passt
+++ b/test/dhcp/passt
@@ -21,7 +21,7 @@ hout	HOST_IFNAME ip -j -4 route show|jq -rM '.[] | select(.dst == "default").dev
 check	[ -n "__IFNAME__" ]
 
 test	DHCP: address
-guest	/sbin/dhclient __IFNAME__
+guest	/sbin/dhclient -4 __IFNAME__
 gout	ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[0].local'
 hout	HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
 check	[ "__ADDR__" = "__HOST_ADDR__" ]
diff --git a/test/dhcp/pasta b/test/dhcp/pasta
index 77e9e42..e76454a 100644
--- a/test/dhcp/pasta
+++ b/test/dhcp/pasta
@@ -35,7 +35,7 @@ nsout	MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu'
 check	[ __MTU__ = 65520 ]
 
 test	DHCPv6: address
-ns	/sbin/dhclient -6 __IFNAME__
+ns	/sbin/dhclient -6 --no-pid __IFNAME__
 nsout	ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local'
 hout	HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local'
 check	[ __ADDR6__ = __HOST_ADDR6__ ]
diff --git a/test/distro/ubuntu b/test/distro/ubuntu
index 3ce156d..c9a2b4d 100644
--- a/test/distro/ubuntu
+++ b/test/distro/ubuntu
@@ -150,7 +150,7 @@ host	guestfish --rw -a __IMG__ -i copy-in __GUEST_FILES__ /root/
 
 host	./qrap 5 qemu-system-ppc64 -m 1024 -M pseries -nographic -nodefaults -serial stdio -no-reboot -nographic -vga none -hda __IMG__ -net socket,fd=5 -net nic,model=virtio
 host	PS1='$ '
-host	dhclient
+host	dhclient -4
 # Skip apt-get update here: some updates to xenial-updates around 2022-01-30
 # broke dependencies for libc6 and gcc-5 -- note that powerpc is not officially
 # supported on this version
@@ -185,7 +185,7 @@ host	./qrap 5 qemu-system-s390x -m 2048 -smp 2 -serial stdio -nodefaults -nograp
 host	service systemd-resolved stop
 host	export DEBIAN_FRONTEND=noninteractive
 host	apt-get -y remove needrestart snapd
-host	dhclient
+host	dhclient -4
 sleep	2
 host	apt-get update
 host	apt-get -y install make gcc netcat-openbsd
diff --git a/test/lib/setup b/test/lib/setup
index ffc4171..32515bf 100755
--- a/test/lib/setup
+++ b/test/lib/setup
@@ -147,7 +147,7 @@ setup_passt_in_ns() {
 	pane_run NS "/sbin/udhcpc -i ${__ifname}"
 	pane_status NS
 	sleep 2
-	pane_run NS "/sbin/dhclient -6 ${__ifname}"
+	pane_run NS "/sbin/dhclient -6 --no-pid ${__ifname}"
 	pane_status NS
 
 	__opts=
diff --git a/test/perf/passt_tcp b/test/perf/passt_tcp
index 5f017db..c97178e 100644
--- a/test/perf/passt_tcp
+++ b/test/perf/passt_tcp
@@ -18,7 +18,7 @@ htools	bc head sed seq
 
 # In this setup, virtio_net TX queue sometimes hangs, still under investigation
 def	virtio_net_workaround
-guest	modprobe -r virtio_net; modprobe virtio_net napi_tx=1; dhclient; dhclient -6; sleep 3
+guest	modprobe -r virtio_net; modprobe virtio_net napi_tx=1; dhclient -4; dhclient -6; sleep 3
 endef
 
 test	passt: throughput and latency
diff --git a/test/perf/passt_udp b/test/perf/passt_udp
index 0515f00..5155099 100644
--- a/test/perf/passt_udp
+++ b/test/perf/passt_udp
@@ -18,7 +18,7 @@ htools	bc head sed
 
 # In this setup, virtio_net TX queue sometimes hangs, still under investigation
 def	virtio_net_workaround
-guest	modprobe -r virtio_net; modprobe virtio_net napi_tx=1; dhclient; dhclient -6; sleep 3
+guest	modprobe -r virtio_net; modprobe virtio_net napi_tx=1; dhclient -4; dhclient -6; sleep 3
 endef
 
 test	passt: throughput and latency
diff --git a/test/two_guests/basic b/test/two_guests/basic
index 09a06da..afe104b 100644
--- a/test/two_guests/basic
+++ b/test/two_guests/basic
@@ -23,8 +23,8 @@ check	[ -n "__IFNAME1__" ]
 check	[ -n "__IFNAME2__" ]
 
 test	DHCP: addresses
-guest1	/sbin/dhclient __IFNAME1__
-guest2	/sbin/dhclient __IFNAME1__
+guest1	/sbin/dhclient -4 __IFNAME1__
+guest2	/sbin/dhclient -4 __IFNAME1__
 g1out	ADDR1 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[0].local'
 g2out	ADDR2 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[0].local'
 hout	HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
-- 
@@ -23,8 +23,8 @@ check	[ -n "__IFNAME1__" ]
 check	[ -n "__IFNAME2__" ]
 
 test	DHCP: addresses
-guest1	/sbin/dhclient __IFNAME1__
-guest2	/sbin/dhclient __IFNAME1__
+guest1	/sbin/dhclient -4 __IFNAME1__
+guest2	/sbin/dhclient -4 __IFNAME1__
 g1out	ADDR1 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME1__").addr_info[0].local'
 g2out	ADDR2 ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__IFNAME2__").addr_info[0].local'
 hout	HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname == "__HOST_IFNAME__").addr_info[0].local'
-- 
2.36.1


  parent reply	other threads:[~2022-06-10  2:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10  2:32 [PATCH 0/5] More test fixes for Fedora host David Gibson
2022-06-10  2:32 ` [PATCH 1/5] tests: Use more explicit netcat options for distro/fedora tests David Gibson
2022-06-14 14:10   ` Stefano Brivio
2022-06-15  0:35     ` David Gibson
2022-06-10  2:32 ` [PATCH 2/5] Don't abbreviate ip(8) arguments in examples and tests David Gibson
2022-06-10  2:32 ` David Gibson [this message]
2022-06-10  2:32 ` [PATCH 4/5] Use dhclient instead of udhcpc David Gibson
2022-06-14  1:32   ` Stefano Brivio
2022-06-14  2:47     ` David Gibson
2022-06-10  2:32 ` [PATCH 5/5] tests: Use nmap-ncat instead of openbsd netcat for pasta tests David Gibson
2022-06-18  7:03   ` Stefano Brivio
2022-06-14  1:32 ` [PATCH 0/5] More test fixes for Fedora host Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610023245.845652-4-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).