Revert "tcp/dccp: get rid of inet_twsk_purge()"
Subsystems (3)
PATCH 1/1 Revert "tcp/dccp: get rid of inet_twsk_purge()"
From: Eric Dumazet <[email protected]>
This reverts commits:
0dad4087a86a2cbe177404dc73f18ada26a2c390 ("tcp/dccp: get rid of inet_twsk_purge()") d507204d3c5cc57d9a8bdf0a477615bb59ea1611 ("tcp/dccp: add tw->tw_bslot")
As Leonard pointed out, a newly allocated netns can happen to reuse a freed 'struct net'.
While TCP TW timers were covered by my patches, other things were not:
1) Lookups in rx path (INET_MATCH() and INET6_MATCH()), as they look at 4-tuple plus the 'struct net' pointer.
2) /proc/net/tcp[6] and inet_diag, same reason.
3) hashinfo->bhash[], same reason.
Fixing all this seems risky, lets instead revert.
In the future, we might have a per netns tcp hash table, or a per netns list of timewait sockets...
--- include/net/inet_timewait_sock.h | 3 +- net/dccp/ipv4.c | 6 ++++ net/dccp/ipv6.c | 6 ++++ net/ipv4/inet_timewait_sock.c | 58 ++++++++++++++++++++++++++++---- net/ipv4/tcp_ipv4.c | 2 ++ net/ipv6/tcp_ipv6.c | 6 ++++ 6 files changed, 73 insertions(+), 8 deletions(-)
include/net/inet_timewait_sock.h +2 -1
@@ -71,7 +71,6 @@ struct inet_timewait_sock { tw_tos :8 ;u32 tw_txhash;u32 tw_priority; -u32 tw_bslot;/* bind bucket slot */ struct timer_list tw_timer;struct inet_bind_bucket *tw_tb; };
@@ -110,6 +109,8 @@ static inline void inet_twsk_reschedule(struct inet_timewait_sock *tw, int timeovoid inet_twsk_deschedule_put (struct inet_timewait_sock *tw); +void inet_twsk_purge (struct inet_hashinfo *hashinfo,int family); +static inline struct net *twsk_net (const struct inet_timewait_sock *twsk) {
net/dccp/ipv4.c +6 -0
@@ -1030,9 +1030,15 @@ static void __net_exit dccp_v4_exit_net(struct net *net)inet_ctl_sock_destroy (pn->v4_ctl_sk); } +static void __net_exit dccp_v4_exit_batch(struct list_head *net_exit_list) +{ +inet_twsk_purge (&dccp_hashinfo,AF_INET ); +} +static struct pernet_operations dccp_v4_ops = { .init = dccp_v4_init_net, .exit = dccp_v4_exit_net, + .exit_batch = dccp_v4_exit_batch, .id = &dccp_v4_pernet_id, .size =sizeof (struct dccp_v4_pernet ), };
net/dccp/ipv6.c +6 -0
@@ -1115,9 +1115,15 @@ static void __net_exit dccp_v6_exit_net(struct net *net)inet_ctl_sock_destroy (pn->v6_ctl_sk); } +static void __net_exit dccp_v6_exit_batch(struct list_head *net_exit_list) +{ +inet_twsk_purge (&dccp_hashinfo,AF_INET6 ); +} +static struct pernet_operations dccp_v6_ops = { .init = dccp_v6_init_net, .exit = dccp_v6_exit_net, + .exit_batch = dccp_v6_exit_batch, .id = &dccp_v6_pernet_id, .size =sizeof (struct dccp_v6_pernet ), };
net/ipv4/inet_timewait_sock.c +51 -7
73 lines not on this page · raw message
net/ipv4/tcp_ipv4.c +2 -0
@@ -3173,6 +3173,8 @@ static void __net_exit tcp_sk_exit_batch(struct list_head *net_exit_list) {struct net *net; +inet_twsk_purge (&tcp_hashinfo,AF_INET ); +list_for_each_entry (net, net_exit_list, exit_list)tcp_fastopen_ctx_destroy (net); }
net/ipv6/tcp_ipv6.c +6 -0
@@ -2207,9 +2207,15 @@ static void __net_exit tcpv6_net_exit(struct net *net)inet_ctl_sock_destroy (net->ipv6.tcp_sk); } +static void __net_exit tcpv6_net_exit_batch(struct list_head *net_exit_list) +{ +inet_twsk_purge (&tcp_hashinfo,AF_INET6 ); +} +static struct pernet_operations tcpv6_net_ops = { .init = tcpv6_net_init, .exit = tcpv6_net_exit, + .exit_batch = tcpv6_net_exit_batch, };int __init tcpv6_init (void )
Signature · 1 line
2.36.0.550.gb090851708-goog
Quoted 19 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
This reverts commits:
0dad4087a86a2cbe177404dc73f18ada26a2c390("tcp/dccp: get rid ofinet_twsk_purge()")d507204d3c5cc57d9a8bdf0a477615bb59ea1611("tcp/dccp: addtw->tw_bslot")As Leonard pointed out, a newly allocated netns can happen to reuse a freed 'struct net'.
While TCP TW timers were covered by my patches, other things were not:
1) Lookups in rx path (
INET_MATCH()andINET6_MATCH()), as they look at 4-tuple plus the 'struct net' pointer.2) /proc/net/tcp[6] and
inet_diag, same reason.3) hashinfo->bhash[], same reason.
Quoted 8 lines
Fixing all this seems risky, lets instead revert.
In the future, we might have a per netns tcp hash table, or a per netns list of timewait sockets...
Fixes 0dad4087a86a ("tcp/dccp: get rid of inet_twsk_purge()")Signed-off-by Eric Dumazet <[email protected]>Reported-by Leonard Crestez <[email protected]>
This patch was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <[email protected]>:
Quoted 8 lines · On Thu, 12 May 2022 14:14:56 -0700 you wrote:
From: Eric Dumazet <[email protected]>
This reverts commits:
0dad4087a86a2cbe177404dc73f18ada26a2c390("tcp/dccp: get rid ofinet_twsk_purge()")d507204d3c5cc57d9a8bdf0a477615bb59ea1611("tcp/dccp: addtw->tw_bslot")[...]
Here is the summary with links:
- [net] Revert "tcp/dccp: get rid of inet_twsk_purge()"
https://git.kernel.org/netdev/net/c/04c494e68a13
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html