]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
95fcoe: use interface names instead of MAC addresses 318/head
authorHannes Reinecke <hare@suse.de>
Wed, 24 Aug 2016 13:14:31 +0000 (15:14 +0200)
committerDaniel Molkentin <danimo@molkentin.de>
Mon, 18 Dec 2017 20:48:07 +0000 (21:48 +0100)
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

index 17bc125ec26cea572f0be2dfd92db441dfcb875f..63f45b527fdb6fdd3bf2b0dcb8cadfbadd1aa52a 100755 (executable)
@@ -41,48 +41,52 @@ 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')
+    {
+        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
-        fi
-        if [ "$s" = "on" ] ; then
-            dcb="dcb"
-        else
-            dcb="nodcb"
-        fi
 
-        # Some Combined Network Adapters(CNAs) implement DCB in firmware.
-        # Do not run software-based DCB or LLDP on CNAs that implement DCB.
-        # If the network interface provides hardware DCB/DCBX capabilities,
-        # DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
-        #
-        # Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
-        grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null
-        [ $? -eq 0 ] && dcb="nodcb"
-        if [ "$p" ] ; then
-            grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
+            # Some Combined Network Adapters(CNAs) implement DCB in firmware.
+            # Do not run software-based DCB or LLDP on CNAs that implement DCB.
+            # If the network interface provides hardware DCB/DCBX capabilities,
+            # DCB_REQUIRED in "/etc/fcoe/cfg-xxx" is expected to set to "no".
+            #
+            # Force "nodcb" if there's any DCB_REQUIRED="no"(child or vlan parent).
+            grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${i##*/} &>/dev/null
             [ $? -eq 0 ] && dcb="nodcb"
-        fi
+            if [ "$p" ] ; then
+                grep -q "^[[:blank:]]*DCB_REQUIRED=\"no\"" /etc/fcoe/cfg-${p} &>/dev/null
+                [ $? -eq 0 ] && dcb="nodcb"
+            fi
 
-        echo "fcoe=${mac}:${dcb}:${mode}"
-    done
+            echo "ifname=${ifname}:${mac}"
+            echo "fcoe=${ifname}:${dcb}:${mode}"
+        done
+    } | sort | uniq
 }
 
 # called by dracut