Add 'conntrack_conn_created' and 'conntrack_conn_destroyed' coverage
counters, incremented at the single point in conntrack.c where a new
connection is inserted into the table and the single point where one
is removed. Coverage counters already get the usual 5-second,
1-minute, and 1-hour rate averaging from 'ovs-appctl coverage/show',
so this gives connections-per-second for the userspace connection
tracker without any new timer, sampling, or per-connection state.

Tested with 'make check' (all conntrack-related tests pass) and with
real traffic via 'ovstest'/dperf: at a steady connection rate, the
reported 'conntrack_conn_created'/sec matches the externally measured
connections-per-second.

Signed-off-by: Thilak Raj Surendra Babu <[email protected]>
Assisted-by: Claude Sonnet 5, Claude Code
---
 NEWS            | 5 +++++
 lib/conntrack.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/NEWS b/NEWS
index de1a030ad..d839f73fe 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 Post-v4.0.0
 --------------------
+   - Userspace datapath:
+     * Added 'conntrack_conn_created'/'conntrack_conn_destroyed' coverage
+       counters, visible via 'ovs-appctl coverage/show', giving the rate of
+       new/expired connections per second for the userspace connection
+       tracker.
 
 
 v4.0.0 - 17 Aug 2026
diff --git a/lib/conntrack.c b/lib/conntrack.c
index f84cdd216..23017dba2 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -47,6 +47,8 @@
 
 VLOG_DEFINE_THIS_MODULE(conntrack);
 
+COVERAGE_DEFINE(conntrack_conn_created);
+COVERAGE_DEFINE(conntrack_conn_destroyed);
 COVERAGE_DEFINE(conntrack_full);
 COVERAGE_DEFINE(conntrack_l3csum_checked);
 COVERAGE_DEFINE(conntrack_l3csum_err);
@@ -599,6 +601,7 @@ conn_clean(struct conntrack *ct, struct conn *conn)
 
     ovsrcu_postpone(delete_conn, conn);
     atomic_count_dec(&ct->n_conn);
+    COVERAGE_INC(conntrack_conn_destroyed);
 }
 
 static void
@@ -1123,6 +1126,7 @@ conn_not_found(struct conntrack *ct, struct dp_packet 
*pkt,
                     &fwd_key_node->cm_node, ctx->hash);
         conn_expire_push_front(ct, nc);
         atomic_count_inc(&ct->n_conn);
+        COVERAGE_INC(conntrack_conn_created);
 
         if (zl) {
             atomic_count_inc(&zl->czl.count);
-- 
2.43.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to