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 \
17 -m 512M
-cpu host -smp 2 \
19 -net socket
,listen
=127.0.0.1:12350 \
20 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
21 -serial ${SERIAL:-null} \
22 -watchdog i6300esb
-watchdog-action poweroff \
24 -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
25 -initrd "$TESTDIR"/initramfs.server \
26 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
27 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
29 # Cleanup the terminal if we have one
32 echo Sleeping
10 seconds to give the server a
head start
44 echo "CLIENT TEST START: $test_name"
46 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
47 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
48 echo "Unable to make client sda image" 1>&2
52 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img
-m 512M
-cpu host -smp 2 -nographic \
53 -net socket
,connect
=127.0.0.1:12350 \
54 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
55 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
56 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
57 -watchdog i6300esb
-watchdog-action poweroff \
59 -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" \
60 -initrd "$TESTDIR"/initramfs.testing
62 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
64 if [[ "$OK" != "OK" ]]; then
65 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
70 if [[ " $IFACES " != *\
$i\
* ]]; then
71 echo "$i not in '$IFACES'"
72 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
78 if [[ " $check " != *\
$i\
* ]]; then
79 echo "$i in '$IFACES', but should not be"
80 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
85 echo "CLIENT TEST END: $test_name [OK]"
92 echo "Failed to start server" 1>&2
102 # Mac Numbering Scheme
103 # ...:00-02 receive IP adresses all others don't
104 # ...:02 receives a dhcp root-path
107 client_test
"MULTINIC root=nfs BOOTIF=" \
109 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
112 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
114 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
115 "ens3 ens4" ||
return 1
117 # PXE Style BOOTIF= with dhcp root-path
118 client_test
"MULTINIC root=dhcp BOOTIF=" \
120 "root=dhcp BOOTIF=52-54-00-12-34-02" \
123 # Multinic case, where only one nic works
124 client_test
"MULTINIC root=nfs ip=dhcp" \
126 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
129 # Require two interfaces
130 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
132 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
133 "ens4 ens5" ||
return 1
135 # Require three interfaces with dhcp root-path
136 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
138 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
139 "ens3 ens4 ens5" ||
return 1
141 client_test
"MULTINIC bonding" \
143 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
146 client_test
"MULTINIC bridging" \
148 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens4,ens5" \
149 "bridge0" ||
return 1
155 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
156 mke2fs
-j -F -- "$TESTDIR"/server.ext3
157 mkdir
-- "$TESTDIR"/mnt
158 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
161 export initdir
="$TESTDIR"/mnt
162 .
"$basedir"/dracut-init.sh
166 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
167 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
168 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
171 for _f
in modules.
builtin.bin modules.
builtin; do
172 [[ $srcmods/$_f ]] && break
174 dfatal
"No modules.builtin.bin and modules.builtin found!"
178 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
179 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
182 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
183 dmesg mkdir
cp ping exportfs \
184 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
185 /etc
/services
sleep mount
chmod
186 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
187 [ -f "${_terminfodir}"/l
/linux
] && break
189 inst_multiple
-o "${_terminfodir}"/l
/linux
190 type -P portmap
>/dev
/null
&& inst_multiple portmap
191 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
192 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
193 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
194 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
195 instmods nfsd sunrpc ipv6 lockd af_packet
196 inst_simple
/etc
/os-release
197 inst .
/server-init.sh
/sbin
/init
198 inst .
/hosts
/etc
/hosts
199 inst .
/exports
/etc
/exports
200 inst .
/dhcpd.conf
/etc
/dhcpd.conf
201 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
203 inst_multiple rpc.idmapd
/etc
/idmapd.conf
205 inst_libdir_file
'libnfsidmap_nsswitch.so*'
206 inst_libdir_file
'libnfsidmap/*.so*'
207 inst_libdir_file
'libnfsidmap*.so*'
209 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
210 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
211 _nsslibs
=${_nsslibs#|}
212 _nsslibs
=${_nsslibs%|}
214 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
216 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
217 inst
/etc
/passwd
/etc
/passwd
218 inst
/etc
/group
/etc
/group
220 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
221 ldconfig
-r "$initdir"
225 # Make client root inside server root
227 export initdir
="$TESTDIR"/mnt
/nfs
/client
228 .
"$basedir"/dracut-init.sh
231 mkdir
-p dev sys proc etc run
232 mkdir
-p var
/lib
/nfs
/rpc_pipefs
233 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
234 for i
in bin sbin lib lib64
; do
238 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
239 mount dmesg mkdir
cp ping grep ls
240 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
241 [[ -f ${_terminfodir}/l
/linux
]] && break
243 inst_multiple
-o "${_terminfodir}"/l
/linux
244 inst_simple
/etc
/os-release
245 inst .
/client-init.sh
/sbin
/init
246 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
247 inst
/etc
/passwd
/etc
/passwd
248 inst
/etc
/group
/etc
/group
250 inst_multiple rpc.idmapd
/etc
/idmapd.conf
251 inst_libdir_file
'libnfsidmap_nsswitch.so*'
252 inst_libdir_file
'libnfsidmap/*.so*'
253 inst_libdir_file
'libnfsidmap*.so*'
255 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
256 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
257 _nsslibs
=${_nsslibs#|}
258 _nsslibs
=${_nsslibs%|}
260 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
262 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
263 sudo ldconfig
-r "$initdir"
266 sudo umount
"$TESTDIR"/mnt
267 rm -fr -- "$TESTDIR"/mnt
269 # Make an overlay with needed tools for the test harness
271 export initdir
="$TESTDIR"/overlay
272 .
"$basedir"/dracut-init.sh
273 inst_multiple poweroff shutdown
274 inst_hook shutdown-emergency
000 .
/hard-off.sh
275 inst_hook emergency
000 .
/hard-off.sh
276 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
279 # Make server's dracut image
280 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
281 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
282 -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" \
283 --no-hostonly-cmdline -N \
284 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
286 # Make client's dracut image
287 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
290 -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" \
291 --no-hostonly-cmdline -N \
292 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
296 if [[ -s "$TESTDIR"/server.pid
]]; then
297 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
298 rm -f -- "$TESTDIR"/server.pid
306 .
"$testdir"/test-functions