aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig
diff options
context:
space:
mode:
authorAshish Samant <ashish.samant@oracle.com>2014-10-29 17:47:29 -0700
committerLukas Nykryn <lnykryn@redhat.com>2015-02-04 15:50:40 +0100
commit520a2c79081e14e7de04dc756629f83535d31f0c (patch)
tree99e2e3b6a0806d394f602842dc3cfffb676bead7 /sysconfig
parent8f193b7145d627b90a1cbe1bc0e74fb275ce30ef (diff)
downloadinitscripts-520a2c79081e14e7de04dc756629f83535d31f0c.tar
initscripts-520a2c79081e14e7de04dc756629f83535d31f0c.tar.gz
initscripts-520a2c79081e14e7de04dc756629f83535d31f0c.tar.bz2
initscripts-520a2c79081e14e7de04dc756629f83535d31f0c.tar.xz
initscripts-520a2c79081e14e7de04dc756629f83535d31f0c.zip
improve_check_for_bond_master_in_install_bonding_driver
The current grep check (fgrep -sqx) in install_bonding_driver, to determine whether bond master exists, fails when there are multiple bond masters. The fix assumes that multiple bond masters are on different lines in the file "/sys/class/net/bonding_masters", while they are in fact on the same line. Since fgrep -sqx checks for the entire line,it will never match any one bond master within the line and always fail if there are multiple bonds. This patch improves the check by creating a new function, bond_master_exists() to handle this and other conditions. Orabug: 19897586 Signed-off-by: Ashish Samant <ashish.samant@oracle.com> Signed-off-by: John Haxby <john.haxby@oracle.com> Acked-by: Mukesh Kacker <mukesh.kacker@oracle.com> Conflicts: sysconfig/network-scripts/network-functions
Diffstat (limited to 'sysconfig')
-rw-r--r--sysconfig/network-scripts/network-functions16
1 files changed, 14 insertions, 2 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 8d47e4ff..85a8880b 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -429,10 +429,22 @@ phy_wireless_device ()
cat /sys/class/net/$1/phy80211/name
}
+bond_master_exists ()
+{
+ local bond_name
+ [ -z "${1}" ] && return 1
+ [ ! -f /sys/class/net/bonding_masters ] && return 1
+
+ for bond_name in $(< /sys/class/net/bonding_masters); do
+ [ "${bond_name}" == "${1}" ] && return 0
+ done
+ return 1
+}
+
install_bonding_driver ()
{
- [ ! -f /sys/class/net/bonding_masters ] && ( modprobe bonding || return 1 )
- if ! grep -sqw "$1" /sys/class/net/bonding_masters; then
+ if ! bond_master_exists ${1}; then
+ modprobe bonding || return 1
echo "+$1" > /sys/class/net/bonding_masters 2>/dev/null
fi
(