net/bonding: subsume functionality for NFS booting

If the kernel is NFS-booting, it is critical that we don't down the
slave interfaces when we activate the bond. To do so will break the root
filesystem when networking is temporarily lost.

Reported-by: Walter <walter@pratyeka.org>
X-Gentoo-Bug: 428604
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=428604
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2012-10-11 03:49:45 +00:00
parent 9a9c2acd8d
commit 27984c0d2d

View File

@ -4,6 +4,7 @@
bonding_depend() bonding_depend()
{ {
before interface macchanger before interface macchanger
program /sbin/ifconfig /bin/ifconfig
} }
_config_vars="$_config_vars slaves" _config_vars="$_config_vars slaves"
@ -23,6 +24,9 @@ bonding_pre_start()
eval primary="\$primary_${IFVAR}" eval primary="\$primary_${IFVAR}"
unset primary_${IFVAR} unset primary_${IFVAR}
eval subsume="\$subsume_${IFVAR}"
unset subsume_${IFVAR}
[ -z "${slaves}" ] && return 0 [ -z "${slaves}" ] && return 0
@ -84,15 +88,44 @@ bonding_pre_start()
_exists true || return 1 _exists true || return 1
done done
# Must force the slaves to a particular state before adding them # Unless we are subsuming an existing interface (NFS root), we down
for IFACE in ${slaves}; do # slave interfaces to work around bugs supposedly in some chipsets
_delete_addresses # that cause failure to enslave from other states.
_down if [ -z "${subsume}" ]; then
done for IFACE in ${slaves}; do
_delete_addresses
_down
done
fi
) )
# now force the master to up # Now force the master to up
_up # - First test for interface subsume request (required for NFS root)
if [ -n "${subsume}" ]; then
einfo "Subsuming ${subsume} interface characteristics."
eindent
local oiface=${IFACE}
IFACE=${subsume}
local addr="$(_get_inet_address)"
einfo "address: ${addr}"
IFACE=${oiface}
unset oiface
eoutdent
# subsume (presumably kernel auto-)configured IP
ifconfig ${IFACE} ${addr} up
else
# warn if root on nfs and no subsume interface supplied
local root_fs_type=$(mountinfo -s /)
if [ "${root_fs_type}" == "nfs" ]; then
warn_nfs=1
ewarn "NFS root detected!!!"
ewarn " If your system crashes here, /etc/conf.d/net needs"
ewarn " subsume_${IFACE}=\"<iface>\" ... where <iface> is the"
ewarn " existing, (usually kernel auto-)configured interface."
fi
# up the interface
_up
fi
# finally add in slaves # finally add in slaves
# things needed in the process, and if they are done by ifenslave, openrc, and/or the kernel. # things needed in the process, and if they are done by ifenslave, openrc, and/or the kernel.
@ -132,6 +165,11 @@ bonding_stop()
{ {
_is_bond || return 0 _is_bond || return 0
# Wipe subsumed interface
if [ -n "${subsume}" ]; then
ifconfig ${subsume} 0.0.0.0
fi
local slaves= s= local slaves= s=
slaves=$( \ slaves=$( \
sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${IFACE}" \ sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${IFACE}" \