# We should go last, and default the root if needed
-if [ -z "$root" ]; then
- root=dhcp
+if [ -z "$root" -a -z "$netroot" ]; then
+ netroot=dhcp
fi
if [ "$root" = "dhcp" -a -z "$netroot" ]; then
rootok=1
netroot=dhcp
+ unset root
+fi
+
+# Cleanup any coversions from root->netroot if they are the same
+if [ "$netroot" = "$root" ]; then
+ unset root
fi
if [ "${netroot+set}" = "set" ]; then
# Run the handler; don't store the root, it may change from device to device
# XXX other variables to export?
export NEWROOT
-if $handler $netif $root; then
+if $handler $netif $netroot; then
# Network rootfs mount successful
[ -f /tmp/dhclient.$netif.lease ] && cp /tmp/dhclient.$netif.lease /tmp/net.$netif.lease
[ -f /tmp/dhclient.$netif.dhcpopts ] && cp /tmp/dhclient.$netif.dhcpopts /tmp/net.$netif.dhcpopts
-if [ "$root" = "dhcp" ]; then
+if [ "$netroot" = "dhcp" ]; then
if [ -n "$new_root_path" -a -z "${new_root_path%%nbd:*}" ]; then
- root="$new_root_path"
+ netroot="$new_root_path"
fi
fi
-if [ -z "${root%nbd:*}" ]; then
+if [ -z "${netroot%nbd:*}" ]; then
handler=/sbin/nbdroot
fi
;;
esac
-if [ "${root%%:*}" = "nbd" ]; then
+if [ -z "$netroot" -a -n "$root" -a -z "${root%%nbd:*}" ]; then
+ netroot="$root"
+ unset root
+fi
+
+if [ "${netroot%%:*}" = "nbd" ]; then
# XXX validate options here?
# XXX generate udev rules?
rootok=1
- netroot=nbd
fi
# that the number of colons match what we expect, and our glob didn't
# inadvertently match a different handler's.
#
-if [ "$root" = "dhcp" -o "$root" = "nfs" -o "$root" = "nfs4" ]; then
+if [ "$netroot" = "dhcp" -o "$netroot" = "nfs" -o "$netroot" = "nfs4" ]; then
nfsver=nfs
- if [ "$root" = "nfs4" ]; then
+ if [ "$netroot" = "nfs4" ]; then
nfsver=nfs4
fi
case "$new_root_path" in
- nfs:*|nfs4:*) root="$new_root_path" ;;
+ nfs:*|nfs4:*) netroot="$new_root_path" ;;
*:/*:*)
if check_occurances "$new_root_path" ':' 2; then
- root="$nfsver:$new_root_path"
+ netroot="$nfsver:$new_root_path"
fi ;;
*:/*,*)
if check_occurances "$new_root_path" ':' 1; then
- root="$nfsver:$new_root_path"
+ netroot="$nfsver:$new_root_path"
fi ;;
*:/*)
if check_occurances "$new_root_path" ':' 1; then
- root="$nfsver:$new_root_path:"
+ netroot="$nfsver:$new_root_path:"
fi ;;
/*:*)
if check_occurances "$new_root_path" ':' 1; then
- root="$nfsver::$new_root_path"
+ netroot="$nfsver::$new_root_path"
fi ;;
/*,*)
if check_occurances "$new_root_path" ':' 0; then
- root="$nfsver::$new_root_path"
+ netroot="$nfsver::$new_root_path"
fi ;;
/*)
if check_occurances "$new_root_path" ':' 0; then
- root="$nfsver::$new_root_path:"
+ netroot="$nfsver::$new_root_path:"
fi ;;
- '') root="$nfsver:::" ;;
+ '') netroot="$nfsver:::" ;;
esac
fi
-if [ -z "${root%%nfs:*}" -o -z "${root%%nfs4:*}" ]; then
+if [ -z "${netroot%%nfs:*}" -o -z "${netroot%%nfs4:*}" ]; then
# Fill in missing information from DHCP
- nfsver=${root%%:*}; root=${root#*:}
- nfsserver=${root%%:*}; root=${root#*:}
- nfspath=${root%%:*}
- nfsflags=${root#*:}
+ nfsver=${netroot%%:*}; netroot=${netroot#*:}
+ nfsserver=${netroot%%:*}; netroot=${netroot#*:}
+ nfspath=${netroot%%:*}
+ nfsflags=${netroot#*:}
# XXX where does dhclient stash the next-server option? Do we care?
if [ -z "$nfsserver" -o "$nfsserver" = "$nfspath" ]; then
fi
# Handle alternate syntax of path,options
- if [ "$nfsflags" = "$nfspath" -a "${root#*,}" != "$root" ]; then
- nfspath=${root%%,*}
- nfsflags=${root#*,}
+ if [ "$nfsflags" = "$nfspath" -a "${netroot#*,}" != "$netroot" ]; then
+ nfspath=${netroot%%,*}
+ nfsflags=${netroot#*,}
fi
# Catch the case when no additional flags are set
fi
# XXX validate we have all the required info?
- root="$nfsver:$nfsserver:$nfspath:$nfsflags"
+ netroot="$nfsver:$nfsserver:$nfspath:$nfsflags"
handler=/sbin/nfsroot
fi
#
# Preferred format:
# root=nfs[4]:[server:]path[:options]
+# netroot=nfs[4]:[server:]path[:options]
#
# If server is unspecified it will be pulled from one of the following
# sources, in order:
;;
esac
-case "$root" in
+if [ -z "$netroot" -a -n "$root" -a -z "${root%%nfs*}" ]; then
+ netroot="$root"
+ unset root
+fi
+
+case "$netroot" in
nfs|nfs4|nfs:*|nfs4:*)
rootok=1
- netroot=nfs
+ if [ -n "$root" -a "$netroot" != "$root" ]; then
+ echo "WARNING: root= and netroot= do not match, ignoring root="
+ fi
+ unset root
;;
esac
root="error: No handler for root=${root}"
fi
-if [ -z "${root%%error:*}" ]; then
+if [ -n "$root" -a -z "${root%%error:*}" ]; then
case "${root%%:*}" in
'') echo "FATAL: no root= option specified, and no network support" ;;
error) echo "FATAL: ${root#error:}" ;;
# MAC numbering scheme:
# NFSv3: last octect starts at 0x00 and works up
# NFSv4: last octect starts at 0x80 and works up
-
+
+ client_test "NFSv3 netroot=dhcp DHCP path only" 52:54:00:12:34:00 \
+ "netroot=dhcp" 192.168.50.1 -wsize=4096 || return 1
+
client_test "NFSv3 root=dhcp DHCP path only" 52:54:00:12:34:00 \
"root=dhcp" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv3 root=/dev/nfs DHCP path only" 52:54:00:12:34:00 \
"root=/dev/nfs" 192.168.50.1 -wsize=4096 || return 1
+ client_test "NFSv3 netroot=dhcp DHCP IP:path" 52:54:00:12:34:01 \
+ "netroot=dhcp" 192.168.50.2 -wsize=4096 || return 1
+
client_test "NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
"root=dhcp" 192.168.50.2 -wsize=4096 || return 1
client_test "NFSv3 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:02 \
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+ client_test "NFSv3 netroot=dhcp DHCP proto:IP:path:options" \
+ 52:54:00:12:34:03 "netroot=dhcp" 192.168.50.3 wsize=4096 || return 1
+
client_test "NFSv3 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:03 \
"root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ client_test "NFSv3 netroot=nfs:..." 52:54:00:12:34:04 \
+ "netroot=nfs:192.168.50.1:/nfs/client" 192.168.50.1 \
+ -wsize=4096 || return 1
+
client_test "NFSv3 root=nfs:..." 52:54:00:12:34:04 \
"root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
# server, so put these later in the list to avoid a pause when doing
# switch_root
+ client_test "NFSv4 netroot=nfs4 DHCP path only" 52:54:00:12:34:80 \
+ "netroot=nfs4" 192.168.50.1 -wsize=4096 || return 1
+
client_test "NFSv4 root=nfs4 DHCP path only" 52:54:00:12:34:80 \
"root=nfs4" 192.168.50.1 -wsize=4096 || return 1
client_test "NFSv4 root=/dev/nfs4 DHCP path only" 52:54:00:12:34:80 \
"root=/dev/nfs4" 192.168.50.1 -wsize=4096 || return 1
+ client_test "NFSv4 netroot=nfs4 DHCP IP:path" 52:54:00:12:34:81 \
+ "netroot=nfs4" 192.168.50.2 -wsize=4096 || return 1
+
client_test "NFSv4 root=nfs4 DHCP IP:path" 52:54:00:12:34:81 \
"root=nfs4" 192.168.50.2 -wsize=4096 || return 1
client_test "NFSv4 root=/dev/nfs4 DHCP IP:path" 52:54:00:12:34:81 \
"root=/dev/nfs4" 192.168.50.2 -wsize=4096 || return 1
+ client_test "NFSv4 netroot=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
+ "netroot=dhcp" 192.168.50.3 -wsize=4096 || return 1
+
client_test "NFSv4 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
"root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+ client_test "NFSv4 netroot=dhcp DHCP proto:IP:path:options" \
+ 52:54:00:12:34:83 "netroot=dhcp" 192.168.50.3 wsize=4096 || return 1
+
client_test "NFSv4 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:83 \
"root=dhcp" 192.168.50.3 wsize=4096 || return 1
+ client_test "NFSv4 netroot=nfs4:..." 52:54:00:12:34:84 \
+ "netroot=nfs4:192.168.50.1:/client" 192.168.50.1 \
+ -wsize=4096 || return 1
+
client_test "NFSv4 root=nfs4:..." 52:54:00:12:34:84 \
"root=nfs4:192.168.50.1:/client" 192.168.50.1 \
-wsize=4096 || return 1
52:54:00:12:34:84 "root=nfs4 nfsroot=/client,wsize=4096" \
192.168.50.1 wsize=4096 || return 1
- # This one only works with NFSv4 in the test suite -- NFSv3 needs
+ # These two only work with NFSv4 in the test suite -- NFSv3 needs
# a /nfs prefix due to our server configuration
+
+ client_test "NFSv4 netroot=nfs4" 52:54:00:12:34:84 \
+ "netroot=nfs4" 192.168.50.1 -wsize=4096 || return 1
+
client_test "NFSv4 root=nfs4" 52:54:00:12:34:84 \
"root=nfs4" 192.168.50.1 -wsize=4096 || return 1
client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
52:54:00:12:34:04 "root=dhcp" ext2 errors=panic || return 1
+
+ # netroot handling
+
+ client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \
+ "netroot=nbd:192.168.50.1:2000" || return 1
+
+ client_test "NBD netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
+ 52:54:00:12:34:04 "netroot=dhcp" ext2 errors=panic || return 1
}
make_client_root() {