[PATCH v2 3/3] nvmet-tcp: support IPv6 traffic class
Geliang Tang <[email protected]> Sat, 8 Aug 2026 14:55:01 +0800
| Newsgroups | org.infradead.lists.linux-nvme,dev.linux.lists.mptcp,org.kernel.vger.netdev |
|---|---|
| Message-ID | <ef1d3f9cbd321aeb0a49f37685f2fb7e01c60623.1786171863.git.tanggeliang@kylinos.cn> |
From: Geliang Tang <[email protected]> nvmet-tcp currently applies the received IPv4 TOS value when setting up a queue socket, but does not handle the IPv6 traffic class. Extend the queue socket setup to handle AF_INET6 sockets. Obtain the traffic class from the IPv6 socket's rcv_flowinfo and apply it through ip6_sock_set_tclass(). Keep the existing IPv4 TOS handling unchanged. Signed-off-by: Geliang Tang <[email protected]> --- drivers/nvme/target/tcp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 75a276d73be3..1d65519ebc0f 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1725,6 +1725,14 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue) /* Set socket type of service */ if (inet->rcv_tos > 0) ip_sock_set_tos(sock->sk, inet->rcv_tos); +#if IS_ENABLED(CONFIG_IPV6) + if (sock->sk->sk_family == AF_INET6) { + u8 rcv_tclass = ip6_tclass(inet6_sk(sock->sk)->rcv_flowinfo); + + if (rcv_tclass > 0) + ip6_sock_set_tclass(sock->sk, rcv_tclass); + } +#endif ret = 0; write_lock_bh(&sock->sk->sk_callback_lock); -- 2.53.0