Blame 0037-network-net-lib.sh-iface_has_link-fixup.patch

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