From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH] test: Embed script for dhclient(8) in mbuto(1) profile
Date: Thu, 07 Jul 2022 16:48:32 +0200 [thread overview]
Message-ID: <20220707144832.2583526-1-sbrivio@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 3052 bytes --]
David reports that dhclient-script(8) on Fedora needs a number of
binaries that are not included in PROGS of the current mbuto profile,
and we would also need to include hostnamectl(1) there, which will
fail without a systemd init.
Embed a minimal script for dhclient(8) in the profile itself, written
to /sbin/dhclient-script at boot, to just check what we need to check
out of DHCP and DHCPv6 functionality.
While at it, drop busybox and logger from PROGS, as we don't need them,
and add hostname(1). While DHCP option 12 isn't supported yet by the
DHCP implementation in passt, we should probably add it soon.
Reported-by: David Gibson <david(a)gibson.dropbear.id.au>
Suggested-by: David Gibson <david(a)gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
test/passt.mbuto | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/test/passt.mbuto b/test/passt.mbuto
index 150c062..968c1cd 100755
--- a/test/passt.mbuto
+++ b/test/passt.mbuto
@@ -11,7 +11,7 @@
# Author: Stefano Brivio <sbrivio(a)redhat.com>
PROGS="${PROGS:-ash,dash,bash ip mount ls insmod mkdir ln cat chmod lsmod
- modprobe find grep mknod mv rm umount jq iperf3 dhclient busybox logger
+ modprobe find grep mknod mv rm umount jq iperf3 dhclient hostname
sed tr chown sipcalc cut md5sum nc dd strace ping tail killall sleep
sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc}"
@@ -22,15 +22,29 @@ LINKS="${LINKS:-
ash,dash,bash /bin/sh
ash,dash,bash /usr/bin/bash}"
-COPIES="${COPIES}
- /sbin/dhclient-script"
+DIRS="${DIRS} /tmp /sbin"
-DIRS="${DIRS} /tmp"
+FIXUP="${FIXUP}"'
+ cat > /sbin/dhclient-script << EOF
+#!/bin/sh
+[ -n "\${new_interface_mtu}" ] && ip link set dev \${interface} mtu \${new_interface_mtu}
+
+[ -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
+[ -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
-FIXUP="${FIXUP}
+[ -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
+ chmod 755 /sbin/dhclient-script
:> /etc/fstab
sh +m
-"
+'
OUTPUT="KERNEL=__KERNEL__
INITRD=__INITRD__
--
@@ -11,7 +11,7 @@
# Author: Stefano Brivio <sbrivio(a)redhat.com>
PROGS="${PROGS:-ash,dash,bash ip mount ls insmod mkdir ln cat chmod lsmod
- modprobe find grep mknod mv rm umount jq iperf3 dhclient busybox logger
+ modprobe find grep mknod mv rm umount jq iperf3 dhclient hostname
sed tr chown sipcalc cut md5sum nc dd strace ping tail killall sleep
sysctl nproc tcp_rr tcp_crr udp_rr which tee seq bc}"
@@ -22,15 +22,29 @@ LINKS="${LINKS:-
ash,dash,bash /bin/sh
ash,dash,bash /usr/bin/bash}"
-COPIES="${COPIES}
- /sbin/dhclient-script"
+DIRS="${DIRS} /tmp /sbin"
-DIRS="${DIRS} /tmp"
+FIXUP="${FIXUP}"'
+ cat > /sbin/dhclient-script << EOF
+#!/bin/sh
+[ -n "\${new_interface_mtu}" ] && ip link set dev \${interface} mtu \${new_interface_mtu}
+
+[ -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
+[ -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
-FIXUP="${FIXUP}
+[ -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
+ chmod 755 /sbin/dhclient-script
:> /etc/fstab
sh +m
-"
+'
OUTPUT="KERNEL=__KERNEL__
INITRD=__INITRD__
--
2.35.1
reply other threads:[~2022-07-07 14:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220707144832.2583526-1-sbrivio@redhat.com \
--to=sbrivio@redhat.com \
--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).