diff options
author | Bill Nottingham <notting@redhat.com> | 2003-01-14 01:08:09 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2003-01-14 01:08:09 +0000 |
commit | 74614dad93bfee657048777fe54eaf67ac97a3c4 (patch) | |
tree | f3aeb732ca943e3931e73675a13bfd391e33cee3 /sysconfig/network-scripts | |
parent | 1c3c6e0e69b4731bb1e612fafe64ee8324286a87 (diff) | |
download | initscripts-74614dad93bfee657048777fe54eaf67ac97a3c4.tar initscripts-74614dad93bfee657048777fe54eaf67ac97a3c4.tar.gz initscripts-74614dad93bfee657048777fe54eaf67ac97a3c4.tar.bz2 initscripts-74614dad93bfee657048777fe54eaf67ac97a3c4.tar.xz initscripts-74614dad93bfee657048777fe54eaf67ac97a3c4.zip |
fix link check. use both ethtool and mii-tool.
Diffstat (limited to 'sysconfig/network-scripts')
-rw-r--r-- | sysconfig/network-scripts/network-functions | 39 |
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 } |