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 <[email protected]> Signed-off-by: Lorenzo Bianconi <[email protected]> --- northd/ovn-northd.8.xml | 7 +++-- northd/ovn-northd.c | 68 +++++++++++++++++++++++++++++------------ ovn-nb.xml | 8 +++++ tests/ovn.at | 2 +- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index f58338880..d9e8380b1 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -304,7 +304,8 @@ If controller_event has been enabled and load balancing rules with empty backends have been added in <code>OVN_Northbound</code>, a 130 flow is added to trigger ovn-controller events whenever the chassis receives a - packet for that particular VIP + packet for that particular VIP. If <code>event-elb</code> meter has been + previously created, it will be associated to the empty_lb logical flow </p> <h3>Ingress Table 5: Pre-stateful</h3> @@ -1766,7 +1767,9 @@ icmp6 { balancing rules for a Gateway router or Router with gateway port in <code>OVN_Northbound</code> database that does not have configured backends, a priority-130 flow is added to trigger ovn-controller events - whenever the chassis receives a packet for that particular VIP + whenever the chassis receives a packet for that particular VIP. + If <code>event-elb</code> meter has been previously created, it will be + associated to the empty_lb logical flow </li> <li> diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index d6ac8159e..265984339 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -4005,14 +4005,18 @@ static void build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows, struct smap_node *node, char *ip_address, struct nbrec_load_balancer *lb, uint16_t port, - int addr_family, int pl) + int addr_family, int pl, struct shash *meter_groups) { if (!controller_event_en || node->value[0]) { return; } struct ds match = DS_EMPTY_INITIALIZER; - char *action; + char *meter = "", *action; + + if (meter_groups && shash_find(meter_groups, "event-elb")) { + meter = "event-elb"; + } if (addr_family == AF_INET) { ds_put_format(&match, "ip4.dst == %s && %s", @@ -4026,18 +4030,20 @@ build_empty_lb_event_flow(struct ovn_datapath *od, struct hmap *lflows, port); } action = xasprintf("trigger_event(event = \"%s\", " - "vip = \"%s\", protocol = \"%s\", " - "load_balancer = \"" UUID_FMT "\");", - event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS), - node->key, lb->protocol, - UUID_ARGS(&lb->header_.uuid)); + "meter = \"%s\", vip = \"%s\", " + "protocol = \"%s\", " + "load_balancer = \"" UUID_FMT "\");", + event_to_string(OVN_EVENT_EMPTY_LB_BACKENDS), + meter, node->key, lb->protocol, + UUID_ARGS(&lb->header_.uuid)); ovn_lflow_add(lflows, od, pl, 130, ds_cstr(&match), action); ds_destroy(&match); free(action); } 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, @@ -4074,7 +4080,8 @@ build_pre_lb(struct ovn_datapath *od, struct hmap *lflows) } build_empty_lb_event_flow(od, lflows, node, ip_address, lb, - port, addr_family, S_SWITCH_IN_PRE_LB); + port, addr_family, S_SWITCH_IN_PRE_LB, + meter_groups); free(ip_address); @@ -4894,7 +4901,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. */ @@ -4911,7 +4919,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); @@ -6129,10 +6137,12 @@ add_router_lb_flow(struct hmap *lflows, struct ovn_datapath *od, struct ds *match, struct ds *actions, int priority, const char *lb_force_snat_ip, struct smap_node *node, bool is_udp, int addr_family, char *ip_addr, - uint16_t l4_port, struct nbrec_load_balancer *lb) + uint16_t l4_port, struct nbrec_load_balancer *lb, + struct shash *meter_groups) { build_empty_lb_event_flow(od, lflows, node, ip_addr, lb, - l4_port, addr_family, S_ROUTER_IN_DNAT); + l4_port, addr_family, S_ROUTER_IN_DNAT, + meter_groups); /* A match and actions for new connections. */ char *new_match = xasprintf("ct.new && %s", ds_cstr(match)); @@ -6291,7 +6301,7 @@ copy_ra_to_sb(struct ovn_port *op, const char *address_mode) static void build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, - struct hmap *lflows) + struct hmap *lflows, 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. */ @@ -7494,7 +7504,8 @@ build_lrouter_flows(struct hmap *datapaths, struct hmap *ports, } add_router_lb_flow(lflows, od, &match, &actions, prio, lb_force_snat_ip, node, is_udp, - addr_family, ip_address, port, lb); + addr_family, ip_address, port, lb, + meter_groups); free(ip_address); } @@ -8248,13 +8259,14 @@ 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); - build_lrouter_flows(datapaths, ports, &lflows); + igmp_groups, meter_groups); + build_lrouter_flows(datapaths, ports, &lflows, meter_groups); /* Push changes to the Logical_Flow table to database. */ const struct sbrec_logical_flow *sbflow, *next_sbflow; @@ -8921,6 +8933,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, @@ -8934,6 +8956,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); @@ -8942,8 +8965,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); @@ -8964,6 +8988,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 @@ <ref table="Controller_Event"/> table. The intention is for a CMS to see the events and take some sort of action. Please see the <ref table="Controller_Event"/> 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: + + <ul> + <li>empty_lb_backends: event-elb</li> + </ul> + </column> </group> diff --git a/tests/ovn.at b/tests/ovn.at index 014566d50..9ea3ba04e 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -14728,11 +14728,11 @@ ovs-vsctl -- add-port br-int vif33 -- \ options:rxq_pcap=hv$i/vif33-rx.pcap \ ofport-request=33 - 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_lb0=$(ovn-nbctl --bare --columns=_uuid find load_balancer name=lb0) +ovn-nbctl --wait=hv meter-add event-elb drop 100 pktps 10 ovn-nbctl lb-add lb1 192.168.2.100:80 "" ovn-nbctl lr-lb-add lr0 lb1 -- 2.21.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
