diff mbox series

[net-next] tcp: get rid of twsk_unique()

Message ID 20240507164140.940547-1-edumazet@google.com (mailing list archive)
State Accepted
Commit 383eed2de529287337d9153a5084d4291a7c69f2
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tcp: get rid of twsk_unique() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 2951 this patch: 2951
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 980 this patch: 980
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3142 this patch: 3142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 57 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-10--00-00 (tests: 1009)

Commit Message

Eric Dumazet May 7, 2024, 4:41 p.m. UTC
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 <edumazet@google.com>
---
 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(-)

Comments

Kuniyuki Iwashima May 7, 2024, 5:12 p.m. UTC | #1
From: Eric Dumazet <edumazet@google.com>
Date: Tue,  7 May 2024 16:41:40 +0000
> 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 <edumazet@google.com>

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 :)

Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>


> ---
>  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(-)
> 
> diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
> index 74d2b463cc95e61baced94ff3e6aea3913b506ee..62b3e9f2aed404ba818f4b57d7f2d3acb8ef73f2 100644
> --- a/include/net/timewait_sock.h
> +++ b/include/net/timewait_sock.h
> @@ -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)
> diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
> index cf88eca5f1b40563e177c6d84dd59416c62c30e5..48d0d494185b19a5e7282ffb6b33051604c28c9f 100644
> --- a/net/ipv4/inet_hashtables.c
> +++ b/net/ipv4/inet_hashtables.c
> @@ -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;
> diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
> index 0427deca3e0eb9239558aa124a41a1525df62a04..be0f64fec6840cee3d1734b932ba7c8b1e9bfad2 100644
> --- a/net/ipv4/tcp_ipv4.c
> +++ b/net/ipv4/tcp_ipv4.c
> @@ -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,
>  };
>  
> diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
> index 2e81383b663b71b95719a295fd9629f1193e4225..6db71bb1cd300a9a3d91a8d771db4521978bc5d6 100644
> --- a/net/ipv6/inet6_hashtables.c
> +++ b/net/ipv6/inet6_hashtables.c
> @@ -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;
> diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
> index 37201c4fb3931d1eb93fcd6868de7167977bf0a1..7f6693e794bd011371a8a794f703192f400546e5 100644
> --- a/net/ipv6/tcp_ipv6.c
> +++ b/net/ipv6/tcp_ipv6.c
> @@ -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,
>  };
>  
> -- 
> 2.45.0.rc1.225.g2a3ae87e7f-goog
patchwork-bot+netdevbpf@kernel.org May 10, 2024, 3:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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.
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
>  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!
diff mbox series

Patch

diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h
index 74d2b463cc95e61baced94ff3e6aea3913b506ee..62b3e9f2aed404ba818f4b57d7f2d3acb8ef73f2 100644
--- a/include/net/timewait_sock.h
+++ b/include/net/timewait_sock.h
@@ -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)
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index cf88eca5f1b40563e177c6d84dd59416c62c30e5..48d0d494185b19a5e7282ffb6b33051604c28c9f 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -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;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0427deca3e0eb9239558aa124a41a1525df62a04..be0f64fec6840cee3d1734b932ba7c8b1e9bfad2 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -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,
 };
 
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 2e81383b663b71b95719a295fd9629f1193e4225..6db71bb1cd300a9a3d91a8d771db4521978bc5d6 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -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;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 37201c4fb3931d1eb93fcd6868de7167977bf0a1..7f6693e794bd011371a8a794f703192f400546e5 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -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,
 };