From patchwork Mon Aug 19 14:37:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1149321 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=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 46BxQ823j6z9s7T for ; Tue, 20 Aug 2019 00:39:12 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D7E97E84; Mon, 19 Aug 2019 14:37:22 +0000 (UTC) X-Original-To: ovs-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 ECD76E76 for ; Mon, 19 Aug 2019 14:37:20 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5580189E for ; Mon, 19 Aug 2019 14:37:20 +0000 (UTC) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8FC24E924 for ; Mon, 19 Aug 2019 14:37:19 +0000 (UTC) Received: by mail-wr1-f70.google.com with SMTP id k10so5336709wru.23 for ; Mon, 19 Aug 2019 07:37:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RpJCokYMS9RV4DOmCHtNcZPgal17ZhnvrRHhGylS/Xg=; b=XqHMwNnYsUxIl+ytI7x8T5RyZvLKPiPhNXCAIINbLTn7cbv59gX5NlGznn07ea8HfE Z+XyunySSfWf5eisj3P5wsu7yn3Pi23h0If2vkYD1YEZKeFuT/qotYYRlL7xaf5rgOJO aAc+LU2GDqdl5c+OOnm3GhiNcdcVnurDzFgh6oWcMsJJze3K1+g+0UrrBRJkDZZSxKuS KkCBCyPrso7BjQlZK9yzaxUdvtZSzBxYveKbcTAv50FHnOMct6A1f7NNdJabrtqnrh9W tqb9ekDB+c9JDAAIZEEiopISKcp+2wRRIfVbFVGumPWFbvrYc12RVK2lYg8z4dNdqf23 z/Gg== X-Gm-Message-State: APjAAAVq4EOBb42h+erpP2yhdFgwfjUbAEsP8tv/R6/DW6lbqEKn33t0 cUyqdZ9Lh79K+pJ8sWAPe9YbQEL5SYYMMF/rNbleWjd1eLfifzFpFE03nuRYiUDrxdKWY4C6gFn VdXj44pQ5pvudmyscZQ== X-Received: by 2002:a05:600c:24cb:: with SMTP id 11mr20544898wmu.94.1566225438149; Mon, 19 Aug 2019 07:37:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw9y4J8ZxCfUG0fhYkiFlIxR9A2U0/wnPDjNbJDALCQlMN2a1U3WEmdKdkHyOw4CH1XbZoKyQ== X-Received: by 2002:a05:600c:24cb:: with SMTP id 11mr20544870wmu.94.1566225437838; Mon, 19 Aug 2019 07:37:17 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id d16sm22136702wrj.47.2019.08.19.07.37.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 07:37:17 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Mon, 19 Aug 2019 16:37:03 +0200 Message-Id: <77ceea354e1ab13b7679b479fcc4da5cc5e55ad9.1566222622.git.lorenzo.bianconi@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v3 ovn 3/3] OVN: northd: add rate limiting support for SB controller events 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Introduce the capability to associate a meter to each controller event type in order to not overload the pinctrl thread under heavy load. Each event type relies on a meter with a defined name: - empty_lb_backends: event-elb Acked-by: Mark Michelson Signed-off-by: Lorenzo Bianconi --- northd/ovn-northd.c | 44 +++++++++++++++++++++++++++++++++++--------- ovn-nb.xml | 8 ++++++++ tests/ovn.at | 1 + 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index e29b0fff4..27395d6bd 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4002,7 +4002,8 @@ ls_has_dns_records(const struct nbrec_logical_switch *nbs) } static void -build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) +build_pre_lb(struct ovn_datapath *od, struct hmap *lflows, + struct shash *meter_groups) { /* Do not send ND packets to conntrack */ ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, 110, @@ -4040,7 +4041,11 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) if (controller_event_en && !node->value[0]) { struct ds match = DS_EMPTY_INITIALIZER; - char *action; + char *meter = "", *action; + + if (shash_find(meter_groups, "event-elb")) { + meter = "event-elb"; + } if (addr_family == AF_INET) { ds_put_format(&match, "ip4.dst == %s && %s", @@ -4054,10 +4059,11 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) port); } action = xasprintf("trigger_event(event = \"%s\", " - "vip = \"%s\", protocol = \"%s\", " + "meter = \"%s\", vip = \"%s\", " + "protocol = \"%s\", " "load_balancer = \"" UUID_FMT "\");", event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS), - node->key, lb->protocol, + meter, node->key, lb->protocol, UUID_ARGS(&lb->header_.uuid)); ovn_lflow_add(lflows, od, S_SWITCH_IN_PRE_LB, 120, ds_cstr(&match), action); @@ -4884,7 +4890,8 @@ build_lrouter_groups(struct hmap *ports, struct ovs_list *lr_list) static void build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, struct hmap *port_groups, struct hmap *lflows, - struct hmap *mcgroups, struct hmap *igmp_groups) + struct hmap *mcgroups, struct hmap *igmp_groups, + struct shash *meter_groups) { /* This flow table structure is documented in ovn-northd(8), so please * update ovn-northd.8.xml if you change anything. */ @@ -4901,7 +4908,7 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *ports, } build_pre_acls(od, lflows); - build_pre_lb(od, lflows); + build_pre_lb(od, lflows, meter_groups); build_pre_stateful(od, lflows); build_acls(od, lflows, port_groups); build_qos(od, lflows); @@ -8233,12 +8240,13 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, static void build_lflows(struct northd_context *ctx, struct hmap *datapaths, struct hmap *ports, struct hmap *port_groups, - struct hmap *mcgroups, struct hmap *igmp_groups) + struct hmap *mcgroups, struct hmap *igmp_groups, + struct shash *meter_groups) { struct hmap lflows = HMAP_INITIALIZER(&lflows); build_lswitch_flows(datapaths, ports, port_groups, &lflows, mcgroups, - igmp_groups); + igmp_groups, meter_groups); build_lrouter_flows(datapaths, ports, &lflows); /* Push changes to the Logical_Flow table to database. */ @@ -8906,6 +8914,16 @@ build_mcast_groups(struct northd_context *ctx, } } +static void +build_meter_groups(struct northd_context *ctx, + struct shash *meter_groups) +{ + const struct nbrec_meter *nb_meter; + NBREC_METER_FOR_EACH (nb_meter, ctx->ovnnb_idl) { + shash_add(meter_groups, nb_meter->name, nb_meter); + } +} + static void ovnnb_db_run(struct northd_context *ctx, struct ovsdb_idl_index *sbrec_chassis_by_name, @@ -8919,6 +8937,7 @@ ovnnb_db_run(struct northd_context *ctx, struct hmap port_groups; struct hmap mcast_groups; struct hmap igmp_groups; + struct shash meter_groups = SHASH_INITIALIZER(&meter_groups); build_datapaths(ctx, datapaths, lr_list); build_ports(ctx, sbrec_chassis_by_name, datapaths, ports); @@ -8927,8 +8946,9 @@ ovnnb_db_run(struct northd_context *ctx, build_lrouter_groups(ports, lr_list); build_ip_mcast(ctx, datapaths); build_mcast_groups(ctx, datapaths, ports, &mcast_groups, &igmp_groups); + build_meter_groups(ctx, &meter_groups); build_lflows(ctx, datapaths, ports, &port_groups, &mcast_groups, - &igmp_groups); + &igmp_groups, &meter_groups); sync_address_sets(ctx); sync_port_groups(ctx); @@ -8949,6 +8969,12 @@ ovnnb_db_run(struct northd_context *ctx, hmap_destroy(&mcast_groups); hmap_destroy(&port_groups); + struct shash_node *node, *next; + SHASH_FOR_EACH_SAFE (node, next, &meter_groups) { + shash_delete(&meter_groups, node); + } + shash_destroy(&meter_groups); + /* Sync ipsec configuration. * Copy nb_cfg from northbound to southbound database. * Also set up to update sb_cfg once our southbound transaction commits. */ diff --git a/ovn-nb.xml b/ovn-nb.xml index 1f8d7518f..365704a8b 100644 --- a/ovn-nb.xml +++ b/ovn-nb.xml @@ -117,6 +117,14 @@ table. The intention is for a CMS to see the events and take some sort of action. Please see the table in SBDB. + It is possible to associate a meter to each controller event type + in order to not overload the pinctrl thread under heavy load. + Each event type relies on a meter with a defined name: + +
    +
  • empty_lb_backends: event-elb
  • +
+ diff --git a/tests/ovn.at b/tests/ovn.at index 52c044c8d..009de59ce 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14689,6 +14689,7 @@ ovn-nbctl --wait=hv set NB_Global . options:controller_event=true ovn-nbctl lb-add lb0 192.168.1.100:80 "" ovn-nbctl ls-lb-add sw0 lb0 uuid_lb=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0) +ovn-nbctl --wait=hv meter-add event-elb drop 100 pktps 10 OVN_POPULATE_ARP ovn-nbctl --timeout=3 --wait=hv sync