[PATCH RFC] fcping: allow pings using FC_BSG_RPT_ELS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



fcping uses FC-ELS to perform pings. FC ELS is a host as well as rport
service, so allow the rport version of the BSG ioctl() as well as the
host version.

Signed-off-by: Johannes Thumshirn <jthumshirn@xxxxxxx>
---
 fcping.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/fcping.c b/fcping.c
index bf2bc0f..3bc7fe6 100644
--- a/fcping.c
+++ b/fcping.c
@@ -471,6 +471,7 @@ fp_find_hba(void)
 	char *endptr;
 	uint32_t fcid;
 	int hba_cnt;
+	int hostno, chan, num;
 
 	hba_cnt = get_number_of_adapters();
 	if (!hba_cnt)
@@ -495,6 +496,16 @@ fp_find_hba(void)
 		if (*endptr != '\0')
 			SA_LOG_EXIT("invalid hba name %s", fp_hba);
 		host = strdup(fp_hba);
+	} else if (sscanf(fp_hba, "rport-%d:%d-%d", &hostno, &chan, &num)) {
+		char *rport = strdup(fp_hba);
+		port_attrs = get_rport_attribs(rport);
+		if (!port_attrs) {
+			free(rport);
+			return 0;
+		}
+		strncpy(fp_dev, rport, sizeof(fp_dev));
+		free(rport);
+		return 1;
 	} else if (strstr(fp_hba, ":")) {
 		if (strlen(fp_hba) == strlen("xx:yy:aa:bb:cc:dd:ee:ff")) {
 			fc_wwn_t wwn1;
@@ -826,10 +837,16 @@ send_els_echo(int fp_fd, void *fp_buf, uint32_t fp_len,
 {
 	struct fc_bsg_request cdb;
 	char sense[MAX_SENSE_LEN];
+	char *rport;
 	struct sg_io_v4 sg_io;
 	int rc;
 
-	cdb.msgcode = FC_BSG_HST_ELS_NOLOGIN;
+	rport = get_rport_by_fcid(fp_did);
+	if (rport)
+		cdb.msgcode = FC_BSG_RPT_ELS;
+	else
+		cdb.msgcode = FC_BSG_HST_ELS_NOLOGIN;
+
 	cdb.rqst_data.h_els.command_code = ELS_ECHO;
 	hton24(cdb.rqst_data.h_els.port_id, fp_did);
 
-- 
2.10.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux