diff mbox series

[ovs-dev,4/5] conntrack: read current nr of connections.

Message ID 1505730091-19042-4-git-send-email-antonio.fischetti@intel.com
State Changes Requested
Delegated to: Darrell Ball
Headers show
Series [ovs-dev,1/5] conntrack: add commands to r/w conntrack parameters. | expand

Commit Message

Fischetti, Antonio Sept. 18, 2017, 10:21 a.m. UTC
Read current number of connections managed by the
CT module.

Example:
  ovs-appctl dpctl/ct-get totconn

Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/conntrack.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 60eb376..412665a 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2400,6 +2400,13 @@  conntrack_flush(struct conntrack *ct, const uint16_t *zone)
     return 0;
 }
 
+/* Read the total nr of connections currently managed. */
+static int
+rd_tot_conn(struct conntrack *ct, uint32_t *cur_val) {
+    *cur_val = atomic_count_get(&ct->n_conn);
+    return 0;
+}
+
 /* Set an interval value to be used by clean_thread_main. */
 static int
 wr_clean_int(struct conntrack *ct, uint32_t new_val) {
@@ -2435,11 +2442,14 @@  rd_max_conn(struct conntrack *ct, uint32_t *cur_val) {
 #define CT_RW_MAX_CONN "maxconn"
 /* Clean-up interval used by clean_thread_main() thread. */
 #define CT_RW_CLEAN_INTERVAL "cleanup"
+/* Total nr of connections currently managed by CT module. */
+#define CT_RW_TOT_CONN "totconn"
 
 /* List of parameters that can be read/written at run-time. */
 struct ct_wk_params wk_params[] = {
     {CT_RW_MAX_CONN, wr_max_conn, rd_max_conn},
     {CT_RW_CLEAN_INTERVAL, wr_clean_int, rd_clean_int},
+    {CT_RW_TOT_CONN, NULL, rd_tot_conn},
 };
 
 int