[ovs-dev] [PATCH ovn] ovn-controller.c: Avoid adding neighbour flows for non-local datapaths.
Han Zhou
hzhou at ovn.org
Tue Feb 18 23:32:14 UTC 2020
This is usefule when external_ids:ovn-monitor-all is set to true.
Signed-off-by: Han Zhou <hzhou at ovn.org>
---
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;
--
2.1.0
More information about the dev
mailing list