From f8eba14d999a236e350e303d900d95174d524258 Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Thu, 12 Jan 2017 10:22:43 -0500 Subject: [PATCH] Handle failure of carrier check in dhcp-all-interfaces.sh As described in the bug, there are conditions with certain switches in which the interface is 'admin down'ed during initialization. Doing a 'cat' on /sys/class/net//carrier when it is 'admin down'ed produces an 'Invalid Argument' error and the script terminates. What this fix does is ignore failures of the 'cat' operation (by '|| echo 0') and place the link up inside the retry loop. Change-Id: I4f098aa5078b8482681394a3e9a6b17ed4bd4451 Closes-Bug: 1654046 --- .../dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh index 4884c435a..20a49ab6f 100755 --- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh +++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.sh @@ -38,7 +38,7 @@ function serialize_me() { } function get_if_link() { - cat /sys/class/net/${1}/carrier + cat /sys/class/net/${1}/carrier || echo 0 } function enable_interface() { @@ -87,11 +87,11 @@ function inspect_interface() { elif [ "$mac_addr_type" != "0" ]; then echo "Device has generated MAC, skipping." else - ip link set dev $interface up &>/dev/null - local has_link local tries for ((tries = 0; tries < 20; tries++)); do + # Need to set the link up on each iteration + ip link set dev $interface up &>/dev/null has_link=$(get_if_link $interface) [ "$has_link" == "1" ] && break sleep 1