Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iscsi-target: Add IFC_SENDTARGETS_SINGLE support

This patch changes ISCSI_OP_TEXT handling of SendTargets=[iqn.,eui.]
payloads to return explicit discovery information.

It adds checks to iscsit_process_text_cmd() and adds the special single
$TARGETNAME discovery case in iscsit_build_sendtargets_response() code.

Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

+29
+28
drivers/target/iscsi/iscsi_target.c
··· 2016 2016 } 2017 2017 if (!strncmp("=All", text_ptr, 4)) { 2018 2018 cmd->cmd_flags |= IFC_SENDTARGETS_ALL; 2019 + } else if (!strncmp("=iqn.", text_ptr, 5) || 2020 + !strncmp("=eui.", text_ptr, 5)) { 2021 + cmd->cmd_flags |= IFC_SENDTARGETS_SINGLE; 2019 2022 } else { 2020 2023 pr_err("Unable to locate valid SendTargets=%s value\n", text_ptr); 2021 2024 goto reject; ··· 3401 3398 struct iscsi_tpg_np *tpg_np; 3402 3399 int buffer_len, end_of_buf = 0, len = 0, payload_len = 0; 3403 3400 unsigned char buf[ISCSI_IQN_LEN+12]; /* iqn + "TargetName=" + \0 */ 3401 + unsigned char *text_in = cmd->text_in_ptr, *text_ptr = NULL; 3404 3402 3405 3403 buffer_len = max(conn->conn_ops->MaxRecvDataSegmentLength, 3406 3404 SENDTARGETS_BUF_LIMIT); ··· 3412 3408 " response.\n"); 3413 3409 return -ENOMEM; 3414 3410 } 3411 + /* 3412 + * Locate pointer to iqn./eui. string for IFC_SENDTARGETS_SINGLE 3413 + * explicit case.. 3414 + */ 3415 + if (cmd->cmd_flags & IFC_SENDTARGETS_SINGLE) { 3416 + text_ptr = strchr(text_in, '='); 3417 + if (!text_ptr) { 3418 + pr_err("Unable to locate '=' string in text_in:" 3419 + " %s\n", text_in); 3420 + return -EINVAL; 3421 + } 3422 + /* 3423 + * Skip over '=' character.. 3424 + */ 3425 + text_ptr += 1; 3426 + } 3415 3427 3416 3428 spin_lock(&tiqn_lock); 3417 3429 list_for_each_entry(tiqn, &g_tiqn_list, tiqn_list) { 3430 + if ((cmd->cmd_flags & IFC_SENDTARGETS_SINGLE) && 3431 + strcmp(tiqn->tiqn, text_ptr)) { 3432 + continue; 3433 + } 3434 + 3418 3435 len = sprintf(buf, "TargetName=%s", tiqn->tiqn); 3419 3436 len += 1; 3420 3437 ··· 3488 3463 spin_unlock(&tiqn->tiqn_tpg_lock); 3489 3464 eob: 3490 3465 if (end_of_buf) 3466 + break; 3467 + 3468 + if (cmd->cmd_flags & IFC_SENDTARGETS_SINGLE) 3491 3469 break; 3492 3470 } 3493 3471 spin_unlock(&tiqn_lock);
+1
drivers/target/iscsi/iscsi_target_core.h
··· 134 134 ICF_OOO_CMDSN = 0x00000080, 135 135 ICF_REJECT_FAIL_CONN = 0x00000100, 136 136 IFC_SENDTARGETS_ALL = 0x00000200, 137 + IFC_SENDTARGETS_SINGLE = 0x00000400, 137 138 }; 138 139 139 140 /* struct iscsi_cmd->i_state */