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
17 -drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/server.ext3 \
20 -net socket
,listen
=127.0.0.1:12350 \
21 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
22 ${SERIAL:+-serial "$SERIAL"} \
23 ${SERIAL:--serial file:"$TESTDIR"/server.log} \
24 -watchdog i6300esb
-watchdog-action poweroff \
26 -append "panic=1 systemd.crash_reboot loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
27 -initrd "$TESTDIR"/initramfs.server \
28 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
30 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
32 # Cleanup the terminal if we have one
35 echo Sleeping
10 seconds to give the server a
head start
47 echo "CLIENT TEST START: $test_name"
49 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
50 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
51 echo "Unable to make client sda image" 1>&2
55 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img
-m 512M
-smp 2 -nographic \
56 -net socket
,connect
=127.0.0.1:12350 \
57 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
58 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
59 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
60 -netdev hubport
,id
=n1
,hubid
=1 \
61 -netdev hubport
,id
=n2
,hubid
=2 \
62 -device e1000
,netdev
=n1
,mac
=52:54:00:12:34:98 \
63 -device e1000
,netdev
=n2
,mac
=52:54:00:12:34:99 \
64 -watchdog i6300esb
-watchdog-action poweroff \
66 -append "panic=1 systemd.crash_reboot 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" \
67 -initrd "$TESTDIR"/initramfs.testing
69 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
71 if [[ "$OK" != "OK" ]]; then
72 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
77 if [[ " $IFACES " != *\
$i\
* ]]; then
78 echo "$i not in '$IFACES'"
79 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
85 if [[ " $check " != *\
$i\
* ]]; then
86 echo "$i in '$IFACES', but should not be"
87 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
92 echo "CLIENT TEST END: $test_name [OK]"
99 echo "Failed to start server" 1>&2
109 # Mac Numbering Scheme
110 # ...:00-02 receive IP adresses all others don't
111 # ...:02 receives a dhcp root-path
114 client_test
"MULTINIC root=nfs BOOTIF=" \
116 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
119 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
121 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
122 "ens3 ens4" ||
return 1
124 # PXE Style BOOTIF= with dhcp root-path
125 client_test
"MULTINIC root=dhcp BOOTIF=" \
127 "root=dhcp BOOTIF=52-54-00-12-34-02" \
130 # Multinic case, where only one nic works
131 client_test
"MULTINIC root=nfs ip=dhcp" \
133 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
136 # Require two interfaces
137 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
139 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
140 "ens4 ens5" ||
return 1
142 # Require three interfaces with dhcp root-path
143 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
145 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
146 "ens3 ens4 ens5" ||
return 1
148 client_test
"MULTINIC bonding" \
150 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
153 client_test
"MULTINIC bridging" \
155 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens6,ens7" \
156 "bridge0" ||
return 1
162 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=120
163 mke2fs
-j -F -- "$TESTDIR"/server.ext3
164 mkdir
-- "$TESTDIR"/mnt
165 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
168 export initdir
="$TESTDIR"/mnt
169 .
"$basedir"/dracut-init.sh
173 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
174 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
175 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
178 for _f
in modules.
builtin.bin modules.
builtin; do
179 [[ $srcmods/$_f ]] && break
181 dfatal
"No modules.builtin.bin and modules.builtin found!"
185 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
186 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
189 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
190 dmesg mkdir
cp ping exportfs \
191 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
192 /etc
/services
sleep mount
chmod
193 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
194 [ -f "${_terminfodir}"/l
/linux
] && break
196 inst_multiple
-o "${_terminfodir}"/l
/linux
197 type -P portmap
>/dev
/null
&& inst_multiple portmap
198 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
199 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
200 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
201 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
202 instmods nfsd sunrpc ipv6 lockd af_packet
203 inst_simple
/etc
/os-release
204 inst .
/server-init.sh
/sbin
/init
205 inst .
/hosts
/etc
/hosts
206 inst .
/exports
/etc
/exports
207 inst .
/dhcpd.conf
/etc
/dhcpd.conf
208 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
210 inst_multiple rpc.idmapd
/etc
/idmapd.conf
212 inst_libdir_file
'libnfsidmap_nsswitch.so*'
213 inst_libdir_file
'libnfsidmap/*.so*'
214 inst_libdir_file
'libnfsidmap*.so*'
216 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
217 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
218 _nsslibs
=${_nsslibs#|}
219 _nsslibs
=${_nsslibs%|}
221 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
223 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
224 inst
/etc
/passwd
/etc
/passwd
225 inst
/etc
/group
/etc
/group
227 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
228 ldconfig
-r "$initdir"
232 # Make client root inside server root
234 export initdir
="$TESTDIR"/mnt
/nfs
/client
235 .
"$basedir"/dracut-init.sh
238 mkdir
-p dev sys proc etc run
239 mkdir
-p var
/lib
/nfs
/rpc_pipefs
240 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
241 for i
in bin sbin lib lib64
; do
245 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
246 mount dmesg mkdir
cp ping grep ls
247 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
248 [[ -f ${_terminfodir}/l
/linux
]] && break
250 inst_multiple
-o "${_terminfodir}"/l
/linux
251 inst_simple
/etc
/os-release
252 inst .
/client-init.sh
/sbin
/init
253 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
254 inst
/etc
/passwd
/etc
/passwd
255 inst
/etc
/group
/etc
/group
257 inst_multiple rpc.idmapd
/etc
/idmapd.conf
258 inst_libdir_file
'libnfsidmap_nsswitch.so*'
259 inst_libdir_file
'libnfsidmap/*.so*'
260 inst_libdir_file
'libnfsidmap*.so*'
262 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
263 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
264 _nsslibs
=${_nsslibs#|}
265 _nsslibs
=${_nsslibs%|}
267 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
269 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
270 sudo ldconfig
-r "$initdir"
273 sudo umount
"$TESTDIR"/mnt
274 rm -fr -- "$TESTDIR"/mnt
276 # Make an overlay with needed tools for the test harness
278 export initdir
="$TESTDIR"/overlay
279 .
"$basedir"/dracut-init.sh
280 inst_multiple poweroff shutdown
281 inst_hook shutdown-emergency
000 .
/hard-off.sh
282 inst_hook emergency
000 .
/hard-off.sh
283 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
284 inst_simple .
/99-default.link
/etc
/systemd
/network
/99-default.link
287 # Make server's dracut image
289 -l -i "$TESTDIR"/overlay
/ \
290 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
291 -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" \
292 --no-hostonly-cmdline -N \
293 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
295 # Make client's dracut image
297 -l -i "$TESTDIR"/overlay
/ \
300 -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" \
301 --no-hostonly-cmdline -N \
302 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
306 if [[ -s "$TESTDIR"/server.pid
]]; then
307 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
308 rm -f -- "$TESTDIR"/server.pid
316 .
"$testdir"/test-functions