Message ID | 20230707055252.961543-1-numans@ovn.org |
---|---|
State | Changes Requested |
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-_ovn-kubernetes | success | github build: passed |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
On Fri, Jul 7, 2023 at 1:53 PM <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 | 29 +++++++++++++++++++++++++++++ > northd/en-sync-sb.h | 5 +++++ > northd/inc-proc-northd.c | 9 +++++++-- > northd/northd.c | 4 +--- > northd/northd.h | 6 +++++- > 6 files changed, 47 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..821047581c 100644 > --- a/northd/en-sync-sb.c > +++ b/northd/en-sync-sb.c > @@ -211,6 +211,35 @@ 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) > +{ > + > +} > + > /* 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..b3bfb5454f 100644 > --- a/northd/en-sync-sb.h > +++ b/northd/en-sync-sb.h > @@ -16,4 +16,9 @@ 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); > + > #endif /* end of EN_SYNC_SB_H */ > diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c > index d328deb222..507348b719 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"); > nit: better to move closer to sync_to_sb node. > 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,16 @@ 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, NULL); A LSP (VIF) change will trigger northd change, which will trigger sync_to_sb_lb run() -> sync_lbs(), while before this change, it would not trigger sync_lbs(). Maybe sync_lbs() doesn't cost too much, but it would be better to avoid that by doing something similar to sync_from_sb_northd_handler(). (Something similar can be done to sync_to_sb_addr_set, but not directly related to this patch) Thanks, Han > + 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 b9605862e4..2390c159c3 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) > @@ -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, > 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 */ > -- > 2.40.1 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
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..821047581c 100644 --- a/northd/en-sync-sb.c +++ b/northd/en-sync-sb.c @@ -211,6 +211,35 @@ 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) +{ + +} + /* 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..b3bfb5454f 100644 --- a/northd/en-sync-sb.h +++ b/northd/en-sync-sb.h @@ -16,4 +16,9 @@ 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); + #endif /* end of EN_SYNC_SB_H */ diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c index d328deb222..507348b719 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,16 @@ 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, NULL); + 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 b9605862e4..2390c159c3 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) @@ -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, 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 */