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 ${SERIAL:--serial file:"$TESTDIR"/server.log} \
23 -watchdog i6300esb
-watchdog-action poweroff \
25 -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
26 -initrd "$TESTDIR"/initramfs.server \
27 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
28 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
30 # Cleanup the terminal if we have one
33 echo Sleeping
10 seconds to give the server a
head start
45 echo "CLIENT TEST START: $test_name"
47 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
48 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
49 echo "Unable to make client sda image" 1>&2
53 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img
-m 512M
-smp 2 -nographic \
54 -net socket
,vlan
=0,connect
=127.0.0.1:12350 \
55 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
56 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
57 -net nic
,vlan
=0,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
58 -net nic
,vlan
=1,macaddr
=52:54:00:12:34:98,model
=e1000 \
59 -net nic
,vlan
=2,macaddr
=52:54:00:12:34:99,model
=e1000 \
60 -watchdog i6300esb
-watchdog-action poweroff \
62 -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" \
63 -initrd "$TESTDIR"/initramfs.testing
65 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
67 if [[ "$OK" != "OK" ]]; then
68 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
73 if [[ " $IFACES " != *\
$i\
* ]]; then
74 echo "$i not in '$IFACES'"
75 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
81 if [[ " $check " != *\
$i\
* ]]; then
82 echo "$i in '$IFACES', but should not be"
83 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
88 echo "CLIENT TEST END: $test_name [OK]"
95 echo "Failed to start server" 1>&2
105 # Mac Numbering Scheme
106 # ...:00-02 receive IP adresses all others don't
107 # ...:02 receives a dhcp root-path
110 client_test
"MULTINIC root=nfs BOOTIF=" \
112 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
115 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
117 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
118 "ens3 ens4" ||
return 1
120 # PXE Style BOOTIF= with dhcp root-path
121 client_test
"MULTINIC root=dhcp BOOTIF=" \
123 "root=dhcp BOOTIF=52-54-00-12-34-02" \
126 # Multinic case, where only one nic works
127 client_test
"MULTINIC root=nfs ip=dhcp" \
129 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
132 # Require two interfaces
133 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
135 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
136 "ens4 ens5" ||
return 1
138 # Require three interfaces with dhcp root-path
139 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
141 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
142 "ens3 ens4 ens5" ||
return 1
144 client_test
"MULTINIC bonding" \
146 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
149 client_test
"MULTINIC bridging" \
151 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens6,ens7" \
152 "bridge0" ||
return 1
158 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
159 mke2fs
-j -F -- "$TESTDIR"/server.ext3
160 mkdir
-- "$TESTDIR"/mnt
161 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
164 export initdir
="$TESTDIR"/mnt
165 .
"$basedir"/dracut-init.sh
169 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
170 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
171 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
174 for _f
in modules.
builtin.bin modules.
builtin; do
175 [[ $srcmods/$_f ]] && break
177 dfatal
"No modules.builtin.bin and modules.builtin found!"
181 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
182 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
185 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
186 dmesg mkdir
cp ping exportfs \
187 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
188 /etc
/services
sleep mount
chmod
189 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
190 [ -f "${_terminfodir}"/l
/linux
] && break
192 inst_multiple
-o "${_terminfodir}"/l
/linux
193 type -P portmap
>/dev
/null
&& inst_multiple portmap
194 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
195 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
196 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
197 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
198 instmods nfsd sunrpc ipv6 lockd af_packet
199 inst_simple
/etc
/os-release
200 inst .
/server-init.sh
/sbin
/init
201 inst .
/hosts
/etc
/hosts
202 inst .
/exports
/etc
/exports
203 inst .
/dhcpd.conf
/etc
/dhcpd.conf
204 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
206 inst_multiple rpc.idmapd
/etc
/idmapd.conf
208 inst_libdir_file
'libnfsidmap_nsswitch.so*'
209 inst_libdir_file
'libnfsidmap/*.so*'
210 inst_libdir_file
'libnfsidmap*.so*'
212 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
213 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
214 _nsslibs
=${_nsslibs#|}
215 _nsslibs
=${_nsslibs%|}
217 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
219 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
220 inst
/etc
/passwd
/etc
/passwd
221 inst
/etc
/group
/etc
/group
223 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
224 ldconfig
-r "$initdir"
228 # Make client root inside server root
230 export initdir
="$TESTDIR"/mnt
/nfs
/client
231 .
"$basedir"/dracut-init.sh
234 mkdir
-p dev sys proc etc run
235 mkdir
-p var
/lib
/nfs
/rpc_pipefs
236 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
237 for i
in bin sbin lib lib64
; do
241 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
242 mount dmesg mkdir
cp ping grep ls
243 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
244 [[ -f ${_terminfodir}/l
/linux
]] && break
246 inst_multiple
-o "${_terminfodir}"/l
/linux
247 inst_simple
/etc
/os-release
248 inst .
/client-init.sh
/sbin
/init
249 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
250 inst
/etc
/passwd
/etc
/passwd
251 inst
/etc
/group
/etc
/group
253 inst_multiple rpc.idmapd
/etc
/idmapd.conf
254 inst_libdir_file
'libnfsidmap_nsswitch.so*'
255 inst_libdir_file
'libnfsidmap/*.so*'
256 inst_libdir_file
'libnfsidmap*.so*'
258 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
259 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
260 _nsslibs
=${_nsslibs#|}
261 _nsslibs
=${_nsslibs%|}
263 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
265 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
266 sudo ldconfig
-r "$initdir"
269 sudo umount
"$TESTDIR"/mnt
270 rm -fr -- "$TESTDIR"/mnt
272 # Make an overlay with needed tools for the test harness
274 export initdir
="$TESTDIR"/overlay
275 .
"$basedir"/dracut-init.sh
276 inst_multiple poweroff shutdown
277 inst_hook shutdown-emergency
000 .
/hard-off.sh
278 inst_hook emergency
000 .
/hard-off.sh
279 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
282 # Make server's dracut image
283 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
284 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
285 -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" \
286 --no-hostonly-cmdline -N \
287 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
289 # Make client's dracut image
290 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
293 -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" \
294 --no-hostonly-cmdline -N \
295 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
299 if [[ -s "$TESTDIR"/server.pid
]]; then
300 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
301 rm -f -- "$TESTDIR"/server.pid
309 .
"$testdir"/test-functions