@@ -101,8 +101,6 @@ northd_get_input_data(struct engine_node *node,
EN_OVSDB_GET(engine_get_input("SB_chassis", node));
input_data->sbrec_fdb_table =
EN_OVSDB_GET(engine_get_input("SB_fdb", node));
- input_data->sbrec_load_balancer_table =
- EN_OVSDB_GET(engine_get_input("SB_load_balancer", node));
input_data->sbrec_service_monitor_table =
EN_OVSDB_GET(engine_get_input("SB_service_monitor", node));
input_data->sbrec_port_group_table =
@@ -211,6 +211,49 @@ sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node,
return true;
}
+/* sync_to_sb_lb engine node functions.
+ * This engine node syncs the SB load balancers.
+ */
+void *
+en_sync_to_sb_lb_init(struct engine_node *node OVS_UNUSED,
+ struct engine_arg *arg OVS_UNUSED)
+{
+ return NULL;
+}
+
+void
+en_sync_to_sb_lb_run(struct engine_node *node, void *data OVS_UNUSED)
+{
+ const struct sbrec_load_balancer_table *sb_load_balancer_table =
+ EN_OVSDB_GET(engine_get_input("SB_load_balancer", node));
+ const struct engine_context *eng_ctx = engine_get_context();
+ struct northd_data *northd_data = engine_get_input_data("northd", node);
+
+ sync_lbs(eng_ctx->ovnsb_idl_txn, sb_load_balancer_table,
+ &northd_data->ls_datapaths, &northd_data->lbs);
+ engine_set_node_state(node, EN_UPDATED);
+}
+
+void
+en_sync_to_sb_lb_cleanup(void *data OVS_UNUSED)
+{
+
+}
+
+bool
+sync_to_sb_lb_northd_handler(struct engine_node *node, void *data OVS_UNUSED)
+{
+ struct northd_data *nd = engine_get_input_data("northd", node);
+ if (nd->change_tracked) {
+ /* There are only NB LSP related changes and these can be safely
+ * ignore and returned true. However in case the northd engine
+ * tracking data includes other changes, we need to do additional
+ * checks before safely ignoring. */
+ return true;
+ }
+ return false;
+}
+
/* static functions. */
static void
sync_addr_set(struct ovsdb_idl_txn *ovnsb_txn, const char *name,
@@ -16,4 +16,10 @@ bool sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *,
bool sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *,
void *data);
+
+void *en_sync_to_sb_lb_init(struct engine_node *, struct engine_arg *);
+void en_sync_to_sb_lb_run(struct engine_node *, void *data);
+void en_sync_to_sb_lb_cleanup(void *data);
+bool sync_to_sb_lb_northd_handler(struct engine_node *, void *data OVS_UNUSED);
+
#endif /* end of EN_SYNC_SB_H */
@@ -139,6 +139,7 @@ static ENGINE_NODE(sync_to_sb, "sync_to_sb");
static ENGINE_NODE(sync_to_sb_addr_set, "sync_to_sb_addr_set");
static ENGINE_NODE(fdb_aging, "fdb_aging");
static ENGINE_NODE(fdb_aging_waker, "fdb_aging_waker");
+static ENGINE_NODE(sync_to_sb_lb, "sync_to_sb_lb");
void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
struct ovsdb_idl_loop *sb)
@@ -166,7 +167,6 @@ 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_ip_multicast, 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_fdb, NULL);
engine_add_input(&en_northd, &en_sb_static_mac_binding, NULL);
engine_add_input(&en_northd, &en_sb_chassis_template_var, NULL);
@@ -202,11 +202,17 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
engine_add_input(&en_sync_to_sb_addr_set, &en_northd, NULL);
engine_add_input(&en_sync_to_sb_addr_set, &en_sb_address_set, NULL);
+ engine_add_input(&en_sync_to_sb_lb, &en_northd,
+ sync_to_sb_lb_northd_handler);
+ engine_add_input(&en_sync_to_sb_lb, &en_sb_load_balancer, NULL);
+
/* en_sync_to_sb engine node syncs the SB database tables from
* the NB database tables.
- * Right now this engine only syncs the SB Address_Set table.
+ * Right now this engine syncs the SB Address_Set table and
+ * SB Load_Balancer table.
*/
engine_add_input(&en_sync_to_sb, &en_sync_to_sb_addr_set, NULL);
+ engine_add_input(&en_sync_to_sb, &en_sync_to_sb_lb, NULL);
engine_add_input(&en_sync_from_sb, &en_northd,
sync_from_sb_northd_handler);
@@ -4538,7 +4538,7 @@ ovn_dp_group_get_or_create(struct ovsdb_idl_txn *ovnsb_txn,
/* Syncs relevant load balancers (applied to logical switches) to the
* Southbound database.
*/
-static void
+void
sync_lbs(struct ovsdb_idl_txn *ovnsb_txn,
const struct sbrec_load_balancer_table *sbrec_load_balancer_table,
struct ovn_datapaths *ls_datapaths, struct hmap *lbs)
@@ -17580,8 +17580,6 @@ ovnnb_db_run(struct northd_input *input_data,
ovn_update_ipv6_options(&data->lr_ports);
ovn_update_ipv6_prefix(&data->lr_ports);
- sync_lbs(ovnsb_txn, input_data->sbrec_load_balancer_table,
- &data->ls_datapaths, &data->lbs);
sync_port_groups(ovnsb_txn, input_data->sbrec_port_group_table,
&data->port_groups);
sync_meters(ovnsb_txn, input_data->nbrec_meter_table,
@@ -16,6 +16,7 @@
#include "ovsdb-idl.h"
+#include "lib/ovn-sb-idl.h"
#include "lib/ovn-util.h"
#include "lib/ovs-atomic.h"
#include "lib/sset.h"
@@ -47,7 +48,6 @@ struct northd_input {
const struct sbrec_ha_chassis_group_table *sbrec_ha_chassis_group_table;
const struct sbrec_chassis_table *sbrec_chassis_table;
const struct sbrec_fdb_table *sbrec_fdb_table;
- const struct sbrec_load_balancer_table *sbrec_load_balancer_table;
const struct sbrec_service_monitor_table *sbrec_service_monitor_table;
const struct sbrec_port_group_table *sbrec_port_group_table;
const struct sbrec_meter_table *sbrec_meter_table;
@@ -354,4 +354,8 @@ void bfd_cleanup_connections(const struct nbrec_bfd_table *,
void run_update_worker_pool(int n_threads);
const char *northd_get_svc_monitor_mac(void);
+
+void sync_lbs(struct ovsdb_idl_txn *, const struct sbrec_load_balancer_table *,
+ struct ovn_datapaths *ls_datapaths, struct hmap *lbs);
+
#endif /* NORTHD_H */
@@ -9512,6 +9512,29 @@ AT_CHECK([ovn-sbctl lflow-list sw | grep ls_out_pre_lb | grep priority=110 | gre
AT_CLEANUP
])
+
+# This test checks the compute/recompute stats of sync_to_sb_lb engine node
+OVN_FOR_EACH_NORTHD_NO_HV([
+AT_SETUP([sync_to_sb_lb incremental processing])
+ovn_start
+
+check ovn-nbctl ls-add sw
+check ovn-nbctl lsp-add sw p1
+
+check ovn-nbctl --wait=sb sync
+check as northd ovn-appctl -t NORTHD_TYPE inc-engine/clear-stats
+
+check ovn-nbctl --wait=sb lsp-set-options p1 foo=bar
+sb_lb_recomp=$(as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats sync_to_sb_lb recompute)
+AT_CHECK([test x$sb_lb_recomp = x0])
+
+check ovn-nbctl --wait=sb lsp-set-type p1 external
+sb_lb_recomp=$(as northd ovn-appctl -t NORTHD_TYPE inc-engine/show-stats sync_to_sb_lb recompute)
+AT_CHECK([test x$sb_lb_recomp != x0])
+
+AT_CLEANUP
+])
+
OVN_FOR_EACH_NORTHD_NO_HV([
AT_SETUP([LSP incremental processing])
ovn_start