From 67496afe577d9bcf74d1100ac5216e05343930c8 Mon Sep 17 00:00:00 2001 From: Jens Remus Date: Tue, 4 Dec 2018 18:10:06 +0100 Subject: [PATCH] zdev: Report FC Endpoint Security of zfcp devices MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support to report Fibre Channel (FC) Endpoint Security related information for zfcp-host and zfcp-lun devices. Allow to query (lszdev) and provide help for (chzdev) the FC Endpoint Security capability of a FCP device (zfcp-host). Provide this information by defining the FCP device attribute fc_security in zdev zfcp-host. Allow to query (lszdev) and provide help for (chzdev) the FC Endpoint Security in use on a connection between a FCP device and a FC remote port. Provide this information by introducing a virtual zdev zfcp-lun attribute fc_security. It returns the fc_security attribute value of the zfcp port object representing the FC remote port used to access the LUN. This approach allows users of lszdev to easily query the FC Endpoint Security in use on the connections to one or more FCP LUNs. It also does not require the effort to introduce a zfcp-port device type in zdev. The fc_security attribute help for both zfcp-host and zfcp-lun can be queried for example as follows: chzdev zfcp --help-attribute The fc_security attribute values and path of all active zfcp devices can be queried for example as follows: lszdev zfcp -a -c TYPE,ID,ATTR:fc_security,ATTRPATH:fc_security Signed-off-by: Jens Remus Reviewed-by: Peter Oberparleiter Reviewed-by: Steffen Maier Reviewed-by: Fedor Loshakov Reviewed-by: Benjamin Block Signed-off-by: Jan Höppner --- zdev/src/zfcp_host.c | 22 ++++++++++++++++++++++ zdev/src/zfcp_lun.c | 26 ++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/zdev/src/zfcp_host.c b/zdev/src/zfcp_host.c index 0fc87491..14e5ec5e 100644 --- a/zdev/src/zfcp_host.c +++ b/zdev/src/zfcp_host.c @@ -70,6 +70,27 @@ static struct attrib zfcp_host_attr_port_rescan = { .accept = ACCEPT_ARRAY(ACCEPT_NUM(1)), }; +static struct attrib zfcp_host_attr_fc_security = { + .name = "fc_security", + .title = "Show FC Endpoint Security capability of FCP device", + .desc = + "This read-only attribute shows the Fibre Channel Endpoint Security\n" + "capabilities of the FCP device.\n" + "\n" + "Possible values are either one of the following:\n" + " unknown : The Fibre Channel Endpoint Security capabilities\n" + " of the FCP device are not known\n" + " unsupported : The FCP device does not support Fibre Channel\n" + " Endpoint Security\n" + " none : The FCP device does not report any Fibre Channel\n" + " Endpoint Security capabilities\n" + "\n" + "Or one or more comma-separated values:\n" + " Authentication: The FCP device supports authentication\n" + " Encryption : The FCP device supports encryption\n", + .readonly = 1, +}; + /* * zfcp host methods. */ @@ -248,6 +269,7 @@ struct subtype zfcp_host_subtype = { &zfcp_host_attr_failed, &zfcp_host_attr_port_remove, &zfcp_host_attr_port_rescan, + &zfcp_host_attr_fc_security, &internal_attr_early, ), .unknown_dev_attribs = 1, diff --git a/zdev/src/zfcp_lun.c b/zdev/src/zfcp_lun.c index f73acf00..33bceca3 100644 --- a/zdev/src/zfcp_lun.c +++ b/zdev/src/zfcp_lun.c @@ -33,6 +33,7 @@ #include "zfcp_lun.h" #define DEVNAME "zFCP LUN" +#define FC_SECURITY_VATTR "fc_security" /* * zfcp lun namespace. @@ -415,6 +416,24 @@ static struct attrib zfcp_lun_attr_scsi_delete = { .accept = ACCEPT_ARRAY(ACCEPT_NUM(1)), }; +static struct attrib zfcp_lun_attr_fc_security = { + .name = FC_SECURITY_VATTR, + .title = "Show FC Endpoint Security state of connection", + .desc = + "This read-only attribute shows the current state of Fibre Channel\n" + "Endpoint Security of the connection between the FCP device and the\n" + "FC remote port used to access the LUN:\n" + " unknown : The Fibre Channel Endpoint Security state of the\n" + " connection is not known\n" + " unsupported : The FCP device does not support Fibre Channel\n" + " Endpoint Security\n" + " none : The connection has no Fibre Channel Endpoint\n" + " Security\n" + " Authentication: The connection has been authenticated\n" + " Encryption : The connection is encrypted\n", + .readonly = 1, +}; + /* * zfcp lun device methods. */ @@ -770,6 +789,12 @@ static char *zfcp_lun_st_get_active_attrib_path(struct subtype *st, free(hctl); name += strlen(SCSI_ATTR_PREFIX); + } else if (strcmp(name, FC_SECURITY_VATTR) == 0) { + devpath = path_get_zfcp_port_dev(dev->devid); + if (!util_path_exists(devpath)) { + free(devpath); + return NULL; + } } else { devpath = path_get_zfcp_lun_dev(dev->devid); } @@ -1101,6 +1126,7 @@ struct subtype zfcp_lun_subtype = { &zfcp_lun_attr_scsi_timeout, &zfcp_lun_attr_scsi_state, &zfcp_lun_attr_scsi_delete, + &zfcp_lun_attr_fc_security, &internal_attr_early, ), .prefixes = STRING_ARRAY(SCSI_ATTR_PREFIX),