netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
	linux-nvme@lists.infradead.org, Jakub Kicinski <kuba@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 07/18] nvme-tcp: allocate socket file
Date: Thu, 24 Aug 2023 16:39:14 +0200	[thread overview]
Message-ID: <20230824143925.9098-8-hare@suse.de> (raw)
In-Reply-To: <20230824143925.9098-1-hare@suse.de>

When using the TLS upcall we need to allocate a socket file such
that the userspace daemon is able to use the socket.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/tcp.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index 9ce417cd32a7..324d3bce65b8 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1338,7 +1338,9 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
 	}
 
 	noreclaim_flag = memalloc_noreclaim_save();
-	sock_release(queue->sock);
+	/* ->sock will be released by fput() */
+	fput(queue->sock->file);
+	queue->sock = NULL;
 	memalloc_noreclaim_restore(noreclaim_flag);
 
 	kfree(queue->pdu);
@@ -1512,6 +1514,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
 	struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
 	struct nvme_tcp_queue *queue = &ctrl->queues[qid];
 	int ret, rcv_pdu_size;
+	struct file *sock_file;
 
 	mutex_init(&queue->queue_lock);
 	queue->ctrl = ctrl;
@@ -1534,6 +1537,11 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
 		goto err_destroy_mutex;
 	}
 
+	sock_file = sock_alloc_file(queue->sock, O_CLOEXEC, NULL);
+	if (IS_ERR(sock_file)) {
+		ret = PTR_ERR(sock_file);
+		goto err_destroy_mutex;
+	}
 	nvme_tcp_reclassify_socket(queue->sock);
 
 	/* Single syn retry */
@@ -1640,7 +1648,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
 	if (queue->hdr_digest || queue->data_digest)
 		nvme_tcp_free_crypto(queue);
 err_sock:
-	sock_release(queue->sock);
+	/* ->sock will be released by fput() */
+	fput(queue->sock->file);
 	queue->sock = NULL;
 err_destroy_mutex:
 	mutex_destroy(&queue->send_mutex);
-- 
2.35.3


  parent reply	other threads:[~2023-08-24 14:39 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 14:39 [PATCHv11 00/18] nvme: In-kernel TLS support for TCP Hannes Reinecke
2023-08-24 14:39 ` [PATCH 01/18] nvme-keyring: register '.nvme' keyring Hannes Reinecke
2023-08-24 14:39 ` [PATCH 02/18] nvme-keyring: define a 'psk' keytype Hannes Reinecke
2023-08-24 14:39 ` [PATCH 03/18] nvme: add TCP TSAS definitions Hannes Reinecke
2023-08-24 14:39 ` [PATCH 04/18] nvme-tcp: add definitions for TLS cipher suites Hannes Reinecke
2023-08-24 14:39 ` [PATCH 05/18] nvme-keyring: implement nvme_tls_psk_default() Hannes Reinecke
2023-08-24 14:39 ` [PATCH 06/18] security/keys: export key_lookup() Hannes Reinecke
2023-08-24 14:39 ` Hannes Reinecke [this message]
2023-08-24 14:39 ` [PATCH 08/18] nvme-tcp: enable TLS handshake upcall Hannes Reinecke
2023-08-24 14:39 ` [PATCH 09/18] nvme-tcp: control message handling for recvmsg() Hannes Reinecke
2023-08-24 14:39 ` [PATCH 10/18] nvme-tcp: improve icreq/icresp logging Hannes Reinecke
2023-08-24 14:39 ` [PATCH 11/18] nvme-fabrics: parse options 'keyring' and 'tls_key' Hannes Reinecke
2023-10-11 17:32   ` Keith Busch
2023-10-12  6:24     ` Hannes Reinecke
2023-08-24 14:39 ` [PATCH 12/18] nvmet: make TCP sectype settable via configfs Hannes Reinecke
2023-08-24 14:39 ` [PATCH 13/18] nvmet-tcp: make nvmet_tcp_alloc_queue() a void function Hannes Reinecke
2023-08-24 14:39 ` [PATCH 14/18] nvmet-tcp: allocate socket file Hannes Reinecke
2023-08-24 14:39 ` [PATCH 15/18] nvmet: Set 'TREQ' to 'required' when TLS is enabled Hannes Reinecke
2023-08-24 14:39 ` [PATCH 16/18] nvmet-tcp: enable TLS handshake upcall Hannes Reinecke
2023-09-12 11:32   ` Sagi Grimberg
2023-08-24 14:39 ` [PATCH 17/18] nvmet-tcp: control messages for recvmsg() Hannes Reinecke
2023-08-24 14:39 ` [PATCH 18/18] nvmet-tcp: peek icreq before starting TLS Hannes Reinecke
2023-09-12 11:32   ` Sagi Grimberg
2023-09-12 11:48     ` Hannes Reinecke
2023-09-12 12:55       ` Sagi Grimberg
2023-09-12 11:34 ` [PATCHv11 00/18] nvme: In-kernel TLS support for TCP Sagi Grimberg
2023-09-12 11:46   ` Hannes Reinecke
  -- strict thread matches above, loose matches on Subject: below --
2023-08-16 12:05 [PATCHv10 " Hannes Reinecke
2023-08-16 12:05 ` [PATCH 07/18] nvme-tcp: allocate socket file Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230824143925.9098-8-hare@suse.de \
    --to=hare@suse.de \
    --cc=edumazet@google.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).