Blame SOURCES/0048-network-net-lib.sh-iface_has_link-fixup.patch

712866
From 34397fe702ae21a3566e166b4001e8121766d5a7 Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Mon, 2 Dec 2013 10:36:42 +0100
712866
Subject: [PATCH] network/net-lib.sh:iface_has_link() fixup
712866
712866
Just echo'ing the flags IFF_UP|IFF_RUNNING does _not_ reflect the
712866
carrier state immediately. So wait for it to really show up.
712866
---
712866
 modules.d/40network/net-lib.sh | 47 +++++++++++++++++++++---------------------
712866
 1 file changed, 23 insertions(+), 24 deletions(-)
712866
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
5c6c2a
index 0aa312a0..7544401f 100644
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -28,30 +28,6 @@ iface_for_mac() {
712866
     done
712866
 }
712866
 
712866
-iface_has_link() {
712866
-    local interface="$1" flags=""
712866
-    [ -n "$interface" ] || return 2
712866
-    interface="/sys/class/net/$interface"
712866
-    [ -d "$interface" ] || return 2
712866
-    flags=$(cat $interface/flags)
712866
-    echo $(($flags|0x41)) > $interface/flags # 0x41: IFF_UP|IFF_RUNNING
712866
-    [ "$(cat $interface/carrier)" = 1 ] || return 1
712866
-    # XXX Do we need to reset the flags here? anaconda never bothered..
712866
-}
712866
-
712866
-find_iface_with_link() {
712866
-    local iface_path="" iface=""
712866
-    for iface_path in /sys/class/net/*; do
712866
-        iface=${iface_path##*/}
712866
-        str_starts "$iface" "lo" && continue
712866
-        if iface_has_link $iface; then
712866
-            echo "$iface"
712866
-            return 0
712866
-        fi
712866
-    done
712866
-    return 1
712866
-}
712866
-
712866
 # get the iface name for the given identifier - either a MAC, IP, or iface name
712866
 iface_name() {
712866
     case $1 in
712866
@@ -483,3 +459,26 @@ type hostname >/dev/null 2>&1 || \
712866
 hostname() {
712866
 	cat /proc/sys/kernel/hostname
712866
 }
712866
+
712866
+iface_has_link() {
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
+}
712866
+
712866
+find_iface_with_link() {
712866
+    local iface_path="" iface=""
712866
+    for iface_path in /sys/class/net/*; do
712866
+        iface=${iface_path##*/}
712866
+        str_starts "$iface" "lo" && continue
712866
+        if iface_has_link $iface; then
712866
+            echo "$iface"
712866
+            return 0
712866
+        fi
712866
+    done
712866
+    return 1
712866
+}