From: Hannes Reinecke <hare@suse.de>
To: Geliang Tang <geliang@kernel.org>,
Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: Geliang Tang <tanggeliang@kylinos.cn>, linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvme-tcp: look up host_iface in the current netns
Date: Mon, 27 Jul 2026 15:24:17 +0200 [thread overview]
Message-ID: <8a23cec1-2e7b-451b-8c13-dffb72fcc757@suse.de> (raw)
In-Reply-To: <c14cd4633c27abe2dec863480168691023694aee.1785033817.git.tanggeliang@kylinos.cn>
On 7/26/26 4:46 AM, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> nvme_tcp_alloc_ctrl() looks opts->host_iface up in &init_net, the boot-time
> netns. When called from any other netns - e.g. the selftest's ns2, where
> ns2eth1 actually lives - the lookup misses and the controller setup fails
> with "invalid interface passed":
>
> nvmet: adding nsid 1 to subsystem nqn.2014-08.org.nvmexpress.mptcpdev
> nvmet_tcp: enabling port 24660 (0.0.0.0:24099)
> # nvme discover -a 10.1.1.1 --tos=0x10 --host-iface=ns2eth1
> nvme_tcp: invalid interface passed: ns2eth1
> # failed to add controller, error invalid interface
>
> Look the device up in current->nsproxy->net_ns instead so the check sees
> the calling task's netns.
>
> Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> ---
> drivers/nvme/host/tcp.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index ba5c7b3e2a7c..c89d84ccce1a 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -2960,7 +2960,8 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev,
> }
>
> if (opts->mask & NVMF_OPT_HOST_IFACE) {
> - if (!__dev_get_by_name(&init_net, opts->host_iface)) {
> + if (!__dev_get_by_name(current->nsproxy->net_ns,
> + opts->host_iface)) {
> pr_err("invalid interface passed: %s\n",
> opts->host_iface);
> ret = -ENODEV;
Reviewed-by: Hannes Reinecke <hare@kernel.org>
But: if we are running in a network namespace the IP address of the
ports in the discovery log page will be relative to that namespace,
too, and there's a good chance that they are not reachable from
the initiator reading the log page.
Making the whole point of discovery a bit pointless.
But I really don't have a good idea how to resolve that.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
next prev parent reply other threads:[~2026-07-27 13:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 2:46 [PATCH] nvme-tcp: look up host_iface in the current netns Geliang Tang
2026-07-27 13:24 ` Hannes Reinecke [this message]
2026-08-10 18:56 ` Keith Busch
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=8a23cec1-2e7b-451b-8c13-dffb72fcc757@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=geliang@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=tanggeliang@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.