integ/base/initscripts/centos/patches/sysconfig-affirmative-check...

43 lines
1.8 KiB
Diff

From 974b70a23b6a6c579fc4d43efd42e42f26c27310 Mon Sep 17 00:00:00 2001
From: Allain Legacy <allain.legacy@windriver.com>
Date: Thu, 17 Nov 2016 08:27:42 -0500
Subject: [PATCH] sysconfig: affirmative check for link carrier
The /sys/class/net/<iface>/carrier attribute is supposed to return 0 or 1 to
indicate whether a link carrier is present or not. This holds true for regular
ethernet devices but for special devices, such as VLAN interfaces, it appears
to be possible that it returns an error on stderr and nothing on stdout in some
scenarios. One such scenario is if the lower interface of a VLAN is
administratively down then checking the carrier status of the VLAN returns
"invalid argument".
Because of the way the check_link_down() function is currently coded a failure
to produce any output on stdout is interpreted as a sign that the link carrier
is present. That is, the empty string "" is not equal to "0" therefore the
check passes.
To avoid this scenario we are changing this to a more affirmative check so that
it won't actually pass until stdout returns "1".
Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
---
sysconfig/network-scripts/network-functions | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions
index 798f28a..affa8ba 100644
--- a/sysconfig/network-scripts/network-functions
+++ b/sysconfig/network-scripts/network-functions
@@ -463,7 +463,7 @@ check_link_down ()
delay=20
[ -n "$LINKDELAY" ] && delay=$(($LINKDELAY * 2))
while [ $timeout -le $delay ]; do
- [ "$(cat /sys/class/net/$REALDEVICE/carrier 2>/dev/null)" != "0" ] && return 1
+ [ "$(cat /sys/class/net/$REALDEVICE/carrier 2>/dev/null)" == "1" ] && return 1
usleep 500000
timeout=$((timeout+1))
done
--
1.9.1