Signed-off-by: Felix Huettner <[email protected]>
---
northd/en-lflow.c | 1 +
northd/en-routes-sync.c | 49 ++++++++++++++++++++++++++++++++++++----
northd/en-routes-sync.h | 20 +++++++++++++++-
northd/inc-proc-northd.c | 5 ++--
northd/northd.h | 4 ----
5 files changed, 67 insertions(+), 12 deletions(-)
diff --git a/northd/en-lflow.c b/northd/en-lflow.c
index 8995f0300..aabba943e 100644
--- a/northd/en-lflow.c
+++ b/northd/en-lflow.c
@@ -26,6 +26,7 @@
#include "en-northd.h"
#include "en-meters.h"
#include "en-sampling-app.h"
+#include "en-routes-sync.h"
#include "lflow-mgr.h"
#include "lib/inc-proc-eng.h"
diff --git a/northd/en-routes-sync.c b/northd/en-routes-sync.c
index f53d581ab..844e60e9c 100644
--- a/northd/en-routes-sync.c
+++ b/northd/en-routes-sync.c
@@ -35,12 +35,14 @@ routes_table_sync(struct ovsdb_idl_txn *ovnsb_txn,
const struct hmap *parsed_routes,
const struct hmap *lr_ports,
const struct ovn_datapaths *lr_datapaths,
- struct hmap *parsed_routes_out);
+ struct hmap *parsed_routes_out,
+ struct routes_sync_tracked_data *trk_data);
static void
routes_sync_init(struct routes_sync_data *data)
{
hmap_init(&data->parsed_routes);
+ uuidset_init(&data->trk_data.nb_lr_stateful);
}
static void
@@ -51,6 +53,7 @@ routes_sync_destroy(struct routes_sync_data *data)
parsed_route_free(r);
}
hmap_destroy(&data->parsed_routes);
+ uuidset_destroy(&data->trk_data.nb_lr_stateful);
}
bool
@@ -76,6 +79,30 @@ routes_sync_northd_change_handler(struct engine_node *node,
return true;
}
+bool
+routes_sync_lr_stateful_change_handler(struct engine_node *node,
+ void *data_)
+{
+ /* We only actually use lr_stateful data if we expose individual host
+ * routes. In this case we for now just recompute.
+ * */
+ struct ed_type_lr_stateful *lr_stateful_data =
+ engine_get_input_data("lr_stateful", node);
+ struct routes_sync_data *data = data_;
+
+ struct hmapx_node *hmapx_node;
+ const struct lr_stateful_record *lr_stateful_rec;
+ HMAPX_FOR_EACH (hmapx_node, &lr_stateful_data->trk_data.crupdated) {
+ lr_stateful_rec = hmapx_node->data;
+ if (uuidset_contains(&data->trk_data.nb_lr_stateful,
+ &lr_stateful_rec->nbr_uuid)) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
void
*en_routes_sync_init(struct engine_node *node OVS_UNUSED,
struct engine_arg *arg OVS_UNUSED)
@@ -91,6 +118,13 @@ en_routes_sync_cleanup(void *data)
routes_sync_destroy(data);
}
+void
+en_routes_sync_clear_tracked_data(void *data_)
+{
+ struct routes_sync_data *data = data_;
+ uuidset_clear(&data->trk_data.nb_lr_stateful);
+}
+
void
en_routes_sync_run(struct engine_node *node, void *data)
{
@@ -114,7 +148,8 @@ en_routes_sync_run(struct engine_node *node, void *data)
&routes_data->parsed_routes,
&northd_data->lr_ports,
&northd_data->lr_datapaths,
- &routes_sync_data->parsed_routes);
+ &routes_sync_data->parsed_routes,
+ &routes_sync_data->trk_data);
stopwatch_stop(ROUTES_SYNC_RUN_STOPWATCH_NAME, time_msec());
engine_set_node_state(node, EN_UPDATED);
@@ -367,7 +402,8 @@ static void
publish_host_routes(struct ovsdb_idl_txn *ovnsb_txn,
struct hmap *route_map,
const struct lr_stateful_table *lr_stateful_table,
- const struct parsed_route *route)
+ const struct parsed_route *route,
+ struct routes_sync_tracked_data *trk_data)
{
struct ovn_port *port;
HMAP_FOR_EACH (port, dp_node, &route->out_port->peer->od->ports) {
@@ -381,6 +417,8 @@ publish_host_routes(struct ovsdb_idl_txn *ovnsb_txn,
const struct lr_stateful_record *lr_stateful_rec;
lr_stateful_rec = lr_stateful_table_find_by_index(
lr_stateful_table, port->peer->od->index);
+ uuidset_insert(&trk_data->nb_lr_stateful,
+ &lr_stateful_rec->nbr_uuid);
struct ovn_port_routable_addresses addrs = get_op_addresses(
port->peer, lr_stateful_rec, false);
for (int i = 0; i < addrs.n_addrs; i++) {
@@ -409,7 +447,8 @@ routes_table_sync(struct ovsdb_idl_txn *ovnsb_txn,
const struct hmap *parsed_routes,
const struct hmap *lr_ports,
const struct ovn_datapaths *lr_datapaths,
- struct hmap *parsed_routes_out)
+ struct hmap *parsed_routes_out,
+ struct routes_sync_tracked_data *trk_data)
{
if (!ovnsb_txn) {
return;
@@ -466,7 +505,7 @@ routes_table_sync(struct ovsdb_idl_txn *ovnsb_txn,
"dynamic-routing-connected-as-host-routes",
false)) {
publish_host_routes(ovnsb_txn, &sync_routes,
- lr_stateful_table, route);
+ lr_stateful_table, route, trk_data);
} else {
char *ip_prefix = normalize_v46_prefix(&route->prefix,
route->plen);
diff --git a/northd/en-routes-sync.h b/northd/en-routes-sync.h
index 391f17452..3b51b5e56 100644
--- a/northd/en-routes-sync.h
+++ b/northd/en-routes-sync.h
@@ -15,11 +15,29 @@
#define EN_ROUTES_SYNC_H 1
#include "lib/inc-proc-eng.h"
+#include "lib/uuidset.h"
+#include "openvswitch/hmap.h"
+
+struct routes_sync_tracked_data {
+ /* Contains the uuids of all NB Logical Routers where we used a
+ * lr_stateful_record during computation. */
+ struct uuidset nb_lr_stateful;
+};
+
+struct routes_sync_data {
+ struct hmap parsed_routes;
+
+ /* Node's tracked data. */
+ struct routes_sync_tracked_data trk_data;
+};
bool routes_sync_northd_change_handler(struct engine_node *node,
- void *data OVS_UNUSED);
+ void *data);
+bool routes_sync_lr_stateful_change_handler(struct engine_node *node,
+ void *data);
void *en_routes_sync_init(struct engine_node *, struct engine_arg *);
void en_routes_sync_cleanup(void *data);
+void en_routes_sync_clear_tracked_data(void *data);
void en_routes_sync_run(struct engine_node *, void *data);
diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
index ad4a25fa0..99318c633 100644
--- a/northd/inc-proc-northd.c
+++ b/northd/inc-proc-northd.c
@@ -164,7 +164,7 @@ static ENGINE_NODE(route_policies, "route_policies");
static ENGINE_NODE(routes, "routes");
static ENGINE_NODE(bfd, "bfd");
static ENGINE_NODE(bfd_sync, "bfd_sync");
-static ENGINE_NODE(routes_sync, "routes_sync");
+static ENGINE_NODE_WITH_CLEAR_TRACK_DATA(routes_sync, "routes_sync");
void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
struct ovsdb_idl_loop *sb)
@@ -272,7 +272,8 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
engine_add_input(&en_routes_sync, &en_sb_route, NULL);
engine_add_input(&en_routes_sync, &en_northd,
routes_sync_northd_change_handler);
- engine_add_input(&en_routes_sync, &en_lr_stateful, NULL);
+ engine_add_input(&en_routes_sync, &en_lr_stateful,
+ routes_sync_lr_stateful_change_handler);
engine_add_input(&en_sync_meters, &en_nb_acl, NULL);
engine_add_input(&en_sync_meters, &en_nb_meter, NULL);
diff --git a/northd/northd.h b/northd/northd.h
index 4f21c4f28..75ad86973 100644
--- a/northd/northd.h
+++ b/northd/northd.h
@@ -188,10 +188,6 @@ struct routes_data {
struct hmap bfd_active_connections;
};
-struct routes_sync_data {
- struct hmap parsed_routes;
-};
-
struct route_policies_data {
struct hmap route_policies;
struct hmap bfd_active_connections;
--
2.47.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev