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

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