From patchwork Sun Jun 7 20:35:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 11592227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98AD0913 for ; Sun, 7 Jun 2020 20:36:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EAE72074B for ; Sun, 7 Jun 2020 20:36:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="vtUMYzP3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbgFGUgV (ORCPT ); Sun, 7 Jun 2020 16:36:21 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:51676 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726093AbgFGUgU (ORCPT ); Sun, 7 Jun 2020 16:36:20 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KWxHU125879; Sun, 7 Jun 2020 20:36:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2020-01-29; bh=KrgSEtpfrZL+/UxGcqPQkZactA2N8r2O9ZsbXbF5XnU=; b=vtUMYzP3fy/MrjSavc/bZzImD1skzcR9xCEHVDQmo+UIsEa5ps7RryiMaGqZckXkCQ+x UKe6kdQyy/ga4fZly03sourWujIrmjbqwUexwqJYgu3h/fQn+d+MLbSwdlUyM3g7vqz6 5Jt5F8iFDkg9NTG5/lgFoTreWjfxeg4Pq+EBE7sLqXv3C4MdzFi2XlbZ5hjuTBb0ghAI TWExcentBbgzb+Ds1q7KCh8Q9JV8yA51RsEW/oMK6cGB3aZmmaTpHtfZmP5YTQtcX4Px mLsV5praJ1mll4gXtB1H4W1WdpFNBiE/Ay271MMyfwN/V74o6mxwrrvxb4LADYpX5iDr Mg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 31g3smkxfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 07 Jun 2020 20:36:14 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 057KSFZ2020096; Sun, 7 Jun 2020 20:36:14 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 31gn205naq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 07 Jun 2020 20:36:13 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 057KaDnL022728; Sun, 7 Jun 2020 20:36:13 GMT Received: from ol2.localdomain (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 07 Jun 2020 13:36:13 -0700 From: Mike Christie To: bvanassche@acm.org, bstroesser@ts.fujitsu.com, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Subject: [PATCH 07/17] iscsi target: setup transport_id Date: Sun, 7 Jun 2020 15:35:54 -0500 Message-Id: <1591562164-9766-8-git-send-email-michael.christie@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> References: <1591562164-9766-1-git-send-email-michael.christie@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9645 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 cotscore=-2147483648 suspectscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006070161 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org The iscsi target does its own session setup. This patch updates the driver so it sets up the transport id. Signed-off-by: Mike Christie Reviewed-by: Hannes Reinecke --- drivers/target/iscsi/iscsi_target_nego.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/target/iscsi/iscsi_target_nego.c b/drivers/target/iscsi/iscsi_target_nego.c index 685d771..c44613a2 100644 --- a/drivers/target/iscsi/iscsi_target_nego.c +++ b/drivers/target/iscsi/iscsi_target_nego.c @@ -1032,6 +1032,20 @@ static void iscsi_initiatorname_tolower( } } +static int iscsi_setup_i_tpt_id(struct iscsi_session *sess, char *iname) +{ + char isid_buf[13]; + + sprintf(isid_buf, "%6phN", sess->isid); + + sess->se_sess->tpt_id = target_create_transport_id(SCSI_PROTOCOL_ISCSI, + iname, isid_buf); + if (!sess->se_sess->tpt_id) + return -ENOMEM; + + return 0; +} + /* * Processes the first Login Request.. */ @@ -1260,11 +1274,21 @@ int iscsi_target_locate_portal( tag_size = sizeof(struct iscsi_cmd) + conn->conn_transport->priv_size; ret = transport_alloc_session_tags(sess->se_sess, tag_num, tag_size); - if (ret < 0) { - iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, - ISCSI_LOGIN_STATUS_NO_RESOURCES); - ret = -1; + if (ret < 0) + goto return_oom; + + if (conn->tpg != iscsit_global->discovery_tpg) { + if (iscsi_setup_i_tpt_id(sess, i_buf)) + /* tags and nacl released when session is freed */ + goto return_oom; } + + goto out; + +return_oom: + iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, + ISCSI_LOGIN_STATUS_NO_RESOURCES); + ret = -1; out: kfree(tmpbuf); return ret;