4 USE_NETWORK
="network-manager"
5 OMIT_NETWORK
="network-legacy"
7 USE_NETWORK
="network-legacy"
8 OMIT_NETWORK
="network-manager"
11 TEST_DESCRIPTION
="root filesystem on NFS with multiple nics with $USE_NETWORK"
13 KVERSION
=${KVERSION-$(uname -r)}
15 # Uncomment this to debug failures
16 #DEBUGFAIL="rd.shell rd.break"
17 #SERIAL="tcp:127.0.0.1:9999"
21 echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
23 fsck
-a "$TESTDIR"/server.ext3 ||
return 1
26 -drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/server.ext3 \
27 -net socket
,listen
=127.0.0.1:12350 \
28 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
29 ${SERIAL:+-serial "$SERIAL"} \
30 ${SERIAL:--serial file:"$TESTDIR"/server.log} \
31 -watchdog i6300esb
-watchdog-action poweroff \
32 -append "panic=1 systemd.crash_reboot loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
33 -initrd "$TESTDIR"/initramfs.server \
34 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
36 chmod 644 -- "$TESTDIR"/server.pid ||
return 1
38 # Cleanup the terminal if we have one
41 if ! [[ $SERIAL ]]; then
43 grep Serving
"$TESTDIR"/server.log
&& break
44 echo "Waiting for the server to startup"
48 echo Sleeping
10 seconds to give the server a
head start
61 echo "CLIENT TEST START: $test_name"
63 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
64 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
65 echo "Unable to make client sda image" 1>&2
69 $testdir/run-qemu
-drive format
=raw
,index
=0,media
=disk
,file="$TESTDIR"/client.img \
70 -net socket
,connect
=127.0.0.1:12350 \
71 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
72 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
73 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
74 -netdev hubport
,id
=n1
,hubid
=1 \
75 -netdev hubport
,id
=n2
,hubid
=2 \
76 -device e1000
,netdev
=n1
,mac
=52:54:00:12:34:98 \
77 -device e1000
,netdev
=n2
,mac
=52:54:00:12:34:99 \
78 -watchdog i6300esb
-watchdog-action poweroff \
79 -append "quiet rd.net.timeout.dhcp=3 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" \
80 -initrd "$TESTDIR"/initramfs.testing
82 { read OK
; read IFACES
; } < "$TESTDIR"/client.img
84 if [[ "$OK" != "OK" ]]; then
85 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
90 if [[ " $IFACES " != *\
$i\
* ]]; then
91 echo "$i not in '$IFACES'"
92 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
98 if [[ " $check " != *\
$i\
* ]]; then
99 echo "$i in '$IFACES', but should not be"
100 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
105 echo "CLIENT TEST END: $test_name [OK]"
111 if ! run_server
; then
112 echo "Failed to start server" 1>&2
122 # Mac Numbering Scheme
123 # ...:00-02 receive IP adresses all others don't
124 # ...:02 receives a dhcp root-path
127 client_test
"MULTINIC root=nfs BOOTIF=" \
129 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
132 client_test
"MULTINIC root=nfs BOOTIF= ip=ens4:dhcp" \
134 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00 ip=ens3:dhcp" \
135 "ens2 ens3" ||
return 1
137 # PXE Style BOOTIF= with dhcp root-path
138 client_test
"MULTINIC root=dhcp BOOTIF=" \
140 "root=dhcp BOOTIF=52-54-00-12-34-02" \
143 # Multinic case, where only one nic works
144 client_test
"MULTINIC root=nfs ip=dhcp" \
146 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
149 # Require two interfaces
150 client_test
"MULTINIC root=nfs ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
152 "root=nfs:192.168.50.1:/nfs/client ip=ens3:dhcp ip=ens4:dhcp bootdev=ens3" \
153 "ens3 ens4" ||
return 1
155 # Require three interfaces with dhcp root-path
156 client_test
"MULTINIC root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
158 "root=dhcp ip=ens2:dhcp ip=ens3:dhcp ip=ens4:dhcp bootdev=ens4" \
159 "ens2 ens3 ens4" ||
return 1
161 client_test
"MULTINIC bonding" \
163 "root=nfs:192.168.50.1:/nfs/client ip=bond0:dhcp bond=bond0:ens2,ens3,ens4:mode=balance-rr" \
166 # bridge, where only one interface is actually connected
167 client_test
"MULTINIC bridging" \
169 "root=nfs:192.168.50.1:/nfs/client ip=bridge0:dhcp bridge=bridge0:ens2,ens6,ens7" \
170 "bridge0" ||
return 1
176 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=120
177 mke2fs
-j -F -- "$TESTDIR"/server.ext3
178 mkdir
-- "$TESTDIR"/mnt
179 mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
182 export initdir
="$TESTDIR"/mnt
183 .
"$basedir"/dracut-init.sh
187 mkdir
-p -- dev sys proc run var
/run etc tmp var
/lib
/{dhcpd
,rpcbind
}
188 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
189 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
192 for _f
in modules.
builtin.bin modules.
builtin; do
193 [[ $srcmods/$_f ]] && break
195 dfatal
"No modules.builtin.bin and modules.builtin found!"
199 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
200 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
203 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
204 dmesg mkdir
cp ping exportfs \
205 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
206 /etc
/services
sleep mount
chmod
207 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
208 [ -f "${_terminfodir}"/l
/linux
] && break
210 inst_multiple
-o "${_terminfodir}"/l
/linux
211 type -P portmap
>/dev
/null
&& inst_multiple portmap
212 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
213 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
214 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
215 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
216 instmods nfsd sunrpc ipv6 lockd af_packet
217 inst_simple
/etc
/os-release
218 inst .
/server-init.sh
/sbin
/init
219 inst .
/hosts
/etc
/hosts
220 inst .
/exports
/etc
/exports
221 inst .
/dhcpd.conf
/etc
/dhcpd.conf
222 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
224 inst_multiple rpc.idmapd
/etc
/idmapd.conf
226 inst_libdir_file
'libnfsidmap_nsswitch.so*'
227 inst_libdir_file
'libnfsidmap/*.so*'
228 inst_libdir_file
'libnfsidmap*.so*'
230 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
231 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
232 _nsslibs
=${_nsslibs#|}
233 _nsslibs
=${_nsslibs%|}
235 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
237 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
238 inst
/etc
/passwd
/etc
/passwd
239 inst
/etc
/group
/etc
/group
241 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
242 ldconfig
-r "$initdir"
246 # Make client root inside server root
248 export initdir
="$TESTDIR"/mnt
/nfs
/client
249 .
"$basedir"/dracut-init.sh
252 mkdir
-p dev sys proc etc run
253 mkdir
-p var
/lib
/nfs
/rpc_pipefs
254 mkdir
-p root usr
/bin usr
/lib usr
/lib64 usr
/sbin
255 for i
in bin sbin lib lib64
; do
259 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
260 mount dmesg mkdir
cp ping grep ls
261 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
262 [[ -f ${_terminfodir}/l
/linux
]] && break
264 inst_multiple
-o "${_terminfodir}"/l
/linux
265 inst_simple
/etc
/os-release
266 inst .
/client-init.sh
/sbin
/init
267 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
268 inst
/etc
/passwd
/etc
/passwd
269 inst
/etc
/group
/etc
/group
271 inst_multiple rpc.idmapd
/etc
/idmapd.conf
272 inst_libdir_file
'libnfsidmap_nsswitch.so*'
273 inst_libdir_file
'libnfsidmap/*.so*'
274 inst_libdir_file
'libnfsidmap*.so*'
276 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
277 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
278 _nsslibs
=${_nsslibs#|}
279 _nsslibs
=${_nsslibs%|}
281 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
283 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
284 ldconfig
-r "$initdir"
287 umount
"$TESTDIR"/mnt
288 rm -fr -- "$TESTDIR"/mnt
290 # Make an overlay with needed tools for the test harness
292 export initdir
="$TESTDIR"/overlay
293 .
"$basedir"/dracut-init.sh
294 inst_multiple poweroff shutdown
295 inst_hook shutdown-emergency
000 .
/hard-off.sh
296 inst_hook emergency
000 .
/hard-off.sh
297 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
298 inst_simple .
/99-default.link
/etc
/systemd
/network
/99-default.link
301 # Make server's dracut image
303 -l -i "$TESTDIR"/overlay
/ \
304 -m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
305 -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" \
306 --no-hostonly-cmdline -N \
307 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
309 # Make client's dracut image
311 -l -i "$TESTDIR"/overlay
/ \
312 -o "plymouth ${OMIT_NETWORK}" \
313 -a "debug ${USE_NETWORK}" \
314 -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" \
315 --no-hostonly-cmdline -N \
316 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
320 if [[ -s "$TESTDIR"/server.pid
]]; then
321 kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
322 rm -f -- "$TESTDIR"/server.pid
330 .
"$testdir"/test-functions