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.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20240507164140.940547-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Eric Dumazet 2024-05-07 16:41:40 +00:00 committed by Jakub Kicinski
parent 33fb988b67
commit 383eed2de5
5 changed files with 5 additions and 13 deletions

View File

@ -15,18 +15,9 @@ struct timewait_sock_ops {
struct kmem_cache *twsk_slab; struct kmem_cache *twsk_slab;
char *twsk_slab_name; char *twsk_slab_name;
unsigned int twsk_obj_size; unsigned int twsk_obj_size;
int (*twsk_unique)(struct sock *sk,
struct sock *sktw, void *twp);
void (*twsk_destructor)(struct sock *sk); 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) static inline void twsk_destructor(struct sock *sk)
{ {
if (sk->sk_prot->twsk_prot->twsk_destructor != NULL) if (sk->sk_prot->twsk_prot->twsk_destructor != NULL)

View File

@ -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 (likely(inet_match(net, sk2, acookie, ports, dif, sdif))) {
if (sk2->sk_state == TCP_TIME_WAIT) { if (sk2->sk_state == TCP_TIME_WAIT) {
tw = inet_twsk(sk2); tw = inet_twsk(sk2);
if (twsk_unique(sk, sk2, twp)) if (sk->sk_protocol == IPPROTO_TCP &&
tcp_twsk_unique(sk, sk2, twp))
break; break;
} }
goto not_unique; goto not_unique;

View File

@ -2437,7 +2437,6 @@ do_time_wait:
static struct timewait_sock_ops tcp_timewait_sock_ops = { static struct timewait_sock_ops tcp_timewait_sock_ops = {
.twsk_obj_size = sizeof(struct tcp_timewait_sock), .twsk_obj_size = sizeof(struct tcp_timewait_sock),
.twsk_unique = tcp_twsk_unique,
.twsk_destructor= tcp_twsk_destructor, .twsk_destructor= tcp_twsk_destructor,
}; };

View File

@ -21,6 +21,7 @@
#include <net/secure_seq.h> #include <net/secure_seq.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/sock_reuseport.h> #include <net/sock_reuseport.h>
#include <net/tcp.h>
u32 inet6_ehashfn(const struct net *net, u32 inet6_ehashfn(const struct net *net,
const struct in6_addr *laddr, const u16 lport, 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))) { dif, sdif))) {
if (sk2->sk_state == TCP_TIME_WAIT) { if (sk2->sk_state == TCP_TIME_WAIT) {
tw = inet_twsk(sk2); tw = inet_twsk(sk2);
if (twsk_unique(sk, sk2, twp)) if (sk->sk_protocol == IPPROTO_TCP &&
tcp_twsk_unique(sk, sk2, twp))
break; break;
} }
goto not_unique; goto not_unique;

View File

@ -2049,7 +2049,6 @@ void tcp_v6_early_demux(struct sk_buff *skb)
static struct timewait_sock_ops tcp6_timewait_sock_ops = { static struct timewait_sock_ops tcp6_timewait_sock_ops = {
.twsk_obj_size = sizeof(struct tcp6_timewait_sock), .twsk_obj_size = sizeof(struct tcp6_timewait_sock),
.twsk_unique = tcp_twsk_unique,
.twsk_destructor = tcp_twsk_destructor, .twsk_destructor = tcp_twsk_destructor,
}; };