diff mbox series

[ovs-dev,v3,3/5] conntrack: r/w upper limit connection value.

Message ID 1507883117-24347-4-git-send-email-antonio.fischetti@intel.com
State Changes Requested
Delegated to: Darrell Ball
Headers show
Series Conntrack: add commands to r/w CT parameters. | expand

Commit Message

Fischetti, Antonio Oct. 13, 2017, 8:25 a.m. UTC
Read/Write the upper limit value for connections.

Example:
   # set a new upper limit
   ovs-appctl dpctl/ct-set-glbl-cfg maxconn=1000000

   # display cur upper limit
   ovs-appctl dpctl/ct-get-glbl-cfg maxconn

CC: Darrell Ball <dlu998@gmail.com>
CC: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
---
 lib/conntrack.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 29889c9..68d9030 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2492,8 +2492,28 @@  conntrack_flush(struct conntrack *ct, const uint16_t *zone)
     return 0;
 }
 
+/* Set a new value for the upper limit of connections. */
+static int
+ct_wr_max_conn(struct conntrack *ct, uint32_t new_val) {
+    atomic_init(&ct->n_conn_limit, new_val);
+    return 0;
+}
+
+/* Read the current upper limit of connections. */
+static int
+ct_rd_max_conn(struct conntrack *ct, uint32_t *cur_val) {
+    atomic_read_relaxed(&ct->n_conn_limit, cur_val);
+    return 0;
+}
+
+/* List of managed parameters. */
+/* Max nr of connections managed by CT module. */
+#define CT_RW_MAX_CONN "maxconn"
+
 /* List of parameters that can be read/written at run-time. */
-struct ct_cfg_params cfg_params[] = {};
+struct ct_cfg_params cfg_params[] = {
+    {CT_RW_MAX_CONN, ct_wr_max_conn, ct_rd_max_conn},
+};
 
 int
 conntrack_set_param(struct conntrack *ct,