aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2021-12-17 18:50:56 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2021-12-17 18:50:56 +0000
commit75add59a8ee2e24cb76a2f0fcbf9aa6d740e3bb6 (patch)
tree4717b86fc07a6b781473a70157255489b61005b6 /sys
parentfff0ae77b9960bb26034297fcb885d26432354bf (diff)
downloadsrc-75add59a8ee2e24cb76a2f0fcbf9aa6d740e3bb6.tar.gz
src-75add59a8ee2e24cb76a2f0fcbf9aa6d740e3bb6.zip
tcp: allocate statistics in the main tcp_init()
No reason to have a separate SYSINIT.
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/tcp_input.c22
-rw-r--r--sys/netinet/tcp_subr.c6
2 files changed, 6 insertions, 22 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index ee514a11eef6..9332bf16235f 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -258,28 +258,6 @@ SYSCTL_COUNTER_U64_ARRAY(_net_inet_tcp, TCPCTL_STATES, states, CTLFLAG_RD |
CTLFLAG_VNET, &VNET_NAME(tcps_states)[0], TCP_NSTATES,
"TCP connection counts by TCP state");
-static void
-tcp_vnet_init(const void *unused)
-{
-
- COUNTER_ARRAY_ALLOC(V_tcps_states, TCP_NSTATES, M_WAITOK);
- VNET_PCPUSTAT_ALLOC(tcpstat, M_WAITOK);
-}
-VNET_SYSINIT(tcp_vnet_init, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
- tcp_vnet_init, NULL);
-
-#ifdef VIMAGE
-static void
-tcp_vnet_uninit(const void *unused)
-{
-
- COUNTER_ARRAY_FREE(V_tcps_states, TCP_NSTATES);
- VNET_PCPUSTAT_FREE(tcpstat);
-}
-VNET_SYSUNINIT(tcp_vnet_uninit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY,
- tcp_vnet_uninit, NULL);
-#endif /* VIMAGE */
-
/*
* Kernel module interface for updating tcpstat. The first argument is an index
* into tcpstat treated as an array.
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 1ce8cddc30e1..232163fe9fe5 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1503,6 +1503,9 @@ tcp_init(void)
tcp_fastopen_init();
+ COUNTER_ARRAY_ALLOC(V_tcps_states, TCP_NSTATES, M_WAITOK);
+ VNET_PCPUSTAT_ALLOC(tcpstat, M_WAITOK);
+
/* Skip initialization of globals for non-default instances. */
if (!IS_DEFAULT_VNET(curvnet))
return;
@@ -1614,6 +1617,9 @@ tcp_destroy(void *unused __unused)
*/
tcp_fastopen_destroy();
+ COUNTER_ARRAY_FREE(V_tcps_states, TCP_NSTATES);
+ VNET_PCPUSTAT_FREE(tcpstat);
+
#ifdef TCP_HHOOK
error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_IN]);
if (error != 0) {