Blame SOURCES/open-iscsi-2.0.876-67-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch

62f653
commit 7df5edbb427c79337bdd651c2bcdda8eb05f077b
62f653
Author: Lee Duncan <lduncan@suse.com>
62f653
Date:   Mon Sep 24 16:30:34 2018 -0700
62f653
62f653
    Fix incorrect sysfs logic for port and ip address.
62f653
    
62f653
    If "port" is available and "persistent_port" is not, then
62f653
    correctly use the one that is present for both values.
62f653
    Likewise for "address" and "persistent_address".
62f653
---
62f653
 libopeniscsiusr/session.c | 18 ++++++++----------
62f653
 1 file changed, 8 insertions(+), 10 deletions(-)
62f653
62f653
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c
62f653
index f8c89c323afb..98601dcf807e 100644
62f653
--- a/libopeniscsiusr/session.c
62f653
+++ b/libopeniscsiusr/session.c
62f653
@@ -208,22 +208,20 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
62f653
 	_sysfs_prop_get_i32(ctx, sysfs_con_dir_path, "port",
62f653
 			    &((*se)->port), -1, true);
62f653
 
62f653
-	if ((strcmp((*se)->address, "") == 0) &&
62f653
-	    (strcmp((*se)->persistent_address, "") != 0))
62f653
-		_strncpy((*se)->persistent_address, (*se)->address,
62f653
-			 sizeof((*se)->persistent_address) / sizeof(char));
62f653
-
62f653
 	if ((strcmp((*se)->address, "") != 0) &&
62f653
 	    (strcmp((*se)->persistent_address, "") == 0))
62f653
+		_strncpy((*se)->persistent_address, (*se)->address,
62f653
+			 sizeof((*se)->persistent_address) / sizeof(char));
62f653
+	else if ((strcmp((*se)->address, "") == 0) &&
62f653
+	    (strcmp((*se)->persistent_address, "") != 0))
62f653
 		_strncpy((*se)->address, (*se)->persistent_address,
62f653
 			 sizeof((*se)->address) / sizeof(char));
62f653
 
62f653
-	if (((*se)->persistent_port != -1) &&
62f653
-	    ((*se)->port == -1))
62f653
+	if (((*se)->persistent_port == -1) &&
62f653
+	    ((*se)->port != -1))
62f653
 		(*se)->persistent_port = (*se)->port;
62f653
-
62f653
-	if (((*se)->persistent_port != -1) &&
62f653
-	    ((*se)->port == -1))
62f653
+	else if (((*se)->persistent_port != -1) &&
62f653
+		 ((*se)->port == -1))
62f653
 		(*se)->port = (*se)->persistent_port;
62f653
 
62f653
 	_good(_iscsi_host_id_of_session(ctx, sid, &host_id), rc, out);