Skip to contentSkip to conversation

This patch filled the host WWNN. when using the command of multipathd to list the isscsi paths informartion, the host WWNN of paths informartion is not exist. like this: multipathd show paths format "%N %R" host WWNN host WWPN [undef] iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::1020002:129.13.100.240 [undef] iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::20003:129.13.100.241

PATCH New s90006763 1 participant 1 message Aug 24, 2018 Device mapper

lore
Share & tools
lore

s90006763

author
#0 lore raw

PATCH 1/1 This patch filled the host WWNN. when using the command of multipathd to list the isscsi paths informartion, the host WWNN of paths informartion is not exist. like this: multipathd show paths format "%N %R" host WWNN host WWPN [undef] iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::1020002:129.13.100.240 [undef] iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::20003:129.13.100.241

this patch solved this problem and filled the host WWNN.
like this:
multipathd show paths format "%N %R"
host WWNN host WWPN
iqn.1994-05.com.redhat:86329aefccdb iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::1020002:129.13.100.240 iqn.1994-05.com.redhat:86329aefccdb iqn.2006-08.com.huawei:oceanstor:21000022a10beb2a::20003:129.13.100.241

---
 libmultipath/print.c | 52 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 39 insertions(+), 13 deletions(-)
libmultipath/print.c +39 -13
index 9da6a77c..e2b90301 100644
@@ -539,20 +539,39 @@ snprint_host_attr (char * buff, size_t len, const struct path * pp, char *attr)
 	char host_id[32];
 	const char *value = NULL;
 	int ret;
-
-	if (pp->sg_id.proto_id != SCSI_PROTOCOL_FCP)
+    
+	if ((pp->sg_id.proto_id != SCSI_PROTOCOL_FCP) && (pp->sg_id.proto_id != SCSI_PROTOCOL_ISCSI) )
 		return snprintf(buff, len, "[undef]");
-	sprintf(host_id, "host%d", pp->sg_id.host_no);
-	host_dev = udev_device_new_from_subsystem_sysname(udev, "fc_host",
-							  host_id);
-	if (!host_dev) {
-		condlog(1, "%s: No fc_host device for '%s'", pp->dev, host_id);
-		goto out;
+	if((pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI) && strcmp(buff, wwid) == 0)
+		
+    if(pp->sg_id.proto_id == SCSI_PROTOCOL_FCP)
+    {
+		sprintf(host_id, "host%d", pp->sg_id.host_no);
+		host_dev = udev_device_new_from_subsystem_sysname(udev, "fc_host",
+								  host_id);
+		if (!host_dev) {
+			condlog(1, "%s: No fc_host device for '%s'", pp->dev, host_id);
+			goto out;
+		}
+		value = udev_device_get_sysattr_value(host_dev, attr);
+		if (value)
+			ret = snprint_str(buff, len, value);
+		udev_device_unref(host_dev);
+    }
+	else if(pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
+	{
+	    sprintf(host_id, "session%d", pp->sg_id.transport_id);
+		host_dev = udev_device_new_from_subsystem_sysname(udev, "iscsi_session",
+								  host_id);
+		if (!host_dev) {
+			condlog(3, "%s: No iscsi_session for '%s'", pp->dev, host_id);
+			goto out;
+		}
+		value = udev_device_get_sysattr_value(host_dev, attr);
+		if (value)
+			ret = snprint_str(buff, len, value);
+		udev_device_unref(host_dev);
 	}
-	value = udev_device_get_sysattr_value(host_dev, attr);
-	if (value)
-		ret = snprint_str(buff, len, value);
-	udev_device_unref(host_dev);
 out:
 	if (!value)
 		ret = snprintf(buff, len, "[unknown]");
@@ -562,7 +581,14 @@ out:
 int
 snprint_host_wwnn (char * buff, size_t len, const struct path * pp)
 {
-	return snprint_host_attr(buff, len, pp, "node_name");
+	if(pp->sg_id.proto_id == SCSI_PROTOCOL_ISCSI)
+	{
+	    return snprint_host_attr(buff, len, pp, "initiatorname");
+	}
+	else
+	{
+		return snprint_host_attr(buff, len, pp, "node_name");
+	}
 }
 
 int
Signature · 1 line
2.12.0.windows.1