From b37d1b60f11d25f921e51e4eee905f8326fc3722 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Mon, 18 Dec 2017 14:41:21 +0900 Subject: [PATCH] scsi&test/iscsi_tgt: SCSI device == iSCSI name In the iSCSI specification, the SCSI device name is defined to be the iSCSI name of the node. However, when g_spdk_iscsi.nodebase is used, the SCSI device name is made of the device specific string (the part of IQN after the colon). The size of the temporary buffer fullname[MAX_TMPBUF] in spdk_iscsi_tgt_node_construct() is 1024 and the size of spdk_scsi_dev.name is 255. The former is larger than the later. However the max length of IQN, EUI, NAA are 223, 20, and 36, respectively. All are less than 255. Hence even if we use fullname as the SCSI device name, no overflow will occur. Even if fullname is more than 255, strncpy() does not write more than 255 in spdk_scsi_dev_construct(). It's possible to check the length of iSCSI name strictly, but I will do the least in this patch. Change-Id: Icc6655fcd846797720867c10e316d2951c664030 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/390360 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/iscsi/tgt_node.c | 3 +-- test/iscsi_tgt/rpc_config/rpc_config.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/iscsi/tgt_node.c b/lib/iscsi/tgt_node.c index 6c93a0bca..6f165be0f 100644 --- a/lib/iscsi/tgt_node.c +++ b/lib/iscsi/tgt_node.c @@ -920,9 +920,8 @@ spdk_iscsi_tgt_node_construct(int target_index, } } - target->dev = spdk_scsi_dev_construct(name, lun_name_list, lun_id_list, num_luns, + target->dev = spdk_scsi_dev_construct(fullname, lun_name_list, lun_id_list, num_luns, SPDK_SPC_PROTOCOL_IDENTIFIER_ISCSI, NULL, NULL); - if (!target->dev) { SPDK_ERRLOG("Could not construct SCSI device\n"); spdk_iscsi_tgt_node_destruct(target); diff --git a/test/iscsi_tgt/rpc_config/rpc_config.py b/test/iscsi_tgt/rpc_config/rpc_config.py index f70af5e60..41f8552b8 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.py +++ b/test/iscsi_tgt/rpc_config/rpc_config.py @@ -138,9 +138,12 @@ def verify_scsi_devices_rpc_methods(rpc_py): check_output('iscsiadm -m discovery -t st -p {}'.format(rpc_param['target_ip']), shell=True) check_output('iscsiadm -m node --login', shell=True) name = json.loads(rpc.get_target_nodes())[0]['name'] + output = rpc.get_iscsi_global_params() + jsonvalues = json.loads(output) + nodebase = jsonvalues['node_base'] output = rpc.get_scsi_devices() jsonvalues = json.loads(output) - verify(jsonvalues[0]['device_name'] == rpc_param['target_name'], 1, + verify(jsonvalues[0]['device_name'] == nodebase + ":" + rpc_param['target_name'], 1, "device name vaule is {}, expected {}".format(jsonvalues[0]['device_name'], rpc_param['target_name'])) verify(jsonvalues[0]['id'] == 0, 1, "device id value is {}, expected 0".format(jsonvalues[0]['id']))