The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=75add59a8ee2e24cb76a2f0fcbf9aa6d740e3bb6

commit 75add59a8ee2e24cb76a2f0fcbf9aa6d740e3bb6
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2021-12-17 18:50:56 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2021-12-17 18:50:56 +0000

    tcp: allocate statistics in the main tcp_init()
    
    No reason to have a separate SYSINIT.
---
 sys/netinet/tcp_input.c | 22 ----------------------
 sys/netinet/tcp_subr.c  |  6 ++++++
 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) {

Reply via email to