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/<interface>/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
This commit is contained in:
parent
7fc4856c6a
commit
f8eba14d99
1 changed files with 3 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue