add logical routers datapath references in ovn_northd_lb data structure. This is a preliminary patch to invert the logic used during the lb flow creation in order to visit lb first and then related datapath.
Signed-off-by: Lorenzo Bianconi <[email protected]> --- lib/lb.c | 11 +++++++++++ lib/lb.h | 6 ++++++ northd/ovn-northd.c | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/lib/lb.c b/lib/lb.c index f305e9a87..89a8bb794 100644 --- a/lib/lb.c +++ b/lib/lb.c @@ -271,6 +271,16 @@ ovn_northd_lb_add_datapath(struct ovn_northd_lb *lb, lb->dps[lb->n_dps++] = sb; } +void +ovn_northd_lb_add_lr(struct ovn_northd_lb *lb, struct ovn_datapath *od) +{ + if (lb->n_allocated_nb_lr == lb->n_nb_lr) { + lb->nb_lr = x2nrealloc(lb->nb_lr, &lb->n_allocated_nb_lr, + sizeof *lb->nb_lr); + } + lb->nb_lr[lb->n_nb_lr++] = od; +} + void ovn_northd_lb_destroy(struct ovn_northd_lb *lb) { @@ -283,6 +293,7 @@ ovn_northd_lb_destroy(struct ovn_northd_lb *lb) free(lb->selection_fields); destroy_lport_addresses(&lb->hairpin_snat_ips); free(lb->dps); + free(lb->nb_lr); free(lb); } diff --git a/lib/lb.h b/lib/lb.h index 9a78c72f3..cc4942bcf 100644 --- a/lib/lb.h +++ b/lib/lb.h @@ -46,6 +46,10 @@ struct ovn_northd_lb { size_t n_dps; size_t n_allocated_dps; const struct sbrec_datapath_binding **dps; + + size_t n_nb_lr; + size_t n_allocated_nb_lr; + struct ovn_datapath **nb_lr; }; struct ovn_lb_vip { @@ -89,6 +93,8 @@ struct ovn_northd_lb * ovn_northd_lb_find(struct hmap *, const struct uuid *); void ovn_northd_lb_destroy(struct ovn_northd_lb *); void ovn_northd_lb_add_datapath(struct ovn_northd_lb *, const struct sbrec_datapath_binding *); +void +ovn_northd_lb_add_lr(struct ovn_northd_lb *lb, struct ovn_datapath *od); struct ovn_controller_lb { const struct sbrec_load_balancer *slb; /* May be NULL. */ diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index da4ac2b32..35d205eab 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -3436,6 +3436,23 @@ build_ovn_lbs(struct northd_context *ctx, struct hmap *datapaths, } } + HMAP_FOR_EACH (od, key_node, datapaths) { + if (!od->nbr) { + continue; + } + if (!smap_get(&od->nbr->options, "chassis") && !od->l3dgw_port) { + continue; + } + + for (size_t i = 0; i < od->nbr->n_load_balancer; i++) { + const struct uuid *lb_uuid = + &od->nbr->load_balancer[i]->header_.uuid; + lb = ovn_northd_lb_find(lbs, lb_uuid); + + ovn_northd_lb_add_lr(lb, od); + } + } + /* Delete any stale SB load balancer rows. */ const struct sbrec_load_balancer *sbrec_lb, *next; SBREC_LOAD_BALANCER_FOR_EACH_SAFE (sbrec_lb, next, ctx->ovnsb_idl) { -- 2.31.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
