On Thu, Jul 28, 2011 at 7:03 PM, Mike Christie <[email protected]> wrote:
> On 07/26/2011 01:43 PM, rahul gupta wrote:
> > Hi Mike,
> >
>
> Hey,
>
> > I have taken care of points you mentioned in last mail.
> >
> > Following is git diff with my comments (for patch without comments
> please
> > refer attachment):-
> >
> > Note1:
> > I am not sure how much CHAP length user can use is needed so I kept it to
> > huge limit like iqn, if you want to decrease it, please let me know what
> > limit should be kept.
>
> There is a define AUTH_STR_MAX_LEN for this.
>
> >
> >
> > Note2:
> > Forcing session_info_print_tree() to always pass 0 for do_show, because
> of
> > two reasons:-
> > 1. As this part of code comes into picture when iscsiadm -m host -P3
> command
> > is used, and this command throws error if you use -S option.
> > 2. Since I have to assume some value, so I took 0 (ie to not to show
> > password) as to view password/session info we already have iscsiadm -m
> > session -P3 -S :)
>
>
>
>
> >
> > Note3:
> >
> > I have created two new flags SESSION_INFO_ISCSI_TIM and
> > SESSION_INFO_ISCSI_AUTH, as they might be needed in future, otherwise
> > if you want I can merge code these two flag's code into the existing
> > one flag- SESSION_INFO_ISCSI_PARAMS.
>
> Seems fine.
>
>
> > diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
> > index e82fe80..7e8f03f 100644
> > --- a/usr/iscsi_sysfs.c
> > +++ b/usr/iscsi_sysfs.c
> > @@ -675,8 +675,72 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct
> > session_info *info, char *session)
> > return ISCSI_ERR_SYSFS_LOOKUP;
> > }
> >
> > + ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "username",
> > + (info->chap).username,
> > + sizeof((info->chap).username));
> > + if (ret) {
> > + log_error("could not read session targetname: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > + if ((info->chap).username[0] == '\0')
> > + strcpy((info->chap).username, "<NULL>");
> > + if (ret) {
> > + log_error("could not read session username: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > + ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "password",
> > + (info->chap).password,
> > + sizeof((info->chap).password));
> > + if ((info->chap).password[0] == '\0')
> > + strcpy((info->chap).password, "<NULL>");
> > + if (ret) {
> > + log_error("could not read session password: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > + ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "username_in",
> > + (info->chap).username_in,
> > + sizeof((info->chap).username_in));
> > + if ((info->chap).username_in[0] == '\0')
> > + strcpy((info->chap).username_in, "<NULL>");
> > + if (ret) {
> > + log_error("could not read session username_in: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > + ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "password_in",
> > + (info->chap).password_in,
> > + sizeof((info->chap).password_in));
> > + if ((info->chap).password_in[0] == '\0')
> > + strcpy((info->chap).password_in, "<NULL>");
> > + if (ret) {
> > + log_error("could not read session password_in: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > + ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "recovery_tmo",
> > + &((info->tmo).recovery_tmo));
> > + if (ret) {
> > + log_error("could not read session recovery_tmo: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > + ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "lu_reset_tmo",
> > + &((info->tmo).lu_reset_tmo));
> > + if (ret) {
> > + log_error("could not read session lu_reset_tmo: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > + ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "abort_tmo",
> > + &((info->tmo).abort_tmo));
> > + if (ret) {
> > + log_error("could not read session abort_tmo: %d", ret);
> > + return ISCSI_ERR_SYSFS_LOOKUP;
> > + }
> > +
> > ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "tpgt",
> > - &info->tpgt);
> > + &info->tpgt);
> > if (ret) {
> > log_error("could not read session tpgt: %d", ret);
> > return ISCSI_ERR_SYSFS_LOOKUP;
> > @@ -741,7 +805,7 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct
> > session_info *info, char *session)
> > }
>
>
> Some drivers are not able to export all this info so it is currently
> optional. The CHAP info should really be required, but qla4xxx for
> example is not exporting this info.
>
> Also not all drivers support all the different timeout options if they
> do not support the TMF.
>
> So I think if we get an error from sysfs_get_* we can just drop the
> error and continue on as best we can.
>
Please let me know if following changes are ok for this. Thanks.
>
> For printing then I think you can just print something indicating it was
> not set like "<NULL>" (I think that is what do currently do).
>
For integers, like timeout:-
while fetching from sysfs_get_str(), I am setting timeouts to -1 for
indicating error and also in qla card's case where chap is not supported in
/sys,
and then while printing, checking same value by taking its complement.
I found in iscsid.conf file setting timeout value to -1 to huge -ve value is
valid (as after setting that can restart iscsid successfully) but not really
sure does user uses it.
I assume user never uses -1 for timeout in iscsid.conf file, so I have used
it in following code for error purpose:-
Signed-off-by: Rahul Gupta <[email protected]>
iSCSI user space TODO item-2 : Displaying timeout and CHAP.
Date: Wed Aug 3 22:35:30 2011 IST.
diff --git a/usr/host.c b/usr/host.c
index ec983b0..d171455 100644
--- a/usr/host.c
+++ b/usr/host.c
@@ -151,7 +151,7 @@ static int host_info_print_tree(void *data, struct
host_info *hinfo)
printf("\tSessions:\n");
printf("\t*********\n");
- session_info_print_tree(&sessions, "\t", session_info_flags);
+ session_info_print_tree(&sessions, "\t", session_info_flags, 0);
session_info_free_list(&sessions);
return 0;
}
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
index e82fe80..c14ec29 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -675,6 +675,46 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct
session_info *info, char *session)
return ISCSI_ERR_SYSFS_LOOKUP;
}
+ ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "username",
+ (info->chap).username,
+ sizeof((info->chap).username));
+
+ if ((info->chap).username[0] == '\0' || ret)
+ strcpy((info->chap).username, "<NULL>");
+
+ ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "password",
+ (info->chap).password,
+ sizeof((info->chap).password));
+ if ((info->chap).password[0] == '\0' || ret)
+ strcpy((info->chap).password, "<NULL>");
+
+ ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "username_in",
+ (info->chap).username_in,
+ sizeof((info->chap).username_in));
+ if ((info->chap).username_in[0] == '\0' || ret)
+ strcpy((info->chap).username_in, "<NULL>");
+
+ ret = sysfs_get_str(session, ISCSI_SESSION_SUBSYS, "password_in",
+ (info->chap).password_in,
+ sizeof((info->chap).password_in));
+ if ((info->chap).password_in[0] == '\0' || ret)
+ strcpy((info->chap).password_in, "<NULL>");
+
+ ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "recovery_tmo",
+ &((info->tmo).recovery_tmo));
+ if (ret)
+ (info->tmo).recovery_tmo = -1;
+
+ ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "lu_reset_tmo",
+ &((info->tmo).lu_reset_tmo));
+ if (ret)
+ (info->tmo).lu_reset_tmo = -1;
+
+ sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "abort_tmo",
+ &((info->tmo).abort_tmo));
+ if (ret)
+ (info->tmo).abort_tmo = -1;
+
ret = sysfs_get_int(session, ISCSI_SESSION_SUBSYS, "tpgt",
&info->tpgt);
if (ret) {
@@ -741,7 +781,7 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct
session_info *info, char *session)
}
iscsi_sysfs_read_iface(&info->iface, host_no, session);
-
+
log_debug(7, "found targetname %s address %s pers address %s port %d "
"pers port %d driver %s iface name %s ipaddress %s "
"netdev %s hwaddress %s iname %s",
@@ -753,7 +793,7 @@ int iscsi_sysfs_get_sessioninfo_by_id(struct
session_info *info, char *session)
info->iface.iname);
return 0;
}
-
+
int iscsi_sysfs_for_each_session(void *data, int *nr_found,
iscsi_sysfs_session_op_fn *fn)
{
@@ -857,7 +897,7 @@ char *iscsi_sysfs_get_blockdev_from_lun(int
host_no, int target, int lun)
}
sysfs_len = strlcpy(path_full, sysfs_path, sizeof(path_full));
- if(sysfs_len >= sizeof(path_full))
+ if (sysfs_len >= sizeof(path_full))
sysfs_len = sizeof(path_full) - 1;
path = &path_full[sysfs_len];
strlcat(path_full, devpath, sizeof(path_full));
@@ -947,7 +987,7 @@ static uint32_t get_target_no_from_sid(uint32_t
sid, int *err)
* /class/iscsi_session/sessionX/device.
*/
sysfs_len = strlcpy(path_full, sysfs_path, sizeof(path_full));
- if(sysfs_len >= sizeof(path_full))
+ if (sysfs_len >= sizeof(path_full))
sysfs_len = sizeof(path_full) - 1;
path = &path_full[sysfs_len];
strlcat(path_full, devpath, sizeof(path_full));
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
index 91d886b..3b87c3d 100644
--- a/usr/iscsiadm.c
+++ b/usr/iscsiadm.c
@@ -2245,7 +2245,8 @@ main(int argc, char **argv)
if (!do_logout && !do_rescan && !do_stats &&
op == OP_NOOP && info_level > 0) {
- rc = session_info_print(info_level, info);
+ rc = session_info_print(info_level, info,
+ do_show);
goto free_info;
}
@@ -2292,7 +2293,7 @@ free_info:
goto out;
}
- rc = session_info_print(info_level, NULL);
+ rc = session_info_print(info_level, NULL, do_show);
}
break;
default:
diff --git a/usr/session_info.c b/usr/session_info.c
index cded5e3..2a766e7 100644
--- a/usr/session_info.c
+++ b/usr/session_info.c
@@ -224,7 +224,7 @@ static int print_scsi_state(int sid, char *prefix,
unsigned int flags)
}
void session_info_print_tree(struct list_head *list, char *prefix,
- unsigned int flags)
+ unsigned int flags, int do_show)
{
struct session_info *curr, *prev = NULL;
@@ -278,6 +278,48 @@ void session_info_print_tree(struct list_head
*list, char *prefix,
printf("%s\t\tSID: %d\n", prefix, curr->sid);
print_iscsi_state(curr->sid, prefix);
}
+ if (flags & SESSION_INFO_ISCSI_TIM) {
+ printf("%s\t\t*********\n", prefix);
+ printf("%s\t\tTimeouts:\n", prefix);
+ printf("%s\t\t*********\n", prefix);
+
+ if (~(curr->tmo).recovery_tmo)
+ printf("%s\t\tRecovery Timeout: %d\n", prefix,
+ ((curr->tmo).recovery_tmo));
+ else
+ printf("%s\t\tRecovery Timeout: %s\n", prefix,
+ "<NULL>");
+ if (~(curr->tmo).lu_reset_tmo)
+ printf("%s\t\tLUN reset Timeout: %d\n", prefix,
+ ((curr->tmo).lu_reset_tmo));
+ else
+ printf("%s\t\tLUN reset Timeout: %s\n", prefix,
+ "<NULL>");
+ if (~(curr->tmo).lu_reset_tmo)
+ printf("%s\t\tAbort Timeout: %d\n", prefix,
+ ((curr->tmo).abort_tmo));
+ else
+ printf("%s\t\tAbort Timeout: %s\n", prefix,
+ "<NULL>");
+
+ }
+ if (flags & SESSION_INFO_ISCSI_AUTH) {
+ printf("%s\t\t*****\n", prefix);
+ printf("%s\t\tCHAP:\n", prefix);
+ printf("%s\t\t*****\n", prefix);
+ if (!do_show) {
+ strcpy(curr->chap.password, "********");
+ strcpy(curr->chap.password_in, "********");
+ }
+ printf("%s\t\tusername: %s\n", prefix,
+ ((curr->chap).username));
+ printf("%s\t\tpassword: %s\n", prefix,
+ ((curr->chap).password));
+ printf("%s\t\tusername_in: %s\n", prefix,
+ ((curr->chap).username_in));
+ printf("%s\t\tpassword_in: %s\n", prefix,
+ ((curr->chap).password_in));
+ }
if (flags & SESSION_INFO_ISCSI_PARAMS)
print_iscsi_params(curr->sid, prefix);
@@ -289,7 +331,7 @@ void session_info_print_tree(struct list_head
*list, char *prefix,
}
}
-int session_info_print(int info_level, struct session_info *info)
+int session_info_print(int info_level, struct session_info *info, int do_show)
{
struct list_head list;
int num_found = 0, err = 0;
@@ -317,17 +359,18 @@ int session_info_print(int info_level, struct
session_info *info)
flags |= (SESSION_INFO_SCSI_DEVS | SESSION_INFO_HOST_DEVS);
/* fall through */
case 2:
- flags |= SESSION_INFO_ISCSI_PARAMS;
+ flags |= (SESSION_INFO_ISCSI_PARAMS | SESSION_INFO_ISCSI_TIM
+ | SESSION_INFO_ISCSI_AUTH);
/* fall through */
case 1:
INIT_LIST_HEAD(&list);
struct session_link_info link_info;
- flags |= (SESSION_INFO_ISCSI_STATE |SESSION_INFO_IFACE);
+ flags |= (SESSION_INFO_ISCSI_STATE | SESSION_INFO_IFACE);
if (info) {
INIT_LIST_HEAD(&info->list);
list_add_tail(&list, &info->list);
- session_info_print_tree(&list, "", flags);
+ session_info_print_tree(&list, "", flags, do_show);
num_found = 1;
break;
}
@@ -342,7 +385,7 @@ int session_info_print(int info_level, struct
session_info *info)
if (err || !num_found)
break;
- session_info_print_tree(&list, "", flags);
+ session_info_print_tree(&list, "", flags, do_show);
session_info_free_list(&list);
break;
default:
diff --git a/usr/session_info.h b/usr/session_info.h
index 7a22aee..726aefd 100644
--- a/usr/session_info.h
+++ b/usr/session_info.h
@@ -9,12 +9,29 @@
struct list;
+struct session_timeout {
+ int abort_tmo;
+ int lu_reset_tmo;
+ int recovery_tmo;
+ int tgt_reset_tmo;
+};
+
+struct session_CHAP {
+ char username[AUTH_STR_MAX_LEN];
+ char password[AUTH_STR_MAX_LEN];
+ char username_in[AUTH_STR_MAX_LEN];
+ char password_in[AUTH_STR_MAX_LEN];
+};
+
struct session_info {
struct list_head list;
/* local info */
struct iface_rec iface;
int sid;
+ struct session_timeout tmo;
+ struct session_CHAP chap;
+
/* remote info */
char targetname[TARGET_NAME_MAXLEN + 1];
int tpgt;
@@ -37,11 +54,14 @@ struct session_link_info {
#define SESSION_INFO_ISCSI_STATE 0x4
#define SESSION_INFO_SCSI_DEVS 0x8
#define SESSION_INFO_HOST_DEVS 0x10
+#define SESSION_INFO_ISCSI_TIM 0x20
+#define SESSION_INFO_ISCSI_AUTH 0x40
extern int session_info_create_list(void *data, struct session_info *info);
extern void session_info_free_list(struct list_head *list);
-extern int session_info_print(int info_level, struct session_info *match_info);
+extern int session_info_print(int info_level, struct session_info *match_info,
+ int do_show);
extern void session_info_print_tree(struct list_head *list, char *prefix,
- unsigned int flags);
+ unsigned int flags, int do_show);
#endif
--
You received this message because you are subscribed to the Google Groups
"open-iscsi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/open-iscsi?hl=en.
timeout_chap_display2.patch
Description: Binary data
