FAILED: patch "[PATCH] mptcp: do not reschedule the RTX timer for fallback sockets" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x e2ab913f68c7d11e2561b8a8ad0b87ffefcad667
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026091613-tank-dimmed-fed6@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From e2ab913f68c7d11e2561b8a8ad0b87ffefcad667 Mon Sep 17 00:00:00 2001
From: Paolo Abeni <[email protected]>
Date: Tue, 8 Sep 2026 16:07:06 +0200
Subject: [PATCH] mptcp: do not reschedule the RTX timer for fallback sockets
On fallback socket the retrans timer is a quite convoluted no-op, but currently nothing prevents the MPTCP core to keep rescheduling it.
Additionally gate RTX timer reset to the msk not being fallen back to TCP yet. To avoid adding multiple tests in fast-path, use a new flags bit for such condition.
The RTX enable bit is clear at close time and set before the msk could start retransmitting, with a couple of caveats:
- passive sockets inherit the bit from the listener msk; set the bit on such socket to avoid flipping it in the fast-path, even if the listener will obviously never retransmit.
- while fastopening (MPTFO), mptcp_sendmsg_fastopen still ends-up calling mptcp_connect via tcp_sendmsg_fastopen -> __inet_stream_connect(ssk->sk_socket), and the first subflow's sk_socket points to the msk one.
net/mptcp/protocol.c +10 -3
@@ -95,6 +95,7 @@ bool __mptcp_try_fallback(struct mptcp_sock *msk, int fb_mib) msk->allow_subflows = false;set_bit (MPTCP_FALLBACK_DONE , &msk->flags); +clear_bit (MPTCP_RTX_ENABLED , &msk->flags);__MPTCP_INC_STATS (net, fb_mib);spin_unlock_bh (&msk->fallback_lock);return true;
@@ -1084,13 +1085,14 @@ static bool mptcp_rtx_timer_pending(struct sock *sk)static void mptcp_reset_rtx_timer (struct sock *sk) { +struct mptcp_sock *msk =mptcp_sk (sk);unsigned long tout; -/* prevent rescheduling on close */ -if (unlikely (inet_sk_state_load (sk) ==TCP_CLOSE )) +/* Prevent rescheduling on close and in case of fallback. */ +if (!test_bit (MPTCP_RTX_ENABLED , &msk->flags))return ; - tout =mptcp_sk (sk)->timer_ival; + tout = msk->timer_ival;sk_reset_timer (sk, &sk->mptcp_retransmit_timer, jiffies + tout); }
@@ -3323,6 +3325,9 @@ void mptcp_set_state(struct sock *sk, int state)* transition from TCP_SYN_RECV to TCP_CLOSE_WAIT. */ break ; +case TCP_CLOSE : +clear_bit (MPTCP_RTX_ENABLED , &mptcp_sk (sk)->flags); + fallthrough;default :if (oldstate ==TCP_ESTABLISHED || oldstate ==TCP_CLOSE_WAIT )MPTCP_DEC_STATS (sock_net (sk),MPTCP_MIB_CURRESTAB );
@@ -4141,6 +4146,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr_unsized *uaddr,if (IS_ERR (ssk))return PTR_ERR (ssk); +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_SYN_SENT ); subflow =mptcp_subflow_ctx (ssk);#ifdef CONFIG_TCP_MD5SIG
@@ -4288,6 +4294,7 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_LISTEN );sock_set_flag (sk,SOCK_RCU_FREE );
net/mptcp/protocol.h +1 -0
@@ -116,6 +116,7 @@#define MPTCP_WORK_RTX 1#define MPTCP_FALLBACK_DONE 2#define MPTCP_WORK_CLOSE_SUBFLOW 3 +#define MPTCP_RTX_ENABLED 4/* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1
Sasha Levin
maintainerPATCH 1/4 tcp: rename icsk_timeout() to tcp_timeout_expires()
From: Eric Dumazet <[email protected]>
[ Upstream commit 3a6e8fd0bf4042c572dc52e634878b9aca02970d ]
In preparation of sk->tcp_timeout_timer introduction, rename icsk_timeout() helper and change its argument to plain 'const struct sock *sk'.
Stable-dep-of: e2ab913f68c7 ("mptcp: do not reschedule the RTX timer for fallback sockets")
--- include/net/inet_connection_sock.h | 5 ++--- net/ipv4/inet_diag.c | 4 ++-- net/ipv4/tcp_ipv4.c | 4 ++-- net/ipv4/tcp_timer.c | 6 +++--- net/ipv6/tcp_ipv6.c | 4 ++-- net/mptcp/protocol.c | 2 +- 6 files changed, 12 insertions(+), 13 deletions(-)
include/net/inet_connection_sock.h +2 -3
@@ -186,10 +186,9 @@ static inline void inet_csk_delack_init(struct sock *sk)memset (&inet_csk (sk)->icsk_ack,0 ,sizeof (inet_csk (sk)->icsk_ack)); } -static inline unsigned long -icsk_timeout (const struct inet_connection_sock *icsk) +static inline unsigned long tcp_timeout_expires (const struct sock *sk) { -return READ_ONCE (icsk->icsk_retransmit_timer.expires); +return READ_ONCE (inet_csk (sk)->icsk_retransmit_timer.expires); } static inline unsigned long
net/ipv4/inet_diag.c +2 -2
@@ -287,12 +287,12 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, r->idiag_timer =1 ; r->idiag_retrans =READ_ONCE (icsk->icsk_retransmits); r->idiag_expires = -jiffies_delta_to_msecs (icsk_timeout (icsk) - jiffies); +jiffies_delta_to_msecs (tcp_timeout_expires (sk) - jiffies); }else if (icsk_pending ==ICSK_TIME_PROBE0 ) { r->idiag_timer =4 ; r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out); r->idiag_expires = -jiffies_delta_to_msecs (icsk_timeout (icsk) - jiffies); +jiffies_delta_to_msecs (tcp_timeout_expires (sk) - jiffies); }else if (timer_pending (&sk->sk_timer)) { r->idiag_timer =2 ; r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out);
net/ipv4/tcp_ipv4.c +2 -2
@@ -2928,10 +2928,10 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i) icsk_pending == ICSK_TIME_REO_TIMEOUT || icsk_pending == ICSK_TIME_LOSS_PROBE) { timer_active =1 ; - timer_expires =icsk_timeout (icsk); + timer_expires =tcp_timeout_expires (sk); } else if (icsk_pending == ICSK_TIME_PROBE0) { timer_active =4 ; - timer_expires =icsk_timeout (icsk); + timer_expires =tcp_timeout_expires (sk); } else if (timer_pending(&sk->sk_timer)) { timer_active =2 ; timer_expires = sk->sk_timer.expires;
net/ipv4/tcp_timer.c +3 -3
@@ -513,7 +513,7 @@ static bool tcp_rtx_probe0_timed_out(const struct sock *sk,* and tp->rcv_tstamp might very well have been written recently. * rcv_delta can thus be negative. */ - rcv_delta =icsk_timeout (icsk) - tp->rcv_tstamp; + rcv_delta =tcp_timeout_expires (sk) - tp->rcv_tstamp;if (rcv_delta <= timeout)return false;
@@ -700,9 +700,9 @@ void tcp_write_timer_handler(struct sock *sk) !icsk->icsk_pending)return ; -if (time_after (icsk_timeout (icsk), jiffies)) { +if (time_after (tcp_timeout_expires (sk), jiffies)) {sk_reset_timer (sk, &icsk->icsk_retransmit_timer, -icsk_timeout (icsk)); +tcp_timeout_expires (sk));return ; }tcp_mstamp_refresh (tcp_sk (sk));
net/ipv6/tcp_ipv6.c +2 -2
@@ -2200,10 +2200,10 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i) icsk_pending == ICSK_TIME_REO_TIMEOUT || icsk_pending == ICSK_TIME_LOSS_PROBE) { timer_active =1 ; - timer_expires =icsk_timeout (icsk); + timer_expires =tcp_timeout_expires (sp); } else if (icsk_pending == ICSK_TIME_PROBE0) { timer_active =4 ; - timer_expires =icsk_timeout (icsk); + timer_expires =tcp_timeout_expires (sp); } else if (timer_pending(&sp->sk_timer)) { timer_active =2 ; timer_expires = sp->sk_timer.expires;
net/mptcp/protocol.c +1 -1
@@ -533,7 +533,7 @@ static long mptcp_timeout_from_subflow(const struct mptcp_subflow_context *subflconst struct sock *ssk =mptcp_subflow_tcp_sock (subflow);return inet_csk (ssk)->icsk_pending && !subflow->stale_count ? -icsk_timeout (inet_csk (ssk)) - jiffies :0 ; +tcp_timeout_expires (ssk) - jiffies :0 ; }static void mptcp_set_timeout (struct sock *sk)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 tcp: introduce icsk->icsk_keepalive_timer
From: Eric Dumazet <[email protected]>
[ Upstream commit 08dfe370239e53494453cee1e2ded2cdaa1efd12 ]
sk->sk_timer has been used for TCP keepalives.
Keepalive timers are not in fast path, we want to use sk->sk_timer storage for retransmit timers, for better cache locality.
Create icsk->icsk_keepalive_timer and change keepalive code to no longer use sk->sk_timer.
Added space is reclaimed in the following patch.
This includes changes to MPTCP, which was also using sk_timer.
Alias icsk->mptcp_tout_timer and icsk->icsk_keepalive_timer for inet_sk_diag_fill() sake.
Stable-dep-of: e2ab913f68c7 ("mptcp: do not reschedule the RTX timer for fallback sockets")
--- .../net_cachelines/inet_connection_sock.rst | 1 + include/net/inet_connection_sock.h | 11 +++++++++-- net/ipv4/inet_connection_sock.c | 6 +++--- net/ipv4/inet_diag.c | 4 ++-- net/ipv4/tcp_ipv4.c | 4 ++-- net/ipv4/tcp_timer.c | 9 +++++---- net/ipv6/tcp_ipv6.c | 4 ++-- net/mptcp/protocol.c | 10 ++++++---- net/mptcp/protocol.h | 2 +- tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c | 4 ++-- tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c | 4 ++-- 11 files changed, 35 insertions(+), 24 deletions(-)
Documentation/networking/net_cachelines/inet_connection_sock.rst +1 -0
@@ -14,6 +14,7 @@ struct inet_bind_bucket icsk_bind_hash read_mostly struct inet_bind2_bucket icsk_bind2_hash read_mostly tcp_set_state,inet_put_port struct timer_list icsk_retransmit_timer read_write inet_csk_reset_xmit_timer,tcp_connect struct timer_list icsk_delack_timer read_mostly inet_csk_reset_xmit_timer,tcp_connect +struct timer_list icsk_keepalive_timer u32 icsk_rto read_write tcp_cwnd_validate,tcp_schedule_loss_probe,tcp_connect_init,tcp_connect,tcp_write_xmit,tcp_push_one u32 icsk_rto_min u32 icsk_rto_max read_mostly tcp_reset_xmit_timer
include/net/inet_connection_sock.h +9 -2
@@ -59,6 +59,9 @@ struct inet_connection_sock_af_ops {* @icsk_bind_hash: Bind node * @icsk_bind2_hash: Bind node in the bhash2 table * @icsk_retransmit_timer: Resend (no ack) +* @icsk_delack_timer: Delayed ACK timer +* @icsk_keepalive_timer: Keepalive timer +* @mptcp_tout_timer: mptcp timer * @icsk_rto: Retransmit timeout * @icsk_pmtu_cookie Last pmtu seen by socket * @icsk_ca_ops Pluggable congestion control hook
@@ -83,8 +86,12 @@ struct inet_connection_sock {struct request_sock_queue icsk_accept_queue;struct inet_bind_bucket *icsk_bind_hash;struct inet_bind2_bucket *icsk_bind2_hash; -struct timer_list icsk_retransmit_timer; -struct timer_list icsk_delack_timer; +struct timer_list icsk_retransmit_timer; +struct timer_list icsk_delack_timer; +union { +struct timer_list icsk_keepalive_timer; +struct timer_list mptcp_tout_timer; + };__u32 icsk_rto;__u32 icsk_rto_min;u32 icsk_rto_max;
net/ipv4/inet_connection_sock.c +3 -3
@@ -750,7 +750,7 @@ void inet_csk_init_xmit_timers(struct sock *sk,timer_setup (&icsk->icsk_retransmit_timer, retransmit_handler,0 );timer_setup (&icsk->icsk_delack_timer, delack_handler,0 ); -timer_setup (&sk->sk_timer, keepalive_handler,0 ); +timer_setup (&icsk->icsk_keepalive_timer, keepalive_handler,0 ); icsk->icsk_pending = icsk->icsk_ack.pending =0 ; }
@@ -763,7 +763,7 @@ void inet_csk_clear_xmit_timers(struct sock *sk)sk_stop_timer (sk, &icsk->icsk_retransmit_timer);sk_stop_timer (sk, &icsk->icsk_delack_timer); -sk_stop_timer (sk, &sk->sk_timer); +sk_stop_timer (sk, &icsk->icsk_keepalive_timer); }void inet_csk_clear_xmit_timers_sync (struct sock *sk)
@@ -778,7 +778,7 @@ void inet_csk_clear_xmit_timers_sync(struct sock *sk)sk_stop_timer_sync (sk, &icsk->icsk_retransmit_timer);sk_stop_timer_sync (sk, &icsk->icsk_delack_timer); -sk_stop_timer_sync (sk, &sk->sk_timer); +sk_stop_timer_sync (sk, &icsk->icsk_keepalive_timer); } struct dst_entry *inet_csk_route_req(const struct sock *sk,
net/ipv4/inet_diag.c +2 -2
@@ -293,11 +293,11 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out); r->idiag_expires =jiffies_delta_to_msecs (tcp_timeout_expires (sk) - jiffies); - }else if (timer_pending (&sk->sk_timer)) { + }else if (timer_pending (&icsk->icsk_keepalive_timer)) { r->idiag_timer =2 ; r->idiag_retrans =READ_ONCE (icsk->icsk_probes_out); r->idiag_expires = -jiffies_delta_to_msecs (sk->sk_timer.expires - jiffies); +jiffies_delta_to_msecs (icsk->icsk_keepalive_timer.expires - jiffies); }if ((ext & (1 << (INET_DIAG_INFO -1 ))) && handler->idiag_info_size) {
net/ipv4/tcp_ipv4.c +2 -2
@@ -2932,9 +2932,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i) }else if (icsk_pending ==ICSK_TIME_PROBE0 ) { timer_active =4 ; timer_expires =tcp_timeout_expires (sk); - }else if (timer_pending (&sk->sk_timer)) { + }else if (timer_pending (&icsk->icsk_keepalive_timer)) { timer_active =2 ; - timer_expires = sk->sk_timer.expires; + timer_expires = icsk->icsk_keepalive_timer.expires; }else { timer_active =0 ; timer_expires = jiffies;
net/ipv4/tcp_timer.c +5 -4
@@ -759,12 +759,12 @@ EXPORT_IPV6_MOD(tcp_syn_ack_timeout);void tcp_reset_keepalive_timer (struct sock *sk,unsigned long len) { -sk_reset_timer (sk, &sk->sk_timer, jiffies + len); +sk_reset_timer (sk, &inet_csk (sk)->icsk_keepalive_timer, jiffies + len); }static void tcp_delete_keepalive_timer (struct sock *sk) { -sk_stop_timer (sk, &sk->sk_timer); +sk_stop_timer (sk, &inet_csk (sk)->icsk_keepalive_timer); }void tcp_set_keepalive (struct sock *sk,int val)
@@ -781,8 +781,9 @@ EXPORT_IPV6_MOD_GPL(tcp_set_keepalive);static void tcp_keepalive_timer (struct timer_list *t) { -struct sock *sk =timer_container_of (sk, t, sk_timer); -struct inet_connection_sock *icsk =inet_csk (sk); +struct inet_connection_sock *icsk = +timer_container_of (icsk, t, icsk_keepalive_timer); +struct sock *sk = &icsk->icsk_inet.sk;struct tcp_sock *tp =tcp_sk (sk);u32 elapsed;
net/ipv6/tcp_ipv6.c +2 -2
@@ -2204,9 +2204,9 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i) }else if (icsk_pending ==ICSK_TIME_PROBE0 ) { timer_active =4 ; timer_expires =tcp_timeout_expires (sp); - }else if (timer_pending (&sp->sk_timer)) { + }else if (timer_pending (&icsk->icsk_keepalive_timer)) { timer_active =2 ; - timer_expires = sp->sk_timer.expires; + timer_expires = icsk->icsk_keepalive_timer.expires; }else { timer_active =0 ; timer_expires = jiffies;
net/mptcp/protocol.c +6 -4
@@ -2348,7 +2348,9 @@ static void mptcp_retransmit_timer(struct timer_list *t)static void mptcp_tout_timer (struct timer_list *t) { -struct sock *sk =timer_container_of (sk, t, sk_timer); +struct inet_connection_sock *icsk = +timer_container_of (icsk, t, mptcp_tout_timer); +struct sock *sk = &icsk->icsk_inet.sk;mptcp_schedule_work (sk);sock_put (sk);
@@ -2804,7 +2806,7 @@ void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout)*/ timeout =inet_csk (sk)->icsk_mtup.probe_timestamp ? close_timeout : fail_tout; -sk_reset_timer (sk, &sk->sk_timer, timeout); +sk_reset_timer (sk, &inet_csk (sk)->mptcp_tout_timer, timeout); }static void mptcp_mp_fail_no_response (struct mptcp_sock *msk)
@@ -2936,7 +2938,7 @@ static void __mptcp_init_sock(struct sock *sk)/* re-use the csk retrans timer for MPTCP-level retrans */ timer_setup (&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer,0 ); -timer_setup (&sk->sk_timer, mptcp_tout_timer,0 ); +timer_setup (&msk->sk.mptcp_tout_timer, mptcp_tout_timer,0 ); }static void mptcp_ca_reset (struct sock *sk)
@@ -3138,7 +3140,7 @@ static void __mptcp_destroy_sock(struct sock *sk)might_sleep ();mptcp_stop_rtx_timer (sk); -sk_stop_timer (sk, &sk->sk_timer); +sk_stop_timer (sk, &inet_csk (sk)->mptcp_tout_timer); msk->pm.status =0 ;mptcp_release_sched (msk);
net/mptcp/protocol.h +1 -1
@@ -880,7 +880,7 @@ static inline void mptcp_stop_tout_timer(struct sock *sk)if (!inet_csk (sk)->icsk_mtup.probe_timestamp)return ; -sk_stop_timer (sk, &sk->sk_timer); +sk_stop_timer (sk, &inet_csk (sk)->mptcp_tout_timer);inet_csk (sk)->icsk_mtup.probe_timestamp =0 ; }
tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c +2 -2
@@ -103,9 +103,9 @@ static int dump_tcp_sock(struct seq_file *seq, struct tcp_sock *tp, }else if (icsk->icsk_pending ==ICSK_TIME_PROBE0 ) { timer_active =4 ; timer_expires = icsk->icsk_retransmit_timer.expires; - }else if (timer_pending (&sp->sk_timer)) { + }else if (timer_pending (&icsk->icsk_keepalive_timer)) { timer_active =2 ; - timer_expires = sp->sk_timer.expires; + timer_expires = icsk->icsk_keepalive_timer.expires; }else { timer_active =0 ; timer_expires =bpf_jiffies64 ();
tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c +2 -2
@@ -103,9 +103,9 @@ static int dump_tcp6_sock(struct seq_file *seq, struct tcp6_sock *tp, }else if (icsk->icsk_pending ==ICSK_TIME_PROBE0 ) { timer_active =4 ; timer_expires = icsk->icsk_retransmit_timer.expires; - }else if (timer_pending (&sp->sk_timer)) { + }else if (timer_pending (&icsk->icsk_keepalive_timer)) { timer_active =2 ; - timer_expires = sp->sk_timer.expires; + timer_expires = icsk->icsk_keepalive_timer.expires; }else { timer_active =0 ; timer_expires =bpf_jiffies64 ();
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 tcp: remove icsk->icsk_retransmit_timer
In reply to Sasha LevinFrom: Eric Dumazet <[email protected]>
[ Upstream commit 9a5e5334adc039fa652aa071ea95b18db0bc1f43 ]
Now sk->sk_timer is no longer used by TCP keepalive, we can use its storage for TCP and MPTCP retransmit timers for better cache locality.
Stable-dep-of: e2ab913f68c7 ("mptcp: do not reschedule the RTX timer for fallback sockets")
--- .../net_cachelines/inet_connection_sock.rst | 1 - include/net/inet_connection_sock.h | 8 +++----- include/net/sock.h | 9 +++++++-- net/ipv4/inet_connection_sock.c | 6 +++--- net/ipv4/tcp_timer.c | 8 +++----- net/mptcp/protocol.c | 15 +++++---------- tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c | 4 ++-- tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c | 4 ++-- 8 files changed, 25 insertions(+), 30 deletions(-)
Documentation/networking/net_cachelines/inet_connection_sock.rst +0 -1
@@ -12,7 +12,6 @@ struct inet_sock icsk_inet read_mostly r struct request_sock_queue icsk_accept_queue struct inet_bind_bucket icsk_bind_hash read_mostly tcp_set_state struct inet_bind2_bucket icsk_bind2_hash read_mostly tcp_set_state,inet_put_port -struct timer_list icsk_retransmit_timer read_write inet_csk_reset_xmit_timer,tcp_connect struct timer_list icsk_delack_timer read_mostly inet_csk_reset_xmit_timer,tcp_connect struct timer_list icsk_keepalive_timer u32 icsk_rto read_write tcp_cwnd_validate,tcp_schedule_loss_probe,tcp_connect_init,tcp_connect,tcp_write_xmit,tcp_push_one
include/net/inet_connection_sock.h +3 -5
@@ -58,7 +58,6 @@ struct inet_connection_sock_af_ops {* @icsk_accept_queue: FIFO of established children * @icsk_bind_hash: Bind node * @icsk_bind2_hash: Bind node in the bhash2 table -* @icsk_retransmit_timer: Resend (no ack) * @icsk_delack_timer: Delayed ACK timer * @icsk_keepalive_timer: Keepalive timer * @mptcp_tout_timer: mptcp timer
@@ -86,7 +85,6 @@ struct inet_connection_sock {struct request_sock_queue icsk_accept_queue;struct inet_bind_bucket *icsk_bind_hash;struct inet_bind2_bucket *icsk_bind2_hash; -struct timer_list icsk_retransmit_timer;struct timer_list icsk_delack_timer;union {struct timer_list icsk_keepalive_timer;
@@ -195,7 +193,7 @@ static inline void inet_csk_delack_init(struct sock *sk)static inline unsigned long tcp_timeout_expires (const struct sock *sk) { -return READ_ONCE (inet_csk (sk)->icsk_retransmit_timer.expires); +return READ_ONCE (sk->tcp_retransmit_timer.expires); } static inline unsigned long
@@ -211,7 +209,7 @@ static inline void inet_csk_clear_xmit_timer(struct sock *sk, const int what)if (what ==ICSK_TIME_RETRANS || what ==ICSK_TIME_PROBE0 ) {smp_store_release (&icsk->icsk_pending,0 );#ifdef INET_CSK_CLEAR_TIMERS -sk_stop_timer (sk, &icsk->icsk_retransmit_timer); +sk_stop_timer (sk, &sk->tcp_retransmit_timer);#endif }else if (what ==ICSK_TIME_DACK ) {smp_store_release (&icsk->icsk_ack.pending,0 );
@@ -243,7 +241,7 @@ static inline void inet_csk_reset_xmit_timer(struct sock *sk, const int what,if (what ==ICSK_TIME_RETRANS || what ==ICSK_TIME_PROBE0 || what ==ICSK_TIME_LOSS_PROBE || what ==ICSK_TIME_REO_TIMEOUT ) {smp_store_release (&icsk->icsk_pending, what); -sk_reset_timer (sk, &icsk->icsk_retransmit_timer, when); +sk_reset_timer (sk, &sk->tcp_retransmit_timer, when); }else if (what ==ICSK_TIME_DACK ) {smp_store_release (&icsk->icsk_ack.pending, icsk->icsk_ack.pending |ICSK_ACK_TIMER );
include/net/sock.h +7 -2
@@ -303,6 +303,8 @@ struct sk_filter;* @sk_txrehash: enable TX hash rethink * @sk_filter: socket filtering instructions * @sk_timer: sock cleanup timer +* @tcp_retransmit_timer: tcp retransmit timer +* @mptcp_retransmit_timer: mptcp retransmit timer * @sk_stamp: time stamp of last packet received * @sk_stamp_seq: lock for accessing sk_stamp on 32 bit architectures only * @sk_tsflags: SO_TIMESTAMPING flags
@@ -480,8 +482,11 @@ struct sock {u32 sk_dst_pending_confirm;u32 sk_pacing_status;/* see enum sk_pacing */ struct page_frag sk_frag; -struct timer_list sk_timer; - +union { +struct timer_list sk_timer; +struct timer_list tcp_retransmit_timer; +struct timer_list mptcp_retransmit_timer; + };unsigned long sk_pacing_rate;/* bytes per second */ atomic_t sk_zckey;atomic_t sk_tskey;
net/ipv4/inet_connection_sock.c +3 -3
@@ -748,7 +748,7 @@ void inet_csk_init_xmit_timers(struct sock *sk, {struct inet_connection_sock *icsk =inet_csk (sk); -timer_setup (&icsk->icsk_retransmit_timer, retransmit_handler,0 ); +timer_setup (&sk->tcp_retransmit_timer, retransmit_handler,0 );timer_setup (&icsk->icsk_delack_timer, delack_handler,0 );timer_setup (&icsk->icsk_keepalive_timer, keepalive_handler,0 ); icsk->icsk_pending = icsk->icsk_ack.pending =0 ;
@@ -761,7 +761,7 @@ void inet_csk_clear_xmit_timers(struct sock *sk)smp_store_release (&icsk->icsk_pending,0 );smp_store_release (&icsk->icsk_ack.pending,0 ); -sk_stop_timer (sk, &icsk->icsk_retransmit_timer); +sk_stop_timer (sk, &sk->tcp_retransmit_timer);sk_stop_timer (sk, &icsk->icsk_delack_timer);sk_stop_timer (sk, &icsk->icsk_keepalive_timer); }
@@ -776,7 +776,7 @@ void inet_csk_clear_xmit_timers_sync(struct sock *sk)smp_store_release (&icsk->icsk_pending,0 );smp_store_release (&icsk->icsk_ack.pending,0 ); -sk_stop_timer_sync (sk, &icsk->icsk_retransmit_timer); +sk_stop_timer_sync (sk, &sk->tcp_retransmit_timer);sk_stop_timer_sync (sk, &icsk->icsk_delack_timer);sk_stop_timer_sync (sk, &icsk->icsk_keepalive_timer); }
net/ipv4/tcp_timer.c +3 -5
@@ -701,7 +701,7 @@ void tcp_write_timer_handler(struct sock *sk)return ;if (time_after (tcp_timeout_expires (sk), jiffies)) { -sk_reset_timer (sk, &icsk->icsk_retransmit_timer, +sk_reset_timer (sk, &sk->tcp_retransmit_timer,tcp_timeout_expires (sk));return ; }
@@ -728,12 +728,10 @@ void tcp_write_timer_handler(struct sock *sk)static void tcp_write_timer (struct timer_list *t) { -struct inet_connection_sock *icsk = -timer_container_of (icsk, t, icsk_retransmit_timer); -struct sock *sk = &icsk->icsk_inet.sk; +struct sock *sk =timer_container_of (sk, t, tcp_retransmit_timer);/* Avoid locking the socket when there is no pending event. */ -if (!smp_load_acquire (&icsk->icsk_pending)) +if (!smp_load_acquire (&inet_csk (sk)->icsk_pending)) goto out;bh_lock_sock (sk);
net/mptcp/protocol.c +5 -10
@@ -425,9 +425,7 @@ static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb)static void mptcp_stop_rtx_timer (struct sock *sk) { -struct inet_connection_sock *icsk =inet_csk (sk); - -sk_stop_timer (sk, &icsk->icsk_retransmit_timer); +sk_stop_timer (sk, &sk->mptcp_retransmit_timer);mptcp_sk (sk)->timer_ival =0 ; }
@@ -936,12 +934,11 @@ static void __mptcp_flush_join_list(struct sock *sk, struct list_head *join_liststatic bool mptcp_rtx_timer_pending (struct sock *sk) { -return timer_pending (&inet_csk (sk)->icsk_retransmit_timer); +return timer_pending (&sk->mptcp_retransmit_timer); }static void mptcp_reset_rtx_timer (struct sock *sk) { -struct inet_connection_sock *icsk =inet_csk (sk);unsigned long tout;/* prevent rescheduling on close */
@@ -949,7 +946,7 @@ static void mptcp_reset_rtx_timer(struct sock *sk)return ; tout =mptcp_sk (sk)->timer_ival; -sk_reset_timer (sk, &icsk->icsk_retransmit_timer, jiffies + tout); +sk_reset_timer (sk, &sk->mptcp_retransmit_timer, jiffies + tout); }bool mptcp_schedule_work (struct sock *sk)
@@ -2328,9 +2325,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,static void mptcp_retransmit_timer (struct timer_list *t) { -struct inet_connection_sock *icsk =timer_container_of (icsk, t, - icsk_retransmit_timer); -struct sock *sk = &icsk->icsk_inet.sk; +struct sock *sk =timer_container_of (sk, t, mptcp_retransmit_timer);struct mptcp_sock *msk =mptcp_sk (sk);bh_lock_sock (sk);
@@ -2937,7 +2932,7 @@ static void __mptcp_init_sock(struct sock *sk)spin_lock_init (&msk->fallback_lock);/* re-use the csk retrans timer for MPTCP-level retrans */ -timer_setup (&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer,0 ); +timer_setup (&sk->mptcp_retransmit_timer, mptcp_retransmit_timer,0 );timer_setup (&msk->sk.mptcp_tout_timer, mptcp_tout_timer,0 ); }
tools/testing/selftests/bpf/progs/bpf_iter_tcp4.c +2 -2
@@ -99,10 +99,10 @@ static int dump_tcp_sock(struct seq_file *seq, struct tcp_sock *tp, icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) { timer_active =1 ; - timer_expires = icsk->icsk_retransmit_timer.expires; + timer_expires = sp->tcp_retransmit_timer.expires; } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) { timer_active =4 ; - timer_expires = icsk->icsk_retransmit_timer.expires; + timer_expires = sp->tcp_retransmit_timer.expires; } else if (timer_pending(&icsk->icsk_keepalive_timer)) { timer_active =2 ; timer_expires = icsk->icsk_keepalive_timer.expires;
tools/testing/selftests/bpf/progs/bpf_iter_tcp6.c +2 -2
@@ -99,10 +99,10 @@ static int dump_tcp6_sock(struct seq_file *seq, struct tcp6_sock *tp, icsk->icsk_pending == ICSK_TIME_REO_TIMEOUT || icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) { timer_active =1 ; - timer_expires = icsk->icsk_retransmit_timer.expires; + timer_expires = sp->tcp_retransmit_timer.expires; } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) { timer_active =4 ; - timer_expires = icsk->icsk_retransmit_timer.expires; + timer_expires = sp->tcp_retransmit_timer.expires; } else if (timer_pending(&icsk->icsk_keepalive_timer)) { timer_active =2 ; timer_expires = icsk->icsk_keepalive_timer.expires;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 mptcp: do not reschedule the RTX timer for fallback sockets
In reply to Sasha LevinFrom: Paolo Abeni <[email protected]>
[ Upstream commit e2ab913f68c7d11e2561b8a8ad0b87ffefcad667 ]
On fallback socket the retrans timer is a quite convoluted no-op, but currently nothing prevents the MPTCP core to keep rescheduling it.
Additionally gate RTX timer reset to the msk not being fallen back to TCP yet. To avoid adding multiple tests in fast-path, use a new flags bit for such condition.
The RTX enable bit is clear at close time and set before the msk could start retransmitting, with a couple of caveats:
- passive sockets inherit the bit from the listener msk; set the bit on such socket to avoid flipping it in the fast-path, even if the listener will obviously never retransmit.
- while fastopening (MPTFO), mptcp_sendmsg_fastopen still ends-up calling mptcp_connect via tcp_sendmsg_fastopen -> __inet_stream_connect(ssk->sk_socket), and the first subflow's sk_socket points to the msk one.
--- net/mptcp/protocol.c | 13 ++++++++++--- net/mptcp/protocol.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +10 -3
@@ -93,6 +93,7 @@ bool __mptcp_try_fallback(struct mptcp_sock *msk, int fb_mib) msk->allow_subflows = false;set_bit (MPTCP_FALLBACK_DONE , &msk->flags); +clear_bit (MPTCP_RTX_ENABLED , &msk->flags);__MPTCP_INC_STATS (net, fb_mib);spin_unlock_bh (&msk->fallback_lock);return true;
@@ -939,13 +940,14 @@ static bool mptcp_rtx_timer_pending(struct sock *sk)static void mptcp_reset_rtx_timer (struct sock *sk) { +struct mptcp_sock *msk =mptcp_sk (sk);unsigned long tout; -/* prevent rescheduling on close */ -if (unlikely (inet_sk_state_load (sk) ==TCP_CLOSE )) +/* Prevent rescheduling on close and in case of fallback. */ +if (!test_bit (MPTCP_RTX_ENABLED , &msk->flags))return ; - tout =mptcp_sk (sk)->timer_ival; + tout = msk->timer_ival;sk_reset_timer (sk, &sk->mptcp_retransmit_timer, jiffies + tout); }
@@ -3051,6 +3053,9 @@ void mptcp_set_state(struct sock *sk, int state)* transition from TCP_SYN_RECV to TCP_CLOSE_WAIT. */ break ; +case TCP_CLOSE : +clear_bit (MPTCP_RTX_ENABLED , &mptcp_sk (sk)->flags); + fallthrough;default :if (oldstate ==TCP_ESTABLISHED || oldstate ==TCP_CLOSE_WAIT )MPTCP_DEC_STATS (sock_net (sk),MPTCP_MIB_CURRESTAB );
@@ -3851,6 +3856,7 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)if (IS_ERR (ssk))return PTR_ERR (ssk); +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_SYN_SENT ); subflow =mptcp_subflow_ctx (ssk);#ifdef CONFIG_TCP_MD5SIG
@@ -3998,6 +4004,7 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } +set_bit (MPTCP_RTX_ENABLED , &msk->flags);mptcp_set_state (sk,TCP_LISTEN );sock_set_flag (sk,SOCK_RCU_FREE );
net/mptcp/protocol.h +1 -0
@@ -116,6 +116,7 @@#define MPTCP_WORK_RTX 1#define MPTCP_FALLBACK_DONE 2#define MPTCP_WORK_CLOSE_SUBFLOW 3 +#define MPTCP_RTX_ENABLED 4/* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1
Signature · 1 line
2.53.0