tcp: preserve const qualifier in tcp_rsk() and inet_rsk()
Subsystems (4)
PATCH 1/1 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 <[email protected]>
--- include/linux/tcp.h | 5 +---- include/net/inet_sock.h | 5 +---- include/trace/events/tcp.h | 2 +- net/ipv4/inet_connection_sock.c | 2 +- net/ipv6/inet6_connection_sock.c | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-)
include/linux/tcp.h +1 -4
@@ -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) {
include/net/inet_sock.h +1 -4
@@ -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) {
include/trace/events/tcp.h +1 -1
@@ -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;
net/ipv4/inet_connection_sock.c +1 -1
@@ -1196,7 +1196,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, {struct sock *newsk =sk_clone_lock (sk, priority);struct inet_connection_sock *newicsk; -struct inet_request_sock *ireq; +const struct inet_request_sock *ireq;struct inet_sock *newinet;if (!newsk)
net/ipv6/inet6_connection_sock.c +1 -1
@@ -29,7 +29,7 @@ struct dst_entry *inet6_csk_route_req(const struct sock *sk, const struct request_sock *req, u8 proto) { -struct inet_request_sock *ireq =inet_rsk (req); +const struct inet_request_sock *ireq =inet_rsk (req);const struct ipv6_pinfo *np =inet6_sk (sk);struct in6_addr *final_p, final;struct dst_entry *dst;
Signature · 1 line
2.52.0.457.g6b5491de43-goog
Quoted 5 lines · Eric Dumazet
We can change
tcp_rsk()andinet_rsk()to propagate their argument const qualifier thanks tocontainer_of_const().Signed-off-by Eric Dumazet <[email protected]>
Reviewed-by Kuniyuki Iwashima <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Tue, 20 Jan 2026 12:53:53 +0000 you wrote:
We can change
tcp_rsk()andinet_rsk()to propagate their argument const qualifier thanks tocontainer_of_const().Signed-off-by Eric Dumazet <[email protected]>--- include/linux/tcp.h | 5 +---- include/net/inet_sock.h | 5 +---- include/trace/events/tcp.h | 2 +- net/ipv4/inet_connection_sock.c | 2 +- net/ipv6/inet6_connection_sock.c | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-)
Here is the summary with links:
- [net-next] tcp: preserve const qualifier in tcp_rsk() and inet_rsk()
https://git.kernel.org/netdev/net-next/c/a4674aa58be5
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html