feat(nbd): support ipv6 link local nbds
parent
7c0bc0b2fd
commit
b12f8188a4
|
@ -575,7 +575,7 @@ USB Android phone::
|
|||
* enp0s29u1u2
|
||||
=====================
|
||||
|
||||
**ip=**__{dhcp|on|any|dhcp6|auto6|either6|single-dhcp}__::
|
||||
**ip=**__{dhcp|on|any|dhcp6|auto6|either6|link6|single-dhcp}__::
|
||||
dhcp|on|any::: get ip from dhcp server from all interfaces. If root=dhcp,
|
||||
loop sequentially through all interfaces (eth0, eth1, ...) and use the first
|
||||
with a valid DHCP root-path.
|
||||
|
@ -592,12 +592,15 @@ USB Android phone::
|
|||
|
||||
either6::: if auto6 fails, then dhcp6
|
||||
|
||||
**ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6}__[:[__<mtu>__][:__<macaddr>__]]::
|
||||
link6::: bring up interface for IPv6 link-local addressing
|
||||
|
||||
**ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6|link6}__[:[__<mtu>__][:__<macaddr>__]]::
|
||||
This parameter can be specified multiple times.
|
||||
+
|
||||
=====================
|
||||
dhcp|on|any|dhcp6::: get ip from dhcp server on a specific interface
|
||||
auto6::: do IPv6 autoconfiguration
|
||||
link6::: bring up interface for IPv6 link local address
|
||||
<macaddr>::: optionally **set** <macaddr> on the <interface>. This
|
||||
cannot be used in conjunction with the **ifname** argument for the
|
||||
same <interface>.
|
||||
|
|
|
@ -123,6 +123,19 @@ do_ipv6auto() {
|
|||
return $ret
|
||||
}
|
||||
|
||||
do_ipv6link() {
|
||||
local ret
|
||||
load_ipv6
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/accept_ra
|
||||
echo 0 > /proc/sys/net/ipv6/conf/$netif/accept_redirects
|
||||
linkup $netif
|
||||
|
||||
[ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
|
||||
|
||||
return $ret
|
||||
}
|
||||
|
||||
# Handle static ip configuration
|
||||
do_static() {
|
||||
strglobin $ip '*:*:*' && load_ipv6
|
||||
|
@ -449,6 +462,8 @@ for p in $(getargs ip=); do
|
|||
do_ipv6auto ;;
|
||||
either6)
|
||||
do_ipv6auto || do_dhcp -6 ;;
|
||||
link6)
|
||||
do_ipv6link ;;
|
||||
*)
|
||||
do_static ;;
|
||||
esac
|
||||
|
|
|
@ -75,7 +75,7 @@ for p in $(getargs ip=); do
|
|||
[ -z "$mask" ] && \
|
||||
die "Sorry, automatic calculation of netmask is not yet supported"
|
||||
;;
|
||||
auto6);;
|
||||
auto6|link6);;
|
||||
either6);;
|
||||
dhcp|dhcp6|on|any|single-dhcp) \
|
||||
[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
|
||||
|
|
|
@ -14,7 +14,13 @@ GENERATOR_DIR="$2"
|
|||
ROOTFLAGS="$(getarg rootflags)"
|
||||
|
||||
nroot=${root#nbd:}
|
||||
nbdserver=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdserver=${nroot%%:*};
|
||||
if [ "${nbdserver%"${nbdserver#?}"}" = "[" ]; then
|
||||
nbdserver=${nroot#[}
|
||||
nbdserver=${nbdserver%%]:*}\]; nroot=${nroot#*]:}
|
||||
else
|
||||
nroot=${nroot#*:}
|
||||
fi
|
||||
nbdport=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdfstype=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdflags=${nroot%%:*}
|
||||
|
|
|
@ -22,7 +22,13 @@ NEWROOT="$3"
|
|||
[ "${nroot%%:*}" = "nbd" ] || return
|
||||
|
||||
nroot=${nroot#nbd:}
|
||||
nbdserver=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdserver=${nroot%%:*};
|
||||
if [ "${nbdserver%"${nbdserver#?}"}" = "[" ]; then
|
||||
nbdserver=${nroot#[}
|
||||
nbdserver=${nbdserver%%]:*}; nroot=${nroot#*]:}
|
||||
else
|
||||
nroot=${nroot#*:}
|
||||
fi
|
||||
nbdport=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdfstype=${nroot%%:*}; nroot=${nroot#*:}
|
||||
nbdflags=${nroot%%:*}
|
||||
|
@ -91,29 +97,37 @@ done
|
|||
# If we didn't get a root= on the command line, then we need to
|
||||
# add the udev rules for mounting the nbd0 device
|
||||
if [ "$root" = "block:/dev/root" -o "$root" = "dhcp" ]; then
|
||||
printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' >> /etc/udev/rules.d/99-nbd-root.rules
|
||||
printf 'KERNEL=="nbd0", ENV{DEVTYPE}!="partition", ENV{ID_FS_TYPE}=="?*", SYMLINK+="root"\n' > /etc/udev/rules.d/99-nbd-root.rules
|
||||
udevadm control --reload
|
||||
type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
|
||||
write_fs_tab /dev/root "$nbdfstype" "$fsopts"
|
||||
wait_for_dev -n /dev/root
|
||||
|
||||
if [ -z "$DRACUT_SYSTEMD" ]; then
|
||||
type write_fs_tab >/dev/null 2>&1 || . /lib/fs-lib.sh
|
||||
|
||||
write_fs_tab /dev/root "$nbdfstype" "$fsopts"
|
||||
|
||||
printf '/bin/mount %s\n' \
|
||||
"$NEWROOT" \
|
||||
> $hookdir/mount/01-$$-nbd.sh
|
||||
fi
|
||||
# if we're on systemd, use the nbd-generator script
|
||||
# to create the /sysroot mount.
|
||||
fi
|
||||
|
||||
# supported since nbd 3.8 via 77e97612
|
||||
if strstr "$(nbd-client --help 2>&1)" "systemd-mark"; then
|
||||
preopts="--systemd-mark $preopts"
|
||||
preopts="-systemd-mark $preopts"
|
||||
fi
|
||||
|
||||
if [ "$nbdport" -gt 0 ] 2>/dev/null; then
|
||||
nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
|
||||
nbdport="$nbdport"
|
||||
else
|
||||
nbd-client -name "$nbdport" "$nbdserver" /dev/nbd0 $preopts $opts || exit 1
|
||||
nbdport="-name $nbdport"
|
||||
fi
|
||||
|
||||
nbd-client -check /dev/nbd0 >/dev/null || \
|
||||
nbd-client "$nbdserver" $nbdport /dev/nbd0 $preopts $opts || exit 1
|
||||
|
||||
# NBD doesn't emit uevents when it gets connected, so kick it
|
||||
echo change > /sys/block/nbd0/uevent
|
||||
udevadm settle
|
||||
|
|
|
@ -9,18 +9,6 @@
|
|||
# root= takes precedence over netroot= if root=nbd[...]
|
||||
#
|
||||
|
||||
# Sadly there's no easy way to split ':' separated lines into variables
|
||||
netroot_to_var() {
|
||||
local v=${1}:
|
||||
set --
|
||||
while [ -n "$v" ]; do
|
||||
set -- "$@" "${v%%:*}"
|
||||
v=${v#*:}
|
||||
done
|
||||
|
||||
unset server port
|
||||
server=$2; port=$3;
|
||||
}
|
||||
|
||||
# This script is sourced, so root should be set. But let's be paranoid
|
||||
[ -z "$root" ] && root=$(getarg root=)
|
||||
|
@ -46,13 +34,18 @@ fi
|
|||
[ "${netroot%%:*}" = "nbd" ] || return
|
||||
|
||||
|
||||
#if [ -n "${DRACUT_SYSTEMD}" ] && [ "$root" = "dhcp" ]; then
|
||||
# echo "root=$netroot" > /etc/cmdline.d/root.conf
|
||||
# systemctl --no-block daemon-reload
|
||||
#fi
|
||||
|
||||
# Check required arguments
|
||||
netroot_to_var $netroot
|
||||
nroot=${netroot#nbd:}
|
||||
server=${nroot%%:*};
|
||||
if [ "${server%"${server#?}"}" = "[" ]; then
|
||||
server=${nroot#[}
|
||||
server=${server%%]:*}\]; nroot=${nroot#*]:}
|
||||
else
|
||||
nroot=${nroot#*:}
|
||||
fi
|
||||
port=${nroot%%:*}
|
||||
unset nroot
|
||||
|
||||
[ -z "$server" ] && die "Argument server for nbdroot is missing"
|
||||
[ -z "$port" ] && die "Argument port for nbdroot is missing"
|
||||
|
||||
|
@ -65,6 +58,6 @@ rootok=1
|
|||
# Shut up init error check
|
||||
if [ -z "$root" ]; then
|
||||
root=block:/dev/root
|
||||
wait_for_dev -n /dev/root
|
||||
# the device is created and waited for in ./nbdroot.sh
|
||||
fi
|
||||
|
||||
|
|
|
@ -247,7 +247,11 @@ write_fs_tab() {
|
|||
fi
|
||||
fi
|
||||
|
||||
echo "$_root /sysroot $_rootfstype $_rootflags $_fspassno 0" >> /etc/fstab
|
||||
if grep -q "$_root /sysroot" /etc/fstab; then
|
||||
echo "$_root /sysroot $_rootfstype $_rootflags $_fspassno 0" >> /etc/fstab
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
if type systemctl >/dev/null 2>/dev/null; then
|
||||
systemctl daemon-reload
|
||||
|
|
Loading…
Reference in New Issue