Message ID | 20230818085713.1030920-1-numans@ovn.org |
---|---|
State | Accepted |
Headers | show |
Series | northd: I-P for load balancer and lb groups | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/github-robot-_ovn-kubernetes | success | github build: passed |
On Fri, Aug 18, 2023 at 1:57 AM <numans@ovn.org> wrote: > > From: Numan Siddique <numans@ovn.org> > > Similar to the commit [1], a new sub-engine node "sync_to_sb_lb" > is added with-in the "sync_to_sb" to sync the SB load balancers. > Its main input nodes are "northd" (to access the "lbs" hmap built > by this node) and "sb_load_balancer" to access the SB load balancer. > "sync_to_sb_lb" doesn't add any handlers and falls back to full > recompute all the time. > > [1] - ccafcc2dc321("northd I-P: Add a new engine node 'en_sync_to_sb' to sync SB tables.") > > Signed-off-by: Numan Siddique <numans@ovn.org> > --- > northd/en-northd.c | 2 -- > northd/en-sync-sb.c | 43 ++++++++++++++++++++++++++++++++++++++++ > northd/en-sync-sb.h | 6 ++++++ > northd/inc-proc-northd.c | 10 ++++++++-- > northd/northd.c | 4 +--- > northd/northd.h | 6 +++++- > tests/ovn-northd.at | 23 +++++++++++++++++++++ > 7 files changed, 86 insertions(+), 8 deletions(-) > > diff --git a/northd/en-northd.c b/northd/en-northd.c > index 044fa70190..f9f2d04452 100644 > --- a/northd/en-northd.c > +++ b/northd/en-northd.c > @@ -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 = > diff --git a/northd/en-sync-sb.c b/northd/en-sync-sb.c > index d7fea981f2..dbe3c63752 100644 > --- a/northd/en-sync-sb.c > +++ b/northd/en-sync-sb.c > @@ -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, > diff --git a/northd/en-sync-sb.h b/northd/en-sync-sb.h > index bcb9799d24..06d2a57710 100644 > --- a/northd/en-sync-sb.h > +++ b/northd/en-sync-sb.h > @@ -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 */ > diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c > index d328deb222..c0874d5294 100644 > --- a/northd/inc-proc-northd.c > +++ b/northd/inc-proc-northd.c > @@ -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); > diff --git a/northd/northd.c b/northd/northd.c > index 0a749931ee..a3bce551bc 100644 > --- a/northd/northd.c > +++ b/northd/northd.c > @@ -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) > @@ -17619,8 +17619,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, > diff --git a/northd/northd.h b/northd/northd.h > index f3e63b1e1a..48c282476a 100644 > --- a/northd/northd.h > +++ b/northd/northd.h > @@ -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 */ > diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at > index d5be3be75b..9e36f96182 100644 > --- a/tests/ovn-northd.at > +++ b/tests/ovn-northd.at > @@ -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 > -- > 2.40.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev Acked-by: Han Zhou <hzhou@ovn.org>
On Fri, Aug 18, 2023 at 10:57 AM <numans@ovn.org> wrote: > > From: Numan Siddique <numans@ovn.org> > > Similar to the commit [1], a new sub-engine node "sync_to_sb_lb" > is added with-in the "sync_to_sb" to sync the SB load balancers. > Its main input nodes are "northd" (to access the "lbs" hmap built > by this node) and "sb_load_balancer" to access the SB load balancer. > "sync_to_sb_lb" doesn't add any handlers and falls back to full > recompute all the time. > > [1] - ccafcc2dc321("northd I-P: Add a new engine node 'en_sync_to_sb' to sync SB tables.") > > Signed-off-by: Numan Siddique <numans@ovn.org> > --- > northd/en-northd.c | 2 -- > northd/en-sync-sb.c | 43 ++++++++++++++++++++++++++++++++++++++++ > northd/en-sync-sb.h | 6 ++++++ > northd/inc-proc-northd.c | 10 ++++++++-- > northd/northd.c | 4 +--- > northd/northd.h | 6 +++++- > tests/ovn-northd.at | 23 +++++++++++++++++++++ > 7 files changed, 86 insertions(+), 8 deletions(-) > > diff --git a/northd/en-northd.c b/northd/en-northd.c > index 044fa70190..f9f2d04452 100644 > --- a/northd/en-northd.c > +++ b/northd/en-northd.c > @@ -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 = > diff --git a/northd/en-sync-sb.c b/northd/en-sync-sb.c > index d7fea981f2..dbe3c63752 100644 > --- a/northd/en-sync-sb.c > +++ b/northd/en-sync-sb.c > @@ -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, > diff --git a/northd/en-sync-sb.h b/northd/en-sync-sb.h > index bcb9799d24..06d2a57710 100644 > --- a/northd/en-sync-sb.h > +++ b/northd/en-sync-sb.h > @@ -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 */ > diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c > index d328deb222..c0874d5294 100644 > --- a/northd/inc-proc-northd.c > +++ b/northd/inc-proc-northd.c > @@ -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); > diff --git a/northd/northd.c b/northd/northd.c > index 0a749931ee..a3bce551bc 100644 > --- a/northd/northd.c > +++ b/northd/northd.c > @@ -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) > @@ -17619,8 +17619,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, > diff --git a/northd/northd.h b/northd/northd.h > index f3e63b1e1a..48c282476a 100644 > --- a/northd/northd.h > +++ b/northd/northd.h > @@ -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 */ > diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at > index d5be3be75b..9e36f96182 100644 > --- a/tests/ovn-northd.at > +++ b/tests/ovn-northd.at > @@ -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 > -- > 2.40.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > Looks good to me, thanks. Reviewed-by: Ales Musil <amusil@redhat.com>
diff --git a/northd/en-northd.c b/northd/en-northd.c index 044fa70190..f9f2d04452 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -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 = diff --git a/northd/en-sync-sb.c b/northd/en-sync-sb.c index d7fea981f2..dbe3c63752 100644 --- a/northd/en-sync-sb.c +++ b/northd/en-sync-sb.c @@ -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, diff --git a/northd/en-sync-sb.h b/northd/en-sync-sb.h index bcb9799d24..06d2a57710 100644 --- a/northd/en-sync-sb.h +++ b/northd/en-sync-sb.h @@ -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 */ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index d328deb222..c0874d5294 100644 --- a/northd/inc-proc-northd.c +++ b/northd/inc-proc-northd.c @@ -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); diff --git a/northd/northd.c b/northd/northd.c index 0a749931ee..a3bce551bc 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -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) @@ -17619,8 +17619,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, diff --git a/northd/northd.h b/northd/northd.h index f3e63b1e1a..48c282476a 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -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 */ diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index d5be3be75b..9e36f96182 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -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