open-iscsi/0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch

51 lines
1.8 KiB
Diff
Raw Normal View History

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