|
|
877c8e |
From 3f8029f837ef6680e280eb700d5930c1b38dbc27 Mon Sep 17 00:00:00 2001
|
|
|
877c8e |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
877c8e |
Date: Thu, 7 Apr 2016 13:33:14 +0200
|
|
|
877c8e |
Subject: [PATCH 1/2] Discovery: return multiple portals for the same
|
|
|
877c8e |
discovered target
|
|
|
877c8e |
|
|
|
877c8e |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
877c8e |
Message-id: <1460035995-9887-2-git-send-email-pbonzini@redhat.com>
|
|
|
877c8e |
Patchwork-id: 69977
|
|
|
877c8e |
O-Subject: [RHEL7.3 libiscsi PATCH 1/2] Discovery: return multiple portals for the same discovered target
|
|
|
877c8e |
Bugzilla: 1266523
|
|
|
877c8e |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
877c8e |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
877c8e |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
877c8e |
|
|
|
877c8e |
Some targets return multiple TargetAddress for individual targets.
|
|
|
877c8e |
Upstream added a list of addresses for each target, here we do not
|
|
|
877c8e |
want to break the ABI and thus return the same target name multiple
|
|
|
877c8e |
times. Either way, failing the discovery is wrong.
|
|
|
877c8e |
|
|
|
877c8e |
The patch is very different from upstream commit
|
|
|
877c8e |
354f00fd4f63abec86ed0b9b64db1933936283b0, but the effect on
|
|
|
877c8e |
the operation of iscsi-ls is the same.
|
|
|
877c8e |
|
|
|
877c8e |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
877c8e |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
877c8e |
---
|
|
|
877c8e |
lib/discovery.c | 30 +++++++++++++++++++++++++++++-
|
|
|
877c8e |
1 file changed, 29 insertions(+), 1 deletion(-)
|
|
|
877c8e |
|
|
|
877c8e |
diff --git a/lib/discovery.c b/lib/discovery.c
|
|
|
877c8e |
index b5d918b..e504cf8 100644
|
|
|
877c8e |
--- a/lib/discovery.c
|
|
|
877c8e |
+++ b/lib/discovery.c
|
|
|
877c8e |
@@ -162,7 +162,7 @@ iscsi_process_text_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|
|
877c8e |
target->next = targets;
|
|
|
877c8e |
targets = target;
|
|
|
877c8e |
} else if (!strncmp((char *)ptr, "TargetAddress=", 14)) {
|
|
|
877c8e |
- if (targets == NULL || targets->target_address != NULL) {
|
|
|
877c8e |
+ if (targets == NULL) {
|
|
|
877c8e |
iscsi_set_error(iscsi, "Invalid discovery "
|
|
|
877c8e |
"reply");
|
|
|
877c8e |
pdu->callback(iscsi, SCSI_STATUS_ERROR, NULL,
|
|
|
877c8e |
@@ -170,6 +170,34 @@ iscsi_process_text_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
|
|
|
877c8e |
iscsi_free_discovery_addresses(iscsi, targets);
|
|
|
877c8e |
return -1;
|
|
|
877c8e |
}
|
|
|
877c8e |
+ if (targets->target_address != NULL) {
|
|
|
877c8e |
+ struct iscsi_discovery_address *target;
|
|
|
877c8e |
+
|
|
|
877c8e |
+ target = iscsi_zmalloc(iscsi, sizeof(struct iscsi_discovery_address));
|
|
|
877c8e |
+ if (target == NULL) {
|
|
|
877c8e |
+ iscsi_set_error(iscsi, "Failed to allocate "
|
|
|
877c8e |
+ "data for new discovered "
|
|
|
877c8e |
+ "target");
|
|
|
877c8e |
+ pdu->callback(iscsi, SCSI_STATUS_ERROR, NULL,
|
|
|
877c8e |
+ pdu->private_data);
|
|
|
877c8e |
+ iscsi_free_discovery_addresses(iscsi, targets);
|
|
|
877c8e |
+ return -1;
|
|
|
877c8e |
+ }
|
|
|
877c8e |
+ target->target_name = iscsi_strdup(iscsi, targets->target_name);
|
|
|
877c8e |
+ if (target->target_name == NULL) {
|
|
|
877c8e |
+ iscsi_set_error(iscsi, "Failed to allocate "
|
|
|
877c8e |
+ "data for new discovered "
|
|
|
877c8e |
+ "target name");
|
|
|
877c8e |
+ pdu->callback(iscsi, SCSI_STATUS_ERROR, NULL,
|
|
|
877c8e |
+ pdu->private_data);
|
|
|
877c8e |
+ iscsi_free(iscsi, target);
|
|
|
877c8e |
+ target = NULL;
|
|
|
877c8e |
+ iscsi_free_discovery_addresses(iscsi, targets);
|
|
|
877c8e |
+ return -1;
|
|
|
877c8e |
+ }
|
|
|
877c8e |
+ target->next = targets;
|
|
|
877c8e |
+ targets = target;
|
|
|
877c8e |
+ }
|
|
|
877c8e |
targets->target_address = iscsi_strdup(iscsi, (char *)ptr+14);
|
|
|
877c8e |
if (targets->target_address == NULL) {
|
|
|
877c8e |
iscsi_set_error(iscsi, "Failed to allocate "
|
|
|
877c8e |
--
|
|
|
877c8e |
1.8.3.1
|
|
|
877c8e |
|