File 0143-iscsi-Fix-up-ipv6-in-brackets-iterate-over-all-possi.patch of Package dracut.892

From 59ca38d9c6f8e01600c167827df8dc5dd3e140d8 Mon Sep 17 00:00:00 2001
From: Thomas Renninger <trenn@suse.de>
Date: Tue, 19 Aug 2014 15:59:21 +0200
Subject: iscsi: Fix up ipv6 in brackets, iterate over all possible needed
 iscsi mounts

for_each_host_dev_and_slaves only iterates over the rootfs, this one is
successful and then it exits.

This does not work if the --mount option is passed on a iscsi target.
Now really iterate over all host_devs via:
for_each_host_dev_and_slaves_all

and set needed iscsi kernel commandline accordingly.
Now also the parent block device, e.g. /dev/sda and /dev/sda4 are iterated
which results in duplicated iscsi parameters.
Avoid this by piping the final iscsi cmdline function through | sort |uniq

Signed-off-by: Thomas Renninger <trenn@suse.de>
---
 modules.d/95iscsi/module-setup.sh | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules.d/95iscsi/module-setup.sh b/modules.d/95iscsi/module-setup.sh
index 94eb023..9772210 100755
--- a/modules.d/95iscsi/module-setup.sh
+++ b/modules.d/95iscsi/module-setup.sh
@@ -93,6 +93,12 @@ install_iscsiroot() {
         if [ -n "$iscsi_lun" -a "$iscsi_lun" -eq 0 ] ; then
             iscsi_lun=
         fi
+        # In IPv6 case rd.iscsi.initatior= must pass address in [] brackets
+        case "$iscsi_address" in
+            *:*)
+                iscsi_address="[$iscsi_address]"
+                ;;
+        esac
         echo "rd.iscsi.initiator=${iscsi_initiator} netroot=iscsi:${iscsi_address}::${iscsi_port}:${iscsi_lun}:${iscsi_targetname}"
     fi
     return 0
@@ -111,7 +117,7 @@ install_softiscsi() {
         install_iscsiroot $iscsi_dev
     }
 
-    for_each_host_dev_and_slaves is_softiscsi || return 255
+    for_each_host_dev_and_slaves_all is_softiscsi || return 255
     return 0
 }
 
@@ -194,11 +200,13 @@ installkernel() {
 # called by dracut
 cmdline() {
     local _iscsiconf=$(install_ibft)
-    if [ "$_iscsiconf" ] ; then
-        echo ${_iscsiconf}
-    else
-        install_softiscsi
-    fi
+    {
+        if [ "$_iscsiconf" ] ; then
+            echo ${_iscsiconf}
+        else
+            install_softiscsi
+        fi
+    } | sort | uniq
 }
 
 # called by dracut
-- 
1.8.4.5