Blame SOURCES/0404-95fcoe-Store-current-configuration-in-dracut-cmdline.patch

18971c
From f501c955e86eb3043ab5e3c5f2648ed4c8bb58a3 Mon Sep 17 00:00:00 2001
18971c
From: Hannes Reinecke <hare@suse.de>
18971c
Date: Thu, 11 Dec 2014 15:46:22 +0100
18971c
Subject: [PATCH] 95fcoe: Store current configuration in dracut cmdline
18971c
18971c
When running with --hostonly-cmdline we should be storing
18971c
the current configuration in /etc/cmdline.d so that dracut
18971c
will be configure the system automatically.
18971c
18971c
References: bnc#877288
18971c
18971c
Signed-off-by: Hannes Reinecke <hare@suse.de>
18971c
Signed-off-by: Thomas Renninger <trenn@suse.de>
18971c
(cherry picked from commit 8b257fcc86f9a470613c1a5719641144a688acf7)
18971c
---
18971c
 modules.d/95fcoe/module-setup.sh | 45 ++++++++++++++++++++++++++++++++
18971c
 1 file changed, 45 insertions(+)
18971c
18971c
diff --git a/modules.d/95fcoe/module-setup.sh b/modules.d/95fcoe/module-setup.sh
18971c
index c000b3be..af2798dc 100755
18971c
--- a/modules.d/95fcoe/module-setup.sh
18971c
+++ b/modules.d/95fcoe/module-setup.sh
18971c
@@ -13,6 +13,7 @@ check() {
18971c
     }
18971c
 
18971c
     require_binaries dcbtool fipvlan lldpad ip readlink fcoemon fcoeadm || return 1
18971c
+
18971c
     return 0
18971c
 }
18971c
 
18971c
@@ -25,6 +26,46 @@ installkernel() {
18971c
     instmods fcoe 8021q edd
18971c
 }
18971c
 
18971c
+get_vlan_parent() {
18971c
+    local link=$1
18971c
+
18971c
+    [ -d $link ] || return
18971c
+    read iflink < $link/iflink
18971c
+    for if in /sys/class/net/* ; do
18971c
+	read idx < $if/ifindex
18971c
+	if [ $idx -eq $iflink ] ; then
18971c
+	    echo ${if##*/}
18971c
+	fi
18971c
+    done
18971c
+}
18971c
+
18971c
+# called by dracut
18971c
+cmdline() {
18971c
+
18971c
+    for c in /sys/bus/fcoe/devices/ctlr_* ; do
18971c
+        [ -L $c ] || continue
18971c
+        read enabled < $c/enabled
18971c
+        [ $enabled -eq 0 ] && continue
18971c
+        d=$(cd -P $c; echo $PWD)
18971c
+        i=${d%/*}
18971c
+        read mac < ${i}/address
18971c
+        s=$(dcbtool gc ${i##*/} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
18971c
+        if [ -z "$s" ] ; then
18971c
+	    p=$(get_vlan_parent ${i})
18971c
+	    if [ "$p" ] ; then
18971c
+	        s=$(dcbtool gc ${p} dcb | sed -n 's/^DCB State:\t*\(.*\)/\1/p')
18971c
+	    fi
18971c
+        fi
18971c
+        if [ "$s" = "on" ] ; then
18971c
+	    dcb="dcb"
18971c
+        else
18971c
+	    dcb="nodcb"
18971c
+        fi
18971c
+        echo "fcoe=${mac}:${dcb}"
18971c
+    done
18971c
+}
18971c
+
18971c
+# called by dracut
18971c
 install() {
18971c
     inst_multiple ip dcbtool fipvlan lldpad readlink lldptool fcoemon fcoeadm
18971c
     inst_libdir_file 'libhbalinux.so*'
18971c
@@ -33,6 +74,10 @@ install() {
18971c
     mkdir -m 0755 -p "$initdir/var/lib/lldpad"
18971c
     mkdir -m 0755 -p "$initdir/etc/fcoe"
18971c
 
18971c
+    if [[ $hostonly_cmdline == "yes" ]] ; then
18971c
+        local _fcoeconf=$(cmdline)
18971c
+        [[ $_fcoeconf ]] && printf "%s\n" "$_fcoeconf" >> "${initdir}/etc/cmdline.d/95fcoe.conf"
18971c
+    fi
18971c
     inst "$moddir/fcoe-up.sh" "/sbin/fcoe-up"
18971c
     inst "$moddir/fcoe-edd.sh" "/sbin/fcoe-edd"
18971c
     inst "$moddir/fcoe-genrules.sh" "/sbin/fcoe-genrules.sh"