|
|
786c6d |
From b3913c5943b6e908a1bb8ce83a2e79200d0ceed9 Mon Sep 17 00:00:00 2001
|
|
|
786c6d |
From: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
|
|
|
786c6d |
Date: Tue, 17 Sep 2013 08:07:29 -0400
|
|
|
786c6d |
Subject: [PATCH] iscsiadm: Use '-x' option instead of '-v' to specify
|
|
|
786c6d |
chap_tbl_idx
|
|
|
786c6d |
|
|
|
786c6d |
Make appropriate changes to use -x option for chap_tbl_idx cmdline
|
|
|
786c6d |
param. This is done because -v option is used along with -n option
|
|
|
786c6d |
to get the name/value pair.
|
|
|
786c6d |
|
|
|
786c6d |
Signed-off-by: Adheer Chandravanshi <adheer.chandravanshi@qlogic.com>
|
|
|
786c6d |
Signed-off-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
|
|
|
786c6d |
---
|
|
|
786c6d |
usr/host.h | 1 +
|
|
|
786c6d |
usr/iscsiadm.c | 36 +++++++++++++++++-------------------
|
|
|
786c6d |
2 files changed, 18 insertions(+), 19 deletions(-)
|
|
|
786c6d |
|
|
|
786c6d |
diff --git a/usr/host.h b/usr/host.h
|
|
|
786c6d |
index db44cfa..52e5b9e 100644
|
|
|
786c6d |
--- a/usr/host.h
|
|
|
786c6d |
+++ b/usr/host.h
|
|
|
786c6d |
@@ -7,6 +7,7 @@
|
|
|
786c6d |
|
|
|
786c6d |
#define MAX_HOST_NO UINT_MAX
|
|
|
786c6d |
|
|
|
786c6d |
+#define MAX_CHAP_ENTRIES 2048
|
|
|
786c6d |
#define MAX_CHAP_BUF_SZ 4096
|
|
|
786c6d |
#define REQ_CHAP_BUF_SZ (MAX_CHAP_BUF_SZ + sizeof(struct iscsi_uevent))
|
|
|
786c6d |
|
|
|
786c6d |
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
|
|
786c6d |
index c7337ae..beabdf0 100644
|
|
|
786c6d |
--- a/usr/iscsiadm.c
|
|
|
786c6d |
+++ b/usr/iscsiadm.c
|
|
|
786c6d |
@@ -115,7 +115,7 @@ static struct option const long_options[] =
|
|
|
786c6d |
{"packetsize", required_argument, NULL, 'b'},
|
|
|
786c6d |
{"count", required_argument, NULL, 'c'},
|
|
|
786c6d |
{"interval", required_argument, NULL, 'i'},
|
|
|
786c6d |
- {"flashnode_idx", optional_argument, NULL, 'x'},
|
|
|
786c6d |
+ {"index", optional_argument, NULL, 'x'},
|
|
|
786c6d |
{"portal_type", optional_argument, NULL, 'A'},
|
|
|
786c6d |
{NULL, 0, NULL, 0},
|
|
|
786c6d |
};
|
|
|
786c6d |
@@ -136,7 +136,7 @@ iscsiadm -m node [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -L all,manual,au
|
|
|
786c6d |
iscsiadm -m session [ -hV ] [ -d debug_level ] [ -P printlevel] [ -r sessionid | sysfsdir [ -R | -u | -s ] [ -o operation ] [ -n name ] [ -v value ] ]\n\
|
|
|
786c6d |
iscsiadm -m iface [ -hV ] [ -d debug_level ] [ -P printlevel ] [ -I ifacename | -H hostno|MAC ] [ [ -o operation ] [ -n name ] [ -v value ] ] [ -C ping [ -a ip ] [ -b packetsize ] [ -c count ] [ -i interval ] ]\n\
|
|
|
786c6d |
iscsiadm -m fw [ -d debug_level ] [ -l ]\n\
|
|
|
786c6d |
-iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -o operation ] [ -v chap_tbl_idx ] ] | [ -C flashnode [ -o operation ] [ -A portal_type ] [ -x flashnode_idx ] [ -n name ] [ -v value ] ] ]\n\
|
|
|
786c6d |
+iscsiadm -m host [ -P printlevel ] [ -H hostno|MAC ] [ [ -C chap [ -x chap_tbl_idx ] ] | [ -C flashnode [ -A portal_type ] [ -x flashnode_idx ] ] ] [ [ -o operation ] [ -n name ] [ -v value ] ] \n\
|
|
|
786c6d |
iscsiadm -k priority\n");
|
|
|
786c6d |
}
|
|
|
786c6d |
exit(status);
|
|
|
786c6d |
@@ -1426,18 +1426,10 @@ exit_chap_info:
|
|
|
786c6d |
return rc;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
-static int delete_host_chap_info(uint32_t host_no, char *value)
|
|
|
786c6d |
+static int delete_host_chap_info(uint32_t host_no, uint16_t chap_tbl_idx)
|
|
|
786c6d |
{
|
|
|
786c6d |
struct iscsi_transport *t = NULL;
|
|
|
786c6d |
int fd, rc = 0;
|
|
|
786c6d |
- uint16_t chap_tbl_idx;
|
|
|
786c6d |
-
|
|
|
786c6d |
- if (!value) {
|
|
|
786c6d |
- log_error("CHAP deletion requires --value=table_index.");
|
|
|
786c6d |
- return ISCSI_ERR_INVAL;
|
|
|
786c6d |
- }
|
|
|
786c6d |
-
|
|
|
786c6d |
- chap_tbl_idx = (uint16_t)atoi(value);
|
|
|
786c6d |
|
|
|
786c6d |
t = iscsi_sysfs_get_transport_by_hba(host_no);
|
|
|
786c6d |
if (!t) {
|
|
|
786c6d |
@@ -1472,22 +1464,28 @@ exit_delete_chap:
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
static int exec_host_chap_op(int op, int info_level, uint32_t host_no,
|
|
|
786c6d |
- char *value)
|
|
|
786c6d |
+ uint64_t chap_index)
|
|
|
786c6d |
{
|
|
|
786c6d |
int rc = ISCSI_ERR_INVAL;
|
|
|
786c6d |
|
|
|
786c6d |
+ if (op != OP_SHOW && (chap_index > (uint64_t)MAX_CHAP_ENTRIES)) {
|
|
|
786c6d |
+ log_error("Invalid chap table index.");
|
|
|
786c6d |
+ goto exit_chap_op;
|
|
|
786c6d |
+ }
|
|
|
786c6d |
+
|
|
|
786c6d |
switch (op) {
|
|
|
786c6d |
case OP_SHOW:
|
|
|
786c6d |
rc = get_host_chap_info(host_no);
|
|
|
786c6d |
break;
|
|
|
786c6d |
case OP_DELETE:
|
|
|
786c6d |
- rc = delete_host_chap_info(host_no, value);
|
|
|
786c6d |
+ rc = delete_host_chap_info(host_no, chap_index);
|
|
|
786c6d |
break;
|
|
|
786c6d |
default:
|
|
|
786c6d |
log_error("Invalid operation.");
|
|
|
786c6d |
break;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
+exit_chap_op:
|
|
|
786c6d |
return rc;
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
@@ -2818,7 +2816,7 @@ main(int argc, char **argv)
|
|
|
786c6d |
struct iface_rec *iface = NULL, *tmp;
|
|
|
786c6d |
struct node_rec *rec = NULL;
|
|
|
786c6d |
uint64_t host_no = (uint64_t)MAX_HOST_NO + 1;
|
|
|
786c6d |
- uint64_t flashnode_idx = (uint64_t)MAX_FLASHNODE_IDX + 1;
|
|
|
786c6d |
+ uint64_t index = (uint64_t)MAX_FLASHNODE_IDX + 1;
|
|
|
786c6d |
struct user_param *param;
|
|
|
786c6d |
struct list_head params;
|
|
|
786c6d |
|
|
|
786c6d |
@@ -2962,9 +2960,9 @@ main(int argc, char **argv)
|
|
|
786c6d |
ISCSI_VERSION_STR);
|
|
|
786c6d |
return 0;
|
|
|
786c6d |
case 'x':
|
|
|
786c6d |
- flashnode_idx = strtoull(optarg, NULL, 10);
|
|
|
786c6d |
+ index = strtoull(optarg, NULL, 10);
|
|
|
786c6d |
if (errno) {
|
|
|
786c6d |
- log_error("Invalid flashnode index %s. %s.",
|
|
|
786c6d |
+ log_error("Invalid index %s. %s.",
|
|
|
786c6d |
optarg, strerror(errno));
|
|
|
786c6d |
rc = ISCSI_ERR_INVAL;
|
|
|
786c6d |
goto free_ifaces;
|
|
|
786c6d |
@@ -3041,7 +3039,7 @@ main(int argc, char **argv)
|
|
|
786c6d |
break;
|
|
|
786c6d |
}
|
|
|
786c6d |
rc = exec_host_chap_op(op, info_level, host_no,
|
|
|
786c6d |
- value);
|
|
|
786c6d |
+ index);
|
|
|
786c6d |
break;
|
|
|
786c6d |
case MODE_FLASHNODE:
|
|
|
786c6d |
if (host_no > MAX_HOST_NO) {
|
|
|
786c6d |
@@ -3051,8 +3049,8 @@ main(int argc, char **argv)
|
|
|
786c6d |
}
|
|
|
786c6d |
|
|
|
786c6d |
rc = exec_flashnode_op(op, info_level, host_no,
|
|
|
786c6d |
- flashnode_idx,
|
|
|
786c6d |
- portal_type, ¶ms);
|
|
|
786c6d |
+ index, portal_type,
|
|
|
786c6d |
+ ¶ms);
|
|
|
786c6d |
break;
|
|
|
786c6d |
default:
|
|
|
786c6d |
log_error("Invalid Sub Mode");
|
|
|
786c6d |
--
|
|
|
786c6d |
1.8.3.1
|
|
|
786c6d |
|