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 <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/390360
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2017-12-18 14:41:21 +09:00 committed by Jim Harris
parent 6e82aa5ace
commit b37d1b60f1
2 changed files with 5 additions and 3 deletions

View File

@ -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);

View File

@ -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']))