2 TEST_DESCRIPTION
="root filesystem on NFS with multiple nics"
4 KVERSION
=${KVERSION-$(uname -r)}
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell rd.break"
8 #SERIAL="tcp:127.0.0.1:9999"
12 echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
14 fsck
-a "$TESTDIR"/server.ext3 ||
return 1
16 -drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/server.ext3 \
19 -net socket
,listen
=127.0.0.1:12350 \
20 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
21 ${SERIAL:+-serial "$SERIAL"} \
22 -watchdog i6300esb
-watchdog-action poweroff \
23 -append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
24 -initrd "$TESTDIR"/initramfs.server \
25 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
26 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
28 # Cleanup the terminal if we have one
31 echo Sleeping
10 seconds to give the server a
head start
43 echo "CLIENT TEST START: $test_name"
45 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
46 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
47 echo "Unable to make client sda image" 1>&2
51 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img
-m 512M
-smp 2 -nographic \
52 -net socket
,connect
=127.0.0.1:12350 \
53 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
54 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
55 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
56 -watchdog i6300esb
-watchdog-action poweroff \
57 -append "$cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
58 -initrd "$TESTDIR"/initramfs.testing
60 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
62 if [[ "$OK" != "OK" ]]; then
63 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
68 if [[ " $IFACES " != *\
$i\
* ]]; then
69 echo "$i not in '$IFACES'"
70 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
76 if [[ " $check " != *\
$i\
* ]]; then
77 echo "$i in '$IFACES', but should not be"
78 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
83 echo "CLIENT TEST END: $test_name [OK]"
90 echo "Failed to start server" 1>&2
93 test_client ||
{ kill_server
; return 1; }
97 # Mac Numbering Scheme
98 # ...:00-02 receive IP adresses all others don't
99 # ...:02 receives a dhcp root-path
102 client_test
"MULTINIC root=nfs BOOTIF=" \
104 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
107 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
109 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
110 "ens3 ens4" ||
return 1
112 # PXE Style BOOTIF= with dhcp root-path
113 client_test
"MULTINIC root=dhcp BOOTIF=" \
115 "root=dhcp BOOTIF=52-54-00-12-34-02" \
118 # Multinic case, where only one nic works
119 client_test
"MULTINIC root=nfs ip=dhcp" \
121 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
124 # Require two interfaces
125 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
127 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
128 "ens4 ens5" ||
return 1
130 # Require three interfaces with dhcp root-path
131 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
133 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
134 "ens3 ens4 ens5" ||
return 1
142 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
143 mke2fs
-j -F -- "$TESTDIR"/server.ext3
144 mkdir
-- "$TESTDIR"/mnt
145 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
148 export initdir
="$TESTDIR"/mnt
149 .
"$basedir"/dracut-functions.sh
153 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
154 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
155 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
158 for _f
in modules.
builtin.bin modules.
builtin; do
159 [[ $srcmods/$_f ]] && break
161 dfatal
"No modules.builtin.bin and modules.builtin found!"
165 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
166 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
169 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
170 dmesg mkdir
cp ping exportfs \
171 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
172 /etc
/services
sleep mount
chmod
173 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
174 [ -f "${_terminfodir}"/l
/linux
] && break
176 inst_multiple
-o "${_terminfodir}"/l
/linux
177 type -P portmap
>/dev
/null
&& inst_multiple portmap
178 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
179 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
180 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
181 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
182 instmods nfsd sunrpc ipv6 lockd af_packet
183 inst_simple
/etc
/os-release
184 inst .
/server-init.sh
/sbin
/init
185 inst .
/hosts
/etc
/hosts
186 inst .
/exports
/etc
/exports
187 inst .
/dhcpd.conf
/etc
/dhcpd.conf
188 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
190 inst_multiple rpc.idmapd
/etc
/idmapd.conf
192 inst_libdir_file
'libnfsidmap_nsswitch.so*'
193 inst_libdir_file
'libnfsidmap/*.so*'
194 inst_libdir_file
'libnfsidmap*.so*'
196 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
197 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
198 _nsslibs
=${_nsslibs#|}
199 _nsslibs
=${_nsslibs%|}
201 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
203 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
204 inst
/etc
/passwd
/etc
/passwd
205 inst
/etc
/group
/etc
/group
207 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
208 sudo ldconfig
-r -- "$initdir"
212 # Make client root inside server root
214 export initdir
="$TESTDIR"/mnt
/nfs
/client
215 .
"$basedir"/dracut-functions.sh
218 mkdir
-p dev sys proc etc run
219 mkdir
-p var
/lib
/nfs
/rpc_pipefs
220 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
221 for i
in bin sbin lib lib64
; do
225 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
226 mount dmesg mkdir
cp ping grep ls
227 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
228 [[ -f ${_terminfodir}/l
/linux
]] && break
230 inst_multiple
-o "${_terminfodir}"/l
/linux
231 inst_simple
/etc
/os-release
232 inst .
/client-init.sh
/sbin
/init
233 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
234 inst
/etc
/passwd
/etc
/passwd
235 inst
/etc
/group
/etc
/group
237 inst_multiple rpc.idmapd
/etc
/idmapd.conf
238 inst_libdir_file
'libnfsidmap_nsswitch.so*'
239 inst_libdir_file
'libnfsidmap/*.so*'
240 inst_libdir_file
'libnfsidmap*.so*'
242 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
243 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
244 _nsslibs
=${_nsslibs#|}
245 _nsslibs
=${_nsslibs%|}
247 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
249 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
250 sudo ldconfig
-r "$initdir"
253 sudo umount
"$TESTDIR"/mnt
254 rm -fr -- "$TESTDIR"/mnt
256 # Make an overlay with needed tools for the test harness
258 export initdir
="$TESTDIR"/overlay
259 .
"$basedir"/dracut-functions.sh
260 inst_multiple poweroff shutdown
261 inst_hook emergency
000 .
/hard-off.sh
262 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
265 # Make server's dracut image
266 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
267 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
268 -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
269 --no-hostonly-cmdline -N \
270 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
272 # Make client's dracut image
273 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
276 -d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
277 --no-hostonly-cmdline -N \
278 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
282 if [[ -s "$TESTDIR"/server.pid
]]; then
283 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
284 rm -f -- "$TESTDIR"/server.pid
292 .
"$testdir"/test-functions