net/bonding: ensure mode & miimon are handled correctly.

miimon & mode must be set before other parameters, and then not changed
again. Prior commit f671e0a28 per bug #421757 introduced a small logic
error. Fixed & refactored to prevent it happening as easily.

X-Gentoo-Bug: 447790
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=447790
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
Robin H. Johnson 2012-12-20 21:28:23 +00:00
parent b44f96ac9b
commit e0bbe8d0bd

View File

@ -62,22 +62,13 @@ bonding_pre_start()
# Interface must be down in order to configure
_down
# Configure the bond mode, then we can reloop to ensure we configure
# All other options
[ -d /sys/class/net ] && for x in /sys/class/net/"${IFACE}"/bonding/mode; do
# Configure the bond mode & link monitoring, then we can reloop to ensure
# we configure all other options
# mode needs to be done before all other options.
# miimon needs to be done BEFORE downdelay
[ -d /sys/class/net ] && for n in mode miimon; do
x=/sys/class/net/"${IFACE}"/bonding/$n
[ -f "${x}" ] || continue
n=${x##*/}
eval s=\$${n}_${IFVAR}
if [ -n "${s}" ]; then
einfo "Setting ${n}: ${s}"
echo "${s}" >"${x}" || \
eerror "Failed to configure $n (${n}_${IFVAR})"
fi
done
# Configure link monitoring
for x in /sys/class/net/"${IFACE}"/bonding/miimon; do
[ -f "${x}" ] || continue
n=${x##*/}
eval s=\$${n}_${IFVAR}
if [ -n "${s}" ]; then
einfo "Setting ${n}: ${s}"
@ -90,7 +81,8 @@ bonding_pre_start()
[ -f "${x}" ] || continue
n=${x##*/}
eval s=\$${n}_${IFVAR}
[ "${n}" != "mode" -o "${n}" != "miimon" ] || continue
# skip mode and miimon
[ "${n}" == "mode" -o "${n}" == "miimon" ] && continue
if [ -n "${s}" ]; then
einfo "Setting ${n}: ${s}"
echo "${s}" >"${x}" || \