Blame 0061-95fcoe-Store-current-configuration-in-dracut-cmdline.patch

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