Blame SOURCES/0228-net-lib.sh-parse_iscsi_root-fix-target-parsing.patch

712866
From 20700e3dea3c10aa2c9d4a724ec3d671455d556f Mon Sep 17 00:00:00 2001
712866
From: Harald Hoyer <harald@redhat.com>
712866
Date: Mon, 12 Jan 2015 14:06:10 +0100
712866
Subject: [PATCH] net-lib.sh:parse_iscsi_root() fix target parsing
712866
712866
For targets with colons in the iSCSI target name:
712866
  "iqn.2000-09.com.foo:storage-system.e2000:00000001cm1p1"
712866
712866
the parser was confused with the optional iscsi_iface_name and
712866
iscsi_netdev_name.
712866
712866
This patch reintroduces the old IQN, EUI and NAA parsing and enhances
712866
the fallback parser by checking the LUN for a numerical value.
712866
712866
(cherry picked from commit 36e8ce4fb01824b49697bd0e7ad3ca3c4cfd4297)
712866
---
712866
 modules.d/40network/net-lib.sh | 50 ++++++++++++++++++++++++++++++++----------
712866
 1 file changed, 38 insertions(+), 12 deletions(-)
712866
712866
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
5c6c2a
index 337817e3..f0850207 100755
712866
--- a/modules.d/40network/net-lib.sh
712866
+++ b/modules.d/40network/net-lib.sh
712866
@@ -310,6 +310,23 @@ parse_iscsi_root()
712866
             ;;
712866
     esac
712866
 
712866
+    unset iscsi_target_name
712866
+    # extract target name
712866
+    case "$v" in
712866
+        *:iqn.*)
712866
+            iscsi_target_name=iqn.${v##*:iqn.}
712866
+            v=${v%:iqn.*}:
712866
+            ;;
712866
+        *:eui.*)
712866
+            iscsi_target_name=iqn.${v##*:eui.}
712866
+            v=${v%:iqn.*}:
712866
+            ;;
712866
+        *:naa.*)
712866
+            iscsi_target_name=iqn.${v##*:naa.}
712866
+            v=${v%:iqn.*}:
712866
+            ;;
712866
+    esac
712866
+
712866
     # parse the rest
712866
     OLDIFS="$IFS"
712866
     IFS=:
712866
@@ -319,24 +336,33 @@ parse_iscsi_root()
712866
     iscsi_protocol=$1; shift # ignored
712866
     iscsi_target_port=$1; shift
712866
 
712866
-    if [ $# -gt 3 ] && [ -n "$1$2" ]; then
712866
-        iscsi_iface_name=$1; shift
712866
-        iscsi_netdev_name=$1; shift
712866
+    if [ -n "$iscsi_target_name" ]; then
712866
+        if [ $# -eq 3 ]; then
712866
+            iscsi_iface_name=$1; shift
712866
+        fi
712866
+        if [ $# -eq 2 ]; then
712866
+            iscsi_netdev_name=$1; shift
712866
+        fi
712866
+        iscsi_lun=$1; shift
712866
+        if [ $# -ne 0 ]; then
712866
+            warn "Invalid parameter in iscsi: parameter!"
712866
+            return 1
712866
+        fi
712866
+        return 0
712866
     fi
712866
 
712866
-    iscsi_lun=$1; shift
712866
 
712866
-    if [ $# -gt 2 ]; then
712866
-        warn "Invalid parameter in iscsi: parameter!"
712866
-        return 1
712866
+    if [ $# -gt 3 ] && [ -n "$1$2" ]; then
712866
+        if [ -z "$3" ] || [ "$3" -ge 0 ]  2>/dev/null ; then
712866
+            iscsi_iface_name=$1; shift
712866
+            iscsi_netdev_name=$1; shift
712866
+        fi
712866
     fi
712866
 
712866
-    if [ $# -eq 2 ]; then
712866
-        iscsi_target_name="$1:$2"
712866
-    else
712866
-        iscsi_target_name="$1"
712866
-    fi
712866
+    iscsi_lun=$1; shift
712866
 
712866
+    iscsi_target_name=$(printf "%s:" "$@")
712866
+    iscsi_target_name=${iscsi_target_name%:}
712866
 }
712866
 
712866
 ip_to_var() {