aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sysconfig/network-scripts/network-functions39
1 files changed, 25 insertions, 14 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 49d9cca5..68c17ccd 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -128,6 +128,21 @@ check_device_down ()
fi
}
+check_mii_tool ()
+{
+ output=`LC_ALL=C mii-tool $1 2>&1`
+ echo $output | LC_ALL=C grep -q "link ok" && return 1
+ echo $output | LC_ALL=C grep -q "no link" && return 0 || return 2
+}
+
+check_ethtool ()
+{
+ output=`LC_ALL=C ethtool $1 2>&1`
+ echo $output | LC_ALL=C grep -q "Link detected: yes" && return 1
+ echo $output | LC_ALL=C grep -q "Link detected: no" && return 0 || return 2
+}
+
+
check_link_down ()
{
if [ -x /sbin/mii-tool ]; then
@@ -135,24 +150,20 @@ check_link_down ()
ip link set $1 up >/dev/null 2>&1
timeout=0
while [ $timeout -le 10 ]; do
- LC_ALL=C ip link show $1 2>/dev/null | grep -q UP && break
+ check_mii_tool $1
+ m=$?
+ check_ethtool $1
+ e=$?
+ if [ $m -eq 1 ] || [ $e -eq 1 ] ; then
+ return 1
+ fi
+ if [ $m -eq 2 ] && [ $e -eq 2 ] ; then
+ return 1
+ fi
usleep 500000
timeout=$((timeout+1))
done
fi
- /sbin/mii-tool $1 >/dev/null 2>&1 || return 1
- output=`LC_ALL=C /sbin/mii-tool $1 2>&1`
- if echo $output | grep -q "Operation not supported"; then
- return 1
- elif echo $output | grep -q "Invalid argument"; then
- return 1
- elif echo $output | grep -q "link ok"; then
- return 1
- elif echo $output | grep -q "No MII transceiver present"; then
- return 1
- else
- return 0
- fi
fi
return 0
}