+ }
+}
+
void
ovn_lb_datapaths_add_lr(struct ovn_lb_datapaths *lb_dps, size_t n,
- struct ovn_datapath **ods)
+ struct ovn_datapath **ods,
+ size_t n_lr_datapaths)
{
+ dynamic_bitmap_realloc(&lb_dps->nb_lr_map, n_lr_datapaths);
for (size_t i = 0; i < n; i++) {
+ ovs_assert(ods[i]->index < lb_dps->nb_lr_map.capacity);
if (!bitmap_is_set(lb_dps->nb_lr_map.map, ods[i]->index)) {
bitmap_set1(lb_dps->nb_lr_map.map, ods[i]->index);
lb_dps->nb_lr_map.n_elems++;
@@ -609,9 +623,12 @@ ovn_lb_datapaths_add_lr(struct ovn_lb_datapaths *lb_dps,
size_t n,
void
ovn_lb_datapaths_add_ls(struct ovn_lb_datapaths *lb_dps, size_t n,
- struct ovn_datapath **ods)
+ struct ovn_datapath **ods,
+ size_t n_ls_datapaths)
{
+ dynamic_bitmap_realloc(&lb_dps->nb_ls_map, n_ls_datapaths);
for (size_t i = 0; i < n; i++) {
+ ovs_assert(ods[i]->index < lb_dps->nb_ls_map.capacity);
if (!bitmap_is_set(lb_dps->nb_ls_map.map, ods[i]->index)) {
bitmap_set1(lb_dps->nb_ls_map.map, ods[i]->index);
lb_dps->nb_ls_map.n_elems++;
@@ -643,6 +660,8 @@ ovn_lb_group_datapaths_create(const struct ovn_lb_group
*lb_group,
lb_group_dps->lb_group = lb_group;
lb_group_dps->ls = xmalloc(max_ls_datapaths * sizeof *lb_group_dps->ls);
lb_group_dps->lr = xmalloc(max_lr_datapaths * sizeof *lb_group_dps->lr);
+ lb_group_dps->max_lr = max_ls_datapaths;
+ lb_group_dps->max_lr = max_lr_datapaths;
return lb_group_dps;
}
diff --git a/northd/lb.h b/northd/lb.h
index 1d6152a1d..be9f9a837 100644
--- a/northd/lb.h
+++ b/northd/lb.h
@@ -185,9 +185,11 @@ struct ovn_lb_datapaths *ovn_lb_datapaths_find(const
struct hmap *,
void ovn_lb_datapaths_destroy(struct ovn_lb_datapaths *);
void ovn_lb_datapaths_add_lr(struct ovn_lb_datapaths *, size_t n,
- struct ovn_datapath **);
+ struct ovn_datapath **,
+ size_t n_lr_datapaths);
void ovn_lb_datapaths_add_ls(struct ovn_lb_datapaths *, size_t n,
- struct ovn_datapath **);
+ struct ovn_datapath **,
+ size_t n_ls_datapaths);
struct ovn_lb_group_datapaths {
struct hmap_node hmap_node;
@@ -196,8 +198,10 @@ struct ovn_lb_group_datapaths {
/* Datapaths to which 'lb_group' is applied. */
size_t n_ls;
+ size_t max_ls;
struct ovn_datapath **ls;
size_t n_lr;
+ size_t max_lr;
struct ovn_datapath **lr;
};
@@ -211,16 +215,26 @@ struct ovn_lb_group_datapaths *ovn_lb_group_datapaths_find(
static inline void
ovn_lb_group_datapaths_add_ls(struct ovn_lb_group_datapaths *lbg_dps, size_t
n,
- struct ovn_datapath **ods)
+ struct ovn_datapath **ods, size_t n_ls_datapaths)
{
+ if (n_ls_datapaths > lbg_dps->max_ls) {
+ lbg_dps->ls = xrealloc(lbg_dps->ls,
+ n_ls_datapaths * sizeof *lbg_dps->ls);
+ lbg_dps->max_ls = n_ls_datapaths;
+ }
diff --git a/northd/northd.c b/northd/northd.c
index 95cd67a5a..e4125606a 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -3669,7 +3669,7 @@ build_lb_datapaths(const struct hmap *lbs, const struct
hmap *lb_groups,
&od->nbs->load_balancer[i]->header_.uuid;
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, lb_uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_ls(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_ls(lb_dps, 1, &od, ods_size(ls_datapaths));
if (od->lb_with_stateless_mode) {
hmapx_add(&lb_dps->ls_lb_with_stateless_mode, od);
}
@@ -3682,7 +3682,8 @@ build_lb_datapaths(const struct hmap *lbs, const struct
hmap *lb_groups,
ovn_lb_group_datapaths_find(lb_group_datapaths_map,
lb_group_uuid);
ovs_assert(lb_group_dps);
- ovn_lb_group_datapaths_add_ls(lb_group_dps, 1, &od);
+ ovn_lb_group_datapaths_add_ls(lb_group_dps, 1, &od,
+ ods_size(ls_datapaths));
}
}
@@ -3697,7 +3698,8 @@ build_lb_datapaths(const struct hmap *lbs, const struct hmap *lb_groups,
ovn_lb_group_datapaths_find(lb_group_datapaths_map,
lb_group_uuid);
ovs_assert(lb_group_dps);
- ovn_lb_group_datapaths_add_lr(lb_group_dps, od);
+ ovn_lb_group_datapaths_add_lr(lb_group_dps, od,
+ ods_size(lr_datapaths));
}
for (size_t i = 0; i < od->nbr->n_load_balancer; i++) {
@@ -3705,7 +3707,7 @@ build_lb_datapaths(const struct hmap *lbs, const struct
hmap *lb_groups,
&od->nbr->load_balancer[i]->header_.uuid;
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, lb_uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_lr(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_lr(lb_dps, 1, &od, ods_size(lr_datapaths));
}
}
@@ -3716,9 +3718,11 @@ build_lb_datapaths(const struct hmap *lbs, const struct hmap *lb_groups,
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, lb_uuid);
ovs_assert(lb_dps);
ovn_lb_datapaths_add_ls(lb_dps, lb_group_dps->n_ls,
- lb_group_dps->ls);
+ lb_group_dps->ls,
+ ods_size(ls_datapaths));
ovn_lb_datapaths_add_lr(lb_dps, lb_group_dps->n_lr,
- lb_group_dps->lr);
+ lb_group_dps->lr,
+ ods_size(lr_datapaths));
}
}
}
@@ -3764,6 +3768,7 @@ build_lb_svcs(
static void
build_lswitch_lbs_from_lrouter(struct ovn_datapaths *lr_datapaths,
+ struct ovn_datapaths *ls_datapaths,
struct hmap *lb_dps_map,
struct hmap *lb_group_dps_map)
{
@@ -3779,7 +3784,8 @@ build_lswitch_lbs_from_lrouter(struct ovn_datapaths
*lr_datapaths,
lb_dps->nb_lr_map.map) {
struct ovn_datapath *od = lr_datapaths->array[index];
ovn_lb_datapaths_add_ls(lb_dps, vector_len(&od->ls_peers),
- vector_get_array(&od->ls_peers));
+ vector_get_array(&od->ls_peers),
+ ods_size(ls_datapaths));
}
}
@@ -3789,14 +3795,15 @@ build_lswitch_lbs_from_lrouter(struct ovn_datapaths *lr_datapaths,
struct ovn_datapath *od = lb_group_dps->lr[i];
ovn_lb_group_datapaths_add_ls(lb_group_dps,
vector_len(&od->ls_peers),
- vector_get_array(&od->ls_peers));
+ vector_get_array(&od->ls_peers), 0);
for (size_t j = 0; j < lb_group_dps->lb_group->n_lbs; j++) {
const struct uuid *lb_uuid =
&lb_group_dps->lb_group->lbs[j]->nlb->header_.uuid;
lb_dps = ovn_lb_datapaths_find(lb_dps_map, lb_uuid);
ovs_assert(lb_dps);
ovn_lb_datapaths_add_ls(lb_dps, vector_len(&od->ls_peers),
- vector_get_array(&od->ls_peers));
+ vector_get_array(&od->ls_peers),
+ ods_size(ls_datapaths));
}
}
}
@@ -3827,7 +3834,9 @@ build_lb_port_related_data(
const struct sbrec_service_monitor_table *sbrec_service_monitor_table,
const char *svc_monitor_mac,
const struct eth_addr *svc_monitor_mac_ea,
- struct ovn_datapaths *lr_datapaths, struct hmap *ls_ports,
+ struct ovn_datapaths *lr_datapaths,
+ struct ovn_datapaths *ls_datapaths,
+ struct hmap *ls_ports,
struct hmap *lb_dps_map, struct hmap *lb_group_dps_map,
struct sset *svc_monitor_lsps,
struct hmap *svc_monitor_map)
@@ -3835,7 +3844,8 @@ build_lb_port_related_data(
build_lb_svcs(ovnsb_txn, sbrec_service_monitor_table, svc_monitor_mac,
svc_monitor_mac_ea, ls_ports, lb_dps_map,
svc_monitor_lsps, svc_monitor_map);
- build_lswitch_lbs_from_lrouter(lr_datapaths, lb_dps_map, lb_group_dps_map);
+ build_lswitch_lbs_from_lrouter(lr_datapaths, ls_datapaths, lb_dps_map,
+ lb_group_dps_map);
}
/* Returns true if the peer port IPs of op should be added in the nat_addresses
@@ -5324,7 +5334,7 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
UUIDSET_FOR_EACH (uuidnode, &codlb->assoc_lbs) {
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, &uuidnode->uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_ls(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_ls(lb_dps, 1, &od, ods_size(ls_datapaths));
if (od->lb_with_stateless_mode) {
hmapx_add(&lb_dps->ls_lb_with_stateless_mode, od);
@@ -5338,7 +5348,8 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
lbgrp_dps = ovn_lb_group_datapaths_find(lbgrp_datapaths_map,
&uuidnode->uuid);
ovs_assert(lbgrp_dps);
- ovn_lb_group_datapaths_add_ls(lbgrp_dps, 1, &od);
+ ovn_lb_group_datapaths_add_ls(lbgrp_dps, 1, &od,
+ ods_size(ls_datapaths));
/* Associate all the lbs of the lbgrp to the datapath 'od' */
for (size_t j = 0; j < lbgrp_dps->lb_group->n_lbs; j++) {
@@ -5346,7 +5357,8 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
= &lbgrp_dps->lb_group->lbs[j]->nlb->header_.uuid;
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, lb_uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_ls(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_ls(lb_dps, 1, &od,
+ ods_size(ls_datapaths));
/* Add the lb to the northd tracked data. */
hmapx_add(&nd_changes->trk_lbs.crupdated, lb_dps);
@@ -5365,7 +5377,7 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
UUIDSET_FOR_EACH (uuidnode, &codlb->assoc_lbs) {
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, &uuidnode->uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_lr(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_lr(lb_dps, 1, &od, ods_size(lr_datapaths));
/* Add the lb to the northd tracked data. */
hmapx_add(&nd_changes->trk_lbs.crupdated, lb_dps);
@@ -5375,7 +5387,8 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
lbgrp_dps = ovn_lb_group_datapaths_find(lbgrp_datapaths_map,
&uuidnode->uuid);
ovs_assert(lbgrp_dps);
- ovn_lb_group_datapaths_add_lr(lbgrp_dps, od);
+ ovn_lb_group_datapaths_add_lr(lbgrp_dps, od,
+ ods_size(lr_datapaths));
/* Associate all the lbs of the lbgrp to the datapath 'od' */
for (size_t j = 0; j < lbgrp_dps->lb_group->n_lbs; j++) {
@@ -5383,7 +5396,8 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
= &lbgrp_dps->lb_group->lbs[j]->nlb->header_.uuid;
lb_dps = ovn_lb_datapaths_find(lb_datapaths_map, lb_uuid);
ovs_assert(lb_dps);
- ovn_lb_datapaths_add_lr(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_lr(lb_dps, 1, &od,
+ ods_size(lr_datapaths));
/* Add the lb to the northd tracked data. */
hmapx_add(&nd_changes->trk_lbs.crupdated, lb_dps);
@@ -5424,12 +5438,14 @@ northd_handle_lb_data_changes(struct tracked_lb_data
*trk_lb_data,
ovs_assert(lb_dps);
for (size_t i = 0; i < lbgrp_dps->n_lr; i++) {
od = lbgrp_dps->lr[i];
- ovn_lb_datapaths_add_lr(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_lr(lb_dps, 1, &od,
+ ods_size(lr_datapaths));
}
for (size_t i = 0; i < lbgrp_dps->n_ls; i++) {
od = lbgrp_dps->ls[i];
- ovn_lb_datapaths_add_ls(lb_dps, 1, &od);
+ ovn_lb_datapaths_add_ls(lb_dps, 1, &od,
+ ods_size(ls_datapaths));
/* Add the ls datapath to the northd tracked data. */
hmapx_add(&nd_changes->ls_with_changed_lbs, od);
@@ -19215,7 +19231,9 @@ ovnnb_db_run(struct northd_input *input_data,
input_data->sbrec_service_monitor_table,
input_data->svc_monitor_mac,
&input_data->svc_monitor_mac_ea,
- &data->lr_datapaths, &data->ls_ports,
+ &data->lr_datapaths,
+ &data->ls_datapaths,
+ &data->ls_ports,
&data->lb_datapaths_map,
&data->lb_group_datapaths_map,
&data->svc_monitor_lsps,