[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250821061540.2876953-3-kuniyu@google.com>
Date: Thu, 21 Aug 2025 06:15:13 +0000
From: Kuniyuki Iwashima <kuniyu@...gle.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Neal Cardwell <ncardwell@...gle.com>, David Ahern <dsahern@...nel.org>
Cc: Simon Horman <horms@...nel.org>, Kuniyuki Iwashima <kuniyu@...gle.com>,
Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org,
Kuniyuki Iwashima <kuniyu@...zon.com>
Subject: [PATCH v1 net-next 2/7] tcp: Save __module_get() for TIME_WAIT sockets.
From: Kuniyuki Iwashima <kuniyu@...zon.com>
__module_get() in inet_twsk_alloc() was necessary to prevent
unloading tw->tw_prot, which is used in inet_twsk_free().
DCCP has gone, and TCP is built-in, so the pair is no longer needed.
ULPs also do not need it because
* kTLS and XFRM_ESPINTCP restore sk_prot before close()
* MPTCP is built-in
* SMC uses TCP as is
, but using tw_prot without module_get() would be error prone to
future ULP addition.
Now we can use kfree() without the slab cache pointer thanks to SLUB.
Let's use kfree() in inet_twsk_free() and remove 2 atomic ops
for each connection.
Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
---
include/net/inet_timewait_sock.h | 1 -
net/ipv4/inet_timewait_sock.c | 7 +------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index 67a313575780..500a0478370f 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -48,7 +48,6 @@ struct inet_timewait_sock {
#define tw_tx_queue_mapping __tw_common.skc_tx_queue_mapping
#define tw_rx_queue_mapping __tw_common.skc_rx_queue_mapping
#define tw_hash __tw_common.skc_hash
-#define tw_prot __tw_common.skc_prot
#define tw_net __tw_common.skc_net
#define tw_daddr __tw_common.skc_daddr
#define tw_v6_daddr __tw_common.skc_v6_daddr
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index 875ff923a8ed..024463a3e696 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -73,10 +73,8 @@ static void inet_twsk_kill(struct inet_timewait_sock *tw)
void inet_twsk_free(struct inet_timewait_sock *tw)
{
- struct module *owner = tw->tw_prot->owner;
twsk_destructor((struct sock *)tw);
- kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
- module_put(owner);
+ kfree(tw);
}
void inet_twsk_put(struct inet_timewait_sock *tw)
@@ -206,7 +204,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
tw->tw_hash = sk->sk_hash;
tw->tw_ipv6only = 0;
tw->tw_transparent = inet_test_bit(TRANSPARENT, sk);
- tw->tw_prot = sk->sk_prot_creator;
atomic64_set(&tw->tw_cookie, atomic64_read(&sk->sk_cookie));
twsk_net_set(tw, sock_net(sk));
timer_setup(&tw->tw_timer, tw_timer_handler, 0);
@@ -216,8 +213,6 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
* timewait socket.
*/
refcount_set(&tw->tw_refcnt, 0);
-
- __module_get(tw->tw_prot->owner);
}
return tw;
--
2.51.0.rc1.193.gad69d77794-goog
Powered by blists - more mailing lists