From 36fc9b2d09aa8b460087aa56edc7d572440f152f Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 22 Feb 2018 02:51:16 +0900 Subject: [PATCH] iscsi/rpc: Convert type of CHAP params of target from int to bool This is a TODO from long ago. Complete this while adjusting dump() and construct() format of target. Besides names of variables and parameters about CHAP are not unified between JSON-RPC and SPDK internal. JSON-RPC's wording looks better and adjust SPDK internal to JSON-RPC. Change-Id: I89bcd1ce13a11f7d63a62d51ef094dd302186d37 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/400201 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- lib/iscsi/iscsi_rpc.c | 42 +++++++++---------- lib/iscsi/tgt_node.c | 40 +++++++++--------- lib/iscsi/tgt_node.h | 8 ++-- scripts/rpc.py | 14 +++---- scripts/rpc/iscsi.py | 12 ++++-- test/iscsi_tgt/calsoft/calsoft.sh | 2 +- test/iscsi_tgt/digests/digests.sh | 2 +- test/iscsi_tgt/ext4test/ext4test.sh | 4 +- test/iscsi_tgt/filesystem/filesystem.sh | 2 +- test/iscsi_tgt/fio/fio.sh | 2 +- test/iscsi_tgt/ip_migration/ip_migration.sh | 4 +- test/iscsi_tgt/lvol/iscsi_lvol.sh | 2 +- .../multiconnection/multiconnection.sh | 2 +- test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh | 2 +- test/iscsi_tgt/pmem/iscsi_pmem.sh | 2 +- test/iscsi_tgt/rbd/rbd.sh | 2 +- test/iscsi_tgt/reset/reset.sh | 2 +- test/iscsi_tgt/rpc_config/rpc_config.py | 36 +++++++--------- test/unit/lib/iscsi/tgt_node.c/tgt_node_ut.c | 24 +++++------ 19 files changed, 100 insertions(+), 104 deletions(-) diff --git a/lib/iscsi/iscsi_rpc.c b/lib/iscsi/iscsi_rpc.c index c7eb68105..d9adbff53 100644 --- a/lib/iscsi/iscsi_rpc.c +++ b/lib/iscsi/iscsi_rpc.c @@ -392,20 +392,16 @@ dump_target_node(struct spdk_json_write_ctx *w, struct spdk_iscsi_tgt_node *tgtn spdk_json_write_name(w, "queue_depth"); spdk_json_write_int32(w, tgtnode->queue_depth); - /* - * TODO: convert these to bool - */ + spdk_json_write_name(w, "disable_chap"); + spdk_json_write_bool(w, tgtnode->auth_chap_disabled); - spdk_json_write_name(w, "chap_disabled"); - spdk_json_write_int32(w, tgtnode->auth_chap_disabled); + spdk_json_write_name(w, "require_chap"); + spdk_json_write_bool(w, tgtnode->auth_chap_required); - spdk_json_write_name(w, "chap_required"); - spdk_json_write_int32(w, tgtnode->auth_chap_required); + spdk_json_write_name(w, "mutual_chap"); + spdk_json_write_bool(w, tgtnode->auth_chap_mutual); - spdk_json_write_name(w, "chap_mutual"); - spdk_json_write_int32(w, tgtnode->auth_chap_mutual); - - spdk_json_write_name(w, "chap_auth_group"); + spdk_json_write_name(w, "chap_group"); spdk_json_write_int32(w, tgtnode->auth_group); spdk_json_write_name(w, "header_digest"); @@ -536,10 +532,10 @@ struct rpc_target_node { struct rpc_luns luns; int32_t queue_depth; - int32_t chap_disabled; - int32_t chap_required; - int32_t chap_mutual; - int32_t chap_auth_group; + bool disable_chap; + bool require_chap; + bool mutual_chap; + int32_t chap_group; bool header_digest; bool data_digest; @@ -559,10 +555,10 @@ static const struct spdk_json_object_decoder rpc_target_node_decoders[] = { {"pg_ig_maps", offsetof(struct rpc_target_node, pg_ig_maps), decode_rpc_pg_ig_maps}, {"luns", offsetof(struct rpc_target_node, luns), decode_rpc_luns}, {"queue_depth", offsetof(struct rpc_target_node, queue_depth), spdk_json_decode_int32}, - {"chap_disabled", offsetof(struct rpc_target_node, chap_disabled), spdk_json_decode_int32}, - {"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}, + {"disable_chap", offsetof(struct rpc_target_node, disable_chap), spdk_json_decode_bool, true}, + {"require_chap", offsetof(struct rpc_target_node, require_chap), spdk_json_decode_bool, true}, + {"mutual_chap", offsetof(struct rpc_target_node, mutual_chap), spdk_json_decode_bool, true}, + {"chap_group", offsetof(struct rpc_target_node, chap_group), 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}, }; @@ -609,10 +605,10 @@ spdk_rpc_construct_target_node(struct spdk_jsonrpc_request *request, lun_ids, req.luns.num_luns, req.queue_depth, - req.chap_disabled, - req.chap_required, - req.chap_mutual, - req.chap_auth_group, + req.disable_chap, + req.require_chap, + req.mutual_chap, + req.chap_group, req.header_digest, req.data_digest); diff --git a/lib/iscsi/tgt_node.c b/lib/iscsi/tgt_node.c index 364ecc7c4..c99ced778 100644 --- a/lib/iscsi/tgt_node.c +++ b/lib/iscsi/tgt_node.c @@ -844,16 +844,16 @@ spdk_check_iscsi_name(const char *name) } static bool -spdk_iscsi_check_chap_params(int disabled, int required, int mutual, int group) +spdk_iscsi_check_chap_params(bool disabled, bool required, bool mutual, int group) { if (group < 0) { SPDK_ERRLOG("Invalid auth group ID (%d)\n", group); return false; } - if ((disabled == 0 && required == 0 && mutual == 0) || /* Auto */ - (disabled == 1 && required == 0 && mutual == 0) || /* None */ - (disabled == 0 && required == 1 && mutual == 0) || /* CHAP */ - (disabled == 0 && required == 1 && mutual == 1)) { /* CHAP Mutual */ + if ((!disabled && !required && !mutual) || /* Auto */ + (disabled && !required && !mutual) || /* None */ + (!disabled && required && !mutual) || /* CHAP */ + (!disabled && required && mutual)) { /* CHAP Mutual */ return true; } SPDK_ERRLOG("Invalid combination of CHAP params (d=%d,r=%d,m=%d)\n", @@ -867,7 +867,7 @@ spdk_iscsi_tgt_node_construct(int target_index, int *pg_tag_list, int *ig_tag_list, uint16_t num_maps, 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, + bool auth_chap_disabled, bool auth_chap_required, bool auth_chap_mutual, int auth_group, bool header_digest, bool data_digest) { char fullname[MAX_TMPBUF]; @@ -991,7 +991,7 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp) const char *val, *name; int target_num, auth_group, pg_tag_i, ig_tag_i; bool header_digest, data_digest; - int auth_chap_disabled, auth_chap_required, auth_chap_mutual; + bool auth_chap_disabled, auth_chap_required, auth_chap_mutual; int i; int lun_id_list[SPDK_SCSI_DEV_MAX_LUN]; const char *bdev_name_list[SPDK_SCSI_DEV_MAX_LUN]; @@ -1056,9 +1056,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp) /* Setup AuthMethod */ val = spdk_conf_section_get_val(sp, "AuthMethod"); - auth_chap_disabled = 0; - auth_chap_required = 0; - auth_chap_mutual = 0; + auth_chap_disabled = false; + auth_chap_required = false; + auth_chap_mutual = false; if (val != NULL) { for (i = 0; ; i++) { val = spdk_conf_section_get_nmval(sp, "AuthMethod", 0, i); @@ -1066,17 +1066,17 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp) break; } if (strcasecmp(val, "CHAP") == 0) { - auth_chap_required = 1; + auth_chap_required = true; } else if (strcasecmp(val, "Mutual") == 0) { - auth_chap_mutual = 1; + auth_chap_mutual = true; } else if (strcasecmp(val, "Auto") == 0) { - auth_chap_disabled = 0; - auth_chap_required = 0; - auth_chap_mutual = 0; + auth_chap_disabled = false; + auth_chap_required = false; + auth_chap_mutual = false; } else if (strcasecmp(val, "None") == 0) { - auth_chap_disabled = 1; - auth_chap_required = 0; - auth_chap_mutual = 0; + auth_chap_disabled = true; + auth_chap_required = false; + auth_chap_mutual = false; } else { SPDK_ERRLOG("tgt_node%d: unknown auth\n", target_num); return -1; @@ -1087,9 +1087,9 @@ spdk_cf_add_iscsi_tgt_node(struct spdk_conf_section *sp) return -1; } } - if (auth_chap_disabled == 1) { + if (auth_chap_disabled) { SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod None\n"); - } else if (auth_chap_required == 0) { + } else if (!auth_chap_required) { SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod Auto\n"); } else { SPDK_DEBUGLOG(SPDK_LOG_ISCSI, "AuthMethod CHAP %s\n", diff --git a/lib/iscsi/tgt_node.h b/lib/iscsi/tgt_node.h index 108b717f9..c617aea3f 100644 --- a/lib/iscsi/tgt_node.h +++ b/lib/iscsi/tgt_node.h @@ -66,9 +66,9 @@ struct spdk_iscsi_tgt_node { pthread_mutex_t mutex; - int auth_chap_disabled; - int auth_chap_required; - int auth_chap_mutual; + bool auth_chap_disabled; + bool auth_chap_required; + bool auth_chap_mutual; int auth_group; bool header_digest; bool data_digest; @@ -112,7 +112,7 @@ spdk_iscsi_tgt_node_construct(int target_index, int *pg_tag_list, int *ig_tag_list, uint16_t num_maps, 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, + bool no_auth_chap, bool auth_chap, bool auth_chap_mutual, int auth_group, bool header_digest, bool data_digest); int spdk_iscsi_tgt_node_add_pg_ig_maps(struct spdk_iscsi_tgt_node *target, diff --git a/scripts/rpc.py b/scripts/rpc.py index 964a03012..769859f6d 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -134,14 +134,14 @@ if __name__ == "__main__": Example: '1:1 2:2 2:1' *** The Portal/Initiator Groups must be precreated ***""") p.add_argument('queue_depth', help='Desired target queue depth', type=int) - p.add_argument('chap_disabled', help="""CHAP authentication should be disabled for this target node. - *** Mutually exclusive with chap_required ***""", type=int) - p.add_argument('chap_required', help="""CHAP authentication should be required for this target node. - *** Mutually exclusive with chap_disabled ***""", type=int) + p.add_argument('-g', '--chap-group', help="""Authentication group ID for this target node. + *** Authentication group must be precreated ***""", type=int, default=0) + p.add_argument('-d', '--disable-chap', help="""CHAP authentication should be disabled for this target node. + *** Mutually exclusive with --require-chap ***""", action='store_true') + p.add_argument('-r', '--require-chap', help="""CHAP authentication should be required for this target node. + *** Mutually exclusive with --disable-chap ***""", action='store_true') p.add_argument( - '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) + '-m', '--mutual-chap', help='CHAP authentication should be mutual/bidirectional.', action='store_true') 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', diff --git a/scripts/rpc/iscsi.py b/scripts/rpc/iscsi.py index 462da0ca5..3e06e767c 100755 --- a/scripts/rpc/iscsi.py +++ b/scripts/rpc/iscsi.py @@ -34,12 +34,16 @@ def construct_target_node(args): 'pg_ig_maps': pg_ig_maps, 'luns': luns, 'queue_depth': args.queue_depth, - 'chap_disabled': args.chap_disabled, - 'chap_required': args.chap_required, - 'chap_mutual': args.chap_mutual, - 'chap_auth_group': args.chap_auth_group, } + if args.chap_group: + params['chap_group'] = args.chap_group + if args.disable_chap: + params['disable_chap'] = args.disable_chap + if args.require_chap: + params['require_chap'] = args.require_chap + if args.mutual_chap: + params['mutual_chap'] = args.mutual_chap if args.header_digest: params['header_digest'] = args.header_digest if args.data_digest: diff --git a/test/iscsi_tgt/calsoft/calsoft.sh b/test/iscsi_tgt/calsoft/calsoft.sh index e737c591a..dccd6d5e0 100755 --- a/test/iscsi_tgt/calsoft/calsoft.sh +++ b/test/iscsi_tgt/calsoft/calsoft.sh @@ -47,7 +47,7 @@ $rpc_py construct_malloc_bdev -b MyBdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "0 0 0 1" ==> enable CHAP authentication using auth group 1 -$rpc_py construct_target_node Target3 Target3_alias 'MyBdev:0' '1:2' 64 0 0 0 1 +$rpc_py construct_target_node Target3 Target3_alias 'MyBdev:0' '1:2' 64 -g 1 sleep 1 if [ "$1" ]; then diff --git a/test/iscsi_tgt/digests/digests.sh b/test/iscsi_tgt/digests/digests.sh index 25e86a2de..a733d96cd 100755 --- a/test/iscsi_tgt/digests/digests.sh +++ b/test/iscsi_tgt/digests/digests.sh @@ -96,7 +96,7 @@ $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 1 0 0 0 +$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/ext4test/ext4test.sh b/test/iscsi_tgt/ext4test/ext4test.sh index 02f164ca2..0ac3165dc 100755 --- a/test/iscsi_tgt/ext4test/ext4test.sh +++ b/test/iscsi_tgt/ext4test/ext4test.sh @@ -41,7 +41,7 @@ $rpc_py construct_error_bdev 'Malloc0' # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target0 Target0_alias EE_Malloc0:0 1:2 64 1 0 0 0 +$rpc_py construct_target_node Target0 Target0_alias EE_Malloc0:0 1:2 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT @@ -76,7 +76,7 @@ echo "Error injection test done" iscsicleanup if [ -z "$NO_NVME" ]; then -$rpc_py construct_target_node Target1 Target1_alias Nvme0n1:0 1:2 64 1 0 0 0 +$rpc_py construct_target_node Target1 Target1_alias Nvme0n1:0 1:2 64 -d fi iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/filesystem/filesystem.sh b/test/iscsi_tgt/filesystem/filesystem.sh index 674d5ad90..3247c68d2 100755 --- a/test/iscsi_tgt/filesystem/filesystem.sh +++ b/test/iscsi_tgt/filesystem/filesystem.sh @@ -37,7 +37,7 @@ $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 256 1 0 0 0 +$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 256 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/fio/fio.sh b/test/iscsi_tgt/fio/fio.sh index 1c794a074..953768a18 100755 --- a/test/iscsi_tgt/fio/fio.sh +++ b/test/iscsi_tgt/fio/fio.sh @@ -77,7 +77,7 @@ $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 1 0 0 0 +$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/ip_migration/ip_migration.sh b/test/iscsi_tgt/ip_migration/ip_migration.sh index 34a06d8cf..c1fbd7e70 100755 --- a/test/iscsi_tgt/ip_migration/ip_migration.sh +++ b/test/iscsi_tgt/ip_migration/ip_migration.sh @@ -61,7 +61,7 @@ done rpc_first_addr="/var/tmp/spdk0.sock" rpc_add_ip $rpc_first_addr $MIGRATION_ADDRESS $rpc_py -s $rpc_first_addr add_portal_group 1 $MIGRATION_ADDRESS:$PORT -$rpc_py -s $rpc_first_addr construct_target_node target1 target1_alias 'Malloc0:0' '1:1' 64 1 0 0 0 +$rpc_py -s $rpc_first_addr construct_target_node target1 target1_alias 'Malloc0:0' '1:1' 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $MIGRATION_ADDRESS:$PORT @@ -79,7 +79,7 @@ $rpc_py -s $rpc_first_addr kill_instance SIGTERM rpc_second_addr="/var/tmp/spdk1.sock" rpc_add_ip $rpc_second_addr $MIGRATION_ADDRESS $rpc_py -s $rpc_second_addr add_portal_group 1 $MIGRATION_ADDRESS:$PORT -$rpc_py -s $rpc_second_addr construct_target_node target1 target1_alias 'Malloc0:0' '1:1' 64 1 0 0 0 +$rpc_py -s $rpc_second_addr construct_target_node target1 target1_alias 'Malloc0:0' '1:1' 64 -d wait $fiopid diff --git a/test/iscsi_tgt/lvol/iscsi_lvol.sh b/test/iscsi_tgt/lvol/iscsi_lvol.sh index 6e93caa51..2adacdd05 100755 --- a/test/iscsi_tgt/lvol/iscsi_lvol.sh +++ b/test/iscsi_tgt/lvol/iscsi_lvol.sh @@ -53,7 +53,7 @@ for i in `seq 1 $NUM_MALLOC`; do lb_name=$($rpc_py construct_lvol_bdev -u $ls_guid lbd_$j 10) LUNs+="$lb_name:$((j-1)) " done - $rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 1 0 0 0 + $rpc_py construct_target_node Target$i Target${i}_alias "$LUNs" "1:$INITIATOR_TAG" 256 -d done timing_exit setup diff --git a/test/iscsi_tgt/multiconnection/multiconnection.sh b/test/iscsi_tgt/multiconnection/multiconnection.sh index 5df378a5b..585c80197 100755 --- a/test/iscsi_tgt/multiconnection/multiconnection.sh +++ b/test/iscsi_tgt/multiconnection/multiconnection.sh @@ -71,7 +71,7 @@ done for i in `seq 1 $CONNECTION_NUMBER`; do lun="lvs0/lbd_$i:0" - $rpc_py construct_target_node Target$i Target${i}_alias "$lun" "1:1" 256 1 0 0 0 + $rpc_py construct_target_node Target$i Target${i}_alias "$lun" "1:1" 256 -d done sleep 1 diff --git a/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh b/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh index 8b0b1eb69..86a829598 100755 --- a/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh +++ b/test/iscsi_tgt/nvme_remote/fio_remote_nvme.sh @@ -59,7 +59,7 @@ $rpc_py -s "$iscsi_rpc_addr" add_initiator_group 1 ANY $INITIATOR_IP/32 if [ $1 -eq 0 ]; then $rpc_py -s "$iscsi_rpc_addr" construct_nvme_bdev -b "Nvme0" -t "rdma" -f "ipv4" -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode1 fi -$rpc_py -s "$iscsi_rpc_addr" construct_target_node Target1 Target1_alias 'Nvme0n1:0' '1:1' 64 1 0 0 0 +$rpc_py -s "$iscsi_rpc_addr" construct_target_node Target1 Target1_alias 'Nvme0n1:0' '1:1' 64 -d sleep 1 echo "Logging in to iSCSI target." diff --git a/test/iscsi_tgt/pmem/iscsi_pmem.sh b/test/iscsi_tgt/pmem/iscsi_pmem.sh index 0261e47b1..c1e40dd11 100755 --- a/test/iscsi_tgt/pmem/iscsi_pmem.sh +++ b/test/iscsi_tgt/pmem/iscsi_pmem.sh @@ -49,7 +49,7 @@ for i in `seq 1 $TGT_NR`; do PMEM_BDEVS+="$bdevs_name " luns+="$bdevs_name:$((j-1)) " done - $rpc_py construct_target_node Target$i Target${i}_alias "$luns" "1:$INITIATOR_TAG " 256 1 0 0 0 + $rpc_py construct_target_node Target$i Target${i}_alias "$luns" "1:$INITIATOR_TAG " 256 -d done timing_exit setup sleep 1 diff --git a/test/iscsi_tgt/rbd/rbd.sh b/test/iscsi_tgt/rbd/rbd.sh index 4106d5277..a9278c970 100755 --- a/test/iscsi_tgt/rbd/rbd.sh +++ b/test/iscsi_tgt/rbd/rbd.sh @@ -41,7 +41,7 @@ $rpc_py get_bdevs # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target3 Target3_alias 'Ceph0:0' '1:2' 64 1 0 0 0 +$rpc_py construct_target_node Target3 Target3_alias 'Ceph0:0' '1:2' 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/reset/reset.sh b/test/iscsi_tgt/reset/reset.sh index eac689694..c842a4ae4 100755 --- a/test/iscsi_tgt/reset/reset.sh +++ b/test/iscsi_tgt/reset/reset.sh @@ -44,7 +44,7 @@ $rpc_py construct_malloc_bdev $MALLOC_BDEV_SIZE $MALLOC_BLOCK_SIZE # "1:2" ==> map PortalGroup1 to InitiatorGroup2 # "64" ==> iSCSI queue depth 64 # "1 0 0 0" ==> disable CHAP authentication -$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 1 0 0 0 +$rpc_py construct_target_node Target3 Target3_alias 'Malloc0:0' '1:2' 64 -d sleep 1 iscsiadm -m discovery -t sendtargets -p $TARGET_IP:$PORT diff --git a/test/iscsi_tgt/rpc_config/rpc_config.py b/test/iscsi_tgt/rpc_config/rpc_config.py index 2979e3f79..2e4e52441 100755 --- a/test/iscsi_tgt/rpc_config/rpc_config.py +++ b/test/iscsi_tgt/rpc_config/rpc_config.py @@ -22,10 +22,10 @@ rpc_param = { 'queue_depth': 64, 'target_name': 'Target3', 'alias_name': 'Target3_alias', - 'chap_disable': 1, - 'chap_mutal': 0, - 'chap_required': 0, - 'chap_auth_group': 0, + 'disable_chap': True, + 'mutual_chap': False, + 'require_chap': False, + 'chap_group': 0, 'header_digest': False, 'data_digest': False, 'trace_flag': 'rpc', @@ -94,8 +94,7 @@ def verify_iscsi_connection_rpc_methods(rpc_py): 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']) + rpc.construct_target_node(rpc_param['target_name'], rpc_param['alias_name'], lun_mapping, net_mapping, rpc_param['queue_depth'], '-d') 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'] @@ -138,8 +137,7 @@ def verify_scsi_devices_rpc_methods(rpc_py): 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']) + rpc.construct_target_node(rpc_param['target_name'], rpc_param['alias_name'], lun_mapping, net_mapping, rpc_param['queue_depth'], '-d') 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'] @@ -333,8 +331,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']) + rpc.construct_target_node(rpc_param['target_name'], rpc_param['alias_name'], lun_mapping, net_mapping, rpc_param['queue_depth'], '-d') output = rpc.get_target_nodes() jsonvalues = json.loads(output) verify(len(jsonvalues) == 1, 1, @@ -355,14 +352,14 @@ def verify_target_nodes_rpc_methods(rpc_py, rpc_param): "queue depth value is {}, expected {}".format(jsonvalues[0]['queue_depth'], rpc_param['queue_depth'])) verify(jsonvalues[0]['pg_ig_maps'][0]['pg_tag'] == int(portal_tag), 1, "portal group tag value is {}, expected {}".format(jsonvalues[0]['pg_ig_maps'][0]['pg_tag'], portal_tag)) - verify(jsonvalues[0]['chap_disabled'] == rpc_param['chap_disable'], 1, - "chap disable value is {}, expected {}".format(jsonvalues[0]['chap_disabled'], rpc_param['chap_disable'])) - verify(jsonvalues[0]['chap_mutual'] == rpc_param['chap_mutal'], 1, - "chap mutual value is {}, expected {}".format(jsonvalues[0]['chap_mutual'], rpc_param['chap_mutal'])) - verify(jsonvalues[0]['chap_required'] == rpc_param['chap_required'], 1, - "chap required value is {}, expected {}".format(jsonvalues[0]['chap_required'], rpc_param['chap_required'])) - verify(jsonvalues[0]['chap_auth_group'] == rpc_param['chap_auth_group'], 1, - "chap auth group value is {}, expected {}".format(jsonvalues[0]['chap_auth_group'], rpc_param['chap_auth_group'])) + verify(jsonvalues[0]['disable_chap'] == rpc_param['disable_chap'], 1, + "disable chap value is {}, expected {}".format(jsonvalues[0]['disable_chap'], rpc_param['disable_chap'])) + verify(jsonvalues[0]['mutual_chap'] == rpc_param['mutual_chap'], 1, + "chap mutual value is {}, expected {}".format(jsonvalues[0]['mutual_chap'], rpc_param['mutual_chap'])) + verify(jsonvalues[0]['require_chap'] == rpc_param['require_chap'], 1, + "chap required value is {}, expected {}".format(jsonvalues[0]['require_chap'], rpc_param['require_chap'])) + verify(jsonvalues[0]['chap_group'] == rpc_param['chap_group'], 1, + "chap auth group value is {}, expected {}".format(jsonvalues[0]['chap_group'], rpc_param['chap_group'])) verify(jsonvalues[0]['header_digest'] == rpc_param['header_digest'], 1, "header digest value is {}, expected {}".format(jsonvalues[0]['header_digest'], rpc_param['header_digest'])) verify(jsonvalues[0]['data_digest'] == rpc_param['data_digest'], 1, @@ -382,8 +379,7 @@ def verify_target_nodes_rpc_methods(rpc_py, rpc_param): verify(not jsonvalues, 1, "get_target_nodes returned {}, expected empty".format(jsonvalues)) - 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']) + rpc.construct_target_node(rpc_param['target_name'], rpc_param['alias_name'], lun_mapping, net_mapping, rpc_param['queue_depth'], '-d') rpc.delete_portal_group(portal_tag) rpc.delete_initiator_group(initiator_tag) diff --git a/test/unit/lib/iscsi/tgt_node.c/tgt_node_ut.c b/test/unit/lib/iscsi/tgt_node.c/tgt_node_ut.c index edd2853ef..076ec10bc 100644 --- a/test/unit/lib/iscsi/tgt_node.c/tgt_node_ut.c +++ b/test/unit/lib/iscsi/tgt_node.c/tgt_node_ut.c @@ -796,39 +796,39 @@ allow_iscsi_name_multi_maps_case(void) /* * static bool - * spdk_iscsi_check_chap_params(int auth_chap_disabled, int auth_chap_required, - * int auth_chap_mutual, int auth_group); + * spdk_iscsi_check_chap_params(bool auth_chap_disabled, bool auth_chap_required, + * bool auth_chap_mutual, int auth_group); */ static void chap_param_test_cases(void) { /* Auto */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 0, 0, 0) == true); + CU_ASSERT(spdk_iscsi_check_chap_params(false, false, false, 0) == true); /* None */ - CU_ASSERT(spdk_iscsi_check_chap_params(1, 0, 0, 0) == true); + CU_ASSERT(spdk_iscsi_check_chap_params(true, false, false, 0) == true); /* CHAP */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 1, 0, 0) == true); + CU_ASSERT(spdk_iscsi_check_chap_params(false, true, false, 0) == true); /* CHAP Mutual */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 1, 1, 0) == true); + CU_ASSERT(spdk_iscsi_check_chap_params(false, true, true, 0) == true); /* Check mutual exclusiveness of disabled and required */ - CU_ASSERT(spdk_iscsi_check_chap_params(1, 1, 0, 0) == false); + CU_ASSERT(spdk_iscsi_check_chap_params(true, true, false, 0) == false); /* Mutual requires Required */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 0, 1, 0) == false); + CU_ASSERT(spdk_iscsi_check_chap_params(false, false, true, 0) == false); /* Remaining combinations */ - CU_ASSERT(spdk_iscsi_check_chap_params(1, 0, 1, 0) == false); - CU_ASSERT(spdk_iscsi_check_chap_params(1, 1, 1, 0) == false); + CU_ASSERT(spdk_iscsi_check_chap_params(true, false, true, 0) == false); + CU_ASSERT(spdk_iscsi_check_chap_params(true, true, true, 0) == false); /* Valid auth group ID */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 0, 0, 1) == true); + CU_ASSERT(spdk_iscsi_check_chap_params(false, false, false, 1) == true); /* Invalid auth group ID */ - CU_ASSERT(spdk_iscsi_check_chap_params(0, 0, 0, -1) == false); + CU_ASSERT(spdk_iscsi_check_chap_params(false, false, false, -1) == false); } int