tcp: get rid of twsk_unique()
Subsystems (3)
PATCH 1/1 tcp: get rid of twsk_unique()
DCCP is going away soon, and had no twsk_unique() method.
We can directly call tcp_twsk_unique() for TCP sockets.
--- include/net/timewait_sock.h | 9 --------- net/ipv4/inet_hashtables.c | 3 ++- net/ipv4/tcp_ipv4.c | 1 - net/ipv6/inet6_hashtables.c | 4 +++- net/ipv6/tcp_ipv6.c | 1 - 5 files changed, 5 insertions(+), 13 deletions(-)
include/net/timewait_sock.h +0 -9
@@ -15,18 +15,9 @@ struct timewait_sock_ops {struct kmem_cache *twsk_slab;char *twsk_slab_name;unsigned int twsk_obj_size; -int (*twsk_unique)(struct sock *sk, -struct sock *sktw,void *twp);void (*twsk_destructor)(struct sock *sk); }; -static inline int twsk_unique (struct sock *sk,struct sock *sktw,void *twp) -{ -if (sk->sk_prot->twsk_prot->twsk_unique !=NULL ) -return sk->sk_prot->twsk_prot->twsk_unique (sk, sktw, twp); -return 0 ; -} -static inline void twsk_destructor (struct sock *sk) {if (sk->sk_prot->twsk_prot->twsk_destructor !=NULL )
net/ipv4/inet_hashtables.c +2 -1
@@ -565,7 +565,8 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,if (likely (inet_match (net, sk2, acookie, ports, dif, sdif))) {if (sk2->sk_state ==TCP_TIME_WAIT ) { tw =inet_twsk (sk2); -if (twsk_unique (sk, sk2, twp)) +if (sk->sk_protocol ==IPPROTO_TCP && +tcp_twsk_unique (sk, sk2, twp))break ; } goto not_unique;
net/ipv4/tcp_ipv4.c +0 -1
@@ -2431,7 +2431,6 @@ int tcp_v4_rcv(struct sk_buff *skb)static struct timewait_sock_ops tcp_timewait_sock_ops = { .twsk_obj_size =sizeof (struct tcp_timewait_sock ), - .twsk_unique = tcp_twsk_unique, .twsk_destructor= tcp_twsk_destructor, };
net/ipv6/inet6_hashtables.c +3 -1
@@ -21,6 +21,7 @@#include <net/secure_seq.h> #include <net/ip.h> #include <net/sock_reuseport.h> +#include <net/tcp.h> u32 inet6_ehashfn(const struct net *net, const struct in6_addr *laddr, const u16 lport,
@@ -289,7 +290,8 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, dif, sdif))) {if (sk2->sk_state ==TCP_TIME_WAIT ) { tw =inet_twsk (sk2); -if (twsk_unique (sk, sk2, twp)) +if (sk->sk_protocol ==IPPROTO_TCP && +tcp_twsk_unique (sk, sk2, twp))break ; } goto not_unique;
net/ipv6/tcp_ipv6.c +0 -1
@@ -2049,7 +2049,6 @@ void tcp_v6_early_demux(struct sk_buff *skb)static struct timewait_sock_ops tcp6_timewait_sock_ops = { .twsk_obj_size =sizeof (struct tcp6_timewait_sock ), - .twsk_unique = tcp_twsk_unique, .twsk_destructor = tcp_twsk_destructor, };
Signature · 1 line
2.45.0.rc1.225.g2a3ae87e7f-goog
From: Eric Dumazet <[email protected]>
Date: Tue, 7 May 2024 16:41:40 +0000
Quoted 5 lines
DCCP is going away soon, and had no
twsk_unique()method.We can directly call
tcp_twsk_unique()for TCP sockets.Signed-off-by Eric Dumazet <[email protected]>
I had a similar patch that guards if (sk->sk_protocol == IPPROTO_TCP) with #ifdef CONFIG_DCCP and calls tcp_twsk_unique() directly otherwise, so that I will not forget removing the if part while removing DCCP.
But anyway we'll review timewait_sock_ops then, so this looks fine :)
Quoted 93 lines
--- include/net/timewait_sock.h | 9 --------- net/ipv4/inet_hashtables.c | 3 ++- net/ipv4/tcp_ipv4.c | 1 - net/ipv6/inet6_hashtables.c | 4 +++- net/ipv6/tcp_ipv6.c | 1 - 5 files changed, 5 insertions(+), 13 deletions(-)include/net/timewait_sock.h +0
-9@@ -15,18 +15,9 @@ struct timewait_sock_ops {struct kmem_cache *twsk_slab;char *twsk_slab_name;unsigned int twsk_obj_size; -int (*twsk_unique)(struct sock *sk, -struct sock *sktw,void *twp);void (*twsk_destructor)(struct sock *sk); }; -static inline int twsk_unique (struct sock *sk,struct sock *sktw,void *twp) -{ -if (sk->sk_prot->twsk_prot->twsk_unique !=NULL ) -return sk->sk_prot->twsk_prot->twsk_unique (sk, sktw, twp); -return 0 ; -} -static inline void twsk_destructor (struct sock *sk) {if (sk->sk_prot->twsk_prot->twsk_destructor !=NULL )net/ipv4/inet_hashtables.c +2
-1@@ -565,7 +565,8 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,if (likely (inet_match (net, sk2, acookie, ports, dif, sdif))) {if (sk2->sk_state ==TCP_TIME_WAIT ) { tw =inet_twsk (sk2); -if (twsk_unique (sk, sk2, twp)) +if (sk->sk_protocol ==IPPROTO_TCP && +tcp_twsk_unique (sk, sk2, twp))break ; } goto not_unique;net/ipv4/tcp_ipv4.c +0
-1@@ -2431,7 +2431,6 @@ int tcp_v4_rcv(struct sk_buff *skb)static struct timewait_sock_ops tcp_timewait_sock_ops = { .twsk_obj_size =sizeof (struct tcp_timewait_sock ), - .twsk_unique = tcp_twsk_unique, .twsk_destructor= tcp_twsk_destructor, };net/ipv6/inet6_hashtables.c +3
-1@@ -21,6 +21,7 @@#include <net/secure_seq.h> #include <net/ip.h> #include <net/sock_reuseport.h> +#include <net/tcp.h> u32 inet6_ehashfn(const struct net *net, const struct in6_addr *laddr, const u16 lport,@@ -289,7 +290,8 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, dif, sdif))) {if (sk2->sk_state ==TCP_TIME_WAIT ) { tw =inet_twsk (sk2); -if (twsk_unique (sk, sk2, twp)) +if (sk->sk_protocol ==IPPROTO_TCP && +tcp_twsk_unique (sk, sk2, twp))break ; } goto not_unique;net/ipv6/tcp_ipv6.c +0
-1@@ -2049,7 +2049,6 @@ void tcp_v6_early_demux(struct sk_buff *skb)static struct timewait_sock_ops tcp6_timewait_sock_ops = { .twsk_obj_size =sizeof (struct tcp6_timewait_sock ), - .twsk_unique = tcp_twsk_unique, .twsk_destructor = tcp_twsk_destructor, };Signature · 1 line
2.45.0.rc1.225.g2a3ae87e7f-goog
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 4 lines · On Tue, 7 May 2024 16:41:40 +0000 you wrote:
DCCP is going away soon, and had no
twsk_unique()method.We can directly call
tcp_twsk_unique()for TCP sockets.
Quoted 8 lines
Signed-off-by Eric Dumazet <[email protected]>--- include/net/timewait_sock.h | 9 --------- net/ipv4/inet_hashtables.c | 3 ++- net/ipv4/tcp_ipv4.c | 1 - net/ipv6/inet6_hashtables.c | 4 +++- net/ipv6/tcp_ipv6.c | 1 - 5 files changed, 5 insertions(+), 13 deletions(-)
Here is the summary with links:
- [net-next] tcp: get rid of twsk_unique()
https://git.kernel.org/netdev/net-next/c/383eed2de529
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html