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
,connect
=127.0.0.1:12350 \
55 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
56 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
57 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
58 -watchdog i6300esb
-watchdog-action poweroff \
60 -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" \
61 -initrd "$TESTDIR"/initramfs.testing
63 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
65 if [[ "$OK" != "OK" ]]; then
66 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
71 if [[ " $IFACES " != *\
$i\
* ]]; then
72 echo "$i not in '$IFACES'"
73 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
79 if [[ " $check " != *\
$i\
* ]]; then
80 echo "$i in '$IFACES', but should not be"
81 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
86 echo "CLIENT TEST END: $test_name [OK]"
93 echo "Failed to start server" 1>&2
103 # Mac Numbering Scheme
104 # ...:00-02 receive IP adresses all others don't
105 # ...:02 receives a dhcp root-path
108 client_test
"MULTINIC root=nfs BOOTIF=" \
110 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
113 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
115 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens4:dhcp" \
116 "ens3 ens4" ||
return 1
118 # PXE Style BOOTIF= with dhcp root-path
119 client_test
"MULTINIC root=dhcp BOOTIF=" \
121 "root=dhcp BOOTIF=52-54-00-12-34-02" \
124 # Multinic case, where only one nic works
125 client_test
"MULTINIC root=nfs ip=dhcp" \
127 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
130 # Require two interfaces
131 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
133 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
134 "ens4 ens5" ||
return 1
136 # Require three interfaces with dhcp root-path
137 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
139 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
140 "ens3 ens4 ens5" ||
return 1
142 client_test
"MULTINIC bonding" \
144 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens3,ens4,ens5:mode=balance-rr" \
147 client_test
"MULTINIC bridging" \
149 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens3,ens4,ens5" \
150 "bridge0" ||
return 1
156 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
157 mke2fs
-j -F -- "$TESTDIR"/server.ext3
158 mkdir
-- "$TESTDIR"/mnt
159 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
162 export initdir
="$TESTDIR"/mnt
163 .
"$basedir"/dracut-init.sh
167 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
168 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
169 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
172 for _f
in modules.
builtin.bin modules.
builtin; do
173 [[ $srcmods/$_f ]] && break
175 dfatal
"No modules.builtin.bin and modules.builtin found!"
179 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
180 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
183 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
184 dmesg mkdir
cp ping exportfs \
185 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
186 /etc
/services
sleep mount
chmod
187 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
188 [ -f "${_terminfodir}"/l
/linux
] && break
190 inst_multiple
-o "${_terminfodir}"/l
/linux
191 type -P portmap
>/dev
/null
&& inst_multiple portmap
192 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
193 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
194 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
195 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
196 instmods nfsd sunrpc ipv6 lockd af_packet
197 inst_simple
/etc
/os-release
198 inst .
/server-init.sh
/sbin
/init
199 inst .
/hosts
/etc
/hosts
200 inst .
/exports
/etc
/exports
201 inst .
/dhcpd.conf
/etc
/dhcpd.conf
202 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
204 inst_multiple rpc.idmapd
/etc
/idmapd.conf
206 inst_libdir_file
'libnfsidmap_nsswitch.so*'
207 inst_libdir_file
'libnfsidmap/*.so*'
208 inst_libdir_file
'libnfsidmap*.so*'
210 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
211 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
212 _nsslibs
=${_nsslibs#|}
213 _nsslibs
=${_nsslibs%|}
215 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
217 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
218 inst
/etc
/passwd
/etc
/passwd
219 inst
/etc
/group
/etc
/group
221 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
222 ldconfig
-r "$initdir"
226 # Make client root inside server root
228 export initdir
="$TESTDIR"/mnt
/nfs
/client
229 .
"$basedir"/dracut-init.sh
232 mkdir
-p dev sys proc etc run
233 mkdir
-p var
/lib
/nfs
/rpc_pipefs
234 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
235 for i
in bin sbin lib lib64
; do
239 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
240 mount dmesg mkdir
cp ping grep ls
241 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
242 [[ -f ${_terminfodir}/l
/linux
]] && break
244 inst_multiple
-o "${_terminfodir}"/l
/linux
245 inst_simple
/etc
/os-release
246 inst .
/client-init.sh
/sbin
/init
247 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
248 inst
/etc
/passwd
/etc
/passwd
249 inst
/etc
/group
/etc
/group
251 inst_multiple rpc.idmapd
/etc
/idmapd.conf
252 inst_libdir_file
'libnfsidmap_nsswitch.so*'
253 inst_libdir_file
'libnfsidmap/*.so*'
254 inst_libdir_file
'libnfsidmap*.so*'
256 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
257 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
258 _nsslibs
=${_nsslibs#|}
259 _nsslibs
=${_nsslibs%|}
261 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
263 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
264 sudo ldconfig
-r "$initdir"
267 sudo umount
"$TESTDIR"/mnt
268 rm -fr -- "$TESTDIR"/mnt
270 # Make an overlay with needed tools for the test harness
272 export initdir
="$TESTDIR"/overlay
273 .
"$basedir"/dracut-init.sh
274 inst_multiple poweroff shutdown
275 inst_hook shutdown-emergency
000 .
/hard-off.sh
276 inst_hook emergency
000 .
/hard-off.sh
277 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
280 # Make server's dracut image
281 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
282 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
283 -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" \
284 --no-hostonly-cmdline -N \
285 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
287 # Make client's dracut image
288 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
291 -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" \
292 --no-hostonly-cmdline -N \
293 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
297 if [[ -s "$TESTDIR"/server.pid
]]; then
298 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
299 rm -f -- "$TESTDIR"/server.pid
307 .
"$testdir"/test-functions