|
|
bbaaef |
From da1253be2ed4bc2ff43d8eb2e2f57c4abdbd5e5f Mon Sep 17 00:00:00 2001
|
|
|
bbaaef |
Message-Id: <da1253be2ed4bc2ff43d8eb2e2f57c4abdbd5e5f.1568637354.git.lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
In-Reply-To: <3624362cb395b6bc90f6fd69e12988979db95b7e.1568637354.git.lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
References: <3624362cb395b6bc90f6fd69e12988979db95b7e.1568637354.git.lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
Date: Tue, 3 Sep 2019 16:22:52 +0200
|
|
|
bbaaef |
Subject: [PATCH ovn 2/3] add meter support to trigger_event action
|
|
|
bbaaef |
|
|
|
bbaaef |
Introduce meter support to trigger_event action in order to not
|
|
|
bbaaef |
overload pinctrl thread under heavy load
|
|
|
bbaaef |
|
|
|
bbaaef |
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
bbaaef |
Signed-off-by: Mark Michelson <mmichels@redhat.com>
|
|
|
bbaaef |
Acked-by: Mark Michelson <mmichels@redhat.com>
|
|
|
bbaaef |
---
|
|
|
bbaaef |
include/ovn/actions.h | 1 +
|
|
|
bbaaef |
ovn/lib/actions.c | 43 +++++++++++++++++++++++++++++++++++++------
|
|
|
bbaaef |
ovn/ovn-sb.xml | 5 ++++-
|
|
|
bbaaef |
tests/ovn.at | 4 ++++
|
|
|
bbaaef |
4 files changed, 46 insertions(+), 7 deletions(-)
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/include/ovn/actions.h
|
|
|
bbaaef |
+++ b/include/ovn/actions.h
|
|
|
bbaaef |
@@ -327,6 +327,7 @@ struct ovnact_controller_event {
|
|
|
bbaaef |
int event_type; /* controller event type */
|
|
|
bbaaef |
struct ovnact_gen_option *options;
|
|
|
bbaaef |
size_t n_options;
|
|
|
bbaaef |
+ char *meter;
|
|
|
bbaaef |
};
|
|
|
bbaaef |
|
|
|
bbaaef |
/* OVNACT_BIND_VPORT. */
|
|
|
bbaaef |
--- a/ovn/lib/actions.c
|
|
|
bbaaef |
+++ b/ovn/lib/actions.c
|
|
|
bbaaef |
@@ -1273,6 +1273,9 @@ format_TRIGGER_EVENT(const struct ovnact
|
|
|
bbaaef |
{
|
|
|
bbaaef |
ds_put_format(s, "trigger_event(event = \"%s\"",
|
|
|
bbaaef |
event_to_string(event->event_type));
|
|
|
bbaaef |
+ if (event->meter) {
|
|
|
bbaaef |
+ ds_put_format(s, ", meter = \"%s\"", event->meter);
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
for (const struct ovnact_gen_option *o = event->options;
|
|
|
bbaaef |
o < &event->options[event->n_options]; o++) {
|
|
|
bbaaef |
ds_put_cstr(s, ", ");
|
|
|
bbaaef |
@@ -1420,10 +1423,21 @@ encode_TRIGGER_EVENT(const struct ovnact
|
|
|
bbaaef |
const struct ovnact_encode_params *ep OVS_UNUSED,
|
|
|
bbaaef |
struct ofpbuf *ofpacts)
|
|
|
bbaaef |
{
|
|
|
bbaaef |
+ uint32_t meter_id = NX_CTLR_NO_METER;
|
|
|
bbaaef |
size_t oc_offset;
|
|
|
bbaaef |
|
|
|
bbaaef |
+ if (event->meter) {
|
|
|
bbaaef |
+ meter_id = ovn_extend_table_assign_id(ep->meter_table, event->meter,
|
|
|
bbaaef |
+ ep->lflow_uuid);
|
|
|
bbaaef |
+ if (meter_id == EXT_TABLE_ID_INVALID) {
|
|
|
bbaaef |
+ VLOG_WARN("Unable to assign id for trigger meter: %s",
|
|
|
bbaaef |
+ event->meter);
|
|
|
bbaaef |
+ return;
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+
|
|
|
bbaaef |
oc_offset = encode_start_controller_op(ACTION_OPCODE_EVENT, false,
|
|
|
bbaaef |
- NX_CTLR_NO_METER, ofpacts);
|
|
|
bbaaef |
+ meter_id, ofpacts);
|
|
|
bbaaef |
ovs_be32 ofs = htonl(event->event_type);
|
|
|
bbaaef |
ofpbuf_put(ofpacts, &ofs, sizeof ofs);
|
|
|
bbaaef |
|
|
|
bbaaef |
@@ -1738,11 +1752,27 @@ parse_trigger_event(struct action_contex
|
|
|
bbaaef |
sizeof *event->options);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
- struct ovnact_gen_option *o = &event->options[event->n_options++];
|
|
|
bbaaef |
- memset(o, 0, sizeof *o);
|
|
|
bbaaef |
- parse_gen_opt(ctx, o,
|
|
|
bbaaef |
- &ctx->pp->controller_event_opts->event_opts[event_type],
|
|
|
bbaaef |
- event_to_string(event_type));
|
|
|
bbaaef |
+ if (lexer_match_id(ctx->lexer, "meter")) {
|
|
|
bbaaef |
+ if (!lexer_force_match(ctx->lexer, LEX_T_EQUALS)) {
|
|
|
bbaaef |
+ return;
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ /* If multiple meters are given, use the most recent. */
|
|
|
bbaaef |
+ if (ctx->lexer->token.type == LEX_T_STRING &&
|
|
|
bbaaef |
+ strlen(ctx->lexer->token.s)) {
|
|
|
bbaaef |
+ free(event->meter);
|
|
|
bbaaef |
+ event->meter = xstrdup(ctx->lexer->token.s);
|
|
|
bbaaef |
+ } else if (ctx->lexer->token.type != LEX_T_STRING) {
|
|
|
bbaaef |
+ lexer_syntax_error(ctx->lexer, "expecting string");
|
|
|
bbaaef |
+ return;
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ lexer_get(ctx->lexer);
|
|
|
bbaaef |
+ } else {
|
|
|
bbaaef |
+ struct ovnact_gen_option *o = &event->options[event->n_options++];
|
|
|
bbaaef |
+ memset(o, 0, sizeof *o);
|
|
|
bbaaef |
+ parse_gen_opt(ctx, o,
|
|
|
bbaaef |
+ &ctx->pp->controller_event_opts->event_opts[event_type],
|
|
|
bbaaef |
+ event_to_string(event_type));
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
if (ctx->lexer->error) {
|
|
|
bbaaef |
return;
|
|
|
bbaaef |
}
|
|
|
bbaaef |
@@ -1763,6 +1793,7 @@ static void
|
|
|
bbaaef |
ovnact_controller_event_free(struct ovnact_controller_event *event)
|
|
|
bbaaef |
{
|
|
|
bbaaef |
free_gen_options(event->options, event->n_options);
|
|
|
bbaaef |
+ free(event->meter);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
static void
|
|
|
bbaaef |
--- a/ovn/ovn-sb.xml
|
|
|
bbaaef |
+++ b/ovn/ovn-sb.xml
|
|
|
bbaaef |
@@ -1994,7 +1994,9 @@ tcp.flags = RST;
|
|
|
bbaaef |
|
|
|
bbaaef |
This action is used to allow ovs-vswitchd to report CMS related
|
|
|
bbaaef |
events writing them in <ref table="Controller_Event"/> table.
|
|
|
bbaaef |
- Supported event:
|
|
|
bbaaef |
+ It is possible to associate a meter to a each event in order to
|
|
|
bbaaef |
+ not overload pinctrl thread under heavy load; each meter is
|
|
|
bbaaef |
+ identified though a defined naming convention. Supported events:
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
@@ -2005,6 +2007,7 @@ tcp.flags = RST;
|
|
|
bbaaef |
no configured backend destinations. For this event, the event
|
|
|
bbaaef |
info includes the load balancer VIP, the load balancer UUID,
|
|
|
bbaaef |
and the transport protocol.
|
|
|
bbaaef |
+ Associated meter: event-elb
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
--- a/tests/ovn.at
|
|
|
bbaaef |
+++ b/tests/ovn.at
|
|
|
bbaaef |
@@ -1363,6 +1363,10 @@ tcp_reset { };
|
|
|
bbaaef |
trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c");
|
|
|
bbaaef |
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)
|
|
|
bbaaef |
|
|
|
bbaaef |
+trigger_event(event = "empty_lb_backends", meter="event-elb" vip = "10.0.0.1:80", protocol = "tcp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c");
|
|
|
bbaaef |
+ 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");
|
|
|
bbaaef |
+ 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)
|
|
|
bbaaef |
+
|
|
|
bbaaef |
# Testing invalid vip results in extra error messages from socket-util.c
|
|
|
bbaaef |
trigger_event(event = "empty_lb_backends", vip = "10.0.0.1:80", protocol = "sctp", load_balancer = "12345678-abcd-9876-fedc-11119f8e7d6c");
|
|
|
bbaaef |
Load balancer protocol 'sctp' is not 'tcp' or 'udp'
|