iscsi/rpc: Convert type of data/header digest params of target from int to bool

This is a TODO from long ago. Complete this while adjusting dump()
and construct() format of target.

Change-Id: I44348ec404cae8882086a1a71a65914c9bafccc3
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/400202
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2018-02-21 18:47:34 +09:00 committed by Jim Harris
parent 4578890716
commit b94ba1ee7a
5 changed files with 25 additions and 30 deletions

View File

@ -409,10 +409,10 @@ dump_target_node(struct spdk_json_write_ctx *w, struct spdk_iscsi_tgt_node *tgtn
spdk_json_write_int32(w, tgtnode->auth_group);
spdk_json_write_name(w, "header_digest");
spdk_json_write_int32(w, tgtnode->header_digest);
spdk_json_write_bool(w, tgtnode->header_digest);
spdk_json_write_name(w, "data_digest");
spdk_json_write_int32(w, tgtnode->data_digest);
spdk_json_write_bool(w, tgtnode->data_digest);
spdk_json_write_object_end(w);
}
@ -541,8 +541,8 @@ struct rpc_target_node {
int32_t chap_mutual;
int32_t chap_auth_group;
int32_t header_digest;
int32_t data_digest;
bool header_digest;
bool data_digest;
};
static void
@ -563,8 +563,8 @@ static const struct spdk_json_object_decoder rpc_target_node_decoders[] = {
{"chap_required", offsetof(struct rpc_target_node, chap_required), spdk_json_decode_int32},
{"chap_mutual", offsetof(struct rpc_target_node, chap_mutual), spdk_json_decode_int32},
{"chap_auth_group", offsetof(struct rpc_target_node, chap_auth_group), spdk_json_decode_int32},
{"header_digest", offsetof(struct rpc_target_node, header_digest), spdk_json_decode_int32, true},
{"data_digest", offsetof(struct rpc_target_node, data_digest), spdk_json_decode_int32, true},
{"header_digest", offsetof(struct rpc_target_node, header_digest), spdk_json_decode_bool, true},
{"data_digest", offsetof(struct rpc_target_node, data_digest), spdk_json_decode_bool, true},
};
static void
@ -579,9 +579,6 @@ spdk_rpc_construct_target_node(struct spdk_jsonrpc_request *request,
int32_t lun_ids[RPC_CONSTRUCT_TARGET_NODE_MAX_LUN] = {0};
size_t i;
req.header_digest = 0;
req.data_digest = 0;
if (spdk_json_decode_object(params, rpc_target_node_decoders,
SPDK_COUNTOF(rpc_target_node_decoders),
&req)) {
@ -603,7 +600,6 @@ spdk_rpc_construct_target_node(struct spdk_jsonrpc_request *request,
* Use default parameters in a few places:
* index = -1 : automatically pick an index for the new target node
* alias = NULL
* 0, 0 = disable header/data digests
*/
target = spdk_iscsi_tgt_node_construct(-1, req.name, req.alias_name,
pg_tags,

View File

@ -868,7 +868,7 @@ spdk_iscsi_tgt_node_construct(int target_index,
const char *bdev_name_list[], int *lun_id_list, int num_luns,
int queue_depth,
int auth_chap_disabled, int auth_chap_required, int auth_chap_mutual, int auth_group,
int header_digest, int data_digest)
bool header_digest, bool data_digest)
{
char fullname[MAX_TMPBUF];
struct spdk_iscsi_tgt_node *target;
@ -990,7 +990,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
const char *ag_tag;
const char *val, *name;
int target_num, auth_group, pg_tag_i, ig_tag_i;
int header_digest, data_digest;
bool header_digest, data_digest;
int auth_chap_disabled, auth_chap_required, auth_chap_mutual;
int i;
int lun_id_list[SPDK_SCSI_DEV_MAX_LUN];
@ -1001,8 +1001,8 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "add unit %d\n", target_num);
data_digest = 0;
header_digest = 0;
data_digest = false;
header_digest = false;
name = spdk_conf_section_get_val(sp, "TargetName");
@ -1131,19 +1131,19 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp)
break;
}
if (strcasecmp(val, "Header") == 0) {
header_digest = 1;
header_digest = true;
} else if (strcasecmp(val, "Data") == 0) {
data_digest = 1;
data_digest = true;
} else if (strcasecmp(val, "Auto") == 0) {
header_digest = 0;
data_digest = 0;
header_digest = false;
data_digest = false;
} else {
SPDK_ERRLOG("tgt_node%d: unknown digest\n", target_num);
return -1;
}
}
}
if (header_digest == 0 && data_digest == 0) {
if (!header_digest && !data_digest) {
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "UseDigest Auto\n");
} else {
SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "UseDigest %s %s\n",

View File

@ -70,8 +70,8 @@ struct spdk_iscsi_tgt_node {
int auth_chap_required;
int auth_chap_mutual;
int auth_group;
int header_digest;
int data_digest;
bool header_digest;
bool data_digest;
int queue_depth;
struct spdk_scsi_dev *dev;
@ -113,7 +113,7 @@ spdk_iscsi_tgt_node_construct(int target_index,
const char *bdev_name_list[], int *lun_id_list, int num_luns,
int queue_depth,
int no_auth_chap, int auth_chap, int auth_chap_mutual, int auth_group,
int header_digest, int data_digest);
bool header_digest, bool data_digest);
int spdk_iscsi_tgt_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target,
int *pg_tag_list, int *ig_tag_list,

View File

@ -142,10 +142,10 @@ if __name__ == "__main__":
'chap_mutual', help='CHAP authentication should be mutual/bidirectional.', type=int)
p.add_argument('chap_auth_group', help="""Authentication group ID for this target node.
*** Authentication group must be precreated ***""", type=int)
p.add_argument('-H', dest='header_digest',
help='Header Digest should be required for this target node.', type=int, required=False)
p.add_argument('-D', dest='data_digest',
help='Data Digest should be required for this target node.', type=int, required=False)
p.add_argument('-H', '--header-digest',
help='Header Digest should be required for this target node.', action='store_true')
p.add_argument('-D', '--data-digest',
help='Data Digest should be required for this target node.', action='store_true')
p.set_defaults(func=rpc.iscsi.construct_target_node)
p = subparsers.add_parser('target_node_add_lun', help='Add LUN to the target node')

View File

@ -26,8 +26,8 @@ rpc_param = {
'chap_mutal': 0,
'chap_required': 0,
'chap_auth_group': 0,
'header_digest': 0,
'data_digest': 0,
'header_digest': False,
'data_digest': False,
'trace_flag': 'rpc',
'cpumask': 0x1
}
@ -334,8 +334,7 @@ def verify_target_nodes_rpc_methods(rpc_py, rpc_param):
lun_mapping = "Malloc" + str(rpc_param['lun_total']) + ":0"
net_mapping = portal_tag + ":" + initiator_tag
rpc.construct_target_node(rpc_param['target_name'], rpc_param['alias_name'], lun_mapping, net_mapping, rpc_param['queue_depth'],
rpc_param['chap_disable'], rpc_param['chap_mutal'], rpc_param['chap_required'], rpc_param['chap_auth_group'],
"-H", rpc_param['header_digest'], "-D", rpc_param['data_digest'])
rpc_param['chap_disable'], rpc_param['chap_mutal'], rpc_param['chap_required'], rpc_param['chap_auth_group'])
output = rpc.get_target_nodes()
jsonvalues = json.loads(output)
verify(len(jsonvalues) == 1, 1,