From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WFRG6lAX; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id C1C895A0265 for ; Sun, 21 Jun 2026 03:27:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1782005239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yo4ZhwC2gmbAkWizGeGLSQ9qv98nmGvc3VD2a/7HEbA=; b=WFRG6lAXCYefQNamRGF5IiWHwdkIbkjrUZs6ImDTwJkVtDEmmYliFtMj6UeYUbNEeLUaX2 fkeFjrPVFm2b+QH27l9+gXUTspo+OzT8pNiCmO0QsuyrsCZhvcpUARy8Nk5a+mlkOZV8oi S6rMSQmUs6UbpgCGaeYVqQh8o945tQw= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-448-ztJbcYvbNSyOsuNebbNmAw-1; Sat, 20 Jun 2026 21:27:16 -0400 X-MC-Unique: ztJbcYvbNSyOsuNebbNmAw-1 X-Mimecast-MFC-AGG-ID: ztJbcYvbNSyOsuNebbNmAw_1782005235 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6D9781805A09; Sun, 21 Jun 2026 01:27:15 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.88.44]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D460F195604D; Sun, 21 Jun 2026 01:27:13 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH] test/pasta/dhcp: Fix DHCP tests for --config-net pasta setup Date: Sat, 20 Jun 2026 21:27:13 -0400 Message-ID: <20260621012713.2007724-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: b6XlP6sI86YD0hlA9faWu6ei4SgX3pZQEFA-Km8cZxI_1782005235 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: 7IIU5VIMRZJBSUDMUKWJQ3DWO4G62GI3 X-Message-ID-Hash: 7IIU5VIMRZJBSUDMUKWJQ3DWO4G62GI3 X-MailFrom: jmaloy@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: setup_pasta() now passes --config-net, which pre-configures the namespace interface via NDP/SLAAC before dhclient runs. This caused several issues: - dhclient -6 using the host's dhclient-script failed inside user namespaces (NetworkManager hooks, resolv.conf writes), causing infinite SOLICIT/REPLY loops. Add a minimal dhclient-script that applies leases with 'ip addr replace' and exits cleanly. - The DHCPv6 address check filtered for prefixlen == 128, but --config-net already configures the address with /64 via SLAAC, and 'ip -6 addr replace' cannot change the prefix length of an existing address. Match by scope == "global" instead. - Copy dhclient to STATEDIR and use explicit lease files to avoid conflicts with the host's dhclient state. - Quote variable expansions in test comparisons to prevent failures on empty values. Signed-off-by: Jon Maloy --- test/lib/dhclient-script | 17 +++++++++++++++++ test/pasta/dhcp | 14 ++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100755 test/lib/dhclient-script diff --git a/test/lib/dhclient-script b/test/lib/dhclient-script new file mode 100755 index 00000000..c6f4c0fc --- /dev/null +++ b/test/lib/dhclient-script @@ -0,0 +1,17 @@ +#!/bin/sh +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Minimal dhclient-script for pasta tests. The host's dhclient-script +# fails inside user namespaces (NetworkManager hooks, resolv.conf +# writes, etc.), so we use this stripped-down version instead. +# Based on the guest script in test/passt.mbuto. + +[ -n "${new_interface_mtu}" ] && ip link set dev ${interface} mtu ${new_interface_mtu} + +[ -n "${new_ip_address}" ] && ip addr replace ${new_ip_address}/${new_subnet_mask} dev ${interface} +[ -n "${new_routers}" ] && for r in ${new_routers}; do ip route replace default via ${r} dev ${interface}; done + +[ -n "${new_ip6_address}" ] && ip -6 addr replace ${new_ip6_address}/${new_ip6_prefixlen:-128} dev ${interface} nodad + +exit 0 diff --git a/test/pasta/dhcp b/test/pasta/dhcp index 366935ff..5d7e78b6 100644 --- a/test/pasta/dhcp +++ b/test/pasta/dhcp @@ -19,30 +19,32 @@ nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifnam check [ -n "__IFNAME__" ] test DHCP: address -ns /sbin/dhclient -4 --no-pid __IFNAME__ +ns cp /sbin/dhclient __STATEDIR__/dhclient +ns __STATEDIR__/dhclient -4 --no-pid -lf __STATEDIR__/dhclient4.leases __IFNAME__ +sleep 1 nsout 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 == "__IFNAME__").addr_info[0].local' -check [ __ADDR__ = __HOST_ADDR__ ] +check [ "__ADDR__" = "__HOST_ADDR__" ] test DHCP: route nsout GW ip -j -4 route show|jq -rM '.[] | select(.dst == "default").gateway' hout HOST_GW ip -j -4 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW__ = __HOST_GW__ ] +check [ "__GW__" = "__HOST_GW__" ] test DHCP: MTU nsout MTU ip -j link show | jq -rM '.[] | select(.ifname == "__IFNAME__").mtu' check [ __MTU__ = 65520 ] test DHCPv6: address -ns /sbin/dhclient -6 --no-pid __IFNAME__ +ns __STATEDIR__/dhclient -6 -sf __BASEPATH__/lib/dhclient-script --no-pid -lf __STATEDIR__/dhclient6.leases __IFNAME__ # Wait for DAD to complete ns while ip -j -6 addr show tentative | jq -e '.[].addr_info'; do sleep 0.1; done hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]' -nsout ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.prefixlen == 128).local] | .[0]' +nsout ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global").local] | .[0]' hout HOST_ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname == "__HOST_IFNAME6__").addr_info[] | select(.scope != "host" and .scope != "link" and .deprecated != true).local] | join(" ")' check echo "__HOST_ADDR6__" | grep -wq "__ADDR6__" test DHCPv6: route nsout GW6 ip -j -6 route show|jq -rM '.[] | select(.dst == "default").gateway' hout HOST_GW6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").gateway] | .[0]' -check [ __GW6__ = __HOST_GW6__ ] +check [ "__GW6__" = "__HOST_GW6__" ] -- 2.52.0