Re: [PATCH v4 4/4] nvme-tcp: support IPv6 traffic class

Sagi Grimberg <[email protected]>
Newsgroups org.kernel.vger.netdev,dev.linux.lists.mptcp,org.infradead.lists.linux-nvme
Message-ID <[email protected]>

On 18/08/2026 9:03, Geliang Tang wrote:
> From: Geliang Tang <[email protected]>
>
> Currently, nvme-tcp host only supports setting the IPv4 TOS value when a
> TOS is specified, but does not handle the IPv6 traffic class.
>
> Extend the queue socket setup to handle AF_INET6 sockets by applying the
> TOS value to both IPv4 and IPv6 sockets. For IPv6, the TOS value is set
> as the IPv6 traffic class via IPV6_TCLASS using do_sock_setsockopt().
>
> Signed-off-by: Geliang Tang <[email protected]>
> ---
>   drivers/nvme/host/tcp.c | 20 ++++++++++++++++++++
>   1 file changed, 20 insertions(+)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 025cade370b2..5f30be04a9dd 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -1815,6 +1815,17 @@ static int nvme_tcp_sock_set_tos(struct sock *sk, int tos)
>   				  KERNEL_SOCKPTR(&tos), sizeof(tos));
>   }
>   
> +static int nvme_tcp_sock_set_tclass(struct sock *sk, int tclass)
> +{
> +#if IS_ENABLED(CONFIG_IPV6)
> +	if (sk->sk_family == AF_INET6)
> +		return do_sock_setsockopt(sk->sk_socket, false, SOL_IPV6,
> +					  IPV6_TCLASS, KERNEL_SOCKPTR(&tclass),
> +					  sizeof(tclass));
> +#endif
> +	return 0;
> +}
> +
>   static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
>   				key_serial_t pskid)
>   {
> @@ -1909,6 +1920,15 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid,
>   				qid, ret);
>   			goto err_sock;
>   		}
> +
> +		ret = nvme_tcp_sock_set_tclass(queue->sock->sk,
> +					       nctrl->opts->tos);

Won't it just be cleaner to add a generic ip_sock_set_tclass() that 
hides the IS_ENABLED(CONFIG_IPV6) ifdef? Why do we need to wrap all 
these generic helpers?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.