Skip to content

Commit c50e87e

Browse files
Nicholas Bellingergregkh
authored andcommitted
iscsi-target: Add login_keys_workaround attribute for non RFC initiators
commit 138d351 upstream. This patch re-introduces part of a long standing login workaround that was recently dropped by: commit 1c99de9 Author: Nicholas Bellinger <[email protected]> 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 <[email protected]> Cc: Robert LeBlanc <[email protected]> Reviewed-by: Arun Easi <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8045fe0 commit c50e87e

File tree

7 files changed

+64
-16
lines changed

7 files changed

+64
-16
lines changed

drivers/target/iscsi/iscsi_target_configfs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,7 @@ DEF_TPG_ATTRIB(default_erl);
868868
DEF_TPG_ATTRIB(t10_pi);
869869
DEF_TPG_ATTRIB(fabric_prot_type);
870870
DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
871+
DEF_TPG_ATTRIB(login_keys_workaround);
871872

872873
static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
873874
&iscsi_tpg_attrib_attr_authentication,
@@ -883,6 +884,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
883884
&iscsi_tpg_attrib_attr_t10_pi,
884885
&iscsi_tpg_attrib_attr_fabric_prot_type,
885886
&iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
887+
&iscsi_tpg_attrib_attr_login_keys_workaround,
886888
NULL,
887889
};
888890

drivers/target/iscsi/iscsi_target_nego.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,8 @@ static int iscsi_target_handle_csg_zero(
818818
SENDER_TARGET,
819819
login->rsp_buf,
820820
&login->rsp_length,
821-
conn->param_list);
821+
conn->param_list,
822+
conn->tpg->tpg_attrib.login_keys_workaround);
822823
if (ret < 0)
823824
return -1;
824825

@@ -888,7 +889,8 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log
888889
SENDER_TARGET,
889890
login->rsp_buf,
890891
&login->rsp_length,
891-
conn->param_list);
892+
conn->param_list,
893+
conn->tpg->tpg_attrib.login_keys_workaround);
892894
if (ret < 0) {
893895
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
894896
ISCSI_LOGIN_STATUS_INIT_ERR);

drivers/target/iscsi/iscsi_target_parameters.c

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -764,27 +764,40 @@ static int iscsi_check_for_auth_key(char *key)
764764
return 0;
765765
}
766766

767-
static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
767+
static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param,
768+
bool keys_workaround)
768769
{
769770
if (IS_TYPE_BOOL_AND(param)) {
770771
if (!strcmp(param->value, NO))
771772
SET_PSTATE_REPLY_OPTIONAL(param);
772773
} else if (IS_TYPE_BOOL_OR(param)) {
773774
if (!strcmp(param->value, YES))
774775
SET_PSTATE_REPLY_OPTIONAL(param);
775-
/*
776-
* Required for gPXE iSCSI boot client
777-
*/
778-
if (!strcmp(param->name, IMMEDIATEDATA))
779-
SET_PSTATE_REPLY_OPTIONAL(param);
776+
777+
if (keys_workaround) {
778+
/*
779+
* Required for gPXE iSCSI boot client
780+
*/
781+
if (!strcmp(param->name, IMMEDIATEDATA))
782+
SET_PSTATE_REPLY_OPTIONAL(param);
783+
}
780784
} else if (IS_TYPE_NUMBER(param)) {
781785
if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
782786
SET_PSTATE_REPLY_OPTIONAL(param);
783-
/*
784-
* Required for gPXE iSCSI boot client
785-
*/
786-
if (!strcmp(param->name, MAXCONNECTIONS))
787-
SET_PSTATE_REPLY_OPTIONAL(param);
787+
788+
if (keys_workaround) {
789+
/*
790+
* Required for Mellanox Flexboot PXE boot ROM
791+
*/
792+
if (!strcmp(param->name, FIRSTBURSTLENGTH))
793+
SET_PSTATE_REPLY_OPTIONAL(param);
794+
795+
/*
796+
* Required for gPXE iSCSI boot client
797+
*/
798+
if (!strcmp(param->name, MAXCONNECTIONS))
799+
SET_PSTATE_REPLY_OPTIONAL(param);
800+
}
788801
} else if (IS_PHASE_DECLARATIVE(param))
789802
SET_PSTATE_REPLY_OPTIONAL(param);
790803
}
@@ -1421,7 +1434,8 @@ int iscsi_encode_text_output(
14211434
u8 sender,
14221435
char *textbuf,
14231436
u32 *length,
1424-
struct iscsi_param_list *param_list)
1437+
struct iscsi_param_list *param_list,
1438+
bool keys_workaround)
14251439
{
14261440
char *output_buf = NULL;
14271441
struct iscsi_extra_response *er;
@@ -1457,7 +1471,8 @@ int iscsi_encode_text_output(
14571471
*length += 1;
14581472
output_buf = textbuf + *length;
14591473
SET_PSTATE_PROPOSER(param);
1460-
iscsi_check_proposer_for_optional_reply(param);
1474+
iscsi_check_proposer_for_optional_reply(param,
1475+
keys_workaround);
14611476
pr_debug("Sending key: %s=%s\n",
14621477
param->name, param->value);
14631478
}

drivers/target/iscsi/iscsi_target_parameters.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ extern int iscsi_extract_key_value(char *, char **, char **);
4040
extern int iscsi_update_param_value(struct iscsi_param *, char *);
4141
extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
4242
extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
43-
struct iscsi_param_list *);
43+
struct iscsi_param_list *, bool);
4444
extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
4545
extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
4646
struct iscsi_param_list *);

drivers/target/iscsi/iscsi_target_tpg.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ static void iscsit_set_default_tpg_attribs(struct iscsi_portal_group *tpg)
227227
a->t10_pi = TA_DEFAULT_T10_PI;
228228
a->fabric_prot_type = TA_DEFAULT_FABRIC_PROT_TYPE;
229229
a->tpg_enabled_sendtargets = TA_DEFAULT_TPG_ENABLED_SENDTARGETS;
230+
a->login_keys_workaround = TA_DEFAULT_LOGIN_KEYS_WORKAROUND;
230231
}
231232

232233
int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
@@ -899,3 +900,21 @@ int iscsit_ta_tpg_enabled_sendtargets(
899900

900901
return 0;
901902
}
903+
904+
int iscsit_ta_login_keys_workaround(
905+
struct iscsi_portal_group *tpg,
906+
u32 flag)
907+
{
908+
struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
909+
910+
if ((flag != 0) && (flag != 1)) {
911+
pr_err("Illegal value %d\n", flag);
912+
return -EINVAL;
913+
}
914+
915+
a->login_keys_workaround = flag;
916+
pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
917+
tpg->tpgt, (a->login_keys_workaround) ? "ON" : "OFF");
918+
919+
return 0;
920+
}

drivers/target/iscsi/iscsi_target_tpg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32);
3939
extern int iscsit_ta_t10_pi(struct iscsi_portal_group *, u32);
4040
extern int iscsit_ta_fabric_prot_type(struct iscsi_portal_group *, u32);
4141
extern int iscsit_ta_tpg_enabled_sendtargets(struct iscsi_portal_group *, u32);
42+
extern int iscsit_ta_login_keys_workaround(struct iscsi_portal_group *, u32);
4243

4344
#endif /* ISCSI_TARGET_TPG_H */

include/target/iscsi/iscsi_target_core.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@
6464
#define TA_DEFAULT_FABRIC_PROT_TYPE 0
6565
/* TPG status needs to be enabled to return sendtargets discovery endpoint info */
6666
#define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1
67+
/*
68+
* Used to control the sending of keys with optional to respond state bit,
69+
* as a workaround for non RFC compliant initiators,that do not propose,
70+
* nor respond to specific keys required for login to complete.
71+
*
72+
* See iscsi_check_proposer_for_optional_reply() for more details.
73+
*/
74+
#define TA_DEFAULT_LOGIN_KEYS_WORKAROUND 1
6775

6876
#define ISCSI_IOV_DATA_BUFFER 5
6977

@@ -765,6 +773,7 @@ struct iscsi_tpg_attrib {
765773
u8 t10_pi;
766774
u32 fabric_prot_type;
767775
u32 tpg_enabled_sendtargets;
776+
u32 login_keys_workaround;
768777
struct iscsi_portal_group *tpg;
769778
};
770779

0 commit comments

Comments
 (0)