Skip to content

Commit

Permalink
northd: Handle load balancer changes for a logical router.
Browse files Browse the repository at this point in the history
When a logical router gets updated due to load balancer
or load balancer groups changes, it is now incrementally
handled in the 'northd' engine node.  Other logical router
updates result in the full recompute of 'northd' engine node.

lflow engine node still falls back to recompute due to
logical router changes.

Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
numansiddique authored and igsilya committed Jul 18, 2023
1 parent 4cc8f9d commit cc90d97
Show file tree
Hide file tree
Showing 9 changed files with 422 additions and 53 deletions.
32 changes: 30 additions & 2 deletions lib/lb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,10 @@ ovn_lb_datapaths_add_lr(struct ovn_lb_datapaths *lb_dps, size_t n,
struct ovn_datapath **ods)
{
for (size_t i = 0; i < n; i++) {
bitmap_set1(lb_dps->nb_lr_map, ods[i]->index);
if (!bitmap_is_set(lb_dps->nb_lr_map, ods[i]->index)) {
bitmap_set1(lb_dps->nb_lr_map, ods[i]->index);
lb_dps->n_nb_lr++;
}
}
}

Expand Down Expand Up @@ -1110,6 +1113,18 @@ ovn_lb_datapaths_remove_ls(struct ovn_lb_datapaths *lb_dps, size_t n,
}
}

void
ovn_lb_datapaths_remove_lr(struct ovn_lb_datapaths *lb_dps, size_t n,
struct ovn_datapath **ods)
{
for (size_t i = 0; i < n; i++) {
if (bitmap_is_set(lb_dps->nb_lr_map, ods[i]->index)) {
bitmap_set0(lb_dps->nb_lr_map, ods[i]->index);
lb_dps->n_nb_lr--;
}
}
}

struct ovn_lb_group_datapaths *
ovn_lb_group_datapaths_create(const struct ovn_lb_group *lb_group,
size_t n_ls_datapaths,
Expand Down Expand Up @@ -1175,5 +1190,18 @@ void
ovn_lb_group_datapaths_add_lr(struct ovn_lb_group_datapaths *lbg_dps,
struct ovn_datapath *lr)
{
bitmap_set1(lbg_dps->nb_lr_map, lr->index);
if (!bitmap_is_set(lbg_dps->nb_lr_map, lr->index)) {
bitmap_set1(lbg_dps->nb_lr_map, lr->index);
lbg_dps->n_nb_lr++;
}
}

void
ovn_lb_group_datapaths_remove_lr(struct ovn_lb_group_datapaths *lbg_dps,
struct ovn_datapath *lr)
{
if (bitmap_is_set(lbg_dps->nb_lr_map, lr->index)) {
bitmap_set1(lbg_dps->nb_lr_map, lr->index);
lbg_dps->n_nb_lr--;
}
}
5 changes: 5 additions & 0 deletions lib/lb.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ void ovn_lb_datapaths_set_ls(struct ovn_lb_datapaths *, size_t n,

void ovn_lb_datapaths_remove_ls(struct ovn_lb_datapaths *, size_t n,
struct ovn_datapath **);
void ovn_lb_datapaths_remove_lr(struct ovn_lb_datapaths *, size_t n,
struct ovn_datapath **);

struct ovn_lb_group_datapaths {
struct hmap_node hmap_node;
Expand Down Expand Up @@ -214,6 +216,9 @@ void ovn_lb_group_datapaths_remove_ls(struct ovn_lb_group_datapaths *,

void ovn_lb_group_datapaths_add_lr(struct ovn_lb_group_datapaths *,
struct ovn_datapath *lr);
void ovn_lb_group_datapaths_remove_lr(struct ovn_lb_group_datapaths *,
struct ovn_datapath *lr);

struct ovn_controller_lb {
struct hmap_node hmap_node;

Expand Down
5 changes: 5 additions & 0 deletions northd/en-lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ lflow_northd_handler(struct engine_node *node,
if (!northd_data->change_tracked) {
return false;
}

if (northd_data->lrouters_changed) {
return false;
}

const struct engine_context *eng_ctx = engine_get_context();
struct lflow_data *lflow_data = data;

Expand Down
20 changes: 20 additions & 0 deletions northd/en-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@ northd_nb_logical_switch_handler(struct engine_node *node,
return true;
}

bool
northd_nb_logical_router_handler(struct engine_node *node,
void *data)
{
struct northd_data *nd = data;
struct northd_input input_data;

northd_get_input_data(node, &input_data);

if (!northd_handle_lr_changes(&input_data, nd)) {
return false;
}

if (nd->change_tracked) {
engine_set_node_state(node, EN_UPDATED);
}

return true;
}

bool
northd_sb_port_binding_handler(struct engine_node *node,
void *data)
Expand Down
1 change: 1 addition & 0 deletions northd/en-northd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void en_northd_cleanup(void *data);
void en_northd_clear_tracked_data(void *data);
bool northd_nb_nb_global_handler(struct engine_node *, void *data OVS_UNUSED);
bool northd_nb_logical_switch_handler(struct engine_node *, void *data);
bool northd_nb_logical_router_handler(struct engine_node *, void *data);
bool northd_sb_port_binding_handler(struct engine_node *, void *data);
bool northd_northd_lb_data_handler(struct engine_node *, void *data);

Expand Down
3 changes: 2 additions & 1 deletion northd/inc-proc-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,

engine_add_input(&en_northd, &en_nb_port_group, NULL);
engine_add_input(&en_northd, &en_nb_acl, NULL);
engine_add_input(&en_northd, &en_nb_logical_router, NULL);
engine_add_input(&en_northd, &en_nb_mirror, NULL);
engine_add_input(&en_northd, &en_nb_meter, NULL);
engine_add_input(&en_northd, &en_nb_static_mac_binding, NULL);
Expand Down Expand Up @@ -185,6 +184,8 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
northd_nb_nb_global_handler);
engine_add_input(&en_northd, &en_nb_logical_switch,
northd_nb_logical_switch_handler);
engine_add_input(&en_northd, &en_nb_logical_router,
northd_nb_logical_router_handler);

engine_add_input(&en_mac_binding_aging, &en_nb_nb_global, NULL);
engine_add_input(&en_mac_binding_aging, &en_sb_mac_binding, NULL);
Expand Down
Loading

0 comments on commit cc90d97

Please sign in to comment.