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:-null} \
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
100 # Mac Numbering Scheme
101 # ...:00-02 receive IP adresses all others don't
102 # ...:02 receives a dhcp root-path
105 client_test
"MULTINIC root=nfs BOOTIF=" \
107 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
110 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
112 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
113 "ens3 ens4" ||
return 1
115 # PXE Style BOOTIF= with dhcp root-path
116 client_test
"MULTINIC root=dhcp BOOTIF=" \
118 "root=dhcp BOOTIF=52-54-00-12-34-02" \
121 # Multinic case, where only one nic works
122 client_test
"MULTINIC root=nfs ip=dhcp" \
124 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
127 # Require two interfaces
128 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
130 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
131 "ens4 ens5" ||
return 1
133 # Require three interfaces with dhcp root-path
134 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
136 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
137 "ens3 ens4 ens5" ||
return 1
139 client_test
"MULTINIC bonding" \
141 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
144 client_test
"MULTINIC bridging" \
146 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens4,ens5" \
147 "bridge0" ||
return 1
153 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
154 mke2fs
-j -F -- "$TESTDIR"/server.ext3
155 mkdir
-- "$TESTDIR"/mnt
156 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
159 export initdir
="$TESTDIR"/mnt
160 .
"$basedir"/dracut-init.sh
164 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
165 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
166 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
169 for _f
in modules.
builtin.bin modules.
builtin; do
170 [[ $srcmods/$_f ]] && break
172 dfatal
"No modules.builtin.bin and modules.builtin found!"
176 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
177 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
180 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
181 dmesg mkdir
cp ping exportfs \
182 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
183 /etc
/services
sleep mount
chmod
184 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
185 [ -f "${_terminfodir}"/l
/linux
] && break
187 inst_multiple
-o "${_terminfodir}"/l
/linux
188 type -P portmap
>/dev
/null
&& inst_multiple portmap
189 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
190 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
191 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
192 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
193 instmods nfsd sunrpc ipv6 lockd af_packet
194 inst_simple
/etc
/os-release
195 inst .
/server-init.sh
/sbin
/init
196 inst .
/hosts
/etc
/hosts
197 inst .
/exports
/etc
/exports
198 inst .
/dhcpd.conf
/etc
/dhcpd.conf
199 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
201 inst_multiple rpc.idmapd
/etc
/idmapd.conf
203 inst_libdir_file
'libnfsidmap_nsswitch.so*'
204 inst_libdir_file
'libnfsidmap/*.so*'
205 inst_libdir_file
'libnfsidmap*.so*'
207 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
208 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
209 _nsslibs
=${_nsslibs#|}
210 _nsslibs
=${_nsslibs%|}
212 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
214 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
215 inst
/etc
/passwd
/etc
/passwd
216 inst
/etc
/group
/etc
/group
218 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
219 ldconfig
-r "$initdir"
223 # Make client root inside server root
225 export initdir
="$TESTDIR"/mnt
/nfs
/client
226 .
"$basedir"/dracut-init.sh
229 mkdir
-p dev sys proc etc run
230 mkdir
-p var
/lib
/nfs
/rpc_pipefs
231 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
232 for i
in bin sbin lib lib64
; do
236 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
237 mount dmesg mkdir
cp ping grep ls
238 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
239 [[ -f ${_terminfodir}/l
/linux
]] && break
241 inst_multiple
-o "${_terminfodir}"/l
/linux
242 inst_simple
/etc
/os-release
243 inst .
/client-init.sh
/sbin
/init
244 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
245 inst
/etc
/passwd
/etc
/passwd
246 inst
/etc
/group
/etc
/group
248 inst_multiple rpc.idmapd
/etc
/idmapd.conf
249 inst_libdir_file
'libnfsidmap_nsswitch.so*'
250 inst_libdir_file
'libnfsidmap/*.so*'
251 inst_libdir_file
'libnfsidmap*.so*'
253 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
254 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
255 _nsslibs
=${_nsslibs#|}
256 _nsslibs
=${_nsslibs%|}
258 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
260 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
261 sudo ldconfig
-r "$initdir"
264 sudo umount
"$TESTDIR"/mnt
265 rm -fr -- "$TESTDIR"/mnt
267 # Make an overlay with needed tools for the test harness
269 export initdir
="$TESTDIR"/overlay
270 .
"$basedir"/dracut-init.sh
271 inst_multiple poweroff shutdown
272 inst_hook emergency
000 .
/hard-off.sh
273 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
276 # Make server's dracut image
277 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
278 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
279 -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" \
280 --no-hostonly-cmdline -N \
281 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
283 # Make client's dracut image
284 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
287 -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" \
288 --no-hostonly-cmdline -N \
289 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
293 if [[ -s "$TESTDIR"/server.pid
]]; then
294 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
295 rm -f -- "$TESTDIR"/server.pid
303 .
"$testdir"/test-functions