diff -Nru tgt-1.0.43/debian/changelog tgt-1.0.43/debian/changelog --- tgt-1.0.43/debian/changelog 2014-04-11 10:56:22.000000000 -0300 +++ tgt-1.0.43/debian/changelog 2015-08-04 15:55:58.000000000 -0300 @@ -1,3 +1,9 @@ +tgt (1:1.0.43-0ubuntu5) trusty; urgency=medium + + * iSER: Add Discovery support (LP: #1409904) + + -- Rafael David Tinoco Tue, 04 Aug 2015 15:42:00 -0300 + tgt (1:1.0.43-0ubuntu4) trusty; urgency=medium * debian/patches/fix_delayed_management_request.patch: Adjust patch to fix diff -Nru tgt-1.0.43/debian/patches/add-iser-discovery-support.patch tgt-1.0.43/debian/patches/add-iser-discovery-support.patch --- tgt-1.0.43/debian/patches/add-iser-discovery-support.patch 1969-12-31 21:00:00.000000000 -0300 +++ tgt-1.0.43/debian/patches/add-iser-discovery-support.patch 2015-08-04 15:38:10.000000000 -0300 @@ -0,0 +1,104 @@ +Description: iser: Add Discovery support + +Add support to handle TEXT PDU, such as SendTargets which are used for +running iscsi discovery over iser. + +Signed-off-by: Or Gerlitz +Signed-off-by: Alexander Nezhinsky +Signed-off-by: FUJITA Tomonori + +Author: Or Gerlitz +Origin: upstream, commit: 4a4268bc3a458be0190709bdd7f13392f91ca15f +Bug-Ubuntu: https://launchpad.net/bugs/1445038 +Last-Update: 2015-04-16 +--- tgt-1.0.43.orig/usr/iscsi/iser.c ++++ tgt-1.0.43/usr/iscsi/iser.c +@@ -2597,7 +2597,9 @@ static int iser_task_delivery(struct ise + break; + case ISCSI_OP_TEXT: + err = iser_text_exec(&conn->h, &task->pdu, &conn->text_tx_task->pdu); ++ schedule_resp_tx(conn->text_tx_task, conn); + break; ++ + default: + eprintf("Internal error: Unexpected op:0x%x\n", task->opcode); + err = -EINVAL; +@@ -2829,6 +2831,8 @@ static void iser_rx_handler(struct iser_ + break; + case ISCSI_OP_TEXT: + dprintf("text rx\n"); ++ err = iser_task_delivery(task); ++ queue_task = 0; + break; + case ISCSI_OP_SNACK: + eprintf("Cannot handle SNACK yet\n"); +--- tgt-1.0.43.orig/usr/iscsi/iser_text.c ++++ tgt-1.0.43/usr/iscsi/iser_text.c +@@ -588,6 +588,12 @@ static void iser_login_finish(struct isc + iscsi_conn->tsih = iscsi_conn->session->tsih; + break; + case SESSION_DISCOVERY: ++ err = iser_login_complete(iscsi_conn); ++ if (err) { ++ class = ISCSI_STATUS_CLS_TARGET_ERR; ++ detail = ISCSI_LOGIN_STATUS_NO_RESOURCES; ++ goto fail; ++ } + /* set a dummy tsih value */ + iscsi_conn->tsih = 1; + break; +@@ -785,6 +791,32 @@ auth_err: + return; + } + ++ ++void iser_target_list_build(struct iscsi_connection *conn, struct iser_pdu *tx_pdu, char *addr, char *name) ++{ ++ struct iscsi_target *target; ++ ++ list_for_each_entry(target, &iscsi_targets_list, tlist) { ++ if (name && strcmp(tgt_targetname(target->tid), name)) ++ continue; ++ ++ if (!target->rdma) ++ continue; ++ ++ if (ip_acl(target->tid, conn)) ++ continue; ++ ++ if (iqn_acl(target->tid, conn)) ++ continue; ++ ++ if (isns_scn_access(target->tid, conn->initiator)) ++ continue; ++ ++ iser_text_key_add(conn, tx_pdu, "TargetName", tgt_targetname(target->tid)); ++ iser_text_key_add(conn, tx_pdu, "TargetAddress", addr); ++ } ++} ++ + static void iser_text_scan(struct iscsi_connection *iscsi_conn, + struct iser_pdu *rx_pdu, + struct iser_pdu *tx_pdu) +@@ -826,7 +858,7 @@ static void iser_text_scan(struct iscsi_ + *p++ = ']'; + + sprintf(p, ":%d,1", ISCSI_LISTEN_PORT); +- target_list_build(iscsi_conn, buf, ++ iser_target_list_build(iscsi_conn, tx_pdu, buf, + strcmp(value, "All") ? value : NULL); + } else + iser_text_key_add(iscsi_conn, tx_pdu, key, "NotUnderstood"); +@@ -856,6 +888,12 @@ int iser_text_exec(struct iscsi_connecti + dprintf("Text request: %d\n", iscsi_conn->state); + iser_text_scan(iscsi_conn, rx_pdu, tx_pdu); + ++ if (tx_pdu->membuf.size > MAX_KEY_VALUE_PAIRS) { ++ eprintf("Text pdu size %d too big, can't send at once\n", ++ tx_pdu->membuf.size); ++ tx_pdu->membuf.size = 0; ++ } ++ + if (req->flags & ISCSI_FLAG_CMD_FINAL) + rsp->flags = ISCSI_FLAG_CMD_FINAL; + diff -Nru tgt-1.0.43/debian/patches/series tgt-1.0.43/debian/patches/series --- tgt-1.0.43/debian/patches/series 2014-04-11 10:31:48.000000000 -0300 +++ tgt-1.0.43/debian/patches/series 2015-08-04 15:38:17.000000000 -0300 @@ -2,3 +2,4 @@ fix-config-regression.patch fix_delayed_management_request.patch fix_leak_of_task_in_scsi_flag.patch +add-iser-discovery-support.patch