network: enhance team support
Install ifcfg-* files with team configuration in the initramfs.
Improve the slave configuration of the team interface, by looking up
ifcfg files in the initramfs.
Create a default loadbalance team config, if none present in the
initramfs.
forward port of
4c88c2859e
master
parent
811a070d6c
commit
041e49ee2a
|
@ -298,20 +298,38 @@ if [ -z "$NO_TEAM_MASTER" ]; then
|
|||
# in case of some slave is gone in active-backup mode
|
||||
working_slaves=""
|
||||
for slave in $teamslaves ; do
|
||||
ip link set $slave up 2>/dev/null
|
||||
teamdctl ${teammaster} port present ${slave} 2>/dev/null \
|
||||
&& continue
|
||||
ip link set dev $slave up 2>/dev/null
|
||||
if wait_for_if_up $slave; then
|
||||
working_slaves="$working_slaves$slave "
|
||||
fi
|
||||
done
|
||||
# Do not add slaves now
|
||||
teamd -d -U -n -N -t $teammaster -f /etc/teamd/$teammaster.conf
|
||||
teamd -d -U -n -N -t $teammaster -f /etc/teamd/${teammaster}.conf
|
||||
for slave in $working_slaves; do
|
||||
# team requires the slaves to be down before joining team
|
||||
ip link set $slave down
|
||||
ip link set dev $slave down
|
||||
(
|
||||
unset TEAM_PORT_CONFIG
|
||||
_hwaddr=$(cat /sys/class/net/$slave/address)
|
||||
_subchannels=$(iface_get_subchannels "$slave")
|
||||
if [ -n "$_hwaddr" ] && [ -e "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf" ]; then
|
||||
. "/etc/sysconfig/network-scripts/mac-${_hwaddr}.conf"
|
||||
elif [ -n "$_subchannels" ] && [ -e "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf" ]; then
|
||||
. "/etc/sysconfig/network-scripts/ccw-${_subchannels}.conf"
|
||||
elif [ -e "/etc/sysconfig/network-scripts/ifcfg-${slave}" ]; then
|
||||
. "/etc/sysconfig/network-scripts/ifcfg-${slave}"
|
||||
fi
|
||||
|
||||
if [ -n "${TEAM_PORT_CONFIG}" ]; then
|
||||
/usr/bin/teamdctl ${teammaster} port config update ${slave} "${TEAM_PORT_CONFIG}"
|
||||
fi
|
||||
)
|
||||
teamdctl $teammaster port add $slave
|
||||
done
|
||||
|
||||
ip link set $teammaster up
|
||||
ip link set dev $teammaster up
|
||||
|
||||
> /tmp/team.$teammaster.up
|
||||
NO_TEAM_MASTER=yes ifup $teammaster
|
||||
|
|
|
@ -47,6 +47,43 @@ install() {
|
|||
inst_hook cmdline 99 "$moddir/parse-ifname.sh"
|
||||
inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
|
||||
|
||||
# install all config files for teaming
|
||||
unset TEAM_MASTER
|
||||
unset TEAM_CONFIG
|
||||
unset TEAM_PORT_CONFIG
|
||||
unset HWADDR
|
||||
unset SUBCHANNELS
|
||||
for i in /etc/sysconfig/network-scripts/ifcfg-*; do
|
||||
[ -e "$i" ] || continue
|
||||
case "$i" in
|
||||
*~ | *.bak | *.orig | *.rpmnew | *.rpmorig | *.rpmsave)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
(
|
||||
. "$i"
|
||||
if ! [ "${ONBOOT}" = "no" -o "${ONBOOT}" = "NO" ] \
|
||||
&& [ -n "${TEAM_MASTER}${TEAM_CONFIG}${TEAM_PORT_CONFIG}" ]; then
|
||||
if [ -n "$TEAM_CONFIG" ] && [ -n "$DEVICE" ]; then
|
||||
mkdir -p $initdir/etc/teamd
|
||||
printf -- "%s" "$TEAM_CONFIG" > "$initdir/etc/teamd/${DEVICE}.conf"
|
||||
elif [ -n "$TEAM_PORT_CONFIG" ]; then
|
||||
inst_simple "$i"
|
||||
|
||||
HWADDR="$(echo $HWADDR | sed 'y/ABCDEF/abcdef/')"
|
||||
if [ -n "$HWADDR" ]; then
|
||||
ln_r "$i" "/etc/sysconfig/network-scripts/mac-${HWADDR}.conf"
|
||||
fi
|
||||
|
||||
SUBCHANNELS="$(echo $SUBCHANNELS | sed 'y/ABCDEF/abcdef/')"
|
||||
if [ -n "$SUBCHANNELS" ]; then
|
||||
ln_r "$i" "/etc/sysconfig/network-scripts/ccw-${SUBCHANNELS}.conf"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
)
|
||||
done
|
||||
|
||||
_arch=$(uname -m)
|
||||
|
||||
inst_libdir_file {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
|
||||
|
|
|
@ -817,3 +817,21 @@ is_kernel_ethernet_name() {
|
|||
esac
|
||||
|
||||
}
|
||||
|
||||
iface_get_subchannels() {
|
||||
local _netif
|
||||
local _subchannels
|
||||
|
||||
_netif="$1"
|
||||
|
||||
_subchannels=$({
|
||||
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
|
||||
[ -e $i ] || continue
|
||||
channel=$(readlink -f $i)
|
||||
printf -- "%s" "${channel##*/},"
|
||||
done
|
||||
})
|
||||
[ -n "$_subchannels" ] || return 1
|
||||
|
||||
printf -- "%s" ${_subchannels%,}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,24 @@ parseteam() {
|
|||
2) teammaster=$1; teamslaves=$(str_replace "$2" "," " ") ;;
|
||||
*) die "team= requires two parameters" ;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
for team in $(getargs team); do
|
||||
[ "$team" = "team" ] && continue
|
||||
|
||||
for team in $(getargs team=); do
|
||||
unset teammaster teamslaves
|
||||
parseteam "$(getarg team=)"
|
||||
unset teammaster
|
||||
unset teamslaves
|
||||
|
||||
parseteam "$team" || continue
|
||||
|
||||
echo "teammaster=$teammaster" > /tmp/team.${teammaster}.info
|
||||
echo "teamslaves=\"$teamslaves\"" >> /tmp/team.${teammaster}.info
|
||||
|
||||
if ! [ -e /etc/teamd/${teammaster}.conf ]; then
|
||||
warn "Team master $teammaster specified, but no /etc/teamd/$teammaster.conf present. Using activebackup."
|
||||
mkdir -p /etc/teamd
|
||||
printf -- "%s" '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' > "/etc/teamd/${teammaster}.conf"
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
unset bondoptions
|
||||
unset bridgename
|
||||
unset bridgeslaves
|
||||
unset team
|
||||
unset uuid
|
||||
unset ip
|
||||
unset gw
|
||||
|
@ -137,10 +138,13 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
|
||||
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
|
||||
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
|
||||
[ -e /tmp/team.${netif}.info ] && . /tmp/team.${netif}.info
|
||||
|
||||
uuid=$(cat /proc/sys/kernel/random/uuid)
|
||||
if [ "$netif" = "$bridgename" ]; then
|
||||
bridge=yes
|
||||
elif [ "$netif" = "$teammaster" ]; then
|
||||
team=yes
|
||||
elif [ "$netif" = "$bondname" ]; then
|
||||
# $netif can't be bridge and bond at the same time
|
||||
bond=yes
|
||||
|
@ -153,6 +157,9 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
break
|
||||
done
|
||||
|
||||
# skip team interfaces for now, the host config must be in sync
|
||||
[ "$netif" = "$teammaster" ] && continue
|
||||
|
||||
{
|
||||
echo "# Generated by dracut initrd"
|
||||
echo "NAME=\"$netif\""
|
||||
|
@ -199,7 +206,7 @@ for netup in /tmp/net.*.did-setup ; do
|
|||
} > /tmp/ifcfg/ifcfg-$netif
|
||||
|
||||
# bridge needs different things written to ifcfg
|
||||
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
|
||||
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
|
||||
# standard interface
|
||||
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue