File 0219-95fcoe-use-interface-names-instead-of-MAC-addresses.patch of Package dracut

From 4f19de16df2746b0b742bfbecfb493728a150c86 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 24 Aug 2016 15:14:31 +0200
Subject: [PATCH] 95fcoe: use interface names instead of MAC addresses

Now that we are using persistent network names we can switch
to using the interface names when specifying the fcoe configuration.
With that we can print the fcoe configuration only once.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 modules.d/95fcoe/module-setup.sh | 60 +++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 28 deletions(-)

diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
index 2a5c71a..acc611d 100755
--- a/modules.d/95fcoe/module-setup.sh
+++ b/modules.d/95fcoe/module-setup.sh
@@ -40,34 +40,38 @@ get_vlan_parent() {
 
 # called by dracut
 cmdline() {
-
-    for c in /sys/bus/fcoe/devices/ctlr_* ; do
-        [ -L $c ] || continue
-        read enabled < $c/enabled
-        read mode < $c/mode
-        [ $enabled -eq 0 ] && continue
-        if [ $mode = "VN2VN" ] ; then
-            mode="vn2vn"
-        else
-            mode="fabric"
-        fi
-        d=$(cd -P $c; echo $PWD)
-        i=${d%/*}
-        read mac < ${i}/address
-        s=$(dcbtool gc ${i##*/} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
-        if [ -z "$s" ] ; then
-	    p=$(get_vlan_parent ${i})
-	    if [ "$p" ] ; then
-	        s=$(dcbtool gc ${p} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
-	    fi
-        fi
-        if [ "$s" = "on" ] ; then
-	    dcb="dcb"
-        else
-	    dcb="nodcb"
-        fi
-        echo "fcoe=${mac}:${dcb}:${mode}"
-    done
+    {
+        for c in /sys/bus/fcoe/devices/ctlr_* ; do
+            [ -L $c ] || continue
+            read enabled < $c/enabled
+            read mode < $c/mode
+            [ $enabled -eq 0 ] && continue
+            if [ $mode = "VN2VN" ] ; then
+                mode="vn2vn"
+            else
+                mode="fabric"
+            fi
+            d=$(cd -P $c; echo $PWD)
+            i=${d%/*}
+            ifname=${i##*/}
+            read mac < ${i}/address
+            s=$(dcbtool gc ${i##*/} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
+            if [ -z "$s" ] ; then
+	        p=$(get_vlan_parent ${i})
+	        if [ "$p" ] ; then
+	            s=$(dcbtool gc ${p} dcb 2>/dev/null | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
+                    ifname=${p##*/}
+	        fi
+            fi
+            if [ "$s" = "on" ] ; then
+	        dcb="dcb"
+            else
+	        dcb="nodcb"
+            fi
+            echo "ifname=${ifname}:${mac}"
+            echo "fcoe=${ifname}:${dcb}:${mode}"
+        done
+    } | sort | uniq
 }
 
 # called by dracut
-- 
2.6.6

openSUSE Build Service is sponsored by