From patchwork Tue Feb 18 23:32:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1240408 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Mcb41hlmz9sRR for ; Wed, 19 Feb 2020 10:32:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 2743A87634; Tue, 18 Feb 2020 23:32:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ItIuqTOAHFBk; Tue, 18 Feb 2020 23:32:29 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 4C68381CEE; Tue, 18 Feb 2020 23:32:29 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2B333C08A0; Tue, 18 Feb 2020 23:32:29 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id BEEACC013E for ; Tue, 18 Feb 2020 23:32:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A85188634E for ; Tue, 18 Feb 2020 23:32:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dvK94OIZ0KI1 for ; Tue, 18 Feb 2020 23:32:26 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by whitealder.osuosl.org (Postfix) with ESMTPS id 1456981F3F for ; Tue, 18 Feb 2020 23:32:25 +0000 (UTC) Received: from localhost.localdomain.localdomain (unknown [216.113.160.77]) (Authenticated sender: hzhou@ovn.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id B29C5200009; Tue, 18 Feb 2020 23:32:22 +0000 (UTC) From: Han Zhou To: dev@openvswitch.org Date: Tue, 18 Feb 2020 15:32:14 -0800 Message-Id: <1582068734-70719-1-git-send-email-hzhou@ovn.org> X-Mailer: git-send-email 2.1.0 Cc: Han Zhou Subject: [ovs-dev] [PATCH ovn] ovn-controller.c: Avoid adding neighbour flows for non-local datapaths. 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: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This is usefule when external_ids:ovn-monitor-all is set to true. Signed-off-by: Han Zhou Acked-by: Dumitru Ceara --- controller/lflow.c | 15 +++++++++++---- controller/lflow.h | 1 + controller/ovn-controller.c | 6 +++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/controller/lflow.c b/controller/lflow.c index 79d8913..3c10a16 100644 --- a/controller/lflow.c +++ b/controller/lflow.c @@ -792,12 +792,14 @@ put_load(const uint8_t *data, size_t len, static void consider_neighbor_flow(struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct hmap *local_datapaths, const struct sbrec_mac_binding *b, struct ovn_desired_flow_table *flow_table) { const struct sbrec_port_binding *pb = lport_lookup_by_name(sbrec_port_binding_by_name, b->logical_port); - if (!pb) { + if (!pb || !get_local_datapath(local_datapaths, + pb->datapath->tunnel_key)) { return; } @@ -869,11 +871,13 @@ consider_neighbor_flow(struct ovsdb_idl_index *sbrec_port_binding_by_name, static void add_neighbor_flows(struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct sbrec_mac_binding_table *mac_binding_table, + const struct hmap *local_datapaths, struct ovn_desired_flow_table *flow_table) { const struct sbrec_mac_binding *b; SBREC_MAC_BINDING_TABLE_FOR_EACH (b, mac_binding_table) { - consider_neighbor_flow(sbrec_port_binding_by_name, b, flow_table); + consider_neighbor_flow(sbrec_port_binding_by_name, local_datapaths, + b, flow_table); } } @@ -882,6 +886,7 @@ void lflow_handle_changed_neighbors( struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct sbrec_mac_binding_table *mac_binding_table, + const struct hmap *local_datapaths, struct ovn_desired_flow_table *flow_table) { const struct sbrec_mac_binding *mb; @@ -904,7 +909,8 @@ lflow_handle_changed_neighbors( } VLOG_DBG("handle new mac_binding "UUID_FMT, UUID_ARGS(&mb->header_.uuid)); - consider_neighbor_flow(sbrec_port_binding_by_name, mb, flow_table); + consider_neighbor_flow(sbrec_port_binding_by_name, local_datapaths, + mb, flow_table); } } } @@ -934,7 +940,8 @@ lflow_run(struct lflow_ctx_in *l_ctx_in, struct lflow_ctx_out *l_ctx_out) add_logical_flows(l_ctx_in, l_ctx_out); add_neighbor_flows(l_ctx_in->sbrec_port_binding_by_name, - l_ctx_in->mac_binding_table, l_ctx_out->flow_table); + l_ctx_in->mac_binding_table, l_ctx_in->local_datapaths, + l_ctx_out->flow_table); } void diff --git a/controller/lflow.h b/controller/lflow.h index 8433cc0..f02f709 100644 --- a/controller/lflow.h +++ b/controller/lflow.h @@ -150,6 +150,7 @@ bool lflow_handle_changed_ref(enum ref_type, const char *ref_name, void lflow_handle_changed_neighbors( struct ovsdb_idl_index *sbrec_port_binding_by_name, const struct sbrec_mac_binding_table *, + const struct hmap *local_datapaths, struct ovn_desired_flow_table *); void lflow_destroy(void); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 4d245ca..e7773b8 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1504,11 +1504,15 @@ flow_output_sb_mac_binding_handler(struct engine_node *node, void *data) (struct sbrec_mac_binding_table *)EN_OVSDB_GET( engine_get_input("SB_mac_binding", node)); + struct ed_type_runtime_data *rt_data = + engine_get_input_data("runtime_data", node); + const struct hmap *local_datapaths = &rt_data->local_datapaths; + struct ed_type_flow_output *fo = data; struct ovn_desired_flow_table *flow_table = &fo->flow_table; lflow_handle_changed_neighbors(sbrec_port_binding_by_name, - mac_binding_table, flow_table); + mac_binding_table, local_datapaths, flow_table); engine_set_node_state(node, EN_UPDATED); return true;