From patchwork Tue Sep 26 12:35:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 818627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y1gRc2ZbXz9s83 for ; Tue, 26 Sep 2017 22:36:12 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 115C5B37; Tue, 26 Sep 2017 12:35:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 2A966A92 for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 919433ED for ; Tue, 26 Sep 2017 12:35:32 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 05:35:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,440,1500966000"; d="scan'208"; a="1199143984" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 05:35:26 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Tue, 26 Sep 2017 13:35:21 +0100 Message-Id: <1506429324-10416-2-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> References: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 1/4] dpctl: Add a comment to functions retrieving the datapath name. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Signed-off-by: Antonio Fischetti --- lib/dpctl.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/dpctl.c b/lib/dpctl.c index 8951d6e..b6eecf0 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -825,6 +825,9 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) } } + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc == 1 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc > 1) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { error = EINVAL; @@ -960,6 +963,9 @@ dpctl_put_flow(int argc, const char *argv[], enum dpif_flow_put_flags flags, struct simap port_names; int n, error; + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 4 - we retrieve it from the + * current setup, assuming only one exists. */ dp_name = argc == 4 ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!dp_name) { return EINVAL; @@ -1069,6 +1075,9 @@ dpctl_get_flow(int argc, const char *argv[], struct dpctl_params *dpctl_p) struct ds ds; int n, error; + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 3 - we retrieve it from the + * current setup, assuming only one exists. */ dp_name = argc == 3 ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!dp_name) { return EINVAL; @@ -1125,6 +1134,9 @@ dpctl_del_flow(int argc, const char *argv[], struct dpctl_params *dpctl_p) struct simap port_names; int n, error; + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 3 - we retrieve it from the + * current setup, assuming only one exists. */ dp_name = argc == 3 ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!dp_name) { return EINVAL; @@ -1202,6 +1214,9 @@ dpctl_del_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) char *name; int error; + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 2 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { return EINVAL; @@ -1268,6 +1283,9 @@ dpctl_dump_conntrack(int argc, const char *argv[], pzone = &zone; argc--; } + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 2 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { return EINVAL; @@ -1314,6 +1332,9 @@ dpctl_flush_conntrack(int argc, const char *argv[], pzone = &zone; argc--; } + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 2 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { return EINVAL; @@ -1361,7 +1382,9 @@ dpctl_ct_stats_show(int argc, const char *argv[], } } } - + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc == 1 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc > 1) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { return EINVAL; @@ -1489,6 +1512,9 @@ dpctl_ct_bkts(int argc, const char *argv[], } } + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 2 - we retrieve it from the + * current setup, assuming only one exists. */ name = (argc == 2) ? xstrdup(argv[1]) : get_one_dp(dpctl_p); if (!name) { return EINVAL; From patchwork Tue Sep 26 12:35:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 818629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y1gT70KWyz9s83 for ; Tue, 26 Sep 2017 22:37:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id F0491BC2; Tue, 26 Sep 2017 12:35:37 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 900D7B37 for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DD621452 for ; Tue, 26 Sep 2017 12:35:32 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 05:35:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,440,1500966000"; d="scan'208"; a="1199143987" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 05:35:27 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Tue, 26 Sep 2017 13:35:22 +0100 Message-Id: <1506429324-10416-3-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> References: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 2/4] conntrack: add commands to r/w CT parameters. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Add infrastructure to implement: - dpctl/ct-get-glbl-cfg to read a current value of available conntrack parameters. - dpctl/ct-set-glbl-cfg to set a value to the available conntrack parameters. CC: Kevin Traynor Signed-off-by: Antonio Fischetti --- lib/conntrack.c | 60 ++++++++++++++++++++++++++++++++++++++++++ lib/conntrack.h | 3 +++ lib/ct-dpif.c | 28 ++++++++++++++++++++ lib/ct-dpif.h | 2 ++ lib/dpctl.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/dpif-netdev.c | 19 ++++++++++++++ lib/dpif-netlink.c | 2 ++ lib/dpif-provider.h | 4 +++ 8 files changed, 194 insertions(+) diff --git a/lib/conntrack.c b/lib/conntrack.c index 419cb1d..391d008 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -67,6 +67,13 @@ enum ct_alg_mode { CT_TFTP_MODE, }; +/* Variable to manage read/write on CT parameters. */ +struct ct_cfg_params { + char *cli; /* Parameter name in human format. */ + int (*wr)(struct conntrack *, uint32_t); + int (*rd)(struct conntrack *, uint32_t *); +}; + static bool conn_key_extract(struct conntrack *, struct dp_packet *, ovs_be16 dl_type, struct conn_lookup_ctx *, uint16_t zone); @@ -2391,6 +2398,59 @@ conntrack_flush(struct conntrack *ct, const uint16_t *zone) return 0; } +/* List of parameters that can be read/written at run-time. */ +struct ct_cfg_params cfg_params[] = {}; + +int +conntrack_set_param(struct conntrack *ct, + const char *set_param) +{ + uint32_t max_conn; + char buf[16] = ""; + + /* Check if the specified param can be managed. */ + for (int i = 0; i < sizeof(cfg_params) / sizeof(struct ct_cfg_params); + i++) { + if (!strncmp(set_param, cfg_params[i].cli, + strlen(cfg_params[i].cli))) { + ovs_strzcpy(buf, cfg_params[i].cli, sizeof(buf) - 1); + strncat(buf, "=%"SCNu32, sizeof(buf) - 1 - strlen(buf)); + if (ovs_scan(set_param, buf, &max_conn)) { + return (cfg_params[i].wr + ? cfg_params[i].wr(ct, max_conn) + : EOPNOTSUPP); + } else { + return EINVAL; + } + } + } + /* The entered param didn't match any in the list. */ + VLOG_WARN("%s parameter is not managed by this command.", set_param); + + return EINVAL; +} + +int +conntrack_get_param(struct conntrack *ct, + const char *get_param, uint32_t *val) +{ + /* Check if the specified param can be managed. */ + for (int i = 0; i < sizeof(cfg_params) / sizeof(struct ct_cfg_params); + i++) { + if (!strncmp(get_param, cfg_params[i].cli, + strlen(cfg_params[i].cli))) { + + return (cfg_params[i].rd + ? cfg_params[i].rd(ct, val) + : EOPNOTSUPP); + } + } + /* The entered param didn't match any in the list. */ + VLOG_WARN("%s parameter is not managed by this command.", get_param); + + return EINVAL; +} + /* This function must be called with the ct->resources read lock taken. */ static struct alg_exp_node * expectation_lookup(struct hmap *alg_expectations, diff --git a/lib/conntrack.h b/lib/conntrack.h index fbeef1c..4eb9a9a 100644 --- a/lib/conntrack.h +++ b/lib/conntrack.h @@ -114,6 +114,9 @@ int conntrack_dump_next(struct conntrack_dump *, struct ct_dpif_entry *); int conntrack_dump_done(struct conntrack_dump *); int conntrack_flush(struct conntrack *, const uint16_t *zone); +int conntrack_set_param(struct conntrack *, const char *set_param); +int conntrack_get_param(struct conntrack *, const char *get_param, + uint32_t *val); /* 'struct ct_lock' is a wrapper for an adaptive mutex. It's useful to try * different types of locks (e.g. spinlocks) */ diff --git a/lib/ct-dpif.c b/lib/ct-dpif.c index c79e69e..599bc57 100644 --- a/lib/ct-dpif.c +++ b/lib/ct-dpif.c @@ -127,6 +127,34 @@ ct_dpif_flush(struct dpif *dpif, const uint16_t *zone) : EOPNOTSUPP); } +int +ct_dpif_set_param(struct dpif *dpif, const char *set_param) +{ + if (!set_param) { + VLOG_DBG("%s: ct_set_param: no input param", dpif_name(dpif)); + return EINVAL; + } + VLOG_DBG("%s: ct_set_param: %s", dpif_name(dpif), set_param); + + return (dpif->dpif_class->ct_set_param + ? dpif->dpif_class->ct_set_param(dpif, set_param) + : EOPNOTSUPP); +} + +int +ct_dpif_get_param(struct dpif *dpif, const char *get_param, uint32_t *val) +{ + if (!get_param) { + VLOG_DBG("%s: ct_get_param: no input param", dpif_name(dpif)); + return EINVAL; + } + VLOG_DBG("%s: ct_get_param: %s", dpif_name(dpif), get_param); + + return (dpif->dpif_class->ct_get_param + ? dpif->dpif_class->ct_get_param(dpif, get_param, val) + : EOPNOTSUPP); +} + void ct_dpif_entry_uninit(struct ct_dpif_entry *entry) { diff --git a/lib/ct-dpif.h b/lib/ct-dpif.h index d5f9661..92ce3e9 100644 --- a/lib/ct-dpif.h +++ b/lib/ct-dpif.h @@ -196,6 +196,8 @@ int ct_dpif_dump_start(struct dpif *, struct ct_dpif_dump_state **, int ct_dpif_dump_next(struct ct_dpif_dump_state *, struct ct_dpif_entry *); int ct_dpif_dump_done(struct ct_dpif_dump_state *); int ct_dpif_flush(struct dpif *, const uint16_t *zone); +int ct_dpif_set_param(struct dpif *dpif, const char *set_param); +int ct_dpif_get_param(struct dpif *dpif, const char *get_param, uint32_t *val); void ct_dpif_entry_uninit(struct ct_dpif_entry *); void ct_dpif_format_entry(const struct ct_dpif_entry *, struct ds *, bool verbose, bool print_stats); diff --git a/lib/dpctl.c b/lib/dpctl.c index b6eecf0..5b02951 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -1589,6 +1589,80 @@ dpctl_ct_bkts(int argc, const char *argv[], free(conn_per_bkts); return error; } + +static int +dpctl_ct_set_param(int argc, const char *argv[], + struct dpctl_params *dpctl_p) +{ + struct dpif *dpif; + char *name; + int error; + + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 3 - we retrieve it from the + * current setup, assuming only one exists. */ + name = argc == 3 ? xstrdup(argv[1]) : get_one_dp(dpctl_p); + if (!name) { + return EINVAL; + } + error = parsed_dpif_open(name, false, &dpif); + free(name); + if (error) { + dpctl_error(dpctl_p, error, "opening datapath"); + return error; + } + + error = ct_dpif_set_param(dpif, argv[argc - 1]); + + if (!error) { + dpctl_print(dpctl_p, "Ok"); + } else { + dpctl_print(dpctl_p, "CT set global cfg failed (%s)", + ovs_strerror(error)); + } + + dpif_close(dpif); + + return error; +} + +static int +dpctl_ct_get_param(int argc, const char *argv[], + struct dpctl_params *dpctl_p) +{ + struct dpif *dpif; + uint32_t param_val; + char *name; + int error; + + /* The datapath name is not a mandatory parameter for this command. + * If it is not specified - so argc < 3 - we retrieve it from the + * current setup, assuming only one exists. */ + name = argc == 3 ? xstrdup(argv[1]) : get_one_dp(dpctl_p); + if (!name) { + return EINVAL; + } + error = parsed_dpif_open(name, false, &dpif); + free(name); + if (error) { + dpctl_error(dpctl_p, error, "opening datapath"); + return error; + } + + error = ct_dpif_get_param(dpif, argv[argc - 1], ¶m_val); + + if (!error) { + dpctl_print(dpctl_p, "Current value: %d", param_val); + } else { + dpctl_print(dpctl_p, "CT get global cfg failed (%s)", + ovs_strerror(error)); + } + + dpif_close(dpif); + + return error; +} + /* Undocumented commands for unit testing. */ @@ -1885,6 +1959,8 @@ static const struct dpctl_command all_commands[] = { { "ct-stats-show", "[dp] [zone=N] [verbose]", 0, 3, dpctl_ct_stats_show, DP_RO }, { "ct-bkts", "[dp] [gt=N]", 0, 2, dpctl_ct_bkts, DP_RO }, + { "ct-set-glbl-cfg", "[dp] param=..", 1, 2, dpctl_ct_set_param, DP_RW }, + { "ct-get-glbl-cfg", "[dp] param", 1, 2, dpctl_ct_get_param, DP_RO }, { "help", "", 0, INT_MAX, dpctl_help, DP_RO }, { "list-commands", "", 0, INT_MAX, dpctl_list_commands, DP_RO }, diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index ca74df8..8fda2a9 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -5689,6 +5689,23 @@ dpif_netdev_ct_flush(struct dpif *dpif, const uint16_t *zone) return conntrack_flush(&dp->conntrack, zone); } +static int +dpif_netdev_ct_set_param(struct dpif *dpif, const char *set_param) +{ + struct dp_netdev *dp = get_dp_netdev(dpif); + + return conntrack_set_param(&dp->conntrack, set_param); +} + +static int +dpif_netdev_ct_get_param(struct dpif *dpif, const char *get_param, + uint32_t *val) +{ + struct dp_netdev *dp = get_dp_netdev(dpif); + + return conntrack_get_param(&dp->conntrack, get_param, val); +} + const struct dpif_class dpif_netdev_class = { "netdev", dpif_netdev_init, @@ -5734,6 +5751,8 @@ const struct dpif_class dpif_netdev_class = { dpif_netdev_ct_dump_next, dpif_netdev_ct_dump_done, dpif_netdev_ct_flush, + dpif_netdev_ct_set_param, + dpif_netdev_ct_get_param, dpif_netdev_meter_get_features, dpif_netdev_meter_set, dpif_netdev_meter_get, diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 29001fb..0945fad 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -2986,6 +2986,8 @@ const struct dpif_class dpif_netlink_class = { dpif_netlink_ct_dump_next, dpif_netlink_ct_dump_done, dpif_netlink_ct_flush, + NULL, /* ct_set_param */ + NULL, /* ct_get_param */ dpif_netlink_meter_get_features, dpif_netlink_meter_set, dpif_netlink_meter_get, diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h index 1d82a09..262b2e0 100644 --- a/lib/dpif-provider.h +++ b/lib/dpif-provider.h @@ -427,6 +427,10 @@ struct dpif_class { /* Flushes the connection tracking tables. If 'zone' is not NULL, * only deletes connections in '*zone'. */ int (*ct_flush)(struct dpif *, const uint16_t *zone); + /* Set a value to a connection tracking working parameter. */ + int (*ct_set_param)(struct dpif *, const char *set_param); + /* Read the current value of a connection tracking working parameter. */ + int (*ct_get_param)(struct dpif *, const char *get_param, uint32_t *val); /* Meters */ From patchwork Tue Sep 26 12:35:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 818628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y1gSL6Twwz9s83 for ; Tue, 26 Sep 2017 22:36:50 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EBE8EBAC; Tue, 26 Sep 2017 12:35:36 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 6AF84B37 for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 3620F3ED for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 05:35:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,440,1500966000"; d="scan'208"; a="1199143992" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 05:35:29 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Tue, 26 Sep 2017 13:35:23 +0100 Message-Id: <1506429324-10416-4-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> References: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 3/4] conntrack: r/w upper limit connection value. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 Signed-off-by: Antonio Fischetti --- lib/conntrack.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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, From patchwork Tue Sep 26 12:35:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 818631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y1gTq68XQz9s83 for ; Tue, 26 Sep 2017 22:38:07 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0435ABC7; Tue, 26 Sep 2017 12:35:39 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A6164B5D for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 755E33ED for ; Tue, 26 Sep 2017 12:35:33 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2017 05:35:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,440,1500966000"; d="scan'208"; a="1199143995" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga001.fm.intel.com with ESMTP; 26 Sep 2017 05:35:30 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Tue, 26 Sep 2017 13:35:24 +0100 Message-Id: <1506429324-10416-5-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> References: <1506429324-10416-1-git-send-email-antonio.fischetti@intel.com> X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 4/4] conntrack: read current nr of connections. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Example: ovs-appctl dpctl/ct-get-glbl-cfg totconn CC: Kevin Traynor Signed-off-by: Antonio Fischetti --- lib/conntrack.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/conntrack.c b/lib/conntrack.c index 684e468..b04ffb9 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -2412,13 +2412,23 @@ ct_rd_max_conn(struct conntrack *ct, uint32_t *cur_val) { 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; +} + /* List of managed parameters. */ /* Max nr of connections managed by CT module. */ #define CT_RW_MAX_CONN "maxconn" +/* 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_cfg_params cfg_params[] = { {CT_RW_MAX_CONN, ct_wr_max_conn, ct_rd_max_conn}, + {CT_RW_TOT_CONN, NULL, rd_tot_conn}, }; int