Blame SOURCES/0246-network-net-lib.sh-iface_has_link-wait-5s-for-the-ca.patch

712866
From e863891c154419932617e101ef5549dda41f6e62 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Thu, 7 May 2015 14:47:58 +0200
712866
Subject: [PATCH] network/net-lib.sh:iface_has_link() wait 5s for the carrier
712866
 to appear
712866
712866
https://bugzilla.redhat.com/show_bug.cgi?id=1088808
712866
---
712866
 modules.d/40network/net-lib.sh | 9 +++++++--
712866
 1 file changed, 7 insertions(+), 2 deletions(-)
712866
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
712866
index 220480b..1f77a15 100755
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -556,13 +556,18 @@ hostname() {
712866
 }
712866
 
712866
 iface_has_link() {
712866
+    local cnt=0
712866
     local interface="$1" flags=""
712866
     [ -n "$interface" ] || return 2
712866
     interface="/sys/class/net/$interface"
712866
     [ -d "$interface" ] || return 2
712866
     linkup "$1"
712866
-    [ "$(cat $interface/carrier)" = 1 ] || return 1
712866
-    # XXX Do we need to reset the flags here? anaconda never bothered..
712866
+    while [ $cnt -lt 50 ]; do
712866
+        [ "$(cat $interface/carrier)" = 1 ] && return 0
712866
+        sleep 0.1
712866
+        cnt=$(($cnt+1))
712866
+    done
712866
+    return 1
712866
 }
712866
 
712866
 find_iface_with_link() {