From: Mark Gray <[email protected]> Add an additional node that initially does nothing. This serves as a template for how to add a new node. This node is inserted after the northd_node.
This node will be updated in a later commit to generate logical flows for the SBDB. Signed-off-by: Mark Gray <[email protected]> --- northd/automake.mk | 2 + northd/en-lflow.c | 76 ++++++++++++++++ northd/en-lflow.h | 16 ++++ northd/en-northd.c | 10 --- northd/inc-proc-northd.c | 11 ++- northd/inc-proc-northd.h | 2 - northd/northd.c | 186 ++++++++++++++++++++------------------- northd/northd.h | 27 ++++-- northd/ovn-northd.c | 1 - 9 files changed, 214 insertions(+), 117 deletions(-) create mode 100644 northd/en-lflow.c create mode 100644 northd/en-lflow.h diff --git a/northd/automake.mk b/northd/automake.mk index f0c1fb11c83a..4862ec7b7ff3 100644 --- a/northd/automake.mk +++ b/northd/automake.mk @@ -6,6 +6,8 @@ northd_ovn_northd_SOURCES = \ northd/ovn-northd.c \ northd/en-northd.c \ northd/en-northd.h \ + northd/en-lflow.c \ + northd/en-lflow.h \ northd/inc-proc-northd.c \ northd/inc-proc-northd.h \ northd/ipam.c \ diff --git a/northd/en-lflow.c b/northd/en-lflow.c new file mode 100644 index 000000000000..5bef35cf6117 --- /dev/null +++ b/northd/en-lflow.c @@ -0,0 +1,76 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <config.h> + +#include <getopt.h> +#include <stdlib.h> +#include <stdio.h> + +#include "en-lflow.h" +#include "en-northd.h" + +#include "lib/inc-proc-eng.h" +#include "northd.h" +#include "stopwatch.h" +#include "lib/stopwatch-names.h" +#include "timeval.h" +#include "openvswitch/vlog.h" + +VLOG_DEFINE_THIS_MODULE(en_lflow); + +void en_lflow_run(struct engine_node *node, void *data OVS_UNUSED) +{ + const struct engine_context *eng_ctx = engine_get_context(); + + struct lflow_input lflow_input; + + struct northd_data *northd_data = engine_get_input_data("northd", node); + + lflow_input.sbrec_logical_flow_table = + EN_OVSDB_GET(engine_get_input("SB_logical_flow", node)); + lflow_input.sbrec_multicast_group_table = + EN_OVSDB_GET(engine_get_input("SB_multicast_group", node)); + lflow_input.sbrec_igmp_group_table = + EN_OVSDB_GET(engine_get_input("SB_igmp_group", node)); + + lflow_input.sbrec_mcast_group_by_name_dp = + engine_ovsdb_node_get_index( + engine_get_input("SB_multicast_group", node), + "sbrec_mcast_group_by_name"); + + lflow_input.datapaths = &northd_data->datapaths; + lflow_input.ports = &northd_data->ports; + lflow_input.port_groups = &northd_data->port_groups; + lflow_input.meter_groups = &northd_data->meter_groups; + lflow_input.lbs = &northd_data->lbs; + lflow_input.bfd_connections = &northd_data->bfd_connections; + lflow_input.ovn_internal_version_changed = + northd_data->ovn_internal_version_changed; + + stopwatch_start(BUILD_LFLOWS_STOPWATCH_NAME, time_msec()); + build_lflows(&lflow_input, eng_ctx->ovnsb_idl_txn); + stopwatch_stop(BUILD_LFLOWS_STOPWATCH_NAME, time_msec()); + + engine_set_node_state(node, EN_UPDATED); +} +void *en_lflow_init(struct engine_node *node OVS_UNUSED, + struct engine_arg *arg OVS_UNUSED) +{ + return NULL; +} + +void en_lflow_cleanup(void *data OVS_UNUSED) +{ +} diff --git a/northd/en-lflow.h b/northd/en-lflow.h new file mode 100644 index 000000000000..0e4d522ff3fe --- /dev/null +++ b/northd/en-lflow.h @@ -0,0 +1,16 @@ +#ifndef EN_LFLOW_H +#define EN_LFLOW_H 1 + +#include <config.h> + +#include <getopt.h> +#include <stdlib.h> +#include <stdio.h> + +#include "lib/inc-proc-eng.h" + +void en_lflow_run(struct engine_node *node, void *data); +void *en_lflow_init(struct engine_node *node, struct engine_arg *arg); +void en_lflow_cleanup(void *data); + +#endif /* EN_LFLOW_H */ diff --git a/northd/en-northd.c b/northd/en-northd.c index adcc459a9d16..2fda3a9d219d 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -51,10 +51,6 @@ void en_northd_run(struct engine_node *node, void *data) engine_ovsdb_node_get_index( engine_get_input("SB_ha_chassis_group", node), "sbrec_ha_chassis_grp_by_name"); - input_data.sbrec_mcast_group_by_name_dp = - engine_ovsdb_node_get_index( - engine_get_input("SB_multicast_group", node), - "sbrec_mcast_group_by_name"); input_data.sbrec_ip_mcast_by_dp = engine_ovsdb_node_get_index( engine_get_input("SB_ip_multicast", node), @@ -99,10 +95,6 @@ void en_northd_run(struct engine_node *node, void *data) EN_OVSDB_GET(engine_get_input("SB_service_monitor", node)); input_data.sbrec_bfd_table = EN_OVSDB_GET(engine_get_input("SB_bfd", node)); - input_data.sbrec_logical_flow_table = - EN_OVSDB_GET(engine_get_input("SB_logical_flow", node)); - input_data.sbrec_multicast_group_table = - EN_OVSDB_GET(engine_get_input("SB_multicast_group", node)); input_data.sbrec_address_set_table = EN_OVSDB_GET(engine_get_input("SB_address_set", node)); input_data.sbrec_port_group_table = @@ -113,8 +105,6 @@ void en_northd_run(struct engine_node *node, void *data) EN_OVSDB_GET(engine_get_input("SB_dns", node)); input_data.sbrec_ip_multicast_table = EN_OVSDB_GET(engine_get_input("SB_ip_multicast", node)); - input_data.sbrec_igmp_group_table = - EN_OVSDB_GET(engine_get_input("SB_igmp_group", node)); input_data.sbrec_chassis_private_table = EN_OVSDB_GET(engine_get_input("SB_chassis_private", node)); diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index d2da0489cc1c..d4c913883d9a 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -28,6 +28,7 @@ #include "openvswitch/vlog.h" #include "inc-proc-northd.h" #include "en-northd.h" +#include "en-lflow.h" #include "util.h" VLOG_DEFINE_THIS_MODULE(inc_proc_northd); @@ -143,6 +144,7 @@ enum sb_engine_node { /* Define engine nodes for other nodes. They should be defined as static to * avoid sparse errors. */ static ENGINE_NODE(northd, "northd"); +static ENGINE_NODE(lflow, "lflow"); void inc_proc_northd_init(struct ovsdb_idl_loop *nb, struct ovsdb_idl_loop *sb) @@ -182,9 +184,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_encap, NULL); engine_add_input(&en_northd, &en_sb_address_set, NULL); engine_add_input(&en_northd, &en_sb_port_group, NULL); - engine_add_input(&en_northd, &en_sb_logical_flow, NULL); engine_add_input(&en_northd, &en_sb_logical_dp_group, NULL); - engine_add_input(&en_northd, &en_sb_multicast_group, NULL); engine_add_input(&en_northd, &en_sb_meter, NULL); engine_add_input(&en_northd, &en_sb_meter_band, NULL); engine_add_input(&en_northd, &en_sb_datapath_binding, NULL); @@ -202,11 +202,14 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, engine_add_input(&en_northd, &en_sb_ha_chassis_group, NULL); engine_add_input(&en_northd, &en_sb_controller_event, NULL); engine_add_input(&en_northd, &en_sb_ip_multicast, NULL); - engine_add_input(&en_northd, &en_sb_igmp_group, NULL); engine_add_input(&en_northd, &en_sb_service_monitor, NULL); engine_add_input(&en_northd, &en_sb_load_balancer, NULL); engine_add_input(&en_northd, &en_sb_bfd, NULL); engine_add_input(&en_northd, &en_sb_fdb, NULL); + engine_add_input(&en_lflow, &en_sb_logical_flow, NULL); + engine_add_input(&en_lflow, &en_sb_multicast_group, NULL); + engine_add_input(&en_lflow, &en_sb_igmp_group, NULL); + engine_add_input(&en_lflow, &en_northd, NULL); struct engine_arg engine_arg = { .nb_idl = nb->idl, @@ -224,7 +227,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb, struct ovsdb_idl_index *sbrec_chassis_by_hostname = chassis_hostname_index_create(sb->idl); - engine_init(&en_northd, &engine_arg); + engine_init(&en_lflow, &engine_arg); engine_ovsdb_node_add_index(&en_sb_chassis, "sbrec_chassis_by_name", diff --git a/northd/inc-proc-northd.h b/northd/inc-proc-northd.h index b6c38e68749d..4aeb387b7b0f 100644 --- a/northd/inc-proc-northd.h +++ b/northd/inc-proc-northd.h @@ -6,8 +6,6 @@ #include "northd.h" #include "ovsdb-idl.h" - - void inc_proc_northd_init(struct ovsdb_idl_loop *nb, struct ovsdb_idl_loop *sb); void inc_proc_northd_run(struct ovsdb_idl_txn *ovnnb_txn, diff --git a/northd/northd.c b/northd/northd.c index 1690d0d467a0..dd543378463f 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -1006,7 +1006,8 @@ ovn_datapath_get_type(const struct ovn_datapath *od) } static struct ovn_datapath * -ovn_datapath_find(struct hmap *datapaths, const struct uuid *uuid) +ovn_datapath_find(const struct hmap *datapaths, + const struct uuid *uuid) { struct ovn_datapath *od; @@ -1039,7 +1040,7 @@ ovn_datapath_is_stale(const struct ovn_datapath *od) } static struct ovn_datapath * -ovn_datapath_from_sbrec(struct hmap *datapaths, +ovn_datapath_from_sbrec(const struct hmap *datapaths, const struct sbrec_datapath_binding *sb) { struct uuid key; @@ -1776,7 +1777,7 @@ lrport_is_enabled(const struct nbrec_logical_router_port *lrport) } static struct ovn_port * -ovn_port_get_peer(struct hmap *ports, struct ovn_port *op) +ovn_port_get_peer(const struct hmap *ports, struct ovn_port *op) { if (!op->nbsp || !lsp_is_router(op->nbsp) || op->l3dgw_port) { return NULL; @@ -4279,7 +4280,7 @@ ovn_igmp_group_find(struct hmap *igmp_groups, } static struct ovn_igmp_group * -ovn_igmp_group_add(struct northd_input *input_data, +ovn_igmp_group_add(struct lflow_input *input_data, struct hmap *igmp_groups, struct ovn_datapath *datapath, const struct in6_addr *address, @@ -4335,7 +4336,7 @@ ovn_igmp_group_get_address(const struct sbrec_igmp_group *sb_igmp_group, static struct ovn_port ** ovn_igmp_group_get_ports(const struct sbrec_igmp_group *sb_igmp_group, - size_t *n_ports, struct hmap *ovn_ports) + size_t *n_ports, const struct hmap *ovn_ports) { struct ovn_port **ports = NULL; @@ -5580,7 +5581,8 @@ build_stateless_filter(struct ovn_datapath *od, } static void -build_stateless_filters(struct ovn_datapath *od, struct hmap *port_groups, +build_stateless_filters(struct ovn_datapath *od, + const struct hmap *port_groups, struct hmap *lflows) { for (size_t i = 0; i < od->nbs->n_acls; i++) { @@ -5604,7 +5606,7 @@ build_stateless_filters(struct ovn_datapath *od, struct hmap *port_groups, } static void -build_pre_acls(struct ovn_datapath *od, struct hmap *port_groups, +build_pre_acls(struct ovn_datapath *od, const struct hmap *port_groups, struct hmap *lflows) { /* Ingress and Egress Pre-ACL Table (Priority 0): Packets are @@ -6294,7 +6296,7 @@ build_port_group_lswitches(struct northd_input *input_data, static void build_acls(struct ovn_datapath *od, struct hmap *lflows, - struct hmap *port_groups, const struct shash *meter_groups) + const struct hmap *port_groups, const struct shash *meter_groups) { bool has_stateful = od->has_stateful_acl || od->has_lb_vip; struct ds match = DS_EMPTY_INITIALIZER; @@ -6570,7 +6572,7 @@ build_qos(struct ovn_datapath *od, struct hmap *lflows) { static void build_lb_rules(struct hmap *lflows, struct ovn_northd_lb *lb, struct ds *match, struct ds *action, - struct shash *meter_groups) + const struct shash *meter_groups) { for (size_t i = 0; i < lb->n_vips; i++) { struct ovn_lb_vip *lb_vip = &lb->vips[i]; @@ -7177,7 +7179,7 @@ static void build_dhcpv4_options_flows(struct ovn_port *op, struct lport_addresses *lsp_addrs, struct ovn_port *inport, bool is_external, - struct shash *meter_groups, + const struct shash *meter_groups, struct hmap *lflows) { struct ds match = DS_EMPTY_INITIALIZER; @@ -7270,7 +7272,7 @@ static void build_dhcpv6_options_flows(struct ovn_port *op, struct lport_addresses *lsp_addrs, struct ovn_port *inport, bool is_external, - struct shash *meter_groups, + const struct shash *meter_groups, struct hmap *lflows) { struct ds match = DS_EMPTY_INITIALIZER; @@ -7386,7 +7388,8 @@ is_vlan_transparent(const struct ovn_datapath *od) } static void -build_lswitch_flows(struct hmap *datapaths, struct hmap *lflows) +build_lswitch_flows(const struct hmap *datapaths, + struct hmap *lflows) { /* This flow table structure is documented in ovn-northd(8), so please * update ovn-northd.8.xml if you change anything. */ @@ -7420,9 +7423,9 @@ build_lswitch_flows(struct hmap *datapaths, struct hmap *lflows) * Ingress tables 3 through 10. Egress tables 0 through 7. */ static void build_lswitch_lflows_pre_acl_and_acl(struct ovn_datapath *od, - struct hmap *port_groups, + const struct hmap *port_groups, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbs) { ls_get_acl_flags(od); @@ -7489,8 +7492,8 @@ build_lswitch_arp_nd_responder_skip_local(struct ovn_port *op, static void build_lswitch_arp_nd_responder_known_ips(struct ovn_port *op, struct hmap *lflows, - struct hmap *ports, - struct shash *meter_groups, + const struct hmap *ports, + const struct shash *meter_groups, struct ds *actions, struct ds *match) { @@ -7808,7 +7811,7 @@ build_lswitch_arp_nd_service_monitor(struct ovn_northd_lb *lb, static void build_lswitch_dhcp_options_and_response(struct ovn_port *op, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { if (op->nbsp) { if (!lsp_is_enabled(op->nbsp) || lsp_is_router(op->nbsp)) { @@ -7880,7 +7883,7 @@ build_lswitch_dhcp_and_dns_defaults(struct ovn_datapath *od, static void build_lswitch_dns_lookup_and_response(struct ovn_datapath *od, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbs && ls_has_dns_records(od->nbs)) { ovn_lflow_metered(lflows, od, S_SWITCH_IN_DNS_LOOKUP, 100, @@ -7925,7 +7928,7 @@ static void build_lswitch_destination_lookup_bmcast(struct ovn_datapath *od, struct hmap *lflows, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbs) { @@ -8244,7 +8247,7 @@ struct bfd_entry { }; static struct bfd_entry * -bfd_port_lookup(struct hmap *bfd_map, const char *logical_port, +bfd_port_lookup(const struct hmap *bfd_map, const char *logical_port, const char *dst_ip) { struct bfd_entry *bfd_e; @@ -8490,7 +8493,7 @@ find_lrp_member_ip(const struct ovn_port *op, const char *ip_s) static struct ovn_port* get_outport_for_routing_policy_nexthop(struct ovn_datapath *od, - struct hmap *ports, + const struct hmap *ports, int priority, const char *nexthop) { if (nexthop == NULL) { @@ -8515,7 +8518,7 @@ get_outport_for_routing_policy_nexthop(struct ovn_datapath *od, static void build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, - struct hmap *ports, + const struct hmap *ports, const struct nbrec_logical_router_policy *rule, const struct ovsdb_idl_row *stage_hint) { @@ -8580,7 +8583,7 @@ build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, static void build_ecmp_routing_policy_flows(struct hmap *lflows, struct ovn_datapath *od, - struct hmap *ports, + const struct hmap *ports, const struct nbrec_logical_router_policy *rule, uint16_t ecmp_group_id) { @@ -8700,17 +8703,17 @@ route_hash(struct parsed_route *route) static struct ovs_mutex bfd_lock = OVS_MUTEX_INITIALIZER; static bool -find_static_route_outport(struct ovn_datapath *od, struct hmap *ports, +find_static_route_outport(struct ovn_datapath *od, const struct hmap *ports, const struct nbrec_logical_router_static_route *route, bool is_ipv4, const char **p_lrp_addr_s, struct ovn_port **p_out_port); /* Parse and validate the route. Return the parsed route if successful. * Otherwise return NULL. */ static struct parsed_route * -parsed_routes_add(struct ovn_datapath *od, struct hmap *ports, +parsed_routes_add(struct ovn_datapath *od, const struct hmap *ports, struct ovs_list *routes, const struct nbrec_logical_router_static_route *route, - struct hmap *bfd_connections) + const struct hmap *bfd_connections) { /* Verify that the next hop is an IP address with an all-ones mask. */ struct in6_addr nexthop; @@ -8982,7 +8985,7 @@ build_route_match(const struct ovn_port *op_inport, const char *network_s, /* Output: p_lrp_addr_s and p_out_port. */ static bool -find_static_route_outport(struct ovn_datapath *od, struct hmap *ports, +find_static_route_outport(struct ovn_datapath *od, const struct hmap *ports, const struct nbrec_logical_router_static_route *route, bool is_ipv4, const char **p_lrp_addr_s, struct ovn_port **p_out_port) { @@ -9135,7 +9138,7 @@ add_ecmp_symmetric_reply_flows(struct hmap *lflows, static void build_ecmp_route_flow(struct hmap *lflows, struct ovn_datapath *od, - struct hmap *ports, struct ecmp_groups_node *eg) + const struct hmap *ports, struct ecmp_groups_node *eg) { bool is_ipv4 = IN6_IS_ADDR_V4MAPPED(&eg->prefix); @@ -9280,7 +9283,7 @@ add_route(struct hmap *lflows, struct ovn_datapath *od, static void build_static_route_flow(struct hmap *lflows, struct ovn_datapath *od, - struct hmap *ports, + const struct hmap *ports, const struct parsed_route *route_) { const char *lrp_addr_s = NULL; @@ -9376,7 +9379,7 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, struct ovn_northd_lb_vip *vips_nb, struct hmap *lflows, struct ds *match, struct ds *action, - struct shash *meter_groups) + const struct shash *meter_groups) { char *skip_snat_new_action = NULL; char *skip_snat_est_action = NULL; @@ -9585,7 +9588,7 @@ next: static void build_lswitch_flows_for_lb(struct ovn_northd_lb *lb, struct hmap *lflows, - struct shash *meter_groups, struct ds *match, + const struct shash *meter_groups, struct ds *match, struct ds *action) { if (!lb->n_nb_ls) { @@ -9692,7 +9695,7 @@ build_lrouter_defrag_flows_for_lb(struct ovn_northd_lb *lb, static void build_lrouter_flows_for_lb(struct ovn_northd_lb *lb, struct hmap *lflows, - struct shash *meter_groups, struct ds *match, + const struct shash *meter_groups, struct ds *match, struct ds *action) { if (!lb->n_nb_lr) { @@ -9959,7 +9962,7 @@ build_lrouter_nd_flow(struct ovn_datapath *od, struct ovn_port *op, const char *sn_ip_address, const char *eth_addr, struct ds *extra_match, bool drop, uint16_t priority, const struct ovsdb_idl_row *hint, - struct hmap *lflows, struct shash *meter_groups) + struct hmap *lflows, const struct shash *meter_groups) { struct ds match = DS_EMPTY_INITIALIZER; struct ds actions = DS_EMPTY_INITIALIZER; @@ -10011,7 +10014,7 @@ static void build_lrouter_nat_arp_nd_flow(struct ovn_datapath *od, struct ovn_nat *nat_entry, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { struct lport_addresses *ext_addrs = &nat_entry->ext_addrs; const struct nbrec_nat *nat = nat_entry->nb; @@ -10034,7 +10037,7 @@ static void build_lrouter_port_nat_arp_nd_flow(struct ovn_port *op, struct ovn_nat *nat_entry, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { struct lport_addresses *ext_addrs = &nat_entry->ext_addrs; const struct nbrec_nat *nat = nat_entry->nb; @@ -10256,7 +10259,7 @@ build_lrouter_force_snat_flows_op(struct ovn_port *op, static void build_lrouter_bfd_flows(struct hmap *lflows, struct ovn_port *op, - struct shash *meter_groups) + const struct shash *meter_groups) { if (!op->has_bfd) { return; @@ -10383,7 +10386,7 @@ static void build_neigh_learning_flows_for_lrouter( struct ovn_datapath *od, struct hmap *lflows, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbr) { @@ -10550,7 +10553,7 @@ static void build_ND_RA_flows_for_lrouter_port( struct ovn_port *op, struct hmap *lflows, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (!op->nbrp || op->nbrp->peer || !op->peer) { return; @@ -10705,7 +10708,7 @@ build_ND_RA_flows_for_lrouter(struct ovn_datapath *od, struct hmap *lflows) */ static void build_ip_routing_flows_for_lrouter_port( - struct ovn_port *op, struct hmap *ports,struct hmap *lflows) + struct ovn_port *op, const struct hmap *ports, struct hmap *lflows) { if (op->nbrp) { @@ -10753,7 +10756,7 @@ build_ip_routing_flows_for_lrouter_port( static void build_static_route_flows_for_lrouter( struct ovn_datapath *od, struct hmap *lflows, - struct hmap *ports, struct hmap *bfd_connections) + const struct hmap *ports, const struct hmap *bfd_connections) { if (od->nbr) { ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP, 150, @@ -10876,7 +10879,7 @@ build_mcast_lookup_flows_for_lrouter( static void build_ingress_policy_flows_for_lrouter( struct ovn_datapath *od, struct hmap *lflows, - struct hmap *ports) + const struct hmap *ports) { if (od->nbr) { /* This is a catch-all rule. It has the lowest priority (0) @@ -10968,7 +10971,7 @@ routable_addresses_to_lflows(struct hmap *lflows, struct ovn_port *router_port, static void build_arp_resolve_flows_for_lrouter_port( struct ovn_port *op, struct hmap *lflows, - struct hmap *ports, + const struct hmap *ports, struct ds *match, struct ds *actions) { if (op->nbsp && !lsp_is_enabled(op->nbsp)) { @@ -11303,7 +11306,7 @@ build_arp_resolve_flows_for_lrouter_port( static void build_icmperr_pkt_big_flows(struct ovn_port *op, int mtu, struct hmap *lflows, - struct shash *meter_groups, struct ds *match, + const struct shash *meter_groups, struct ds *match, struct ds *actions, enum ovn_stage stage, struct ovn_port *outport) { @@ -11395,8 +11398,10 @@ build_check_pkt_len_action_string(struct ovn_port *op, struct ds *actions) static void build_check_pkt_len_flows_for_lrp(struct ovn_port *op, - struct hmap *lflows, struct hmap *ports, - struct shash *meter_groups, struct ds *match, + struct hmap *lflows, + const struct hmap *ports, + const struct shash *meter_groups, + struct ds *match, struct ds *actions) { ds_clear(actions); @@ -11449,9 +11454,9 @@ build_check_pkt_len_flows_for_lrp(struct ovn_port *op, static void build_check_pkt_len_flows_for_lrouter( struct ovn_datapath *od, struct hmap *lflows, - struct hmap *ports, + const struct hmap *ports, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (!od->nbr) { return; @@ -11523,7 +11528,7 @@ static void build_arp_request_flows_for_lrouter( struct ovn_datapath *od, struct hmap *lflows, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbr) { for (int i = 0; i < od->nbr->n_static_routes; i++) { @@ -11718,7 +11723,7 @@ static void build_ipv6_input_flows_for_lrouter_port( struct ovn_port *op, struct hmap *lflows, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { if (op->nbrp && (!op->l3dgw_port)) { /* No ingress packets are accepted on a chassisredirect @@ -11879,7 +11884,7 @@ build_ipv6_input_flows_for_lrouter_port( static void build_lrouter_arp_nd_for_datapath(struct ovn_datapath *od, struct hmap *lflows, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->nbr) { @@ -11930,7 +11935,7 @@ static void build_lrouter_ipv4_ip_input(struct ovn_port *op, struct hmap *lflows, struct ds *match, struct ds *actions, - struct shash *meter_groups) + const struct shash *meter_groups) { /* No ingress packets are accepted on a chassisredirect * port, so no need to program flows for that port. */ @@ -12507,7 +12512,8 @@ build_lrouter_ingress_nat_check_pkt_len(struct hmap *lflows, const struct nbrec_nat *nat, struct ovn_datapath *od, bool is_v6, struct ds *match, struct ds *actions, - int mtu, struct shash *meter_groups) + int mtu, + const struct shash *meter_groups) { ds_clear(match); ds_put_format(match, "inport == %s && "REGBIT_PKT_LARGER @@ -12577,7 +12583,7 @@ build_lrouter_ingress_flow(struct hmap *lflows, struct ovn_datapath *od, const struct nbrec_nat *nat, struct ds *match, struct ds *actions, struct eth_addr mac, bool distributed, bool is_v6, - struct shash *meter_groups) + const struct shash *meter_groups) { if (od->n_l3dgw_ports && !strcmp(nat->type, "snat")) { ds_clear(match); @@ -12717,8 +12723,9 @@ lrouter_check_nat_entry(struct ovn_datapath *od, const struct nbrec_nat *nat, /* NAT, Defrag and load balancing. */ static void build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows, - struct hmap *ports, struct ds *match, - struct ds *actions, struct shash *meter_groups) + const struct hmap *ports, struct ds *match, + struct ds *actions, + const struct shash *meter_groups) { if (!od->nbr) { return; @@ -12935,15 +12942,15 @@ build_lrouter_nat_defrag_and_lb(struct ovn_datapath *od, struct hmap *lflows, struct lswitch_flow_build_info { - struct hmap *datapaths; - struct hmap *ports; - struct hmap *port_groups; + const struct hmap *datapaths; + const struct hmap *ports; + const struct hmap *port_groups; struct hmap *lflows; struct hmap *mcgroups; struct hmap *igmp_groups; - struct shash *meter_groups; - struct hmap *lbs; - struct hmap *bfd_connections; + const struct shash *meter_groups; + const struct hmap *lbs; + const struct hmap *bfd_connections; char *svc_check_match; struct ds match; struct ds actions; @@ -13052,7 +13059,6 @@ struct lflows_thread_pool { struct worker_pool *pool; }; - static void * build_lflows_thread(void *arg) { @@ -13199,12 +13205,15 @@ fix_flow_map_size(struct hmap *lflow_map, } static void -build_lswitch_and_lrouter_flows(struct hmap *datapaths, struct hmap *ports, - struct hmap *port_groups, struct hmap *lflows, +build_lswitch_and_lrouter_flows(const struct hmap *datapaths, + const struct hmap *ports, + const struct hmap *port_groups, + struct hmap *lflows, struct hmap *mcgroups, struct hmap *igmp_groups, - struct shash *meter_groups, struct hmap *lbs, - struct hmap *bfd_connections) + const struct shash *meter_groups, + const struct hmap *lbs, + const struct hmap *bfd_connections) { char *svc_check_match = xasprintf("eth.dst == %s", svc_monitor_mac); @@ -13405,21 +13414,22 @@ static bool needs_parallel_init = true; static bool reset_parallel = false; static void -build_mcast_groups(struct northd_input *input_data, - struct hmap *datapaths, struct hmap *ports, +build_mcast_groups(struct lflow_input *data, + const struct hmap *datapaths, + const struct hmap *ports, struct hmap *mcast_groups, struct hmap *igmp_groups); /* Updates the Logical_Flow and Multicast_Group tables in the OVN_SB database, * constructing their contents based on the OVN_NB database. */ -void build_lflows(struct northd_input *input_data, - struct northd_data *data, struct ovsdb_idl_txn *ovnsb_txn) +void build_lflows(struct lflow_input *input_data, + struct ovsdb_idl_txn *ovnsb_txn) { struct hmap lflows; struct hmap mcast_groups; struct hmap igmp_groups; - build_mcast_groups(input_data, &data->datapaths, &data->ports, + build_mcast_groups(input_data, input_data->datapaths, input_data->ports, &mcast_groups, &igmp_groups); if (reset_parallel) { @@ -13440,11 +13450,11 @@ void build_lflows(struct northd_input *input_data, use_parallel_build = false; reset_parallel = true; } - build_lswitch_and_lrouter_flows(&data->datapaths, &data->ports, - &data->port_groups, &lflows, + build_lswitch_and_lrouter_flows(input_data->datapaths, input_data->ports, + input_data->port_groups, &lflows, &mcast_groups, &igmp_groups, - &data->meter_groups, &data->lbs, - &data->bfd_connections); + input_data->meter_groups, input_data->lbs, + input_data->bfd_connections); /* Parallel build may result in a suboptimal hash. Resize the * hash to a correct size before doing lookups */ @@ -13524,7 +13534,7 @@ void build_lflows(struct northd_input *input_data, struct sbrec_datapath_binding *dp = sbflow->logical_datapath; if (dp) { logical_datapath_od = ovn_datapath_from_sbrec( - &data->datapaths, dp); + input_data->datapaths, dp); if (logical_datapath_od && ovn_datapath_is_stale(logical_datapath_od)) { logical_datapath_od = NULL; @@ -13532,7 +13542,7 @@ void build_lflows(struct northd_input *input_data, } for (i = 0; dp_group && i < dp_group->n_datapaths; i++) { logical_datapath_od = ovn_datapath_from_sbrec( - &data->datapaths, dp_group->datapaths[i]); + input_data->datapaths, dp_group->datapaths[i]); if (logical_datapath_od && !ovn_datapath_is_stale(logical_datapath_od)) { break; @@ -13556,7 +13566,7 @@ void build_lflows(struct northd_input *input_data, sbflow->priority, sbflow->match, sbflow->actions, sbflow->controller_meter, sbflow->hash); if (lflow) { - if (data->ovn_internal_version_changed) { + if (input_data->ovn_internal_version_changed) { const char *stage_name = smap_get_def(&sbflow->external_ids, "stage-name", ""); const char *stage_hint = smap_get_def(&sbflow->external_ids, @@ -13608,7 +13618,7 @@ void build_lflows(struct northd_input *input_data, /* Check all logical datapaths from the group. */ for (i = 0; i < dp_group->n_datapaths; i++) { od[n_datapaths] = ovn_datapath_from_sbrec( - &data->datapaths, dp_group->datapaths[i]); + input_data->datapaths, dp_group->datapaths[i]); if (!od[n_datapaths] || ovn_datapath_is_stale(od[n_datapaths])) { continue; @@ -13704,8 +13714,8 @@ void build_lflows(struct northd_input *input_data, const struct sbrec_multicast_group *sbmc, *next_sbmc; SBREC_MULTICAST_GROUP_TABLE_FOR_EACH_SAFE (sbmc, next_sbmc, input_data->sbrec_multicast_group_table) { - struct ovn_datapath *od = ovn_datapath_from_sbrec(&data->datapaths, - sbmc->datapath); + struct ovn_datapath *od = ovn_datapath_from_sbrec( + input_data->datapaths, sbmc->datapath); if (!od || ovn_datapath_is_stale(od)) { sbrec_multicast_group_delete(sbmc); @@ -13744,11 +13754,6 @@ void build_lflows(struct northd_input *input_data, ovn_igmp_group_destroy(&igmp_groups, igmp_group); } - struct ovn_port_group *pg, *next_pg; - HMAP_FOR_EACH_SAFE (pg, next_pg, key_node, &data->port_groups) { - ovn_port_group_destroy(&data->port_groups, pg); - } - hmap_destroy(&igmp_groups); hmap_destroy(&mcast_groups); } @@ -14306,8 +14311,9 @@ build_ip_mcast(struct northd_input *input_data, } static void -build_mcast_groups(struct northd_input *input_data, - struct hmap *datapaths, struct hmap *ports, +build_mcast_groups(struct lflow_input *input_data, + const struct hmap *datapaths, + const struct hmap *ports, struct hmap *mcast_groups, struct hmap *igmp_groups) { @@ -14656,9 +14662,6 @@ ovnnb_db_run(struct northd_input *input_data, build_bfd_table(input_data, ovnsb_txn, &data->bfd_connections, &data->ports); stopwatch_stop(BUILD_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); - stopwatch_start(BUILD_LFLOWS_STOPWATCH_NAME, time_msec()); - build_lflows(input_data, data, ovnsb_txn); - stopwatch_stop(BUILD_LFLOWS_STOPWATCH_NAME, time_msec()); stopwatch_start(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); ovn_update_ipv6_prefix(&data->ports); @@ -14669,7 +14672,6 @@ ovnnb_db_run(struct northd_input *input_data, cleanup_stale_fdp_entries(input_data, &data->datapaths); bfd_cleanup_connections(input_data, &data->bfd_connections); stopwatch_stop(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec()); - } /* Stores the list of chassis which references an ha_chassis_group. diff --git a/northd/northd.h b/northd/northd.h index 12ad010f62e9..2f04b6738e3d 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -41,21 +41,17 @@ struct northd_input { const struct sbrec_load_balancer_table *sbrec_load_balancer_table; const struct sbrec_service_monitor_table *sbrec_service_monitor_table; const struct sbrec_bfd_table *sbrec_bfd_table; - const struct sbrec_logical_flow_table *sbrec_logical_flow_table; - const struct sbrec_multicast_group_table *sbrec_multicast_group_table; const struct sbrec_address_set_table *sbrec_address_set_table; const struct sbrec_port_group_table *sbrec_port_group_table; const struct sbrec_meter_table *sbrec_meter_table; const struct sbrec_dns_table *sbrec_dns_table; const struct sbrec_ip_multicast_table *sbrec_ip_multicast_table; - const struct sbrec_igmp_group_table *sbrec_igmp_group_table; const struct sbrec_chassis_private_table *sbrec_chassis_private_table; /* Indexes */ struct ovsdb_idl_index *sbrec_chassis_by_name; struct ovsdb_idl_index *sbrec_chassis_by_hostname; struct ovsdb_idl_index *sbrec_ha_chassis_grp_by_name; - struct ovsdb_idl_index *sbrec_mcast_group_by_name_dp; struct ovsdb_idl_index *sbrec_ip_mcast_by_dp; }; @@ -64,8 +60,6 @@ struct northd_data { struct hmap datapaths; struct hmap ports; struct hmap port_groups; - struct hmap mcast_groups; - struct hmap igmp_groups; struct shash meter_groups; struct hmap lbs; struct hmap bfd_connections; @@ -73,6 +67,24 @@ struct northd_data { bool ovn_internal_version_changed; }; +struct lflow_input { + /* Southbound table references */ + const struct sbrec_logical_flow_table *sbrec_logical_flow_table; + const struct sbrec_multicast_group_table *sbrec_multicast_group_table; + const struct sbrec_igmp_group_table *sbrec_igmp_group_table; + + /* Indexes */ + struct ovsdb_idl_index *sbrec_mcast_group_by_name_dp; + + const struct hmap *datapaths; + const struct hmap *ports; + const struct hmap *port_groups; + const struct shash *meter_groups; + const struct hmap *lbs; + const struct hmap *bfd_connections; + bool ovn_internal_version_changed; +}; + void northd_run(struct northd_input *input_data, struct northd_data *data, struct ovsdb_idl_txn *ovnnb_txn, @@ -82,8 +94,7 @@ void northd_destroy(struct northd_data *data); void northd_init(struct northd_data *data); void northd_indices_create(struct northd_data *data, struct ovsdb_idl *ovnsb_idl); -void build_lflows(struct northd_input *input_data, - struct northd_data *data, +void build_lflows(struct lflow_input *input_data, struct ovsdb_idl_txn *ovnsb_txn); #endif /* NORTHD_H */ diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index cdbd8eaaffa5..24ff71003197 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -1009,7 +1009,6 @@ main(int argc, char *argv[]) check_and_update_rbac( ovnsb_txn, ovnsb_idl_loop.idl); } - } } else { /* ovn-northd is paused -- 2.17.1 -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
