File 0193-95iscsi-Set-number-of-login-retries.patch of Package dracut.4068

From: Thomas Blume <thomas.blume@suse.com>
Date: Mon, 19 Oct 2015 09:39:41 +0200
Subject: Set number of login retries

Allow to set the number of login retries from the kernel commandline.

References: bsc#919179

Signed-off-by: Thomas Blume <thomas.blume@suse.com>
---
 modules.d/95iscsi/iscsiroot.sh | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

Index: dracut-044/modules.d/95iscsi/iscsiroot.sh
===================================================================
--- dracut-044.orig/modules.d/95iscsi/iscsiroot.sh	2016-04-14 14:52:44.685325362 +0200
+++ dracut-044/modules.d/95iscsi/iscsiroot.sh	2016-04-14 14:57:07.628188324 +0200
@@ -41,6 +41,14 @@ if [ -z "${DRACUT_SYSTEMD}" ] && [ -e /s
         > /tmp/iscsiuio-started
 fi
 
+#set value for initial login retry
+set_login_retries() {
+    local default retries
+    default=2
+    retries=$(getarg rd.iscsilogin.retries)
+    return ${retries:-$default}
+}
+
 handle_firmware()
 {
     if ! iscsiadm -m fw; then
@@ -67,7 +75,7 @@ handle_netroot()
     local iscsi_username iscsi_password
     local iscsi_in_username iscsi_in_password
     local iscsi_iface_name iscsi_netdev_name
-    local iscsi_param
+    local iscsi_param param
     local p
 
     # override conf settings by command line options
@@ -100,6 +108,15 @@ handle_netroot()
         ip route get "$iscsi_target_ip" >/dev/null 2>&1 || return 0
     fi
 
+    #limit iscsistart login retries
+    if [[ ! "$iscsi_param" =~ "node.session.initial_login_retry_max" ]]; then
+        set_login_retries
+        retries=$?
+        if [ $retries -gt 0 ]; then
+            iscsi_param="${iscsi_param% } node.session.initial_login_retry_max=$retries"
+        fi
+    fi
+
 # XXX is this needed?
     getarg ro && iscsirw=ro
     getarg rw && iscsirw=rw
@@ -202,7 +219,7 @@ handle_netroot()
             [ -n "$iscsi_password" ] && $($COMMAND --name=node.session.auth.password --value=$iscsi_password)
             [ -n "$iscsi_in_username" ] && $($COMMAND --name=node.session.auth.username_in --value=$iscsi_in_username)
             [ -n "$iscsi_in_password" ] && $($COMMAND --name=node.session.auth.password_in --value=$iscsi_in_password)
-            [ -n "$iscsi_param" ] && $($COMMAND --name=${iscsi_param%=*} --value=${iscsi_param#*=}
+            [ -n "$iscsi_param" ] && for param in $iscsi_param; do $($COMMAND --name=${param%=*} --value=${param#*=}); done
         fi
     done
 
openSUSE Build Service is sponsored by