diff mbox series

[ovs-dev,2/5] conntrack: r/w upper limit value for connections.

Message ID 1505730091-19042-2-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/Write the upper limit value for connections.

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

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

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

Comments

Darrell Ball Sept. 19, 2017, 8:04 a.m. UTC | #1
On 9/18/17, 3:22 AM, "ovs-dev-bounces@openvswitch.org on behalf of antonio.fischetti@intel.com" <ovs-dev-bounces@openvswitch.org on behalf of antonio.fischetti@intel.com> wrote:

    Read/Write the upper limit value for connections.
    
    Example:
       # set a new upper limit
       ovs-appctl dpctl/ct-set maxconn=1000000
    
       # display cur upper limit
       ovs-appctl dpctl/ct-get maxconn
    
    Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
    ---
     lib/conntrack.c | 22 +++++++++++++++++++++-
     1 file changed, 21 insertions(+), 1 deletion(-)
    
    diff --git a/lib/conntrack.c b/lib/conntrack.c
    index 0642cc8..6d86625 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
    +wr_max_conn(struct conntrack *ct, uint32_t new_val) {
    +    atomic_init(&ct->n_conn_limit, new_val);
    +    VLOG_DBG("Set conn upper limit to %d", new_val);

[Darrell] really needed ?

    +    return 0;
    +}
    +
    +/* Read the current upper limit of connections. */
    +static int
    +rd_max_conn(struct conntrack *ct, uint32_t *cur_val) {
    +    atomic_read_relaxed(&ct->n_conn_limit, cur_val);
    +    return 0;
    +}

[Darrell] I realize you are trying to generalize the function pointer, but I think
it may be nicer to use different function pointers in these cases ?
Name probably should have ct_ ?

    +
    +/* List of managed parameters. */
    +#define CT_RW_MAX_CONN "maxconn"
    +
     /* List of parameters that can be read/written at run-time. */
    -struct ct_wk_params wk_params[] = {};
    +struct ct_wk_params wk_params[] = {
    +    {CT_RW_MAX_CONN, wr_max_conn, rd_max_conn},
    +};
     
     int
     conntrack_set_param(struct conntrack *ct,
    -- 
    2.4.11
    
    _______________________________________________
    dev mailing list
    dev@openvswitch.org
    https://urldefense.proofpoint.com/v2/url?u=https-3A__mail.openvswitch.org_mailman_listinfo_ovs-2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=BVhFA09CGX7JQ5Ih-uZnsw&m=KK4qOk1HsuyVz-TJdOC9uBkoCN1hDN4I7UOmuCDr4ps&s=67tSYBejIuWlKYg0rQazrtErrRHWkL42TvEJUfd3iuU&e=
Fischetti, Antonio Sept. 20, 2017, 6:31 p.m. UTC | #2
> -----Original Message-----
> From: Darrell Ball [mailto:dball@vmware.com]
> Sent: Tuesday, September 19, 2017 9:05 AM
> To: Fischetti, Antonio <antonio.fischetti@intel.com>; dev@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH 2/5] conntrack: r/w upper limit value for
> connections.
> 
> 
> 
> On 9/18/17, 3:22 AM, "ovs-dev-bounces@openvswitch.org on behalf of
> antonio.fischetti@intel.com" <ovs-dev-bounces@openvswitch.org on behalf of
> antonio.fischetti@intel.com> wrote:
> 
>     Read/Write the upper limit value for connections.
> 
>     Example:
>        # set a new upper limit
>        ovs-appctl dpctl/ct-set maxconn=1000000
> 
>        # display cur upper limit
>        ovs-appctl dpctl/ct-get maxconn
> 
>     Signed-off-by: Antonio Fischetti <antonio.fischetti@intel.com>
>     ---
>      lib/conntrack.c | 22 +++++++++++++++++++++-
>      1 file changed, 21 insertions(+), 1 deletion(-)
> 
>     diff --git a/lib/conntrack.c b/lib/conntrack.c
>     index 0642cc8..6d86625 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
>     +wr_max_conn(struct conntrack *ct, uint32_t new_val) {
>     +    atomic_init(&ct->n_conn_limit, new_val);
>     +    VLOG_DBG("Set conn upper limit to %d", new_val);
> 
> [Darrell] really needed ?

[Antonio] ok will remove


> 
>     +    return 0;
>     +}
>     +
>     +/* Read the current upper limit of connections. */
>     +static int
>     +rd_max_conn(struct conntrack *ct, uint32_t *cur_val) {
>     +    atomic_read_relaxed(&ct->n_conn_limit, cur_val);
>     +    return 0;
>     +}
> 
> [Darrell] I realize you are trying to generalize the function pointer, but I
> think
> it may be nicer to use different function pointers in these cases ?
> Name probably should have ct_ ?

[Antonio] ok will add ct_ prefix

> 
>     +
>     +/* List of managed parameters. */
>     +#define CT_RW_MAX_CONN "maxconn"
>     +
>      /* List of parameters that can be read/written at run-time. */
>     -struct ct_wk_params wk_params[] = {};
>     +struct ct_wk_params wk_params[] = {
>     +    {CT_RW_MAX_CONN, wr_max_conn, rd_max_conn},
>     +};
> 
>      int
>      conntrack_set_param(struct conntrack *ct,
>     --
>     2.4.11
> 
>     _______________________________________________
>     dev mailing list
>     dev@openvswitch.org
>     https://urldefense.proofpoint.com/v2/url?u=https-
> 3A__mail.openvswitch.org_mailman_listinfo_ovs-
> 2Ddev&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=BVhFA09CGX7JQ5Ih-
> uZnsw&m=KK4qOk1HsuyVz-
> TJdOC9uBkoCN1hDN4I7UOmuCDr4ps&s=67tSYBejIuWlKYg0rQazrtErrRHWkL42TvEJUfd3iuU&e=
>
diff mbox series

Patch

diff --git a/lib/conntrack.c b/lib/conntrack.c
index 0642cc8..6d86625 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
+wr_max_conn(struct conntrack *ct, uint32_t new_val) {
+    atomic_init(&ct->n_conn_limit, new_val);
+    VLOG_DBG("Set conn upper limit to %d", new_val);
+    return 0;
+}
+
+/* Read the current upper limit of connections. */
+static int
+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. */
+#define CT_RW_MAX_CONN "maxconn"
+
 /* List of parameters that can be read/written at run-time. */
-struct ct_wk_params wk_params[] = {};
+struct ct_wk_params wk_params[] = {
+    {CT_RW_MAX_CONN, wr_max_conn, rd_max_conn},
+};
 
 int
 conntrack_set_param(struct conntrack *ct,