Skip to content

Commit 138d351

Browse files
author
Nicholas Bellinger
committed
iscsi-target: Add login_keys_workaround attribute for non RFC initiators
This patch re-introduces part of a long standing login workaround that was recently dropped by: commit 1c99de9 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>
1 parent 55dd8cf commit 138d351

7 files changed

Lines changed: 64 additions & 16 deletions

File tree

‎drivers/target/iscsi/iscsi_target_configfs.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ DEF_TPG_ATTRIB(default_erl);
781781
DEF_TPG_ATTRIB(t10_pi);
782782
DEF_TPG_ATTRIB(fabric_prot_type);
783783
DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
784+
DEF_TPG_ATTRIB(login_keys_workaround);
784785

785786
static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
786787
&iscsi_tpg_attrib_attr_authentication,
@@ -796,6 +797,7 @@ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
796797
&iscsi_tpg_attrib_attr_t10_pi,
797798
&iscsi_tpg_attrib_attr_fabric_prot_type,
798799
&iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
800+
&iscsi_tpg_attrib_attr_login_keys_workaround,
799801
NULL,
800802
};
801803

‎drivers/target/iscsi/iscsi_target_nego.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,8 @@ static int iscsi_target_handle_csg_zero(
864864
SENDER_TARGET,
865865
login->rsp_buf,
866866
&login->rsp_length,
867-
conn->param_list);
867+
conn->param_list,
868+
conn->tpg->tpg_attrib.login_keys_workaround);
868869
if (ret < 0)
869870
return -1;
870871

@@ -934,7 +935,8 @@ static int iscsi_target_handle_csg_one(struct iscsi_conn *conn, struct iscsi_log
934935
SENDER_TARGET,
935936
login->rsp_buf,
936937
&login->rsp_length,
937-
conn->param_list);
938+
conn->param_list,
939+
conn->tpg->tpg_attrib.login_keys_workaround);
938940
if (ret < 0) {
939941
iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
940942
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
@@ -765,27 +765,40 @@ static int iscsi_check_for_auth_key(char *key)
765765
return 0;
766766
}
767767

768-
static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
768+
static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param,
769+
bool keys_workaround)
769770
{
770771
if (IS_TYPE_BOOL_AND(param)) {
771772
if (!strcmp(param->value, NO))
772773
SET_PSTATE_REPLY_OPTIONAL(param);
773774
} else if (IS_TYPE_BOOL_OR(param)) {
774775
if (!strcmp(param->value, YES))
775776
SET_PSTATE_REPLY_OPTIONAL(param);
776-
/*
777-
* Required for gPXE iSCSI boot client
778-
*/
779-
if (!strcmp(param->name, IMMEDIATEDATA))
780-
SET_PSTATE_REPLY_OPTIONAL(param);
777+
778+
if (keys_workaround) {
779+
/*
780+
* Required for gPXE iSCSI boot client
781+
*/
782+
if (!strcmp(param->name, IMMEDIATEDATA))
783+
SET_PSTATE_REPLY_OPTIONAL(param);
784+
}
781785
} else if (IS_TYPE_NUMBER(param)) {
782786
if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
783787
SET_PSTATE_REPLY_OPTIONAL(param);
784-
/*
785-
* Required for gPXE iSCSI boot client
786-
*/
787-
if (!strcmp(param->name, MAXCONNECTIONS))
788-
SET_PSTATE_REPLY_OPTIONAL(param);
788+
789+
if (keys_workaround) {
790+
/*
791+
* Required for Mellanox Flexboot PXE boot ROM
792+
*/
793+
if (!strcmp(param->name, FIRSTBURSTLENGTH))
794+
SET_PSTATE_REPLY_OPTIONAL(param);
795+
796+
/*
797+
* Required for gPXE iSCSI boot client
798+
*/
799+
if (!strcmp(param->name, MAXCONNECTIONS))
800+
SET_PSTATE_REPLY_OPTIONAL(param);
801+
}
789802
} else if (IS_PHASE_DECLARATIVE(param))
790803
SET_PSTATE_REPLY_OPTIONAL(param);
791804
}
@@ -1422,7 +1435,8 @@ int iscsi_encode_text_output(
14221435
u8 sender,
14231436
char *textbuf,
14241437
u32 *length,
1425-
struct iscsi_param_list *param_list)
1438+
struct iscsi_param_list *param_list,
1439+
bool keys_workaround)
14261440
{
14271441
char *output_buf = NULL;
14281442
struct iscsi_extra_response *er;
@@ -1458,7 +1472,8 @@ int iscsi_encode_text_output(
14581472
*length += 1;
14591473
output_buf = textbuf + *length;
14601474
SET_PSTATE_PROPOSER(param);
1461-
iscsi_check_proposer_for_optional_reply(param);
1475+
iscsi_check_proposer_for_optional_reply(param,
1476+
keys_workaround);
14621477
pr_debug("Sending key: %s=%s\n",
14631478
param->name, param->value);
14641479
}

‎drivers/target/iscsi/iscsi_target_parameters.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern int iscsi_extract_key_value(char *, char **, char **);
4646
extern int iscsi_update_param_value(struct iscsi_param *, char *);
4747
extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
4848
extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
49-
struct iscsi_param_list *);
49+
struct iscsi_param_list *, bool);
5050
extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
5151
extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
5252
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)
@@ -895,3 +896,21 @@ int iscsit_ta_tpg_enabled_sendtargets(
895896

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

‎drivers/target/iscsi/iscsi_target_tpg.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ extern int iscsit_ta_default_erl(struct iscsi_portal_group *, u32);
4848
extern int iscsit_ta_t10_pi(struct iscsi_portal_group *, u32);
4949
extern int iscsit_ta_fabric_prot_type(struct iscsi_portal_group *, u32);
5050
extern int iscsit_ta_tpg_enabled_sendtargets(struct iscsi_portal_group *, u32);
51+
extern int iscsit_ta_login_keys_workaround(struct iscsi_portal_group *, u32);
5152

5253
#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
@@ -66,6 +66,14 @@ struct sock;
6666
#define TA_DEFAULT_FABRIC_PROT_TYPE 0
6767
/* TPG status needs to be enabled to return sendtargets discovery endpoint info */
6868
#define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1
69+
/*
70+
* Used to control the sending of keys with optional to respond state bit,
71+
* as a workaround for non RFC compliant initiators,that do not propose,
72+
* nor respond to specific keys required for login to complete.
73+
*
74+
* See iscsi_check_proposer_for_optional_reply() for more details.
75+
*/
76+
#define TA_DEFAULT_LOGIN_KEYS_WORKAROUND 1
6977

7078
#define ISCSI_IOV_DATA_BUFFER 5
7179

@@ -768,6 +776,7 @@ struct iscsi_tpg_attrib {
768776
u8 t10_pi;
769777
u32 fabric_prot_type;
770778
u32 tpg_enabled_sendtargets;
779+
u32 login_keys_workaround;
771780
struct iscsi_portal_group *tpg;
772781
};
773782

0 commit comments

Comments
 (0)