Browse Source

network: support multiple bonding interfaces

Currently dracut only support 1 bond, namyly bond0 by default. However multiple
bonds configuration may be needed. For example in kdump, in 1st kernel, more
than one bonds may be configured, and bondX other than bond0 is used as output
interface to remote host which will store dump core. This patch can solve this
problem, to write real bond information to initramfs, 2nd kdump kernel will
use it to create the relevant bondX interface.

Tested-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Baoquan He <bhe@redhat.com>
master
Harald Hoyer 12 years ago
parent
commit
d136ca4eeb
  1. 15
      modules.d/40network/ifup.sh
  2. 9
      modules.d/40network/net-genrules.sh
  3. 6
      modules.d/40network/parse-bond.sh
  4. 6
      modules.d/40network/parse-bridge.sh
  5. 9
      modules.d/45ifcfg/write-ifcfg.sh

15
modules.d/40network/ifup.sh

@ -21,14 +21,18 @@ use_bridge='false'
use_vlan='false' use_vlan='false'


# enslave this interface to bond? # enslave this interface to bond?
if [ -e /tmp/bond.info ]; then for i in /tmp/bond.*.info; do
. /tmp/bond.info [ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
for slave in $bondslaves ; do for slave in $bondslaves ; do
if [ "$netif" = "$slave" ] ; then if [ "$netif" = "$slave" ] ; then
netif=$bondname netif=$bondname
break 2
fi fi
done done
fi done


if [ -e /tmp/team.info ]; then if [ -e /tmp/team.info ]; then
. /tmp/team.info . /tmp/team.info
@ -138,11 +142,12 @@ if [ "$netif" = "lo" ] ; then
fi fi


# start bond if needed # start bond if needed
if [ -e /tmp/bond.info ]; then if [ -e /tmp/bond.${netif}.info ]; then
. /tmp/bond.info . /tmp/bond.${netif}.info


if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device if [ "$netif" = "$bondname" ] && [ ! -e /tmp/net.$bondname.up ] ; then # We are master bond device
modprobe bonding modprobe bonding
echo "+$netif" > /sys/class/net/bonding_masters
ip link set $netif down ip link set $netif down


# Stolen from ifup-eth # Stolen from ifup-eth

9
modules.d/40network/net-genrules.sh

@ -28,11 +28,14 @@ fi
fi fi


# bond: attempt only the defined interface (override bridge defines) # bond: attempt only the defined interface (override bridge defines)
if [ -e /tmp/bond.info ]; then for i in /tmp/bond.*.info; do
. /tmp/bond.info [ -e "$i" ] || continue
unset bondslaves
unset bondname
. "$i"
# It is enough to fire up only one # It is enough to fire up only one
IFACES="$IFACES ${bondslaves%% *}" IFACES="$IFACES ${bondslaves%% *}"
fi done


if [ -e /tmp/team.info ]; then if [ -e /tmp/team.info ]; then
. /tmp/team.info . /tmp/team.info

6
modules.d/40network/parse-bond.sh

@ -54,8 +54,8 @@ if getarg bond >/dev/null; then
fi fi
# Make it suitable for initscripts export # Make it suitable for initscripts export
bondoptions=$(str_replace "$bondoptions" ";" ",") bondoptions=$(str_replace "$bondoptions" ";" ",")
echo "bondname=$bondname" > /tmp/bond.info echo "bondname=$bondname" > /tmp/bond.${bondname}.info
echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.info echo "bondslaves=\"$bondslaves\"" >> /tmp/bond.${bondname}.info
echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.info echo "bondoptions=\"$bondoptions\"" >> /tmp/bond.${bondname}.info
return return
fi fi

6
modules.d/40network/parse-bridge.sh

@ -37,12 +37,6 @@ parsebridge() {
unset bridgename ethnames unset bridgename ethnames


iface=eth0 iface=eth0
if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
if [ -n "$bondname" ] ; then
iface=$bondname
fi
fi


# Parse bridge for bridgename and ethnames # Parse bridge for bridgename and ethnames
if bridge="$(getarg bridge)"; then if bridge="$(getarg bridge)"; then

9
modules.d/45ifcfg/write-ifcfg.sh

@ -9,10 +9,6 @@ udevadm settle --timeout=30


read IFACES < /tmp/net.ifaces read IFACES < /tmp/net.ifaces


if [ -e /tmp/bond.info ]; then
. /tmp/bond.info
fi

if [ -e /tmp/bridge.info ]; then if [ -e /tmp/bridge.info ]; then
. /tmp/bridge.info . /tmp/bridge.info
fi fi
@ -89,6 +85,11 @@ for netif in $IFACES ; do
# bridge? # bridge?
unset bridge unset bridge
unset bond unset bond
unset bondslaves
unset bondname
unset bondoptions
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info

uuid=$(cat /proc/sys/kernel/random/uuid) uuid=$(cat /proc/sys/kernel/random/uuid)
if [ "$netif" = "$bridgename" ]; then if [ "$netif" = "$bridgename" ]; then
bridge=yes bridge=yes

Loading…
Cancel
Save