[PATCH 3/3] nvmet-tcp: support IPv6 traffic class
Geliang Tang
geliang at kernel.org
Sun Jul 26 20:19:03 PDT 2026
From: Geliang Tang <tanggeliang at kylinos.cn>
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 <tanggeliang at kylinos.cn>
---
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
More information about the Linux-nvme
mailing list