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

Message ID 1506429324-10416-4-git-send-email-antonio.fischetti@intel.com
State Superseded
Headers show
Series
  • Conntrack: add commands to r/w CT parameters.
Related show

Commit Message

Fischetti, Antonio Sept. 26, 2017, 12:35 p.m.
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: 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(-)

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 391d008..684e468 100644
--- a/lib/conntrack.c
+++ b/lib/conntrack.c
@@ -2398,8 +2398,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,