summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-01-20 12:53:53 +0000
committerJakub Kicinski <kuba@kernel.org>2026-01-21 19:20:04 -0800
commita4674aa58be53921f2aba62e143cc338d6ab142c (patch)
tree3d9f532370c447ac8d36768f866bdfb362ab8341 /include
parent1b58c94e9cf928970d5287550d3005389b198ff9 (diff)
tcp: preserve const qualifier in tcp_rsk() and inet_rsk()
We can change tcp_rsk() and inet_rsk() to propagate their argument const qualifier thanks to container_of_const(). Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260120125353.1470456-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/tcp.h5
-rw-r--r--include/net/inet_sock.h5
-rw-r--r--include/trace/events/tcp.h2
3 files changed, 3 insertions, 9 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 20b8c6e21fef..367b491ddf97 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -181,10 +181,7 @@ struct tcp_request_sock {
#endif
};
-static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
-{
- return (struct tcp_request_sock *)req;
-}
+#define tcp_rsk(ptr) container_of_const(ptr, struct tcp_request_sock, req.req)
static inline bool tcp_rsk_used_ao(const struct request_sock *req)
{
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h
index 3370159556b8..903b2263ec80 100644
--- a/include/net/inet_sock.h
+++ b/include/net/inet_sock.h
@@ -100,10 +100,7 @@ struct inet_request_sock {
};
};
-static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
-{
- return (struct inet_request_sock *)sk;
-}
+#define inet_rsk(ptr) container_of_const(ptr, struct inet_request_sock, req)
static inline u32 inet_request_mark(const struct sock *sk, struct sk_buff *skb)
{
diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 6757233bd064..f155f95cdb6e 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -305,7 +305,7 @@ TRACE_EVENT(tcp_retransmit_synack,
),
TP_fast_assign(
- struct inet_request_sock *ireq = inet_rsk(req);
+ const struct inet_request_sock *ireq = inet_rsk(req);
__be32 *p32;
__entry->skaddr = sk;