From 2f22452b3850d8eb3ade92f2f7dc7bf0c0e4bcb6 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 12 Feb 2010 17:09:22 -0500 Subject: Fix various device checks to not misidentify devices. Also, don't use ifconfig for checking link state on alias devices; /sbin/ip does fine with that. --- sysconfig/network-scripts/network-functions | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'sysconfig/network-scripts') diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 38440e5b..1d1c43d2 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -169,8 +169,7 @@ do_netreport () # Sets $alias to the device module if $? != 0 is_available () { - LC_ALL= LANG= ip -o link | grep -q $1 - [ "$?" = "1" ] || return 0 + [ -d "/sys/class/net/$1" ] && return 0 [ -n "$BONDING_OPTS" ] && install_bonding_driver $1 @@ -201,8 +200,7 @@ END { install_bonding_driver $1 fi - LC_ALL= LANG= ip -o link | grep -q $1 - return $? + [ -d "/sys/class/net/$1" ] && return 0 || return 1 } need_hostname () @@ -233,19 +231,11 @@ set_hostname () check_device_down () { - if echo $1 | grep -q ':' ; then - if LC_ALL=C ifconfig -a 2>/dev/null | grep -q $1 ; then - return 1 - else - return 0 - fi - else - if LC_ALL=C ip -o link 2>/dev/null | grep -q "$1[:@].*,UP" ; then + if LC_ALL=C ip -o link show dev $1 2>/dev/null | grep -q ",UP" ; then return 1 else return 0 fi - fi } check_ethtool () @@ -260,7 +250,7 @@ check_ethtool () check_link_down () { if [ -x /sbin/ethtool ]; then - if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q UP ; then + if ! LC_ALL=C ip link show dev $1 2>/dev/null| grep -q ",UP" ; then ip link set dev $1 up >/dev/null 2>&1 fi timeout=0 -- cgit v1.2.1