[Pkg-iscsi-maintainers] [SCM] Debian Open-iSCSI Packaging branch, upstream-mnc, updated. 2.0-872-193-gde2c0e7

Mike Christie michaelc at cs.wisc.edu
Sat Apr 7 15:43:44 UTC 2012


The following commit has been merged in the upstream-mnc branch:
commit 42a5950919038cac331c7fa69304478bd62bec15
Author: Rahul Gupta <rahulrgupta27 at gmail.com>
Date:   Mon Aug 8 21:46:01 2011 -0500

    iscsi tools: Displaying timeout and CHAP in iscisadm info
    
    I have analysed and coded on some part of it on this weekend :-
    For timeout and CHAP I have taken following parameters values from /sys
    and printed it.
    
    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 <rahulrgupta27 at gmail.com>
    
    iSCSI user space TODO item-2 : Displaying timeout and CHAP.

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 d967fa4..8761e3f 100644
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -677,6 +677,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) {
@@ -743,7 +783,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",
@@ -755,7 +795,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)
 {
@@ -858,7 +898,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;
 	strlcat(path_full, devpath, sizeof(path_full));
 
@@ -946,7 +986,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;
 	strlcat(path_full, devpath, sizeof(path_full));
 	strlcat(path_full, "/device", sizeof(devpath));
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..13f79c0 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

-- 
Debian Open-iSCSI Packaging



More information about the Pkg-iscsi-maintainers mailing list