]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
iscsi-target: Add login_keys_workaround attribute for non RFC initiators
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 7 Jul 2017 21:45:49 +0000 (14:45 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 11 Jul 2017 17:56:39 +0000 (10:56 -0700)
This patch re-introduces part of a long standing login workaround that
was recently dropped by:

  commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46
  Author: Nicholas Bellinger <nab@linux-iscsi.org>
  Date:   Sun Apr 2 13:36:44 2017 -0700

      iscsi-target: Drop work-around for legacy GlobalSAN initiator

Namely, the workaround for FirstBurstLength ended up being required by
Mellanox Flexboot PXE boot ROMs as reported by Robert.

So this patch re-adds the work-around for FirstBurstLength within
iscsi_check_proposer_for_optional_reply(), and makes the key optional
to respond when the initiator does not propose, nor respond to it.

Also as requested by Arun, this patch introduces a new TPG attribute
named 'login_keys_workaround' that controls the use of both the
FirstBurstLength workaround, as well as the two other existing
workarounds for gPXE iSCSI boot client.

By default, the workaround is enabled with login_keys_workaround=1,
since Mellanox FlexBoot requires it, and Arun has verified the Qlogic
MSFT initiator already proposes FirstBurstLength, so it's uneffected
by this re-adding this part of the original work-around.

Reported-by: Robert LeBlanc <robert@leblancnet.us>
Cc: Robert LeBlanc <robert@leblancnet.us>
Reviewed-by: Arun Easi <arun.easi@cavium.com>
Cc: <stable@vger.kernel.org> # 3.1+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_configfs.c
drivers/target/iscsi/iscsi_target_nego.c
drivers/target/iscsi/iscsi_target_parameters.c
drivers/target/iscsi/iscsi_target_parameters.h
drivers/target/iscsi/iscsi_target_tpg.c
drivers/target/iscsi/iscsi_target_tpg.h
include/target/iscsi/iscsi_target_core.h

index 535a8e06a4010f63a2744c1e1d0152d965d6630b..0dd4c45f7575a2795f3987dd874ac4891d93184f 100644 (file)
@@ -781,6 +781,7 @@ DEF_TPG_ATTRIB(default_erl);
 DEF_TPG_ATTRIB(t10_pi);
 DEF_TPG_ATTRIB(fabric_prot_type);
 DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
+DEF_TPG_ATTRIB(login_keys_workaround);
 
 static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
        &iscsi_tpg_attrib_attr_authentication,
@@ -796,6 +797,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
        &iscsi_tpg_attrib_attr_t10_pi,
        &iscsi_tpg_attrib_attr_fabric_prot_type,
        &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
+       &iscsi_tpg_attrib_attr_login_keys_workaround,
        NULL,
 };
 
index 96df63f1f795ebc14c01570e694a8ba4cae7ace1..7a6751fecd323cf948a77e4508430487b3cc4717 100644 (file)
@@ -864,7 +864,8 @@ static int iscsi_target_handle_csg_zero(
                        SENDER_TARGET,
                        login->rsp_buf,
                        &login->rsp_length,
-                       conn->param_list);
+                       conn->param_list,
+                       conn->tpg->tpg_attrib.login_keys_workaround);
        if (ret < 0)
                return -1;
 
@@ -934,7 +935,8 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log
                        SENDER_TARGET,
                        login->rsp_buf,
                        &login->rsp_length,
-                       conn->param_list);
+                       conn->param_list,
+                       conn->tpg->tpg_attrib.login_keys_workaround);
        if (ret < 0) {
                iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
                                ISCSI_LOGIN_STATUS_INIT_ERR);
index fce627628200cf9917a8212da7a17ccff3d6136c..caab1045742dfc659ac906abfffaa4c238f152e4 100644 (file)
@@ -765,7 +765,8 @@ static int iscsi_check_for_auth_key(char *key)
        return 0;
 }
 
-static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
+static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param,
+                                                   bool keys_workaround)
 {
        if (IS_TYPE_BOOL_AND(param)) {
                if (!strcmp(param->value, NO))
@@ -773,19 +774,31 @@ static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
        } else if (IS_TYPE_BOOL_OR(param)) {
                if (!strcmp(param->value, YES))
                        SET_PSTATE_REPLY_OPTIONAL(param);
-                /*
-                 * Required for gPXE iSCSI boot client
-                 */
-               if (!strcmp(param->name, IMMEDIATEDATA))
-                       SET_PSTATE_REPLY_OPTIONAL(param);
+
+               if (keys_workaround) {
+                       /*
+                        * Required for gPXE iSCSI boot client
+                        */
+                       if (!strcmp(param->name, IMMEDIATEDATA))
+                               SET_PSTATE_REPLY_OPTIONAL(param);
+               }
        } else if (IS_TYPE_NUMBER(param)) {
                if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
                        SET_PSTATE_REPLY_OPTIONAL(param);
-               /*
-                * Required for gPXE iSCSI boot client
-                */
-               if (!strcmp(param->name, MAXCONNECTIONS))
-                       SET_PSTATE_REPLY_OPTIONAL(param);
+
+               if (keys_workaround) {
+                       /*
+                        * Required for Mellanox Flexboot PXE boot ROM
+                        */
+                       if (!strcmp(param->name, FIRSTBURSTLENGTH))
+                               SET_PSTATE_REPLY_OPTIONAL(param);
+
+                       /*
+                        * Required for gPXE iSCSI boot client
+                        */
+                       if (!strcmp(param->name, MAXCONNECTIONS))
+                               SET_PSTATE_REPLY_OPTIONAL(param);
+               }
        } else if (IS_PHASE_DECLARATIVE(param))
                SET_PSTATE_REPLY_OPTIONAL(param);
 }
@@ -1422,7 +1435,8 @@ int iscsi_encode_text_output(
        u8 sender,
        char *textbuf,
        u32 *length,
-       struct iscsi_param_list *param_list)
+       struct iscsi_param_list *param_list,
+       bool keys_workaround)
 {
        char *output_buf = NULL;
        struct iscsi_extra_response *er;
@@ -1458,7 +1472,8 @@ int iscsi_encode_text_output(
                        *length += 1;
                        output_buf = textbuf + *length;
                        SET_PSTATE_PROPOSER(param);
-                       iscsi_check_proposer_for_optional_reply(param);
+                       iscsi_check_proposer_for_optional_reply(param,
+                                                               keys_workaround);
                        pr_debug("Sending key: %s=%s\n",
                                param->name, param->value);
                }
index 9962ccf0ccd7d923d074923661a48e4b058e5400..c47b73f5752838a2fcdbc80c3e8ec901498eefa7 100644 (file)
@@ -46,7 +46,7 @@ extern int iscsi_extract_key_value(char *, char **, char **);
 extern int iscsi_update_param_value(struct iscsi_param *, char *);
 extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
 extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
-                       struct iscsi_param_list *);
+                       struct iscsi_param_list *, bool);
 extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
 extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
                        struct iscsi_param_list *);
index abaabbaebd881b74dad4ea341b58df572306a41c..594d07a1e995ec87d467f4286a1d8668f2e32e3d 100644 (file)
@@ -227,6 +227,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
        a->t10_pi = TA_DEFAULT_T10_PI;
        a->fabric_prot_type = TA_DEFAULT_FABRIC_PROT_TYPE;
        a->tpg_enabled_sendtargets = TA_DEFAULT_TPG_ENABLED_SENDTARGETS;
+       a->login_keys_workaround = TA_DEFAULT_LOGIN_KEYS_WORKAROUND;
 }
 
 int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
@@ -895,3 +896,21 @@ int iscsit_ta_tpg_enabled_sendtargets(
 
        return 0;
 }
+
+int iscsit_ta_login_keys_workaround(
+       struct iscsi_portal_group *tpg,
+       u32 flag)
+{
+       struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
+
+       if ((flag != 0) && (flag != 1)) {
+               pr_err("Illegal value %d\n", flag);
+               return -EINVAL;
+       }
+
+       a->login_keys_workaround = flag;
+       pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
+               tpg->tpgt, (a->login_keys_workaround) ? "ON" : "OFF");
+
+       return 0;
+}
index ceba298511677a5cf5ca49d784258f6c111da7dd..59fd3cabe89d0a2726b879074daf5f158abdde39 100644 (file)
@@ -48,5 +48,6 @@ extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32);
 extern int iscsit_ta_t10_pi(struct iscsi_portal_group *, u32);
 extern int iscsit_ta_fabric_prot_type(struct iscsi_portal_group *, u32);
 extern int iscsit_ta_tpg_enabled_sendtargets(struct iscsi_portal_group *, u32);
+extern int iscsit_ta_login_keys_workaround(struct iscsi_portal_group *, u32);
 
 #endif /* ISCSI_TARGET_TPG_H */
index 7948fc68286b350cd3923e3c63fcab94d8d872a0..0ca1fb08805b254fa8ffda73f4decd4c48ac2211 100644 (file)
@@ -66,6 +66,14 @@ struct sock;
 #define TA_DEFAULT_FABRIC_PROT_TYPE    0
 /* TPG status needs to be enabled to return sendtargets discovery endpoint info */
 #define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1
+/*
+ * Used to control the sending of keys with optional to respond state bit,
+ * as a workaround for non RFC compliant initiators,that do not propose,
+ * nor respond to specific keys required for login to complete.
+ *
+ * See iscsi_check_proposer_for_optional_reply() for more details.
+ */
+#define TA_DEFAULT_LOGIN_KEYS_WORKAROUND 1
 
 #define ISCSI_IOV_DATA_BUFFER          5
 
@@ -768,6 +776,7 @@ struct iscsi_tpg_attrib {
        u8                      t10_pi;
        u32                     fabric_prot_type;
        u32                     tpg_enabled_sendtargets;
+       u32                     login_keys_workaround;
        struct iscsi_portal_group *tpg;
 };