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

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