Tweak dhclient arguments for readability

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@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2022-06-10 12:32:43 +10:00 committed by Stefano Brivio
parent 2320ac3349
commit ca0c33ae5b
10 changed files with 17 additions and 17 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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__" ]

View file

@ -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__ ]

View file

@ -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

View file

@ -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=

View file

@ -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

View file

@ -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

View file

@ -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'