aboutsummaryrefslogtreecommitdiffstats
path: root/sysconfig/network-scripts/network-functions
diff options
context:
space:
mode:
authorPreston Brown <pbrown@redhat.com>2002-06-27 16:56:08 +0000
committerPreston Brown <pbrown@redhat.com>2002-06-27 16:56:08 +0000
commitcd90f52da1ca08ca5577be018bb10f9d658f17af (patch)
tree7de6c8a32857e2ca22d9e615301103decd795f14 /sysconfig/network-scripts/network-functions
parent79da64351aa4395a57db31e38cd848b18bdb062c (diff)
downloadinitscripts-cd90f52da1ca08ca5577be018bb10f9d658f17af.tar
initscripts-cd90f52da1ca08ca5577be018bb10f9d658f17af.tar.gz
initscripts-cd90f52da1ca08ca5577be018bb10f9d658f17af.tar.bz2
initscripts-cd90f52da1ca08ca5577be018bb10f9d658f17af.tar.xz
initscripts-cd90f52da1ca08ca5577be018bb10f9d658f17af.zip
fix check_device_down logic
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r--sysconfig/network-scripts/network-functions42
1 files changed, 19 insertions, 23 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index cb56b09f..5ce5fd6c 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -121,26 +121,23 @@ set_hostname()
check_device_down ()
{
- if echo $1 | grep -q ':' ; then
- if LC_ALL=C ifconfig -a 2>/dev/null | grep -q $1 ; then
- retcode=1
- else
- retcode=0
- fi
- else
- if LC_ALL=C ip -o link ls dev $1 2>/dev/null | grep ",UP" >/dev/null 2>&1 ; then
- retcode=1
- else
- retcode=0
- fi
+ # never say alias devices are down
+ if echo $1 | grep -q ':'; then
+ return 1
+ fi
+
+ if LC_ALL=C ip -o link ls dev $1 2>/dev/null | grep -q UP ; then
+ return 1
+ else
+ return 0
fi
- return $retcode
}
check_link_down ()
{
if [ -x /sbin/mii-tool ]; then
LC_ALL=C ip link show $1 2>/dev/null| grep -q UP || ip link set $1 up >/dev/null 2>&1
+ # wait for link to come up
sleep 2
/sbin/mii-tool >/dev/null 2>&1 || return 1
output=`LC_ALL=C /sbin/mii-tool $1 2>&1`
@@ -169,13 +166,12 @@ find_gateway_dev ()
. /etc/sysconfig/network
if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ] ; then
export GATEWAY
- networks=`LC_ALL=C /sbin/route -n|awk '{print $1, ENVIRON["GATEWAY"],$3,$8}'|awk '{system("ipcalc --silent --network "$2" "$3" 2>/dev/null")}'|sed s^NETWORK=^^g`
- for net in $networks; do
- dev=`LC_ALL=C /sbin/route -n|grep ^$net|awk '{print $NF}'`
- if [ "$dev" != "" ] ; then
- GATEWAYDEV=$dev
- fi
- done
+ dev=`LC_ALL=C /sbin/ip route | \
+ grep ${GATEWAY} | \
+ sed -e 's/.* dev \([:alnum:]*\)/\1/'`
+ if [ "$dev" != "" ]; then
+ GATEWAYDEV=$dev
+ fi
fi
}
@@ -183,9 +179,9 @@ add_default_route ()
{
. /etc/sysconfig/network
find_gateway_dev
- if [ "${GATEWAY}" != "" -a \
- "${GATEWAY}" != "none" -a \
- "${GATEWAYDEV}" != "" ] ; then
+ if [ "$GATEWAYDEV" != "" -a \
+ "${GATEWAY}" != "" -a \
+ "${GATEWAY}" != "none" ] ; then
if ! check_device_down $1; then
if [ "$GATEWAY" = "0.0.0.0" ]; then
/sbin/ip route add default dev ${GATEWAYDEV}