[PATCH 3/3] nvmet-tcp: support IPv6 traffic class
Geliang Tang <[email protected]> Mon, 27 Jul 2026 11:19:03 +0800
| Newsgroups | org.infradead.lists.linux-nvme |
|---|---|
| Message-ID | <563c79d8a4b78c79262e236c583a0f6efb53a95d.1785122120.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 and apply it through IPV6_TCLASS. Keep the existing IPv4 TOS handling unchanged. Signed-off-by: Geliang Tang <[email protected]> --- drivers/nvme/target/tcp.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 75a276d73be3..fcdc73dfe5b0 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -13,6 +13,7 @@ #include <linux/nvme-keyring.h> #include <net/sock.h> #include <net/tcp.h> +#include <net/ipv6.h> #include <net/tls.h> #include <net/tls_prot.h> #include <net/handshake.h> @@ -1723,8 +1724,18 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue) sock_set_priority(sock->sk, so_priority); /* Set socket type of service */ - if (inet->rcv_tos > 0) - ip_sock_set_tos(sock->sk, inet->rcv_tos); + if (sock->sk->sk_family == AF_INET) { + if (inet->rcv_tos > 0) + ip_sock_set_tos(sock->sk, inet->rcv_tos); + } else if (sock->sk->sk_family == AF_INET6) { + int tclass = inet6_sk(sock->sk)->tclass; + + if (tclass > 0) + sock_common_setsockopt(sock->sk->sk_socket, SOL_IPV6, + IPV6_TCLASS, + KERNEL_SOCKPTR(&tclass), + sizeof(tclass)); + } ret = 0; write_lock_bh(&sock->sk->sk_callback_lock); -- 2.53.0