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 07/18] tests: Correctly handle domain search list in dhclient-script
Date: Fri, 15 Jul 2022 15:21:30 +1000	[thread overview]
Message-ID: <20220715052141.890703-8-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20220715052141.890703-1-david@gibson.dropbear.id.au>

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

Currently our small custom dhclient-script only handles the 'domain-name'
option, which can just list a single domain, not the 'domain-search'
option, which can handle several.  Correct it to handle both.

We also weren't emptying the resolv.conf file before we began, which
could lead to surprising contents after multiple DHCP transactions.

Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au>
---
 test/passt.mbuto | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/passt.mbuto b/test/passt.mbuto
index b33c0a8..c515a0c 100755
--- a/test/passt.mbuto
+++ b/test/passt.mbuto
@@ -34,13 +34,13 @@ set >> \$LOG
 
 [ -n "\${new_ip_address}" ]          && ip addr add \${new_ip_address}/\${new_subnet_mask} dev \${interface}
 [ -n "\${new_routers}" ]             && for r in \${new_routers}; do ip route add default via \${r} dev \${interface}; done
+:> /etc/resolv.conf
 [ -n "\${new_domain_name_servers}" ] && for d in \${new_domain_name_servers}; do echo "nameserver \${d}" >> /etc/resolv.conf; done
-[ -n "\${new_domain_name}" ]         && (printf "search"; for d in \${new_domain_name}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
-
+[ -n "\${new_domain_name}" ]         && echo "search \${new_domain_name}" >> /etc/resolf.conf
+[ -n "\${new_domain_search}" ]       && (printf "search"; for d in \${new_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
 [ -n "\${new_ip6_address}" ]         && ip addr add \${new_ip6_address}/\${new_ip6_prefixlen} dev \${interface}
 [ -n "\${new_dhcp6_name_servers}" ]  && for d in \${new_dhcp6_name_servers}; do echo "nameserver \${d}%\${interface}" >> /etc/resolv.conf; done
 [ -n "\${new_dhcp6_domain_search}" ] && (printf "search"; for d in \${new_dhcp6_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
-
 [ -n "\${new_host_name}" ]           && hostname "\${new_host_name}"
 exit 0
 EOF
-- 
@@ -34,13 +34,13 @@ set >> \$LOG
 
 [ -n "\${new_ip_address}" ]          && ip addr add \${new_ip_address}/\${new_subnet_mask} dev \${interface}
 [ -n "\${new_routers}" ]             && for r in \${new_routers}; do ip route add default via \${r} dev \${interface}; done
+:> /etc/resolv.conf
 [ -n "\${new_domain_name_servers}" ] && for d in \${new_domain_name_servers}; do echo "nameserver \${d}" >> /etc/resolv.conf; done
-[ -n "\${new_domain_name}" ]         && (printf "search"; for d in \${new_domain_name}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
-
+[ -n "\${new_domain_name}" ]         && echo "search \${new_domain_name}" >> /etc/resolf.conf
+[ -n "\${new_domain_search}" ]       && (printf "search"; for d in \${new_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
 [ -n "\${new_ip6_address}" ]         && ip addr add \${new_ip6_address}/\${new_ip6_prefixlen} dev \${interface}
 [ -n "\${new_dhcp6_name_servers}" ]  && for d in \${new_dhcp6_name_servers}; do echo "nameserver \${d}%\${interface}" >> /etc/resolv.conf; done
 [ -n "\${new_dhcp6_domain_search}" ] && (printf "search"; for d in \${new_dhcp6_domain_search}; do printf " %s" "\${d}"; done; printf "\n") >> /etc/resolv.conf
-
 [ -n "\${new_host_name}" ]           && hostname "\${new_host_name}"
 exit 0
 EOF
-- 
2.36.1


  parent reply	other threads:[~2022-07-15  5:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  5:21 [PATCH 00/18] Test fixes, batch 5 David Gibson
2022-07-15  5:21 ` [PATCH 01/18] tests: Remove no longer needed /usr/bin/bash link David Gibson
2022-07-15  5:21 ` [PATCH 02/18] tests: Let Fedora find dhclient-script in /usr/sbin David Gibson
2022-07-15  5:21 ` [PATCH 03/18] tests: Add rudimentary debugging to dhclient-script David Gibson
2022-07-15  5:21 ` [PATCH 04/18] tests: Add some extra dhclient support directories to mbuto.img David Gibson
2022-07-15  5:21 ` [PATCH 05/18] tests: More robust parsing of resolv.conf for DHCP tests David Gibson
2022-07-15  5:21 ` [PATCH 06/18] tests: Handle the case of a nameserver on host localhost David Gibson
2022-07-15  5:21 ` David Gibson [this message]
2022-07-15  5:21 ` [PATCH 08/18] tests: Fix detection of empty 'hout' responses in passt{,_in_ns} tests David Gibson
2022-07-15  5:21 ` [PATCH 09/18] tests: Fix creation of test file in udp passt tests David Gibson
2022-07-15  5:21 ` [PATCH 10/18] valgrind needs futex David Gibson
2022-07-15  5:21 ` [PATCH 11/18] tests: Use socat instead of netcat David Gibson
2022-07-15  5:21 ` [PATCH 12/18] tests: Remove unnecessary ^D in passt_in_ns teardown David Gibson
2022-07-15  5:21 ` [PATCH 13/18] tests: Remove unnecessary truncation of temporary files in udp tests David Gibson
2022-07-15  5:21 ` [PATCH 14/18] tests: Use dhclient --no-pid for namespaces in two_guests tests David Gibson
2022-07-15  5:21 ` [PATCH 15/18] tests: Clean up better after iperf tests David Gibson
2022-07-15  5:21 ` [PATCH 16/18] tests: No need to retrieve host ifname in ndp/pasta David Gibson
2022-07-15  5:21 ` [PATCH 17/18] tests: Correct determination of host interface name in tests David Gibson
2022-07-19  6:20   ` David Gibson
2022-07-19 19:05     ` Stefano Brivio
2022-07-20  2:47       ` David Gibson
2022-07-20  7:24         ` David Gibson
2022-07-20  8:23           ` Stefano Brivio
2022-07-20 10:33             ` David Gibson
2022-07-15  5:21 ` [PATCH 18/18] demo: Use git protocol downloads David Gibson
2022-07-21 12:13 ` [PATCH 00/18] Test fixes, batch 5 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=20220715052141.890703-8-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).