From patchwork Fri Jan 10 19:25:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1221387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47vXyq5s0rz9sPJ for ; Sat, 11 Jan 2020 06:26:11 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id AA8C4863DB; Fri, 10 Jan 2020 19:26:09 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LSZCNIGVIYsU; Fri, 10 Jan 2020 19:26:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 154A885FC9; Fri, 10 Jan 2020 19:26:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E5784C1D7D; Fri, 10 Jan 2020 19:26:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id E040AC0881 for ; Fri, 10 Jan 2020 19:26:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CE7E586092 for ; Fri, 10 Jan 2020 19:26:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id enzbpUlalLXo for ; Fri, 10 Jan 2020 19:26:02 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by fraxinus.osuosl.org (Postfix) with ESMTPS id ED2E185FC9 for ; Fri, 10 Jan 2020 19:26:01 +0000 (UTC) X-Originating-IP: 27.7.90.242 Received: from nummac.local (unknown [27.7.90.242]) (Authenticated sender: numans@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id E84DE60006; Fri, 10 Jan 2020 19:25:57 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Sat, 11 Jan 2020 00:55:43 +0530 Message-Id: <20200110192543.2918983-1-numans@ovn.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn 1/2] Refactor lflow functions to take one context argument - lflow_ctx. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique Presently most of the lflow_*() functions called from ovn-controller.c takes lots of arguments. This patch adds 'struct lflow_ctx' to simplify the code a bit. This also reduces some code in ovn-controller.c and improves readability to some degree. No functional changes are introduced in this patch. Signed-off-by: Numan Siddique --- controller/lflow.c | 255 ++++++++++-------------------------- controller/lflow.h | 83 ++++-------- controller/ovn-controller.c | 240 ++++++++++++--------------------- 3 files changed, 186 insertions(+), 392 deletions(-) diff --git a/controller/lflow.c b/controller/lflow.c index a6893201e..311f8e2be 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -61,25 +61,12 @@ struct condition_aux { const struct sset *active_tunnels; }; -static bool consider_logical_flow( - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_logical_flow *, - const struct hmap *local_datapaths, - const struct sbrec_chassis *, - struct hmap *dhcp_opts, - struct hmap *dhcpv6_opts, - struct hmap *nd_ra_opts, - struct controller_event_options *controller_event_opts, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs); +static bool +consider_logical_flow(struct lflow_ctx *l_ctx, + const struct sbrec_logical_flow *lflow, + struct hmap *dhcp_opts, struct hmap *dhcpv6_opts, + struct hmap *nd_ra_opts, + struct controller_event_options *controller_event_opts); static bool lookup_port_cb(const void *aux_, const char *port_name, unsigned int *portp) @@ -257,30 +244,15 @@ lflow_resource_destroy_lflow(struct lflow_resource_ref *lfrr, /* Adds the logical flows from the Logical_Flow table to flow tables. */ static void -add_logical_flows( - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *dhcp_options_table, - const struct sbrec_dhcpv6_options_table *dhcpv6_options_table, - const struct sbrec_logical_flow_table *logical_flow_table, - const struct hmap *local_datapaths, - const struct sbrec_chassis *chassis, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *flow_table, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs) +add_logical_flows(struct lflow_ctx *l_ctx) { const struct sbrec_logical_flow *lflow; struct hmap dhcp_opts = HMAP_INITIALIZER(&dhcp_opts); struct hmap dhcpv6_opts = HMAP_INITIALIZER(&dhcpv6_opts); const struct sbrec_dhcp_options *dhcp_opt_row; - SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, dhcp_options_table) { + SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, + l_ctx->dhcp_options_table) { dhcp_opt_add(&dhcp_opts, dhcp_opt_row->name, dhcp_opt_row->code, dhcp_opt_row->type); } @@ -288,7 +260,7 @@ add_logical_flows( const struct sbrec_dhcpv6_options *dhcpv6_opt_row; SBREC_DHCPV6_OPTIONS_TABLE_FOR_EACH (dhcpv6_opt_row, - dhcpv6_options_table) { + l_ctx->dhcpv6_options_table) { dhcp_opt_add(&dhcpv6_opts, dhcpv6_opt_row->name, dhcpv6_opt_row->code, dhcpv6_opt_row->type); } @@ -299,16 +271,9 @@ add_logical_flows( struct controller_event_options controller_event_opts; controller_event_opts_init(&controller_event_opts); - SBREC_LOGICAL_FLOW_TABLE_FOR_EACH (lflow, logical_flow_table) { - if (!consider_logical_flow(sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, - lflow, local_datapaths, - chassis, &dhcp_opts, &dhcpv6_opts, - &nd_ra_opts, &controller_event_opts, - addr_sets, port_groups, - active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, - lfrr, conj_id_ofs)) { + SBREC_LOGICAL_FLOW_TABLE_FOR_EACH (lflow, l_ctx->logical_flow_table) { + if (!consider_logical_flow(l_ctx, lflow, &dhcp_opts, &dhcpv6_opts, + &nd_ra_opts, &controller_event_opts)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 5); VLOG_ERR_RL(&rl, "Conjunction id overflow when processing lflow " UUID_FMT, UUID_ARGS(&lflow->header_.uuid)); @@ -322,23 +287,7 @@ add_logical_flows( } bool -lflow_handle_changed_flows( - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *dhcp_options_table, - const struct sbrec_dhcpv6_options_table *dhcpv6_options_table, - const struct sbrec_logical_flow_table *logical_flow_table, - const struct hmap *local_datapaths, - const struct sbrec_chassis *chassis, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *flow_table, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs) +lflow_handle_changed_flows(struct lflow_ctx *l_ctx) { bool ret = true; const struct sbrec_logical_flow *lflow; @@ -346,7 +295,8 @@ lflow_handle_changed_flows( struct hmap dhcp_opts = HMAP_INITIALIZER(&dhcp_opts); struct hmap dhcpv6_opts = HMAP_INITIALIZER(&dhcpv6_opts); const struct sbrec_dhcp_options *dhcp_opt_row; - SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, dhcp_options_table) { + SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, + l_ctx->dhcp_options_table) { dhcp_opt_add(&dhcp_opts, dhcp_opt_row->name, dhcp_opt_row->code, dhcp_opt_row->type); } @@ -354,7 +304,7 @@ lflow_handle_changed_flows( const struct sbrec_dhcpv6_options *dhcpv6_opt_row; SBREC_DHCPV6_OPTIONS_TABLE_FOR_EACH (dhcpv6_opt_row, - dhcpv6_options_table) { + l_ctx->dhcpv6_options_table) { dhcp_opt_add(&dhcpv6_opts, dhcpv6_opt_row->name, dhcpv6_opt_row->code, dhcpv6_opt_row->type); } @@ -365,21 +315,23 @@ lflow_handle_changed_flows( /* Handle removed flows first, and then other flows, so that when * the flows being added and removed have same match conditions * can be processed in the proper order */ - SBREC_LOGICAL_FLOW_TABLE_FOR_EACH_TRACKED (lflow, logical_flow_table) { + SBREC_LOGICAL_FLOW_TABLE_FOR_EACH_TRACKED (lflow, + l_ctx->logical_flow_table) { /* Remove any flows that should be removed. */ if (sbrec_logical_flow_is_deleted(lflow)) { VLOG_DBG("handle deleted lflow "UUID_FMT, UUID_ARGS(&lflow->header_.uuid)); - ofctrl_remove_flows(flow_table, &lflow->header_.uuid); + ofctrl_remove_flows(l_ctx->flow_table, &lflow->header_.uuid); /* Delete entries from lflow resource reference. */ - lflow_resource_destroy_lflow(lfrr, &lflow->header_.uuid); + lflow_resource_destroy_lflow(l_ctx->lfrr, &lflow->header_.uuid); } } struct controller_event_options controller_event_opts; controller_event_opts_init(&controller_event_opts); - SBREC_LOGICAL_FLOW_TABLE_FOR_EACH_TRACKED (lflow, logical_flow_table) { + SBREC_LOGICAL_FLOW_TABLE_FOR_EACH_TRACKED (lflow, + l_ctx->logical_flow_table) { if (!sbrec_logical_flow_is_deleted(lflow)) { /* Now, add/modify existing flows. If the logical * flow is a modification, just remove the flows @@ -387,21 +339,15 @@ lflow_handle_changed_flows( if (!sbrec_logical_flow_is_new(lflow)) { VLOG_DBG("handle updated lflow "UUID_FMT, UUID_ARGS(&lflow->header_.uuid)); - ofctrl_remove_flows(flow_table, &lflow->header_.uuid); + ofctrl_remove_flows(l_ctx->flow_table, &lflow->header_.uuid); /* Delete entries from lflow resource reference. */ - lflow_resource_destroy_lflow(lfrr, &lflow->header_.uuid); + lflow_resource_destroy_lflow(l_ctx->lfrr, + &lflow->header_.uuid); } VLOG_DBG("handle new lflow "UUID_FMT, UUID_ARGS(&lflow->header_.uuid)); - if (!consider_logical_flow(sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, - lflow, local_datapaths, - chassis, &dhcp_opts, &dhcpv6_opts, - &nd_ra_opts, &controller_event_opts, - addr_sets, port_groups, - active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, - lfrr, conj_id_ofs)) { + if (!consider_logical_flow(l_ctx, lflow, &dhcp_opts, &dhcpv6_opts, + &nd_ra_opts, &controller_event_opts)) { ret = false; break; } @@ -415,29 +361,11 @@ lflow_handle_changed_flows( } bool -lflow_handle_changed_ref( - enum ref_type ref_type, - const char *ref_name, - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *dhcp_options_table, - const struct sbrec_dhcpv6_options_table *dhcpv6_options_table, - const struct sbrec_logical_flow_table *logical_flow_table, - const struct hmap *local_datapaths, - const struct sbrec_chassis *chassis, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *flow_table, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs, - bool *changed) +lflow_handle_changed_ref(struct lflow_ctx *l_ctx, enum ref_type ref_type, + const char *ref_name, bool *changed) { - struct ref_lflow_node *rlfn = ref_lflow_lookup(&lfrr->ref_lflow_table, - ref_type, ref_name); + struct ref_lflow_node *rlfn = + ref_lflow_lookup(&l_ctx->lfrr->ref_lflow_table, ref_type, ref_name); if (!rlfn) { *changed = false; return true; @@ -447,7 +375,7 @@ lflow_handle_changed_ref( *changed = false; bool ret = true; - hmap_remove(&lfrr->ref_lflow_table, &rlfn->node); + hmap_remove(&l_ctx->lfrr->ref_lflow_table, &rlfn->node); struct lflow_ref_list_node *lrln, *next; /* Detach the rlfn->ref_lflow_head nodes from the lfrr table and clean @@ -456,19 +384,21 @@ lflow_handle_changed_ref( * when reparsing the lflows. */ LIST_FOR_EACH (lrln, ref_list, &rlfn->ref_lflow_head) { ovs_list_remove(&lrln->lflow_list); - lflow_resource_destroy_lflow(lfrr, &lrln->lflow_uuid); + lflow_resource_destroy_lflow(l_ctx->lfrr, &lrln->lflow_uuid); } struct hmap dhcp_opts = HMAP_INITIALIZER(&dhcp_opts); struct hmap dhcpv6_opts = HMAP_INITIALIZER(&dhcpv6_opts); const struct sbrec_dhcp_options *dhcp_opt_row; - SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, dhcp_options_table) { + SBREC_DHCP_OPTIONS_TABLE_FOR_EACH (dhcp_opt_row, + l_ctx->dhcp_options_table) { dhcp_opt_add(&dhcp_opts, dhcp_opt_row->name, dhcp_opt_row->code, dhcp_opt_row->type); } const struct sbrec_dhcpv6_options *dhcpv6_opt_row; - SBREC_DHCPV6_OPTIONS_TABLE_FOR_EACH(dhcpv6_opt_row, dhcpv6_options_table) { + SBREC_DHCPV6_OPTIONS_TABLE_FOR_EACH(dhcpv6_opt_row, + l_ctx->dhcpv6_options_table) { dhcp_opt_add(&dhcpv6_opts, dhcpv6_opt_row->name, dhcpv6_opt_row->code, dhcpv6_opt_row->type); } @@ -482,7 +412,7 @@ lflow_handle_changed_ref( /* Re-parse the related lflows. */ LIST_FOR_EACH (lrln, ref_list, &rlfn->ref_lflow_head) { const struct sbrec_logical_flow *lflow = - sbrec_logical_flow_table_get_for_uuid(logical_flow_table, + sbrec_logical_flow_table_get_for_uuid(l_ctx->logical_flow_table, &lrln->lflow_uuid); if (!lflow) { VLOG_DBG("Reprocess lflow "UUID_FMT" for resource type: %d," @@ -495,17 +425,10 @@ lflow_handle_changed_ref( " name: %s.", UUID_ARGS(&lrln->lflow_uuid), ref_type, ref_name); - ofctrl_remove_flows(flow_table, &lrln->lflow_uuid); - - if (!consider_logical_flow(sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, - lflow, local_datapaths, - chassis, &dhcp_opts, &dhcpv6_opts, - &nd_ra_opts, &controller_event_opts, - addr_sets, port_groups, - active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, - lfrr, conj_id_ofs)) { + ofctrl_remove_flows(l_ctx->flow_table, &lrln->lflow_uuid); + + if (!consider_logical_flow(l_ctx, lflow, &dhcp_opts, &dhcpv6_opts, + &nd_ra_opts, &controller_event_opts)) { ret = false; break; } @@ -537,25 +460,11 @@ update_conj_id_ofs(uint32_t *conj_id_ofs, uint32_t n_conjs) } static bool -consider_logical_flow( - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_logical_flow *lflow, - const struct hmap *local_datapaths, - const struct sbrec_chassis *chassis, - struct hmap *dhcp_opts, - struct hmap *dhcpv6_opts, - struct hmap *nd_ra_opts, - struct controller_event_options *controller_event_opts, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *flow_table, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs) +consider_logical_flow(struct lflow_ctx *l_ctx, + const struct sbrec_logical_flow *lflow, + struct hmap *dhcp_opts, struct hmap *dhcpv6_opts, + struct hmap *nd_ra_opts, + struct controller_event_options *controller_event_opts) { /* Determine translation of logical table IDs to physical table IDs. */ bool ingress = !strcmp(lflow->pipeline, "ingress"); @@ -566,7 +475,7 @@ consider_logical_flow( UUID_ARGS(&lflow->header_.uuid)); return true; } - if (!get_local_datapath(local_datapaths, ldp->tunnel_key)) { + if (!get_local_datapath(l_ctx->local_datapaths, ldp->tunnel_key)) { VLOG_DBG("lflow "UUID_FMT" is not for local datapath, skip", UUID_ARGS(&lflow->header_.uuid)); return true; @@ -617,16 +526,17 @@ consider_logical_flow( struct sset addr_sets_ref = SSET_INITIALIZER(&addr_sets_ref); struct sset port_groups_ref = SSET_INITIALIZER(&port_groups_ref); - expr = expr_parse_string(lflow->match, &symtab, addr_sets, port_groups, - &addr_sets_ref, &port_groups_ref, &error); + expr = expr_parse_string(lflow->match, &symtab, l_ctx->addr_sets, + l_ctx->port_groups, &addr_sets_ref, + &port_groups_ref, &error); const char *addr_set_name; SSET_FOR_EACH (addr_set_name, &addr_sets_ref) { - lflow_resource_add(lfrr, REF_TYPE_ADDRSET, addr_set_name, + lflow_resource_add(l_ctx->lfrr, REF_TYPE_ADDRSET, addr_set_name, &lflow->header_.uuid); } const char *port_group_name; SSET_FOR_EACH (port_group_name, &port_groups_ref) { - lflow_resource_add(lfrr, REF_TYPE_PORTGROUP, port_group_name, + lflow_resource_add(l_ctx->lfrr, REF_TYPE_PORTGROUP, port_group_name, &lflow->header_.uuid); } sset_destroy(&addr_sets_ref); @@ -652,14 +562,14 @@ consider_logical_flow( struct lookup_port_aux aux = { .sbrec_multicast_group_by_name_datapath - = sbrec_multicast_group_by_name_datapath, - .sbrec_port_binding_by_name = sbrec_port_binding_by_name, + = l_ctx->sbrec_multicast_group_by_name_datapath, + .sbrec_port_binding_by_name = l_ctx->sbrec_port_binding_by_name, .dp = lflow->logical_datapath }; struct condition_aux cond_aux = { - .sbrec_port_binding_by_name = sbrec_port_binding_by_name, - .chassis = chassis, - .active_tunnels = active_tunnels, + .sbrec_port_binding_by_name = l_ctx->sbrec_port_binding_by_name, + .chassis = l_ctx->chassis, + .active_tunnels = l_ctx->active_tunnels, }; expr = expr_simplify(expr, is_chassis_resident_cb, &cond_aux); expr = expr_normalize(expr); @@ -683,8 +593,8 @@ consider_logical_flow( .lookup_port = lookup_port_cb, .aux = &aux, .is_switch = is_switch(ldp), - .group_table = group_table, - .meter_table = meter_table, + .group_table = l_ctx->group_table, + .meter_table = l_ctx->meter_table, .lflow_uuid = lflow->header_.uuid, .pipeline = ingress ? OVNACT_P_INGRESS : OVNACT_P_EGRESS, @@ -704,7 +614,7 @@ consider_logical_flow( match_set_metadata(&m->match, htonll(lflow->logical_datapath->tunnel_key)); if (m->match.wc.masks.conj_id) { - m->match.flow.conj_id += *conj_id_ofs; + m->match.flow.conj_id += *l_ctx->conj_id_ofs; } if (is_switch(ldp)) { unsigned int reg_index @@ -714,7 +624,7 @@ consider_logical_flow( int64_t dp_id = lflow->logical_datapath->tunnel_key; char buf[16]; snprintf(buf, sizeof(buf), "%"PRId64"_%"PRId64, dp_id, port_id); - if (!sset_contains(local_lport_ids, buf)) { + if (!sset_contains(l_ctx->local_lport_ids, buf)) { VLOG_DBG("lflow "UUID_FMT " port %s in match is not local, skip", UUID_ARGS(&lflow->header_.uuid), @@ -724,7 +634,7 @@ consider_logical_flow( } } if (!m->n) { - ofctrl_add_flow(flow_table, ptable, lflow->priority, + ofctrl_add_flow(l_ctx->flow_table, ptable, lflow->priority, lflow->header_.uuid.parts[0], &m->match, &ofpacts, &lflow->header_.uuid); } else { @@ -737,12 +647,13 @@ consider_logical_flow( struct ofpact_conjunction *dst; dst = ofpact_put_CONJUNCTION(&conj); - dst->id = src->id + *conj_id_ofs; + dst->id = src->id + *l_ctx->conj_id_ofs; dst->clause = src->clause; dst->n_clauses = src->n_clauses; } - ofctrl_add_or_append_flow(flow_table, ptable, lflow->priority, 0, + ofctrl_add_or_append_flow(l_ctx->flow_table, ptable, + lflow->priority, 0, &m->match, &conj, &lflow->header_.uuid); ofpbuf_uninit(&conj); } @@ -751,7 +662,7 @@ consider_logical_flow( /* Clean up. */ expr_matches_destroy(&matches); ofpbuf_uninit(&ofpacts); - return update_conj_id_ofs(conj_id_ofs, n_conjs); + return update_conj_id_ofs(l_ctx->conj_id_ofs, n_conjs); } static void @@ -860,7 +771,6 @@ lflow_handle_changed_neighbors( const struct sbrec_mac_binding_table *mac_binding_table, struct ovn_desired_flow_table *flow_table) { - const struct sbrec_mac_binding *mb; /* Handle deleted mac_bindings first, to avoid *duplicated flow* problem * when same flow needs to be added. */ @@ -890,34 +800,13 @@ lflow_handle_changed_neighbors( /* Translates logical flows in the Logical_Flow table in the OVN_SB database * into OpenFlow flows. See ovn-architecture(7) for more information. */ void -lflow_run(struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *dhcp_options_table, - const struct sbrec_dhcpv6_options_table *dhcpv6_options_table, - const struct sbrec_logical_flow_table *logical_flow_table, - const struct sbrec_mac_binding_table *mac_binding_table, - const struct sbrec_chassis *chassis, - const struct hmap *local_datapaths, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *flow_table, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *lfrr, - uint32_t *conj_id_ofs) +lflow_run(struct lflow_ctx *l_ctx) { COVERAGE_INC(lflow_run); - add_logical_flows(sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, dhcp_options_table, - dhcpv6_options_table, logical_flow_table, - local_datapaths, chassis, addr_sets, port_groups, - active_tunnels, local_lport_ids, flow_table, group_table, - meter_table, lfrr, conj_id_ofs); - add_neighbor_flows(sbrec_port_binding_by_name, mac_binding_table, - flow_table); + add_logical_flows(l_ctx); + add_neighbor_flows(l_ctx->sbrec_port_binding_by_name, + l_ctx->mac_binding_table, l_ctx->flow_table); } void diff --git a/controller/lflow.h b/controller/lflow.h index abdc55e96..4f538e63c 100644 --- a/controller/lflow.h +++ b/controller/lflow.h @@ -115,64 +115,35 @@ void lflow_resource_init(struct lflow_resource_ref *); void lflow_resource_destroy(struct lflow_resource_ref *); void lflow_resource_clear(struct lflow_resource_ref *); +struct lflow_ctx { + struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath; + struct ovsdb_idl_index *sbrec_port_binding_by_name; + const struct sbrec_dhcp_options_table *dhcp_options_table; + const struct sbrec_dhcpv6_options_table *dhcpv6_options_table; + const struct sbrec_datapath_binding_table *dp_binding_table; + const struct sbrec_mac_binding_table *mac_binding_table; + const struct sbrec_logical_flow_table *logical_flow_table; + const struct sbrec_multicast_group_table *mc_group_table; + const struct sbrec_chassis *chassis; + const struct hmap *local_datapaths; + const struct shash *addr_sets; + const struct shash *port_groups; + const struct sset *active_tunnels; + const struct sset *local_lport_ids; + struct ovn_desired_flow_table *flow_table; + struct ovn_extend_table *group_table; + struct ovn_extend_table *meter_table; + struct lflow_resource_ref *lfrr; + uint32_t *conj_id_ofs; +}; + void lflow_init(void); -void lflow_run(struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *, - const struct sbrec_dhcpv6_options_table *, - const struct sbrec_logical_flow_table *, - const struct sbrec_mac_binding_table *, - const struct sbrec_chassis *chassis, - const struct hmap *local_datapaths, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *, - uint32_t *conj_id_ofs); - -bool lflow_handle_changed_flows( - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *, - const struct sbrec_dhcpv6_options_table *, - const struct sbrec_logical_flow_table *, - const struct hmap *local_datapaths, - const struct sbrec_chassis *, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *, - uint32_t *conj_id_ofs); - -bool lflow_handle_changed_ref( - enum ref_type, - const char *ref_name, - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath, - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_dhcp_options_table *, - const struct sbrec_dhcpv6_options_table *, - const struct sbrec_logical_flow_table *, - const struct hmap *local_datapaths, - const struct sbrec_chassis *, - const struct shash *addr_sets, - const struct shash *port_groups, - const struct sset *active_tunnels, - const struct sset *local_lport_ids, - struct ovn_desired_flow_table *, - struct ovn_extend_table *group_table, - struct ovn_extend_table *meter_table, - struct lflow_resource_ref *, - uint32_t *conj_id_ofs, - bool *changed); +void lflow_run(struct lflow_ctx *l_ctx); + +bool lflow_handle_changed_flows(struct lflow_ctx *l_ctx); +bool lflow_handle_changed_ref(struct lflow_ctx *l_ctx, enum ref_type, + const char *ref_name, bool *changed); void lflow_handle_changed_neighbors( struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct sbrec_mac_binding_table *, diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 17744d416..4942df6c4 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1213,6 +1213,81 @@ struct ed_type_flow_output { struct lflow_resource_ref lflow_resource_ref; }; +static void init_lflow_ctx(struct engine_node *node, + struct ed_type_runtime_data *rt_data, + struct ed_type_flow_output *fo, + struct lflow_ctx *l_ctx) +{ + struct ovsdb_idl_index *sbrec_port_binding_by_name = + engine_ovsdb_node_get_index( + engine_get_input("SB_port_binding", node), + "name"); + + struct ovsdb_idl_index *sbrec_mc_group_by_name_dp = + engine_ovsdb_node_get_index( + engine_get_input("SB_multicast_group", node), + "name_datapath"); + + struct sbrec_dhcp_options_table *dhcp_table = + (struct sbrec_dhcp_options_table *)EN_OVSDB_GET( + engine_get_input("SB_dhcp_options", node)); + + struct sbrec_dhcpv6_options_table *dhcpv6_table = + (struct sbrec_dhcpv6_options_table *)EN_OVSDB_GET( + engine_get_input("SB_dhcpv6_options", node)); + + struct sbrec_mac_binding_table *mac_binding_table = + (struct sbrec_mac_binding_table *)EN_OVSDB_GET( + engine_get_input("SB_mac_binding", node)); + + struct sbrec_logical_flow_table *logical_flow_table = + (struct sbrec_logical_flow_table *)EN_OVSDB_GET( + engine_get_input("SB_logical_flow", node)); + + struct sbrec_multicast_group_table *multicast_group_table = + (struct sbrec_multicast_group_table *)EN_OVSDB_GET( + engine_get_input("SB_multicast_group", node)); + + const char *chassis_id = chassis_get_id(); + const struct sbrec_chassis *chassis = NULL; + struct ovsdb_idl_index *sbrec_chassis_by_name = + engine_ovsdb_node_get_index( + engine_get_input("SB_chassis", node), + "name"); + if (chassis_id) { + chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); + } + + ovs_assert(chassis); + + struct ed_type_addr_sets *as_data = + engine_get_input_data("addr_sets", node); + struct shash *addr_sets = &as_data->addr_sets; + + struct ed_type_port_groups *pg_data = + engine_get_input_data("port_groups", node); + struct shash *port_groups = &pg_data->port_groups; + + l_ctx->sbrec_multicast_group_by_name_datapath = sbrec_mc_group_by_name_dp; + l_ctx->sbrec_port_binding_by_name = sbrec_port_binding_by_name; + l_ctx->dhcp_options_table = dhcp_table; + l_ctx->dhcpv6_options_table = dhcpv6_table; + l_ctx->mac_binding_table = mac_binding_table; + l_ctx->logical_flow_table = logical_flow_table; + l_ctx->mc_group_table = multicast_group_table; + l_ctx->chassis = chassis; + l_ctx->local_datapaths = &rt_data->local_datapaths; + l_ctx->addr_sets = addr_sets; + l_ctx->port_groups = port_groups; + l_ctx->active_tunnels = &rt_data->active_tunnels; + l_ctx->local_lport_ids = &rt_data->local_lport_ids; + l_ctx->flow_table = &fo->flow_table; + l_ctx->group_table = &fo->group_table; + l_ctx->meter_table = &fo->meter_table; + l_ctx->lfrr = &fo->lflow_resource_ref; + l_ctx->conj_id_ofs = &fo->conj_id_ofs; +} + static void * en_flow_output_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED) @@ -1244,7 +1319,6 @@ en_flow_output_run(struct engine_node *node, void *data) engine_get_input_data("runtime_data", node); struct hmap *local_datapaths = &rt_data->local_datapaths; struct sset *local_lports = &rt_data->local_lports; - struct sset *local_lport_ids = &rt_data->local_lport_ids; struct sset *active_tunnels = &rt_data->active_tunnels; struct ed_type_ct_zones *ct_zones_data = @@ -1268,13 +1342,6 @@ en_flow_output_run(struct engine_node *node, void *data) engine_ovsdb_node_get_index( engine_get_input("SB_chassis", node), "name"); - struct ed_type_addr_sets *as_data = - engine_get_input_data("addr_sets", node); - struct shash *addr_sets = &as_data->addr_sets; - - struct ed_type_port_groups *pg_data = - engine_get_input_data("port_groups", node); - struct shash *port_groups = &pg_data->port_groups; const struct sbrec_chassis *chassis = NULL; if (chassis_id) { @@ -1300,42 +1367,15 @@ en_flow_output_run(struct engine_node *node, void *data) lflow_resource_clear(lfrr); } - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath = - engine_ovsdb_node_get_index( - engine_get_input("SB_multicast_group", node), - "name_datapath"); - struct ovsdb_idl_index *sbrec_port_binding_by_name = engine_ovsdb_node_get_index( engine_get_input("SB_port_binding", node), "name"); - struct sbrec_dhcp_options_table *dhcp_table = - (struct sbrec_dhcp_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcp_options", node)); - - struct sbrec_dhcpv6_options_table *dhcpv6_table = - (struct sbrec_dhcpv6_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcpv6_options", node)); - - struct sbrec_logical_flow_table *logical_flow_table = - (struct sbrec_logical_flow_table *)EN_OVSDB_GET( - engine_get_input("SB_logical_flow", node)); - - struct sbrec_mac_binding_table *mac_binding_table = - (struct sbrec_mac_binding_table *)EN_OVSDB_GET( - engine_get_input("SB_mac_binding", node)); - *conj_id_ofs = 1; - lflow_run(sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, - dhcp_table, dhcpv6_table, - logical_flow_table, - mac_binding_table, - chassis, local_datapaths, addr_sets, - port_groups, active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, lfrr, - conj_id_ofs); + struct lflow_ctx l_ctx; + init_lflow_ctx(node, rt_data, fo, &l_ctx); + lflow_run(&l_ctx); struct sbrec_multicast_group_table *multicast_group_table = (struct sbrec_multicast_group_table *)EN_OVSDB_GET( @@ -1367,17 +1407,6 @@ flow_output_sb_logical_flow_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - struct hmap *local_datapaths = &rt_data->local_datapaths; - struct sset *local_lport_ids = &rt_data->local_lport_ids; - struct sset *active_tunnels = &rt_data->active_tunnels; - struct ed_type_addr_sets *as_data = - engine_get_input_data("addr_sets", node); - struct shash *addr_sets = &as_data->addr_sets; - - struct ed_type_port_groups *pg_data = - engine_get_input_data("port_groups", node); - struct shash *port_groups = &pg_data->port_groups; - struct ovsrec_open_vswitch_table *ovs_table = (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( engine_get_input("OVS_open_vswitch", node)); @@ -1385,58 +1414,13 @@ flow_output_sb_logical_flow_handler(struct engine_node *node, void *data) (struct ovsrec_bridge_table *)EN_OVSDB_GET( engine_get_input("OVS_bridge", node)); const struct ovsrec_bridge *br_int = get_br_int(bridge_table, ovs_table); - const char *chassis_id = chassis_get_id(); - - struct ovsdb_idl_index *sbrec_chassis_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), - "name"); - - const struct sbrec_chassis *chassis = NULL; - if (chassis_id) { - chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); - } - - ovs_assert(br_int && chassis); + ovs_assert(br_int); struct ed_type_flow_output *fo = data; - struct ovn_desired_flow_table *flow_table = &fo->flow_table; - struct ovn_extend_table *group_table = &fo->group_table; - struct ovn_extend_table *meter_table = &fo->meter_table; - uint32_t *conj_id_ofs = &fo->conj_id_ofs; - struct lflow_resource_ref *lfrr = &fo->lflow_resource_ref; - - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath = - engine_ovsdb_node_get_index( - engine_get_input("SB_multicast_group", node), - "name_datapath"); - - struct ovsdb_idl_index *sbrec_port_binding_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_port_binding", node), - "name"); - - struct sbrec_dhcp_options_table *dhcp_table = - (struct sbrec_dhcp_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcp_options", node)); - - struct sbrec_dhcpv6_options_table *dhcpv6_table = - (struct sbrec_dhcpv6_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcpv6_options", node)); - - struct sbrec_logical_flow_table *logical_flow_table = - (struct sbrec_logical_flow_table *)EN_OVSDB_GET( - engine_get_input("SB_logical_flow", node)); + struct lflow_ctx l_ctx; + init_lflow_ctx(node, rt_data, fo, &l_ctx); - bool handled = lflow_handle_changed_flows( - sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name, - dhcp_table, dhcpv6_table, - logical_flow_table, - local_datapaths, chassis, addr_sets, - port_groups, active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, lfrr, - conj_id_ofs); + bool handled = lflow_handle_changed_flows(&l_ctx); engine_set_node_state(node, EN_UPDATED); return handled; @@ -1624,17 +1608,12 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, { struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - struct hmap *local_datapaths = &rt_data->local_datapaths; - struct sset *local_lport_ids = &rt_data->local_lport_ids; - struct sset *active_tunnels = &rt_data->active_tunnels; struct ed_type_addr_sets *as_data = engine_get_input_data("addr_sets", node); - struct shash *addr_sets = &as_data->addr_sets; struct ed_type_port_groups *pg_data = engine_get_input_data("port_groups", node); - struct shash *port_groups = &pg_data->port_groups; struct ovsrec_open_vswitch_table *ovs_table = (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( @@ -1657,33 +1636,9 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, ovs_assert(br_int && chassis); struct ed_type_flow_output *fo = data; - struct ovn_desired_flow_table *flow_table = &fo->flow_table; - struct ovn_extend_table *group_table = &fo->group_table; - struct ovn_extend_table *meter_table = &fo->meter_table; - uint32_t *conj_id_ofs = &fo->conj_id_ofs; - struct lflow_resource_ref *lfrr = &fo->lflow_resource_ref; - struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath = - engine_ovsdb_node_get_index( - engine_get_input("SB_multicast_group", node), - "name_datapath"); - - struct ovsdb_idl_index *sbrec_port_binding_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_port_binding", node), - "name"); - - struct sbrec_dhcp_options_table *dhcp_table = - (struct sbrec_dhcp_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcp_options", node)); - - struct sbrec_dhcpv6_options_table *dhcpv6_table = - (struct sbrec_dhcpv6_options_table *)EN_OVSDB_GET( - engine_get_input("SB_dhcpv6_options", node)); - - struct sbrec_logical_flow_table *logical_flow_table = - (struct sbrec_logical_flow_table *)EN_OVSDB_GET( - engine_get_input("SB_logical_flow", node)); + struct lflow_ctx l_ctx; + init_lflow_ctx(node, rt_data, fo, &l_ctx); bool changed; const char *ref_name; @@ -1714,14 +1669,7 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, SSET_FOR_EACH (ref_name, deleted) { - if (!lflow_handle_changed_ref(ref_type, ref_name, - sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name,dhcp_table, - dhcpv6_table, logical_flow_table, - local_datapaths, chassis, addr_sets, - port_groups, active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, lfrr, - conj_id_ofs, &changed)) { + if (!lflow_handle_changed_ref(&l_ctx, ref_type, ref_name, &changed)) { return false; } if (changed) { @@ -1729,14 +1677,7 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, } } SSET_FOR_EACH (ref_name, updated) { - if (!lflow_handle_changed_ref(ref_type, ref_name, - sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name,dhcp_table, - dhcpv6_table, logical_flow_table, - local_datapaths, chassis, addr_sets, - port_groups, active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, lfrr, - conj_id_ofs, &changed)) { + if (!lflow_handle_changed_ref(&l_ctx, ref_type, ref_name, &changed)) { return false; } if (changed) { @@ -1744,14 +1685,7 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data, } } SSET_FOR_EACH (ref_name, new) { - if (!lflow_handle_changed_ref(ref_type, ref_name, - sbrec_multicast_group_by_name_datapath, - sbrec_port_binding_by_name,dhcp_table, - dhcpv6_table, logical_flow_table, - local_datapaths, chassis, addr_sets, - port_groups, active_tunnels, local_lport_ids, - flow_table, group_table, meter_table, lfrr, - conj_id_ofs, &changed)) { + if (!lflow_handle_changed_ref(&l_ctx, ref_type, ref_name, &changed)) { return false; } if (changed) { From patchwork Fri Jan 10 19:26:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1221388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47vXz66Lk4z9sPJ for ; Sat, 11 Jan 2020 06:26:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id C5D9D22859; Fri, 10 Jan 2020 19:26:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B8ILdWaiHjJW; Fri, 10 Jan 2020 19:26:21 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 384A6226D0; Fri, 10 Jan 2020 19:26:21 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1C0BDC1D87; Fri, 10 Jan 2020 19:26:21 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id D95F8C0881 for ; Fri, 10 Jan 2020 19:26:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id D62CC226D0 for ; Fri, 10 Jan 2020 19:26:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YBQm7JkbkDxz for ; Fri, 10 Jan 2020 19:26:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by silver.osuosl.org (Postfix) with ESMTPS id 6900922713 for ; Fri, 10 Jan 2020 19:26:17 +0000 (UTC) X-Originating-IP: 27.7.90.242 Received: from nummac.local (unknown [27.7.90.242]) (Authenticated sender: numans@ovn.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 7B5C7FF802; Fri, 10 Jan 2020 19:26:13 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Sat, 11 Jan 2020 00:56:06 +0530 Message-Id: <20200110192606.2919071-1-numans@ovn.org> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn 2/2] Refactor physical module functions to take context argument - physical_ctx. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Numan Siddique No functional changes are introduced in this patch. Signed-off-by: Numan Siddique --- controller/ovn-controller.c | 185 ++++++++++++++---------------------- controller/physical.c | 126 +++++++++++------------- controller/physical.h | 46 ++++----- 3 files changed, 144 insertions(+), 213 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 4942df6c4..390057ee2 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1213,6 +1213,68 @@ struct ed_type_flow_output { struct lflow_resource_ref lflow_resource_ref; }; +static void init_physical_ctx(struct engine_node *node, + struct ed_type_runtime_data *rt_data, + struct ovn_desired_flow_table *flow_table, + struct physical_ctx *p_ctx) +{ + struct ovsdb_idl_index *sbrec_port_binding_by_name = + engine_ovsdb_node_get_index( + engine_get_input("SB_port_binding", node), + "name"); + + struct sbrec_multicast_group_table *multicast_group_table = + (struct sbrec_multicast_group_table *)EN_OVSDB_GET( + engine_get_input("SB_multicast_group", node)); + + struct sbrec_port_binding_table *port_binding_table = + (struct sbrec_port_binding_table *)EN_OVSDB_GET( + engine_get_input("SB_port_binding", node)); + + struct sbrec_chassis_table *chassis_table = + (struct sbrec_chassis_table *)EN_OVSDB_GET( + engine_get_input("SB_chassis", node)); + + struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = + engine_get_input_data("mff_ovn_geneve", node); + + struct ovsrec_open_vswitch_table *ovs_table = + (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( + engine_get_input("OVS_open_vswitch", node)); + struct ovsrec_bridge_table *bridge_table = + (struct ovsrec_bridge_table *)EN_OVSDB_GET( + engine_get_input("OVS_bridge", node)); + const struct ovsrec_bridge *br_int = get_br_int(bridge_table, ovs_table); + const char *chassis_id = chassis_get_id(); + const struct sbrec_chassis *chassis = NULL; + struct ovsdb_idl_index *sbrec_chassis_by_name = + engine_ovsdb_node_get_index( + engine_get_input("SB_chassis", node), + "name"); + if (chassis_id) { + chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); + } + + ovs_assert(br_int && chassis); + + struct ed_type_ct_zones *ct_zones_data = + engine_get_input_data("ct_zones", node); + struct simap *ct_zones = &ct_zones_data->current; + + p_ctx->sbrec_port_binding_by_name = sbrec_port_binding_by_name; + p_ctx->port_binding_table = port_binding_table; + p_ctx->mc_group_table = multicast_group_table; + p_ctx->br_int = br_int; + p_ctx->chassis_table = chassis_table; + p_ctx->chassis = chassis; + p_ctx->flow_table = flow_table; + p_ctx->active_tunnels = &rt_data->active_tunnels; + p_ctx->local_datapaths = &rt_data->local_datapaths; + p_ctx->local_lports = &rt_data->local_lports; + p_ctx->ct_zones = ct_zones; + p_ctx->mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve; +} + static void init_lflow_ctx(struct engine_node *node, struct ed_type_runtime_data *rt_data, struct ed_type_flow_output *fo, @@ -1317,17 +1379,6 @@ en_flow_output_run(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - struct hmap *local_datapaths = &rt_data->local_datapaths; - struct sset *local_lports = &rt_data->local_lports; - struct sset *active_tunnels = &rt_data->active_tunnels; - - struct ed_type_ct_zones *ct_zones_data = - engine_get_input_data("ct_zones", node); - struct simap *ct_zones = &ct_zones_data->current; - - struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = - engine_get_input_data("mff_ovn_geneve", node); - enum mf_field_id mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve; struct ovsrec_open_vswitch_table *ovs_table = (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( @@ -1367,37 +1418,15 @@ en_flow_output_run(struct engine_node *node, void *data) lflow_resource_clear(lfrr); } - struct ovsdb_idl_index *sbrec_port_binding_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_port_binding", node), - "name"); - *conj_id_ofs = 1; struct lflow_ctx l_ctx; init_lflow_ctx(node, rt_data, fo, &l_ctx); lflow_run(&l_ctx); - struct sbrec_multicast_group_table *multicast_group_table = - (struct sbrec_multicast_group_table *)EN_OVSDB_GET( - engine_get_input("SB_multicast_group", node)); - - struct sbrec_port_binding_table *port_binding_table = - (struct sbrec_port_binding_table *)EN_OVSDB_GET( - engine_get_input("SB_port_binding", node)); - - struct sbrec_chassis_table *chassis_table = - (struct sbrec_chassis_table *)EN_OVSDB_GET( - engine_get_input("SB_chassis", node)); + struct physical_ctx p_ctx; + init_physical_ctx(node, rt_data, &fo->flow_table, &p_ctx); - physical_run(sbrec_port_binding_by_name, - multicast_group_table, - port_binding_table, - chassis_table, - mff_ovn_geneve, - br_int, chassis, ct_zones, - local_datapaths, local_lports, - active_tunnels, - flow_table); + physical_run(&p_ctx); engine_set_node_state(node, EN_UPDATED); } @@ -1453,48 +1482,10 @@ flow_output_sb_port_binding_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - struct hmap *local_datapaths = &rt_data->local_datapaths; - struct sset *active_tunnels = &rt_data->active_tunnels; - - struct ed_type_ct_zones *ct_zones_data = - engine_get_input_data("ct_zones", node); - struct simap *ct_zones = &ct_zones_data->current; - - struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = - engine_get_input_data("mff_ovn_geneve", node); - enum mf_field_id mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve; - - struct ovsrec_open_vswitch_table *ovs_table = - (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( - engine_get_input("OVS_open_vswitch", node)); - struct ovsrec_bridge_table *bridge_table = - (struct ovsrec_bridge_table *)EN_OVSDB_GET( - engine_get_input("OVS_bridge", node)); - const struct ovsrec_bridge *br_int = get_br_int(bridge_table, ovs_table); - const char *chassis_id = chassis_get_id(); - - struct ovsdb_idl_index *sbrec_chassis_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), - "name"); - const struct sbrec_chassis *chassis = NULL; - if (chassis_id) { - chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); - } - ovs_assert(br_int && chassis); struct ed_type_flow_output *fo = data; struct ovn_desired_flow_table *flow_table = &fo->flow_table; - struct ovsdb_idl_index *sbrec_port_binding_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_port_binding", node), - "name"); - - struct sbrec_port_binding_table *port_binding_table = - (struct sbrec_port_binding_table *)EN_OVSDB_GET( - engine_get_input("SB_port_binding", node)); - /* XXX: now we handle port-binding changes for physical flow processing * only, but port-binding change can have impact to logical flow * processing, too, in below circumstances: @@ -1542,11 +1533,10 @@ flow_output_sb_port_binding_handler(struct engine_node *node, void *data) * names and the lflows that uses them, and reprocess the related lflows * when related port-bindings change. */ - physical_handle_port_binding_changes( - sbrec_port_binding_by_name, - port_binding_table, mff_ovn_geneve, - chassis, ct_zones, local_datapaths, - active_tunnels, flow_table); + struct physical_ctx p_ctx; + init_physical_ctx(node, rt_data, flow_table, &p_ctx); + + physical_handle_port_binding_changes(&p_ctx); engine_set_node_state(node, EN_UPDATED); return true; @@ -1557,45 +1547,14 @@ flow_output_sb_multicast_group_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); - struct hmap *local_datapaths = &rt_data->local_datapaths; - - struct ed_type_ct_zones *ct_zones_data = - engine_get_input_data("ct_zones", node); - struct simap *ct_zones = &ct_zones_data->current; - - struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve = - engine_get_input_data("mff_ovn_geneve", node); - enum mf_field_id mff_ovn_geneve = ed_mff_ovn_geneve->mff_ovn_geneve; - - struct ovsrec_open_vswitch_table *ovs_table = - (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( - engine_get_input("OVS_open_vswitch", node)); - struct ovsrec_bridge_table *bridge_table = - (struct ovsrec_bridge_table *)EN_OVSDB_GET( - engine_get_input("OVS_bridge", node)); - const struct ovsrec_bridge *br_int = get_br_int(bridge_table, ovs_table); - const char *chassis_id = chassis_get_id(); - - struct ovsdb_idl_index *sbrec_chassis_by_name = - engine_ovsdb_node_get_index( - engine_get_input("SB_chassis", node), - "name"); - const struct sbrec_chassis *chassis = NULL; - if (chassis_id) { - chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id); - } - ovs_assert(br_int && chassis); struct ed_type_flow_output *fo = data; struct ovn_desired_flow_table *flow_table = &fo->flow_table; - struct sbrec_multicast_group_table *multicast_group_table = - (struct sbrec_multicast_group_table *)EN_OVSDB_GET( - engine_get_input("SB_multicast_group", node)); + struct physical_ctx p_ctx; + init_physical_ctx(node, rt_data, flow_table, &p_ctx); - physical_handle_mc_group_changes(multicast_group_table, - mff_ovn_geneve, chassis, ct_zones, local_datapaths, - flow_table); + physical_handle_mc_group_changes(&p_ctx); engine_set_node_state(node, EN_UPDATED); return true; diff --git a/controller/physical.c b/controller/physical.c index 500d41994..8fb84e7f8 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1396,72 +1396,50 @@ update_ofports(struct simap *old, struct simap *new) return changed; } -void physical_handle_port_binding_changes( - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_port_binding_table *pb_table, - enum mf_field_id mff_ovn_geneve, - const struct sbrec_chassis *chassis, - const struct simap *ct_zones, - struct hmap *local_datapaths, - struct sset *active_tunnels, - struct ovn_desired_flow_table *flow_table) +void physical_handle_port_binding_changes(struct physical_ctx *p_ctx) { const struct sbrec_port_binding *binding; struct ofpbuf ofpacts; ofpbuf_init(&ofpacts, 0); - SBREC_PORT_BINDING_TABLE_FOR_EACH_TRACKED (binding, pb_table) { + SBREC_PORT_BINDING_TABLE_FOR_EACH_TRACKED (binding, + p_ctx->port_binding_table) { if (sbrec_port_binding_is_deleted(binding)) { - ofctrl_remove_flows(flow_table, &binding->header_.uuid); + ofctrl_remove_flows(p_ctx->flow_table, &binding->header_.uuid); } else { if (!sbrec_port_binding_is_new(binding)) { - ofctrl_remove_flows(flow_table, &binding->header_.uuid); + ofctrl_remove_flows(p_ctx->flow_table, &binding->header_.uuid); } - consider_port_binding(sbrec_port_binding_by_name, - mff_ovn_geneve, ct_zones, - active_tunnels, local_datapaths, - binding, chassis, - flow_table, &ofpacts); + consider_port_binding(p_ctx->sbrec_port_binding_by_name, + p_ctx->mff_ovn_geneve, p_ctx->ct_zones, + p_ctx->active_tunnels, + p_ctx->local_datapaths, + binding, p_ctx->chassis, + p_ctx->flow_table, &ofpacts); } } ofpbuf_uninit(&ofpacts); } void -physical_handle_mc_group_changes( - const struct sbrec_multicast_group_table *multicast_group_table, - enum mf_field_id mff_ovn_geneve, - const struct sbrec_chassis *chassis, - const struct simap *ct_zones, - const struct hmap *local_datapaths, - struct ovn_desired_flow_table *flow_table) +physical_handle_mc_group_changes(struct physical_ctx *p_ctx) { const struct sbrec_multicast_group *mc; - SBREC_MULTICAST_GROUP_TABLE_FOR_EACH_TRACKED (mc, multicast_group_table) { + SBREC_MULTICAST_GROUP_TABLE_FOR_EACH_TRACKED (mc, p_ctx->mc_group_table) { if (sbrec_multicast_group_is_deleted(mc)) { - ofctrl_remove_flows(flow_table, &mc->header_.uuid); + ofctrl_remove_flows(p_ctx->flow_table, &mc->header_.uuid); } else { if (!sbrec_multicast_group_is_new(mc)) { - ofctrl_remove_flows(flow_table, &mc->header_.uuid); + ofctrl_remove_flows(p_ctx->flow_table, &mc->header_.uuid); } - consider_mc_group(mff_ovn_geneve, ct_zones, local_datapaths, - chassis, mc, flow_table); + consider_mc_group(p_ctx->mff_ovn_geneve, p_ctx->ct_zones, + p_ctx->local_datapaths, + p_ctx->chassis, mc, p_ctx->flow_table); } } } void -physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_multicast_group_table *multicast_group_table, - const struct sbrec_port_binding_table *port_binding_table, - const struct sbrec_chassis_table *chassis_table, - enum mf_field_id mff_ovn_geneve, - const struct ovsrec_bridge *br_int, - const struct sbrec_chassis *chassis, - const struct simap *ct_zones, - const struct hmap *local_datapaths, - const struct sset *local_lports, - const struct sset *active_tunnels, - struct ovn_desired_flow_table *flow_table) +physical_run(struct physical_ctx *p_ctx) { if (!hc_uuid) { hc_uuid = xmalloc(sizeof(struct uuid)); @@ -1475,16 +1453,17 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, SIMAP_INITIALIZER(&new_localvif_to_ofport); struct simap new_tunnel_to_ofport = SIMAP_INITIALIZER(&new_tunnel_to_ofport); - for (int i = 0; i < br_int->n_ports; i++) { - const struct ovsrec_port *port_rec = br_int->ports[i]; - if (!strcmp(port_rec->name, br_int->name)) { + for (int i = 0; i < p_ctx->br_int->n_ports; i++) { + const struct ovsrec_port *port_rec = p_ctx->br_int->ports[i]; + if (!strcmp(port_rec->name, p_ctx->br_int->name)) { continue; } const char *tunnel_id = smap_get(&port_rec->external_ids, "ovn-chassis-id"); - if (tunnel_id && - encaps_tunnel_id_match(tunnel_id, chassis->name, NULL)) { + if (tunnel_id && encaps_tunnel_id_match(tunnel_id, + p_ctx->chassis->name, + NULL)) { continue; } @@ -1520,7 +1499,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, enum chassis_tunnel_type tunnel_type; if (!strcmp(iface_rec->type, "geneve")) { tunnel_type = GENEVE; - if (!mff_ovn_geneve) { + if (!p_ctx->mff_ovn_geneve) { continue; } } else if (!strcmp(iface_rec->type, "stt")) { @@ -1599,24 +1578,26 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, struct ofpbuf ofpacts; ofpbuf_init(&ofpacts, 0); - put_chassis_mac_conj_id_flow(chassis_table, chassis, &ofpacts, flow_table); + put_chassis_mac_conj_id_flow(p_ctx->chassis_table, p_ctx->chassis, + &ofpacts, p_ctx->flow_table); /* Set up flows in table 0 for physical-to-logical translation and in table * 64 for logical-to-physical translation. */ const struct sbrec_port_binding *binding; - SBREC_PORT_BINDING_TABLE_FOR_EACH (binding, port_binding_table) { - consider_port_binding(sbrec_port_binding_by_name, - mff_ovn_geneve, ct_zones, - active_tunnels, local_datapaths, - binding, chassis, - flow_table, &ofpacts); + SBREC_PORT_BINDING_TABLE_FOR_EACH (binding, p_ctx->port_binding_table) { + consider_port_binding(p_ctx->sbrec_port_binding_by_name, + p_ctx->mff_ovn_geneve, p_ctx->ct_zones, + p_ctx->active_tunnels, p_ctx->local_datapaths, + binding, p_ctx->chassis, + p_ctx->flow_table, &ofpacts); } /* Handle output to multicast groups, in tables 32 and 33. */ const struct sbrec_multicast_group *mc; - SBREC_MULTICAST_GROUP_TABLE_FOR_EACH (mc, multicast_group_table) { - consider_mc_group(mff_ovn_geneve, ct_zones, local_datapaths, - chassis, mc, flow_table); + SBREC_MULTICAST_GROUP_TABLE_FOR_EACH (mc, p_ctx->mc_group_table) { + consider_mc_group(p_ctx->mff_ovn_geneve, p_ctx->ct_zones, + p_ctx->local_datapaths, p_ctx->chassis, + mc, p_ctx->flow_table); } /* Table 0, priority 100. @@ -1637,9 +1618,9 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, ofpbuf_clear(&ofpacts); if (tun->type == GENEVE) { put_move(MFF_TUN_ID, 0, MFF_LOG_DATAPATH, 0, 24, &ofpacts); - put_move(mff_ovn_geneve, 16, MFF_LOG_INPORT, 0, 15, + put_move(p_ctx->mff_ovn_geneve, 16, MFF_LOG_INPORT, 0, 15, &ofpacts); - put_move(mff_ovn_geneve, 0, MFF_LOG_OUTPORT, 0, 16, + put_move(p_ctx->mff_ovn_geneve, 0, MFF_LOG_OUTPORT, 0, 16, &ofpacts); } else if (tun->type == STT) { put_move(MFF_TUN_ID, 40, MFF_LOG_INPORT, 0, 15, &ofpacts); @@ -1654,7 +1635,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, 0, &match, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_PHY_TO_LOG, 100, 0, &match, &ofpacts, hc_uuid); } @@ -1668,7 +1649,8 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, continue; } - SBREC_PORT_BINDING_TABLE_FOR_EACH (binding, port_binding_table) { + SBREC_PORT_BINDING_TABLE_FOR_EACH (binding, + p_ctx->port_binding_table) { struct match match = MATCH_CATCHALL_INITIALIZER; if (!binding->chassis || @@ -1688,7 +1670,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_load(1, MFF_LOG_FLAGS, MLF_RCV_FROM_VXLAN_BIT, 1, &ofpacts); put_resubmit(OFTABLE_LOG_INGRESS_PIPELINE, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_PHY_TO_LOG, 100, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_PHY_TO_LOG, 100, binding->header_.uuid.parts[0], &match, &ofpacts, hc_uuid); } @@ -1710,7 +1692,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, /* Resubmit to table 33. */ ofpbuf_clear(&ofpacts); put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, &match, &ofpacts, hc_uuid); /* Table 32, priority 150. @@ -1724,7 +1706,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, /* Resubmit to table 33. */ ofpbuf_clear(&ofpacts); put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, &match, &ofpacts, hc_uuid); /* Table 32, priority 150. @@ -1738,16 +1720,16 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, ofpbuf_clear(&ofpacts); put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); const char *localport; - SSET_FOR_EACH (localport, local_lports) { + SSET_FOR_EACH (localport, p_ctx->local_lports) { /* Iterate over all local logical ports and insert a drop * rule with higher priority for every localport in this * datapath. */ const struct sbrec_port_binding *pb = lport_lookup_by_name( - sbrec_port_binding_by_name, localport); + p_ctx->sbrec_port_binding_by_name, localport); if (pb && !strcmp(pb->type, "localport")) { match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, pb->tunnel_key); match_set_metadata(&match, htonll(pb->datapath->tunnel_key)); - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_REMOTE_OUTPUT, 150, pb->header_.uuid.parts[0], &match, &ofpacts, hc_uuid); } @@ -1761,8 +1743,8 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, match_init_catchall(&match); ofpbuf_clear(&ofpacts); put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 0, 0, &match, &ofpacts, - hc_uuid); + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_REMOTE_OUTPUT, 0, 0, &match, + &ofpacts, hc_uuid); /* Table 34, Priority 0. * ======================= @@ -1776,7 +1758,7 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, put_load(0, MFF_REG0 + i, 0, 32, &ofpacts); } put_resubmit(OFTABLE_LOG_EGRESS_PIPELINE, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_CHECK_LOOPBACK, 0, 0, &match, + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_CHECK_LOOPBACK, 0, 0, &match, &ofpacts, hc_uuid); /* Table 64, Priority 0. @@ -1787,8 +1769,8 @@ physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, match_init_catchall(&match); ofpbuf_clear(&ofpacts); put_resubmit(OFTABLE_LOG_TO_PHY, &ofpacts); - ofctrl_add_flow(flow_table, OFTABLE_SAVE_INPORT, 0, 0, &match, &ofpacts, - hc_uuid); + ofctrl_add_flow(p_ctx->flow_table, OFTABLE_SAVE_INPORT, 0, 0, &match, + &ofpacts, hc_uuid); ofpbuf_uninit(&ofpacts); diff --git a/controller/physical.h b/controller/physical.h index c93f6b1c0..477a1cbad 100644 --- a/controller/physical.h +++ b/controller/physical.h @@ -42,34 +42,24 @@ struct sset; #define OVN_GENEVE_TYPE 0x80 /* Critical option. */ #define OVN_GENEVE_LEN 4 +struct physical_ctx { + struct ovsdb_idl_index *sbrec_port_binding_by_name; + const struct sbrec_port_binding_table *port_binding_table; + const struct sbrec_multicast_group_table *mc_group_table; + const struct ovsrec_bridge *br_int; + const struct sbrec_chassis_table *chassis_table; + const struct sbrec_chassis *chassis; + struct ovn_desired_flow_table *flow_table; + const struct sset *active_tunnels; + struct hmap *local_datapaths; + struct sset *local_lports; + const struct simap *ct_zones; + enum mf_field_id mff_ovn_geneve; +}; + void physical_register_ovs_idl(struct ovsdb_idl *); -void physical_run(struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_multicast_group_table *, - const struct sbrec_port_binding_table *, - const struct sbrec_chassis_table *chassis_table, - enum mf_field_id mff_ovn_geneve, - const struct ovsrec_bridge *br_int, - const struct sbrec_chassis *chassis, - const struct simap *ct_zones, - const struct hmap *local_datapaths, - const struct sset *local_lports, - const struct sset *active_tunnels, - struct ovn_desired_flow_table *); -void physical_handle_port_binding_changes( - struct ovsdb_idl_index *sbrec_port_binding_by_name, - const struct sbrec_port_binding_table *, - enum mf_field_id mff_ovn_geneve, - const struct sbrec_chassis *, - const struct simap *ct_zones, - struct hmap *local_datapaths, - struct sset *active_tunnels, - struct ovn_desired_flow_table *); +void physical_run(struct physical_ctx *); +void physical_handle_port_binding_changes(struct physical_ctx *); -void physical_handle_mc_group_changes( - const struct sbrec_multicast_group_table *, - enum mf_field_id mff_ovn_geneve, - const struct sbrec_chassis *, - const struct simap *ct_zones, - const struct hmap *local_datapaths, - struct ovn_desired_flow_table *); +void physical_handle_mc_group_changes(struct physical_ctx *); #endif /* controller/physical.h */