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 <lorenzo.bianc...@redhat.com> --- 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 4cb46b346..d24672b82 100644 --- a/lib/lb.c +++ b/lib/lb.c @@ -245,6 +245,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) { @@ -258,6 +268,7 @@ ovn_northd_lb_destroy(struct ovn_northd_lb *lb) sset_destroy(&lb->ips_v6); free(lb->selection_fields); free(lb->dps); + free(lb->nb_lr); free(lb); } diff --git a/lib/lb.h b/lib/lb.h index 58e6bb031..4e8fd6604 100644 --- a/lib/lb.h +++ b/lib/lb.h @@ -45,6 +45,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 { @@ -85,6 +89,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 6e182b1cb..f23b299d8 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -3414,6 +3414,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 d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev