aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Glanzmann <thomas@glanzmann.de>2013-10-07 17:13:46 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2013-10-24 00:30:12 -0400
commit2dd1d53fe004cd3b1e93e96508cfe637e6e31ef5 (patch)
tree0b968aa8771c078010cd7bd94834fcf02968bf42
parentb3fde035714b83ef7ddbbd5a520a2150d990349b (diff)
iscsi-target: Implement demo_mode_discovery logic
If demo_mode_discovery=0 and generate_node_acls=0 (demo mode dislabed) do not return TargetName+TargetAddress unless a NodeACL exists. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/iscsi/iscsi_target.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 934b5b9b7cf6..e183352a0645 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -3369,6 +3369,7 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3369 struct iscsi_tiqn *tiqn; 3369 struct iscsi_tiqn *tiqn;
3370 struct iscsi_tpg_np *tpg_np; 3370 struct iscsi_tpg_np *tpg_np;
3371 int buffer_len, end_of_buf = 0, len = 0, payload_len = 0; 3371 int buffer_len, end_of_buf = 0, len = 0, payload_len = 0;
3372 int target_name_printed;
3372 unsigned char buf[ISCSI_IQN_LEN+12]; /* iqn + "TargetName=" + \0 */ 3373 unsigned char buf[ISCSI_IQN_LEN+12]; /* iqn + "TargetName=" + \0 */
3373 unsigned char *text_in = cmd->text_in_ptr, *text_ptr = NULL; 3374 unsigned char *text_in = cmd->text_in_ptr, *text_ptr = NULL;
3374 3375
@@ -3406,19 +3407,23 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3406 continue; 3407 continue;
3407 } 3408 }
3408 3409
3409 len = sprintf(buf, "TargetName=%s", tiqn->tiqn); 3410 target_name_printed = 0;
3410 len += 1;
3411
3412 if ((len + payload_len) > buffer_len) {
3413 end_of_buf = 1;
3414 goto eob;
3415 }
3416 memcpy(payload + payload_len, buf, len);
3417 payload_len += len;
3418 3411
3419 spin_lock(&tiqn->tiqn_tpg_lock); 3412 spin_lock(&tiqn->tiqn_tpg_lock);
3420 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) { 3413 list_for_each_entry(tpg, &tiqn->tiqn_tpg_list, tpg_list) {
3421 3414
3415 /* If demo_mode_discovery=0 and generate_node_acls=0
3416 * (demo mode dislabed) do not return
3417 * TargetName+TargetAddress unless a NodeACL exists.
3418 */
3419
3420 if ((tpg->tpg_attrib.generate_node_acls == 0) &&
3421 (tpg->tpg_attrib.demo_mode_discovery == 0) &&
3422 (!core_tpg_get_initiator_node_acl(&tpg->tpg_se_tpg,
3423 cmd->conn->sess->sess_ops->InitiatorName))) {
3424 continue;
3425 }
3426
3422 spin_lock(&tpg->tpg_state_lock); 3427 spin_lock(&tpg->tpg_state_lock);
3423 if ((tpg->tpg_state == TPG_STATE_FREE) || 3428 if ((tpg->tpg_state == TPG_STATE_FREE) ||
3424 (tpg->tpg_state == TPG_STATE_INACTIVE)) { 3429 (tpg->tpg_state == TPG_STATE_INACTIVE)) {
@@ -3433,6 +3438,22 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd)
3433 struct iscsi_np *np = tpg_np->tpg_np; 3438 struct iscsi_np *np = tpg_np->tpg_np;
3434 bool inaddr_any = iscsit_check_inaddr_any(np); 3439 bool inaddr_any = iscsit_check_inaddr_any(np);
3435 3440
3441 if (!target_name_printed) {
3442 len = sprintf(buf, "TargetName=%s",
3443 tiqn->tiqn);
3444 len += 1;
3445
3446 if ((len + payload_len) > buffer_len) {
3447 spin_unlock(&tpg->tpg_np_lock);
3448 spin_unlock(&tiqn->tiqn_tpg_lock);
3449 end_of_buf = 1;
3450 goto eob;
3451 }
3452 memcpy(payload + payload_len, buf, len);
3453 payload_len += len;
3454 target_name_printed = 1;
3455 }
3456
3436 len = sprintf(buf, "TargetAddress=" 3457 len = sprintf(buf, "TargetAddress="
3437 "%s:%hu,%hu", 3458 "%s:%hu,%hu",
3438 (inaddr_any == false) ? 3459 (inaddr_any == false) ?