Add support for team devices

V4: Sync with the latest teamd

V3: Drop patch 2/2 which harms readability
    Move inst_dir to kdump_setup_team()
    Avoid saying why teamdctl fails
    Error out for vlan over team, like bridge
    Remove the useless exit in kdump_get_perm_addr()

V2: remove the tmp config file in /tmp
    split the non-team part

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=874025
(This BZ is against RHEL7 though...)

Depends on dracut patch:
http://article.gmane.org/gmane.linux.kernel.initramfs/3043

and depends on latest version of teamd.

This patch adds support for team devices on kdump side.
I tested team active-backup mode and round-robin mode,
vmcore can be dumped over ssh successfully.

Note, currently we don't support stacked devices
on/under team, it is tricky and can be added on request.

Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: Cong Wang <amwang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Cong Wang 2012-12-13 22:36:05 +08:00 committed by Dave Young
parent 2c5d631e7d
commit 97e107b5ab

View File

@ -44,6 +44,10 @@ kdump_is_bond() {
[ -d /sys/class/net/"$1"/bonding ]
}
kdump_is_team() {
[ -f /usr/bin/teamnl ] && teamnl $1 ports &> /dev/null
}
kdump_is_vlan() {
[ -f /proc/net/vlan/"$1" ]
}
@ -72,6 +76,18 @@ kdump_get_mac_addr() {
echo `ip addr show $1 2>/dev/null|awk '/ether/{ print $2 }'`
}
#Bonding or team master modifies the mac address
#of its slaves, we should use perm address
kdump_get_perm_addr() {
local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //')
if [ -z "$addr" ] || [ "$addr" = "00:00:00:00:00:00" ]
then
derror "Can't get the permanent address of $1"
else
echo "$addr"
fi
}
kdump_setup_bridge() {
local _netdev=$1
for _dev in `ls /sys/class/net/$_netdev/brif/`; do
@ -96,6 +112,27 @@ kdump_setup_bond() {
echo " bondoptions=\"$bondoptions\"" >> ${initdir}/etc/cmdline.d/42bond.conf
}
kdump_setup_team() {
local _netdev=$1
local slaves=""
for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do
echo -n " ifname=$_dev:$(kdump_get_perm_addr $_dev)" >> ${initdir}/etc/cmdline.d/44team.conf
slaves+="$_dev,"
done
echo " team=$_netdev:$(echo $slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf
#Buggy version teamdctl outputs to stderr!
#Try to use the latest version of teamd.
teamdctl "$_netdev" config dump > /tmp/$$-$_netdev.conf
if [ $? -ne 0 ]
then
derror "teamdctl failed."
exit 1
fi
inst_dir /etc/teamd
inst_simple /tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf"
rm -f /tmp/$$-$_netdev.conf
}
kdump_setup_vlan() {
local _netdev=$1
local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")"
@ -108,6 +145,9 @@ kdump_setup_vlan() {
if kdump_is_bridge "$_phydev"; then
derror "Vlan over bridge is not supported!"
exit 1
elif kdump_is_team "$_phydev"; then
derror "Vlan over team is not supported!"
exit 1
elif kdump_is_bond "$_phydev"; then
kdump_setup_bond "$_phydev"
else
@ -149,6 +189,8 @@ kdump_setup_netdev() {
kdump_setup_bridge "$_netdev"
elif kdump_is_bond "$_netdev"; then
kdump_setup_bond "$_netdev"
elif kdump_is_team "$_netdev"; then
kdump_setup_team "$_netdev"
elif kdump_is_vlan "$_netdev"; then
kdump_setup_vlan "$_netdev"
else