aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2023-06-24 18:57:17 -0700
committerFlorin Coras <florin.coras@gmail.com>2023-06-25 01:49:58 +0000
commit503480d772158d404987aca60c94f96505991d4e (patch)
treee9a65f6448cb8cb6c11c218784d1de933a4e2f50 /src/vnet
parent1271e3a2a1b028e5b9cd7ca35a6bd06ddbe2c63b (diff)
tcp: avoid initializing counters multiple times
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ia98dae5fdde16426d5457742aff0a1b04db4d034
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/tcp/tcp.c9
-rw-r--r--src/vnet/tcp/tcp.h3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 2f90d9add81..c7121b43e23 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -1482,11 +1482,14 @@ tcp_stats_collector_fn (vlib_stats_collector_data_t *d)
}
static void
-tcp_counters_init (void)
+tcp_counters_init (tcp_main_t *tm)
{
vlib_stats_collector_reg_t r = {};
u32 idx;
+ if (tm->counters_init)
+ return;
+
r.entry_index = idx = vlib_stats_add_counter_vector ("/sys/tcp");
r.collect_fn = tcp_stats_collector_fn;
vlib_stats_validate (idx, 0, TCP_STAT_no_buffer);
@@ -1498,6 +1501,8 @@ tcp_counters_init (void)
#undef _
vlib_stats_register_collector_fn (&r);
+
+ tm->counters_init = 1;
}
static clib_error_t *
@@ -1576,7 +1581,7 @@ tcp_main_enable (vlib_main_t * vm)
tm->bytes_per_buffer = vlib_buffer_get_default_data_size (vm);
tm->cc_last_type = TCP_CC_LAST;
- tcp_counters_init ();
+ tcp_counters_init (tm);
return error;
}
diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h
index 962324e2eaf..2362a8bb857 100644
--- a/src/vnet/tcp/tcp.h
+++ b/src/vnet/tcp/tcp.h
@@ -240,6 +240,9 @@ typedef struct _tcp_main
/** Flag that indicates if stack is on or off */
u8 is_enabled;
+ /** Set if counters on stats segment initialized */
+ u8 counters_init;
+
/** Flag that indicates if v4 punting is enabled */
u8 punt_unknown4;