From patchwork Mon Sep 18 10:21:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fischetti, Antonio" X-Patchwork-Id: 814870 X-Patchwork-Delegate: dlu998@gmail.com 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 3xwhrg3tFWz9s78 for ; Mon, 18 Sep 2017 20:22:11 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 62D20B35; Mon, 18 Sep 2017 10:21: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 44C5A87A for ; Mon, 18 Sep 2017 10:21:34 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 0F9FD1E1 for ; Mon, 18 Sep 2017 10:21:34 +0000 (UTC) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Sep 2017 03:21:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,412,1500966000"; d="scan'208"; a="1220241664" Received: from sivswdev01.ir.intel.com (HELO localhost.localdomain) ([10.237.217.45]) by fmsmga002.fm.intel.com with ESMTP; 18 Sep 2017 03:21:32 -0700 From: antonio.fischetti@intel.com To: dev@openvswitch.org Date: Mon, 18 Sep 2017 11:21:28 +0100 Message-Id: <1505730091-19042-2-git-send-email-antonio.fischetti@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1505730091-19042-1-git-send-email-antonio.fischetti@intel.com> References: <1505730091-19042-1-git-send-email-antonio.fischetti@intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, 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 2/5] conntrack: r/w upper limit value for 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 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 --- 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); + 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,