From 97e107b5ab5ff1c23f0b9fb8a68c50d0903a8fbf Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Thu, 13 Dec 2012 22:36:05 +0800 Subject: [PATCH] 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 Cc: Dave Young Cc: Jiri Pirko Signed-off-by: Cong Wang Acked-by: Dave Young --- dracut-module-setup.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 831439a..5dd4a64 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -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