All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH v3 4/4] nvme-tcp: support IPv6 traffic class
Date: Sun, 16 Aug 2026 01:09:56 +0000	[thread overview]
Message-ID: <20260816010957.285D91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <52c4840e36ee6016d18806c2d205f4f9fdc1e830.1786841319.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The NVMe TCP target silently fails to set the IPv6 traffic class because it passes a 1-byte option length for IPV6_TCLASS.
--

--- Patch [4]: [PATCH v3 4/4] nvme-tcp: support IPv6 traffic class ---
commit f06d75be38a565495a1d84b7e856f1a1a552b88e
Author: Geliang Tang <geliang@kernel.org>

nvme-tcp: support IPv6 traffic class

This commit extends the NVMe TCP host queue socket setup to support the IPv6
traffic class. It applies the TOS value to IPv6 sockets via the IPV6_TCLASS
socket option.

> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 3bc41a4735d94..feedd46bd3a2b 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
[ ... ]
> @@ -1815,6 +1815,15 @@ static void nvme_tcp_sock_set_tos(struct sock *sk, int tos)
>  			   KERNEL_SOCKPTR(&tos), sizeof(tos));
>  }
>  
> +static void nvme_tcp_sock_set_tclass(struct sock *sk, int tclass)
> +{
> +#if IS_ENABLED(CONFIG_IPV6)
> +	if (sk->sk_family == AF_INET6)
> +		do_sock_setsockopt(sk->sk_socket, false, SOL_IPV6, IPV6_TCLASS,
> +				   KERNEL_SOCKPTR(&tclass), sizeof(tclass));

While reviewing this patch, I noticed a related bug in the target implementation
which handles this exact same logic.

In drivers/nvme/target/tcp.c:nvmet_tcp_sock_set_tclass():

	u8 tclass = ip6_tclass(inet6_sk(sk)->rcv_flowinfo);

	if (tclass > 0)
		do_sock_setsockopt(sk->sk_socket, false, SOL_IPV6,
				   IPV6_TCLASS, KERNEL_SOCKPTR(&tclass),
				   sizeof(tclass));
                                   ^^^^^^^^^^^^^^

[Severity: Medium]
Will this setsockopt call fail silently in the target code?

The tclass variable is declared as a u8, so sizeof(tclass) evaluates to 1. The
IPv6 networking core strictly requires an option length of at least 4 bytes for
IPV6_TCLASS.

Passing sizeof(u8) causes do_ipv6_setsockopt() to return -EINVAL, which means
the IPv6 traffic class is silently ignored instead of being applied to the
socket, leading to incorrect QoS behavior without alerting the user.

Does the target code need to be updated to pass a 4-byte length?

> +#endif
> +}
> +

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1786841319.git.tanggeliang@kylinos.cn?part=4

  reply	other threads:[~2026-08-16  1:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16  0:59 [PATCH v3 0/4] nvme-tcp: add IPv6 traffic class support Geliang Tang
2026-08-16  0:59 ` [PATCH v3 1/4] nvmet-tcp: unify sockopt with do_sock_setsockopt Geliang Tang
2026-08-16  0:59 ` [PATCH v3 2/4] nvme-tcp: " Geliang Tang
2026-08-16  1:16   ` sashiko-bot
2026-08-16  0:59 ` [PATCH v3 3/4] nvmet-tcp: support IPv6 traffic class Geliang Tang
2026-08-16  1:12   ` sashiko-bot
2026-08-16  1:00 ` [PATCH v3 4/4] nvme-tcp: " Geliang Tang
2026-08-16  1:09   ` sashiko-bot [this message]
2026-08-16  2:13 ` [PATCH v3 0/4] nvme-tcp: add IPv6 traffic class support MPTCP CI

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=20260816010957.285D91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=geliang@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.