tcp: use callout(9) directly instead of pr_slowtimo

Modern TCP stacks uses multiple callouts per tcpcb, and a global
callout is ancient artifact.  However it is still used to garbage
collect compressed timewait entries.

Reviewed by:		melifaro, tuexen
Differential revision:	https://reviews.freebsd.org/D36159
This commit is contained in:
Gleb Smirnoff 2022-08-17 11:50:31 -07:00
parent 160f01f09f
commit 6c452841ef
4 changed files with 21 additions and 8 deletions

View File

@ -131,7 +131,6 @@ struct protosw inetsw[] = {
.pr_flags = PR_CONNREQUIRED|PR_IMPLOPCL|PR_WANTRCVD|
PR_CAPATTACH,
.pr_ctloutput = tcp_ctloutput,
.pr_slowtimo = tcp_slowtimo,
.pr_drain = tcp_drain,
.pr_usrreqs = &tcp_usrreqs
},

View File

@ -233,15 +233,17 @@ inp_to_cpuid(struct inpcb *inp)
}
/*
* Tcp protocol timeout routine called every 500 ms.
* Updates timestamps used for TCP
* causes finite state machine actions if timers expire.
* Legacy TCP global callout routine called every 500 ms.
* Used to cleanup timewait states, which lack their own callouts.
*/
void
tcp_slowtimo(void)
static struct callout tcpslow_callout;
static void
tcp_slowtimo(void *arg __unused)
{
struct epoch_tracker et;
VNET_ITERATOR_DECL(vnet_iter);
NET_EPOCH_ENTER(et);
VNET_LIST_RLOCK_NOSLEEP();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
@ -249,8 +251,22 @@ tcp_slowtimo(void)
CURVNET_RESTORE();
}
VNET_LIST_RUNLOCK_NOSLEEP();
NET_EPOCH_EXIT(et);
callout_reset_sbt(&tcpslow_callout, SBT_1MS * 500, SBT_1MS * 10,
tcp_slowtimo, NULL, 0);
}
static void
tcp_slowtimo_init(void *arg __unused)
{
callout_init(&tcpslow_callout, 1);
callout_reset_sbt(&tcpslow_callout, SBT_1MS * 500, SBT_1MS * 10,
tcp_slowtimo, NULL, 0);
}
SYSINIT(tcp_timer, SI_SUB_VNET_DONE, SI_ORDER_ANY, tcp_slowtimo_init, NULL);
int tcp_backoff[TCP_MAXRXTSHIFT + 1] =
{ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 512, 512, 512 };

View File

@ -1187,7 +1187,6 @@ void tcp_tw_zone_change(void);
int tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,
struct mbuf *, int);
void tcp_setpersist(struct tcpcb *);
void tcp_slowtimo(void);
void tcp_record_dsack(struct tcpcb *tp, tcp_seq start, tcp_seq end, int tlp);
struct tcptemp *
tcpip_maketemplate(struct inpcb *);

View File

@ -166,7 +166,6 @@ struct protosw inet6sw[] = {
PR_LISTEN|PR_CAPATTACH,
.pr_ctloutput = tcp_ctloutput,
#ifndef INET /* don't call initialization, timeout, and drain routines twice */
.pr_slowtimo = tcp_slowtimo,
.pr_drain = tcp_drain,
#endif
.pr_usrreqs = &tcp6_usrreqs,