[SCSI] iscsi class, iscsi_tcp, ib_iser: add sysfs chap file
authorMike Christie <michaelc@cs.wisc.edu>
Wed, 30 May 2007 17:57:16 +0000 (12:57 -0500)
committerJames Bottomley <jejb@mulgrave.(none)>
Fri, 1 Jun 2007 16:58:58 +0000 (12:58 -0400)
The attached patches add sysfs files for the chap settings
to the iscsi transport class, iscsi_tcp and ib_iser. This is
needed for software iscsi because there are times when iscsid
can die and it will need to reread the values it was using.
And it is needed by qla4xxx for basic management opertaions.
This patch does not hook in qla4xxx yet, because I am not sure
the mbx command to use.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Cc: Roland Dreier <rdreier@cisco.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/infiniband/ulp/iser/iscsi_iser.c
drivers/scsi/iscsi_tcp.c
drivers/scsi/libiscsi.c
drivers/scsi/scsi_transport_iscsi.c
include/scsi/iscsi_if.h
include/scsi/libiscsi.h

index 568f88bf7c91ac0a4e102aa541c7a473d43a3da5..6c8cd09c58f0019ff8f0856840c855460c41e1bb 100644 (file)
@@ -574,8 +574,9 @@ static struct iscsi_transport iscsi_iser_transport = {
                                  ISCSI_EXP_STATSN |
                                  ISCSI_PERSISTENT_PORT |
                                  ISCSI_PERSISTENT_ADDRESS |
-                                 ISCSI_TARGET_NAME |
-                                 ISCSI_TPGT,
+                                 ISCSI_TARGET_NAME | ISCSI_TPGT |
+                                 ISCSI_USERNAME | ISCSI_PASSWORD |
+                                 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,
        .host_param_mask        = ISCSI_HOST_HWADDRESS |
                                  ISCSI_HOST_INITIATOR_NAME,
        .host_template          = &iscsi_iser_sht,
index b2827d112cb0a4f599598db7c3d3d04562174c10..1e722f5aabd48614b460f53c3e100cc08feebe4c 100644 (file)
@@ -2186,8 +2186,9 @@ static struct iscsi_transport iscsi_tcp_transport = {
                                  ISCSI_EXP_STATSN |
                                  ISCSI_PERSISTENT_PORT |
                                  ISCSI_PERSISTENT_ADDRESS |
-                                 ISCSI_TARGET_NAME |
-                                 ISCSI_TPGT,
+                                 ISCSI_TARGET_NAME | ISCSI_TPGT |
+                                 ISCSI_USERNAME | ISCSI_PASSWORD |
+                                 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN,
        .host_param_mask        = ISCSI_HOST_HWADDRESS |
                                  ISCSI_HOST_INITIATOR_NAME,
        .host_template          = &iscsi_sht,
index 0a9c64e9ce8b57fd712ccb69e5eeb3ee86ec5c0a..63981edf9ab92028a8928a13dd8e33f6b37e4d05 100644 (file)
@@ -1461,6 +1461,10 @@ void iscsi_session_teardown(struct iscsi_cls_session *cls_session)
        iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);
        iscsi_pool_free(&session->cmdpool, (void**)session->cmds);
 
+       kfree(session->password);
+       kfree(session->password_in);
+       kfree(session->username);
+       kfree(session->username_in);
        kfree(session->targetname);
        kfree(session->hwaddress);
        kfree(session->initiatorname);
@@ -1869,6 +1873,30 @@ int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
        case ISCSI_PARAM_EXP_STATSN:
                sscanf(buf, "%u", &conn->exp_statsn);
                break;
+       case ISCSI_PARAM_USERNAME:
+               kfree(session->username);
+               session->username = kstrdup(buf, GFP_KERNEL);
+               if (!session->username)
+                       return -ENOMEM;
+               break;
+       case ISCSI_PARAM_USERNAME_IN:
+               kfree(session->username_in);
+               session->username_in = kstrdup(buf, GFP_KERNEL);
+               if (!session->username_in)
+                       return -ENOMEM;
+               break;
+       case ISCSI_PARAM_PASSWORD:
+               kfree(session->password);
+               session->password = kstrdup(buf, GFP_KERNEL);
+               if (!session->password)
+                       return -ENOMEM;
+               break;
+       case ISCSI_PARAM_PASSWORD_IN:
+               kfree(session->password_in);
+               session->password_in = kstrdup(buf, GFP_KERNEL);
+               if (!session->password_in)
+                       return -ENOMEM;
+               break;
        case ISCSI_PARAM_TARGET_NAME:
                /* this should not change between logins */
                if (session->targetname)
@@ -1942,6 +1970,18 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session,
        case ISCSI_PARAM_TPGT:
                len = sprintf(buf, "%d\n", session->tpgt);
                break;
+       case ISCSI_PARAM_USERNAME:
+               len = sprintf(buf, "%s\n", session->username);
+               break;
+       case ISCSI_PARAM_USERNAME_IN:
+               len = sprintf(buf, "%s\n", session->username_in);
+               break;
+       case ISCSI_PARAM_PASSWORD:
+               len = sprintf(buf, "%s\n", session->password);
+               break;
+       case ISCSI_PARAM_PASSWORD_IN:
+               len = sprintf(buf, "%s\n", session->password_in);
+               break;
        default:
                return -ENOSYS;
        }
index 5ec2fbea8937abdf81bd7f137ac4e1b287161d42..341d4fb5c6f8c4a66376f35cf789dbbad0387d3c 100644 (file)
@@ -30,7 +30,7 @@
 #include <scsi/scsi_transport_iscsi.h>
 #include <scsi/iscsi_if.h>
 
-#define ISCSI_SESSION_ATTRS 11
+#define ISCSI_SESSION_ATTRS 15
 #define ISCSI_CONN_ATTRS 11
 #define ISCSI_HOST_ATTRS 2
 #define ISCSI_TRANSPORT_VERSION "2.0-724"
@@ -1196,30 +1196,37 @@ iscsi_conn_attr(address, ISCSI_PARAM_CONN_ADDRESS);
 /*
  * iSCSI session attrs
  */
-#define iscsi_session_attr_show(param)                                 \
+#define iscsi_session_attr_show(param, perm)                           \
 static ssize_t                                                         \
 show_session_param_##param(struct class_device *cdev, char *buf)       \
 {                                                                      \
        struct iscsi_cls_session *session = iscsi_cdev_to_session(cdev); \
        struct iscsi_transport *t = session->transport;                 \
+                                                                       \
+       if (perm && !capable(CAP_SYS_ADMIN))                            \
+               return -EACCES;                                         \
        return t->get_session_param(session, param, buf);               \
 }
 
-#define iscsi_session_attr(field, param)                               \
-       iscsi_session_attr_show(param)                                  \
+#define iscsi_session_attr(field, param, perm)                         \
+       iscsi_session_attr_show(param, perm)                            \
 static ISCSI_CLASS_ATTR(sess, field, S_IRUGO, show_session_param_##param, \
                        NULL);
 
-iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME);
-iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN);
-iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T);
-iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN);
-iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST);
-iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST);
-iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN);
-iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN);
-iscsi_session_attr(erl, ISCSI_PARAM_ERL);
-iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT);
+iscsi_session_attr(targetname, ISCSI_PARAM_TARGET_NAME, 0);
+iscsi_session_attr(initial_r2t, ISCSI_PARAM_INITIAL_R2T_EN, 0);
+iscsi_session_attr(max_outstanding_r2t, ISCSI_PARAM_MAX_R2T, 0);
+iscsi_session_attr(immediate_data, ISCSI_PARAM_IMM_DATA_EN, 0);
+iscsi_session_attr(first_burst_len, ISCSI_PARAM_FIRST_BURST, 0);
+iscsi_session_attr(max_burst_len, ISCSI_PARAM_MAX_BURST, 0);
+iscsi_session_attr(data_pdu_in_order, ISCSI_PARAM_PDU_INORDER_EN, 0);
+iscsi_session_attr(data_seq_in_order, ISCSI_PARAM_DATASEQ_INORDER_EN, 0);
+iscsi_session_attr(erl, ISCSI_PARAM_ERL, 0);
+iscsi_session_attr(tpgt, ISCSI_PARAM_TPGT, 0);
+iscsi_session_attr(username, ISCSI_PARAM_USERNAME, 1);
+iscsi_session_attr(username_in, ISCSI_PARAM_USERNAME_IN, 1);
+iscsi_session_attr(password, ISCSI_PARAM_PASSWORD, 1);
+iscsi_session_attr(password_in, ISCSI_PARAM_PASSWORD_IN, 1);
 
 #define iscsi_priv_session_attr_show(field, format)                    \
 static ssize_t                                                         \
@@ -1433,6 +1440,10 @@ iscsi_register_transport(struct iscsi_transport *tt)
        SETUP_SESSION_RD_ATTR(erl, ISCSI_ERL);
        SETUP_SESSION_RD_ATTR(targetname, ISCSI_TARGET_NAME);
        SETUP_SESSION_RD_ATTR(tpgt, ISCSI_TPGT);
+       SETUP_SESSION_RD_ATTR(password, ISCSI_USERNAME);
+       SETUP_SESSION_RD_ATTR(password_in, ISCSI_USERNAME_IN);
+       SETUP_SESSION_RD_ATTR(username, ISCSI_PASSWORD);
+       SETUP_SESSION_RD_ATTR(username_in, ISCSI_PASSWORD_IN);
        SETUP_PRIV_SESSION_RD_ATTR(recovery_tmo);
 
        BUG_ON(count > ISCSI_SESSION_ATTRS);
index e057c5d3703d2b27dcc7ab82912f0c427c07f1f5..1a18196d77f6f5a57f53f783d592b9a900586ecc 100644 (file)
@@ -229,6 +229,11 @@ enum iscsi_param {
        ISCSI_PARAM_CONN_PORT,
        ISCSI_PARAM_CONN_ADDRESS,
 
+       ISCSI_PARAM_USERNAME,
+       ISCSI_PARAM_USERNAME_IN,
+       ISCSI_PARAM_PASSWORD,
+       ISCSI_PARAM_PASSWORD_IN,
+
        /* must always be last */
        ISCSI_PARAM_MAX,
 };
@@ -255,6 +260,10 @@ enum iscsi_param {
 #define ISCSI_SESS_RECOVERY_TMO                (1 << ISCSI_PARAM_SESS_RECOVERY_TMO)
 #define ISCSI_CONN_PORT                        (1 << ISCSI_PARAM_CONN_PORT)
 #define ISCSI_CONN_ADDRESS             (1 << ISCSI_PARAM_CONN_ADDRESS)
+#define ISCSI_USERNAME                 (1 << ISCSI_PARAM_USERNAME)
+#define ISCSI_USERNAME_IN              (1 << ISCSI_PARAM_USERNAME_IN)
+#define ISCSI_PASSWORD                 (1 << ISCSI_PARAM_PASSWORD)
+#define ISCSI_PASSWORD_IN              (1 << ISCSI_PARAM_PASSWORD_IN)
 
 /* iSCSI HBA params */
 enum iscsi_host_param {
index 348265d4a27e152276cb24d22abe788eb4094868..61bc8f75b267c286729916f41bb85755a713fe07 100644 (file)
@@ -221,6 +221,10 @@ struct iscsi_session {
        int                     dataseq_inorder_en;
        int                     erl;
        int                     tpgt;
+       char                    *username;
+       char                    *username_in;
+       char                    *password;
+       char                    *password_in;
        char                    *targetname;
        char                    *initiatorname;
        /* hw address being used for iscsi connection */