Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sctp: do not check hb_timer.expires when resetting hb_timer

It tries to avoid the frequently hb_timer refresh in commit ba6f5e33bdbb
("sctp: avoid refreshing heartbeat timer too often"), and it only allows
mod_timer when the new expires is after hb_timer.expires. It means even
a much shorter interval for hb timer gets applied, it will have to wait
until the current hb timer to time out.

In sctp_do_8_2_transport_strike(), when a transport enters PF state, it
expects to update the hb timer to resend a heartbeat every rto after
calling sctp_transport_reset_hb_timer(), which will not work as the
change mentioned above.

The frequently hb_timer refresh was caused by sctp_transport_reset_timers()
called in sctp_outq_flush() and it was already removed in the commit above.
So we don't have to check hb_timer.expires when resetting hb_timer as it is
now not called very often.

Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Link: https://lore.kernel.org/r/d958c06985713ec84049a2d5664879802710179a.1675095933.git.lucien.xin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Xin Long and committed by
Jakub Kicinski
8f35ae17 de5ca4c3

+1 -3
+1 -3
net/sctp/transport.c
··· 196 196 197 197 /* When a data chunk is sent, reset the heartbeat interval. */ 198 198 expires = jiffies + sctp_transport_timeout(transport); 199 - if ((time_before(transport->hb_timer.expires, expires) || 200 - !timer_pending(&transport->hb_timer)) && 201 - !mod_timer(&transport->hb_timer, 199 + if (!mod_timer(&transport->hb_timer, 202 200 expires + get_random_u32_below(transport->rto))) 203 201 sctp_transport_hold(transport); 204 202 }