From patchwork Wed Aug 28 12:13:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 1154373 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 46JPn3455Nz9sBF for ; Wed, 28 Aug 2019 22:14:31 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 037F32CB9; Wed, 28 Aug 2019 12:14:13 +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 9F9AE2C95 for ; Wed, 28 Aug 2019 12:13:54 +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 0FF8D8AC for ; Wed, 28 Aug 2019 12:13:54 +0000 (UTC) Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (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 5B42D859FB for ; Wed, 28 Aug 2019 12:13:53 +0000 (UTC) Received: by mail-wm1-f71.google.com with SMTP id u13so655352wmm.2 for ; Wed, 28 Aug 2019 05:13:53 -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:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IZHD1HzaEm6vRVF78dnpLdxFUYZLy4di+fgV4Mz5iBQ=; b=a/x8PPM8ly8XJMzgybfNoInuZn+UJTTX2+/ugLc1Pq8Asi2XmoaDtRDVqbQ4pA/2eZ iQ8Dt4CHgkpfQCEsYUipxNZUgr2mGNUy+gdmLlayegSzGpcl1GbrihrBRlSUBbzsYkmN FG3qmy+NoULDeGsK2YmEJZ2jCRlnYZqIMi9MTIDfbyLgnqDrMs8i2F8uwXQMQWap1iUp 0jv6U3tHd1DkTLH4bZw1UWSNeYAEPiRBIK4bom4twvlrLcRhLrzFTODeVkuV+kWgBUJD dktWAdrxU4qPdMbDu3HGf2UocGhAPUdP7RRbrZctzDd67bkDlm7RDZtMhO5+6SN0K+jO 7oUA== X-Gm-Message-State: APjAAAUTyIOTVmebIY2c+AdntuEhnaqa0yKV66vm+0sS5wjeA5XzKHe5 X/QcCNnlg+d32wdB0Jv5jGNVg2e9Q+FfUwWZCuYI1l0V+u8LEQn8WkCiluy96/B+iKPtvj9mSFA BfvAFQWYDVnfiRIkgBg== X-Received: by 2002:adf:f206:: with SMTP id p6mr4487840wro.216.1566994431880; Wed, 28 Aug 2019 05:13:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqzs+NMl3fA5vuOS7pDkjBMEv7VNzcDD+sbbBEf3xr6gazzTh9jA0kTe+st5hoVCmxWeAhgOqQ== X-Received: by 2002:adf:f206:: with SMTP id p6mr4487801wro.216.1566994431581; Wed, 28 Aug 2019 05:13:51 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id n9sm2924661wrp.54.2019.08.28.05.13.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2019 05:13:51 -0700 (PDT) From: Lorenzo Bianconi To: ovs-dev@openvswitch.org Date: Wed, 28 Aug 2019 14:13:36 +0200 Message-Id: <1e8d936ad66a1bdeabaa37b640c06c20fcb0fa9f.1566993890.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 v4 ovn 1/2] OVN: add meter support to trigger_event action 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 meter support to trigger_event action in order to not overload pinctrl thread under heavy load Signed-off-by: Lorenzo Bianconi Acked-by: Mark Michelson --- include/ovn/actions.h | 1 + lib/actions.c | 43 +++++++++++++++++++++++++++++++++++++------ ovn-sb.xml | 5 ++++- tests/ovn.at | 4 ++++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/include/ovn/actions.h b/include/ovn/actions.h index 0ca06537c..145f27f25 100644 --- a/include/ovn/actions.h +++ b/include/ovn/actions.h @@ -327,6 +327,7 @@ struct ovnact_controller_event { int event_type; /* controller event type */ struct ovnact_gen_option *options; size_t n_options; + char *meter; }; /* OVNACT_BIND_VPORT. */ diff --git a/lib/actions.c b/lib/actions.c index 08c589ab3..6a5907e1b 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -1273,6 +1273,9 @@ format_TRIGGER_EVENT(const struct ovnact_controller_event *event, { ds_put_format(s, "trigger_event(event = \"%s\"", event_to_string(event->event_type)); + if (event->meter) { + ds_put_format(s, ", meter = \"%s\"", event->meter); + } for (const struct ovnact_gen_option *o = event->options; o < &event->options[event->n_options]; o++) { ds_put_cstr(s, ", "); @@ -1420,10 +1423,21 @@ encode_TRIGGER_EVENT(const struct ovnact_controller_event *event, const struct ovnact_encode_params *ep OVS_UNUSED, struct ofpbuf *ofpacts) { + uint32_t meter_id = NX_CTLR_NO_METER; size_t oc_offset; + if (event->meter) { + meter_id = ovn_extend_table_assign_id(ep->meter_table, event->meter, + ep->lflow_uuid); + if (meter_id == EXT_TABLE_ID_INVALID) { + VLOG_WARN("Unable to assign id for trigger meter: %s", + event->meter); + return; + } + } + oc_offset = encode_start_controller_op(ACTION_OPCODE_EVENT, false, - NX_CTLR_NO_METER, ofpacts); + meter_id, ofpacts); ovs_be32 ofs = htonl(event->event_type); ofpbuf_put(ofpacts, &ofs, sizeof ofs); @@ -1738,11 +1752,27 @@ parse_trigger_event(struct action_context *ctx, sizeof *event->options); } - struct ovnact_gen_option *o = &event->options[event->n_options++]; - memset(o, 0, sizeof *o); - parse_gen_opt(ctx, o, - &ctx->pp->controller_event_opts->event_opts[event_type], - event_to_string(event_type)); + if (lexer_match_id(ctx->lexer, "meter")) { + if (!lexer_force_match(ctx->lexer, LEX_T_EQUALS)) { + return; + } + /* If multiple meters are given, use the most recent. */ + if (ctx->lexer->token.type == LEX_T_STRING && + strlen(ctx->lexer->token.s)) { + free(event->meter); + event->meter = xstrdup(ctx->lexer->token.s); + } else if (ctx->lexer->token.type != LEX_T_STRING) { + lexer_syntax_error(ctx->lexer, "expecting string"); + return; + } + lexer_get(ctx->lexer); + } else { + struct ovnact_gen_option *o = &event->options[event->n_options++]; + memset(o, 0, sizeof *o); + parse_gen_opt(ctx, o, + &ctx->pp->controller_event_opts->event_opts[event_type], + event_to_string(event_type)); + } if (ctx->lexer->error) { return; } @@ -1763,6 +1793,7 @@ static void ovnact_controller_event_free(struct ovnact_controller_event *event) { free_gen_options(event->options, event->n_options); + free(event->meter); } static void diff --git a/ovn-sb.xml b/ovn-sb.xml index 02691bbd3..477e7bc7a 100644 --- a/ovn-sb.xml +++ b/ovn-sb.xml @@ -1996,7 +1996,9 @@ tcp.flags = RST;

This action is used to allow ovs-vswitchd to report CMS related events writing them in table. - Supported event: + It is possible to associate a meter to a each event in order to + not overload pinctrl thread under heavy load; each meter is + identified though a defined naming convention. Supported events:

    @@ -2007,6 +2009,7 @@ tcp.flags = RST; no configured backend destinations. For this event, the event info includes the load balancer VIP, the load balancer UUID, and the transport protocol. + Associated meter: event-elb

diff --git a/tests/ovn.at b/tests/ovn.at index 86078c400..014566d50 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1353,6 +1353,10 @@ tcp_reset { }; trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); encodes as controller(userdata=00.00.00.0f.00.00.00.00.00.00.00.00.00.01.00.0b.31.30.2e.30.2e.30.2e.31.3a.38.30.00.02.00.03.74.63.70.00.03.00.24.31.32.33.34.35.36.37.38.2d.61.62.63.64.2d.39.38.37.36.2d.66.65.64.63.2d.31.31.31.31.39.66.38.65.37.64.36.63) +trigger_event(event = "empty_lb_backends", meter="event-elb" vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); + formats as trigger_event(event = "empty_lb_backends", meter = "event-elb", vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); + encodes as controller(userdata=00.00.00.0f.00.00.00.00.00.00.00.00.00.01.00.0b.31.30.2e.30.2e.30.2e.31.3a.38.30.00.02.00.03.74.63.70.00.03.00.24.31.32.33.34.35.36.37.38.2d.61.62.63.64.2d.39.38.37.36.2d.66.65.64.63.2d.31.31.31.31.39.66.38.65.37.64.36.63,meter_id=5) + # Testing invalid vip results in extra error messages from socket-util.c trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "sctp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c"); Load balancer protocol 'sctp' is not 'tcp' or 'udp'