Skip to content

Commit 383eed2

Browse files
edumazetkuba-moo
authored andcommitted
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 <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 33fb988 commit 383eed2

File tree

5 files changed

+5
-13
lines changed

5 files changed

+5
-13
lines changed

include/net/timewait_sock.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,9 @@ struct timewait_sock_ops {
1515
struct kmem_cache *twsk_slab;
1616
char *twsk_slab_name;
1717
unsigned int twsk_obj_size;
18-
int (*twsk_unique)(struct sock *sk,
19-
struct sock *sktw, void *twp);
2018
void (*twsk_destructor)(struct sock *sk);
2119
};
2220

23-
static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
24-
{
25-
if (sk->sk_prot->twsk_prot->twsk_unique != NULL)
26-
return sk->sk_prot->twsk_prot->twsk_unique(sk, sktw, twp);
27-
return 0;
28-
}
29-
3021
static inline void twsk_destructor(struct sock *sk)
3122
{
3223
if (sk->sk_prot->twsk_prot->twsk_destructor != NULL)

net/ipv4/inet_hashtables.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
565565
if (likely(inet_match(net, sk2, acookie, ports, dif, sdif))) {
566566
if (sk2->sk_state == TCP_TIME_WAIT) {
567567
tw = inet_twsk(sk2);
568-
if (twsk_unique(sk, sk2, twp))
568+
if (sk->sk_protocol == IPPROTO_TCP &&
569+
tcp_twsk_unique(sk, sk2, twp))
569570
break;
570571
}
571572
goto not_unique;

net/ipv4/tcp_ipv4.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2437,7 +2437,6 @@ int tcp_v4_rcv(struct sk_buff *skb)
24372437

24382438
static struct timewait_sock_ops tcp_timewait_sock_ops = {
24392439
.twsk_obj_size = sizeof(struct tcp_timewait_sock),
2440-
.twsk_unique = tcp_twsk_unique,
24412440
.twsk_destructor= tcp_twsk_destructor,
24422441
};
24432442

net/ipv6/inet6_hashtables.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <net/secure_seq.h>
2222
#include <net/ip.h>
2323
#include <net/sock_reuseport.h>
24+
#include <net/tcp.h>
2425

2526
u32 inet6_ehashfn(const struct net *net,
2627
const struct in6_addr *laddr, const u16 lport,
@@ -289,7 +290,8 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row,
289290
dif, sdif))) {
290291
if (sk2->sk_state == TCP_TIME_WAIT) {
291292
tw = inet_twsk(sk2);
292-
if (twsk_unique(sk, sk2, twp))
293+
if (sk->sk_protocol == IPPROTO_TCP &&
294+
tcp_twsk_unique(sk, sk2, twp))
293295
break;
294296
}
295297
goto not_unique;

net/ipv6/tcp_ipv6.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2049,7 +2049,6 @@ void tcp_v6_early_demux(struct sk_buff *skb)
20492049

20502050
static struct timewait_sock_ops tcp6_timewait_sock_ops = {
20512051
.twsk_obj_size = sizeof(struct tcp6_timewait_sock),
2052-
.twsk_unique = tcp_twsk_unique,
20532052
.twsk_destructor = tcp_twsk_destructor,
20542053
};
20552054

0 commit comments

Comments
 (0)