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 if $testdir/run-qemu
--help |
grep -qF -m1 'netdev hubport,id=str,hubid=n[,netdev=nd]' && echo OK
; then
18 -drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/server.ext3 \
21 -net socket
,listen
=127.0.0.1:12350 \
22 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
23 ${SERIAL:+-serial "$SERIAL"} \
24 ${SERIAL:--serial file:"$TESTDIR"/server.log} \
25 -watchdog i6300esb
-watchdog-action poweroff \
27 -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
28 -initrd "$TESTDIR"/initramfs.server \
29 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
32 -drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/server.ext3 \
35 -net socket
,vlan
=0,connect
=127.0.0.1:12350 \
36 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
37 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
38 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
39 -net nic
,vlan
=1,macaddr
=52:54:00:12:34:98,model
=e1000 \
40 -net nic
,vlan
=2,macaddr
=52:54:00:12:34:99,model
=e1000 \
41 ${SERIAL:+-serial "$SERIAL"} \
42 ${SERIAL:--serial file:"$TESTDIR"/server.log} \
43 -watchdog i6300esb
-watchdog-action poweroff \
45 -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
46 -initrd "$TESTDIR"/initramfs.server \
47 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
50 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
52 # Cleanup the terminal if we have one
55 echo Sleeping
10 seconds to give the server a
head start
67 echo "CLIENT TEST START: $test_name"
69 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
70 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
71 echo "Unable to make client sda image" 1>&2
75 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img
-m 512M
-smp 2 -nographic \
76 -net socket
,connect
=127.0.0.1:12350 \
77 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
78 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
79 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
80 -netdev hubport
,id
=n1
,hubid
=1 \
81 -netdev hubport
,id
=n2
,hubid
=2 \
82 -device e1000
,netdev
=n1
,mac
=52:54:00:12:34:98 \
83 -device e1000
,netdev
=n2
,mac
=52:54:00:12:34:99 \
84 -watchdog i6300esb
-watchdog-action poweroff \
86 -append "panic=1 rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
87 -initrd "$TESTDIR"/initramfs.testing
89 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
91 if [[ "$OK" != "OK" ]]; then
92 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
97 if [[ " $IFACES " != *\
$i\
* ]]; then
98 echo "$i not in '$IFACES'"
99 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
105 if [[ " $check " != *\
$i\
* ]]; then
106 echo "$i in '$IFACES', but should not be"
107 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
112 echo "CLIENT TEST END: $test_name [OK]"
118 if ! run_server
; then
119 echo "Failed to start server" 1>&2
129 # Mac Numbering Scheme
130 # ...:00-02 receive IP adresses all others don't
131 # ...:02 receives a dhcp root-path
134 client_test
"MULTINIC root=nfs BOOTIF=" \
136 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
139 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
141 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
142 "ens3 ens4" ||
return 1
144 # PXE Style BOOTIF= with dhcp root-path
145 client_test
"MULTINIC root=dhcp BOOTIF=" \
147 "root=dhcp BOOTIF=52-54-00-12-34-02" \
150 # Multinic case, where only one nic works
151 client_test
"MULTINIC root=nfs ip=dhcp" \
153 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
156 # Require two interfaces
157 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
159 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
160 "ens4 ens5" ||
return 1
162 # Require three interfaces with dhcp root-path
163 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
165 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
166 "ens3 ens4 ens5" ||
return 1
168 client_test
"MULTINIC bonding" \
170 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
173 client_test
"MULTINIC bridging" \
175 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens6,ens7" \
176 "bridge0" ||
return 1
182 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=120
183 mke2fs
-j -F -- "$TESTDIR"/server.ext3
184 mkdir
-- "$TESTDIR"/mnt
185 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
188 export initdir
="$TESTDIR"/mnt
189 .
"$basedir"/dracut-init.sh
193 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
194 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
195 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
198 for _f
in modules.
builtin.bin modules.
builtin; do
199 [[ $srcmods/$_f ]] && break
201 dfatal
"No modules.builtin.bin and modules.builtin found!"
205 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
206 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
209 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
210 dmesg mkdir
cp ping exportfs \
211 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
212 /etc
/services
sleep mount
chmod
213 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
214 [ -f "${_terminfodir}"/l
/linux
] && break
216 inst_multiple
-o "${_terminfodir}"/l
/linux
217 type -P portmap
>/dev
/null
&& inst_multiple portmap
218 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
219 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
220 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
221 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
222 instmods nfsd sunrpc ipv6 lockd af_packet
223 inst_simple
/etc
/os-release
224 inst .
/server-init.sh
/sbin
/init
225 inst .
/hosts
/etc
/hosts
226 inst .
/exports
/etc
/exports
227 inst .
/dhcpd.conf
/etc
/dhcpd.conf
228 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
230 inst_multiple rpc.idmapd
/etc
/idmapd.conf
232 inst_libdir_file
'libnfsidmap_nsswitch.so*'
233 inst_libdir_file
'libnfsidmap/*.so*'
234 inst_libdir_file
'libnfsidmap*.so*'
236 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
237 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
238 _nsslibs
=${_nsslibs#|}
239 _nsslibs
=${_nsslibs%|}
241 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
243 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
244 inst
/etc
/passwd
/etc
/passwd
245 inst
/etc
/group
/etc
/group
247 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
248 ldconfig
-r "$initdir"
252 # Make client root inside server root
254 export initdir
="$TESTDIR"/mnt
/nfs
/client
255 .
"$basedir"/dracut-init.sh
258 mkdir
-p dev sys proc etc run
259 mkdir
-p var
/lib
/nfs
/rpc_pipefs
260 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
261 for i
in bin sbin lib lib64
; do
265 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
266 mount dmesg mkdir
cp ping grep ls
267 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
268 [[ -f ${_terminfodir}/l
/linux
]] && break
270 inst_multiple
-o "${_terminfodir}"/l
/linux
271 inst_simple
/etc
/os-release
272 inst .
/client-init.sh
/sbin
/init
273 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
274 inst
/etc
/passwd
/etc
/passwd
275 inst
/etc
/group
/etc
/group
277 inst_multiple rpc.idmapd
/etc
/idmapd.conf
278 inst_libdir_file
'libnfsidmap_nsswitch.so*'
279 inst_libdir_file
'libnfsidmap/*.so*'
280 inst_libdir_file
'libnfsidmap*.so*'
282 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
283 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
284 _nsslibs
=${_nsslibs#|}
285 _nsslibs
=${_nsslibs%|}
287 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
289 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
290 sudo ldconfig
-r "$initdir"
293 sudo umount
"$TESTDIR"/mnt
294 rm -fr -- "$TESTDIR"/mnt
296 # Make an overlay with needed tools for the test harness
298 export initdir
="$TESTDIR"/overlay
299 .
"$basedir"/dracut-init.sh
300 inst_multiple poweroff shutdown
301 inst_hook shutdown-emergency
000 .
/hard-off.sh
302 inst_hook emergency
000 .
/hard-off.sh
303 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
306 # Make server's dracut image
308 -l -i "$TESTDIR"/overlay
/ \
309 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
310 -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" \
311 --no-hostonly-cmdline -N \
312 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
314 # Make client's dracut image
316 -l -i "$TESTDIR"/overlay
/ \
319 -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" \
320 --no-hostonly-cmdline -N \
321 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
325 if [[ -s "$TESTDIR"/server.pid
]]; then
326 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
327 rm -f -- "$TESTDIR"/server.pid
335 .
"$testdir"/test-functions