Skip to content

Commit

Permalink
northd: Incremental processing of VIF additions in 'lflow' node.
Browse files Browse the repository at this point in the history
This patch introduces a change handler for 'northd' input within the
'lflow' node. It specifically handles cases when VIFs are created, which
is an easier start for lflow incremental processing. Support for
update/delete will be added later.

Below are the performance test results simulating an ovn-k8s topology of 500
nodes x 50 lsp per node:

Before:
ovn-nbctl --wait=hv --print-wait-time lsp-add ls_1_0001 lsp_1_0001_01 -- lsp-set-addresses lsp_1_0001_01 "ff:f1:bb:00:01:01 1.0.1.101" -- lsp-set-port-security lsp_1_0001_01 "ff:f1:bb:00:01:01 1.0.1.101"
    ovn-northd completion:          773ms

After:
ovn-nbctl --wait=hv --print-wait-time lsp-add ls_1_0001 lsp_1_0001_01 -- lsp-set-addresses lsp_1_0001_01 "ff:f1:bb:00:01:01 1.0.1.101" -- lsp-set-port-security lsp_1_0001_01 "ff:f1:bb:00:01:01 1.0.1.101"
    ovn-northd completion:          30ms

It is more than 95% reduction (or 20x faster).

Signed-off-by: Han Zhou <hzhou@ovn.org>
Reviewed-by: Ales Musil <amusil@redhat.com>
Acked-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
hzhou8 committed Jun 8, 2023
1 parent 7e0617f commit 8bbd678
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 63 deletions.
82 changes: 56 additions & 26 deletions northd/en-lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,49 @@

VLOG_DEFINE_THIS_MODULE(en_lflow);

void en_lflow_run(struct engine_node *node, void *data)
static void
lflow_get_input_data(struct engine_node *node,
struct lflow_input *lflow_input)
{
const struct engine_context *eng_ctx = engine_get_context();

struct lflow_input lflow_input;

struct northd_data *northd_data = engine_get_input_data("northd", node);

struct hmap bfd_connections = HMAP_INITIALIZER(&bfd_connections);

lflow_input.nbrec_bfd_table =
lflow_input->nbrec_bfd_table =
EN_OVSDB_GET(engine_get_input("NB_bfd", node));
lflow_input.sbrec_bfd_table =
lflow_input->sbrec_bfd_table =
EN_OVSDB_GET(engine_get_input("SB_bfd", node));
lflow_input.sbrec_logical_flow_table =
lflow_input->sbrec_logical_flow_table =
EN_OVSDB_GET(engine_get_input("SB_logical_flow", node));
lflow_input.sbrec_multicast_group_table =
lflow_input->sbrec_multicast_group_table =
EN_OVSDB_GET(engine_get_input("SB_multicast_group", node));
lflow_input.sbrec_igmp_group_table =
lflow_input->sbrec_igmp_group_table =
EN_OVSDB_GET(engine_get_input("SB_igmp_group", node));

lflow_input.sbrec_mcast_group_by_name_dp =
lflow_input->sbrec_mcast_group_by_name_dp =
engine_ovsdb_node_get_index(
engine_get_input("SB_multicast_group", node),
"sbrec_mcast_group_by_name");

lflow_input.ls_datapaths = &northd_data->ls_datapaths;
lflow_input.lr_datapaths = &northd_data->lr_datapaths;
lflow_input.ls_ports = &northd_data->ls_ports;
lflow_input.lr_ports = &northd_data->lr_ports;
lflow_input.port_groups = &northd_data->port_groups;
lflow_input.meter_groups = &northd_data->meter_groups;
lflow_input.lbs = &northd_data->lbs;
lflow_input.bfd_connections = &bfd_connections;
lflow_input.features = &northd_data->features;
lflow_input.ovn_internal_version_changed =
lflow_input->ls_datapaths = &northd_data->ls_datapaths;
lflow_input->lr_datapaths = &northd_data->lr_datapaths;
lflow_input->ls_ports = &northd_data->ls_ports;
lflow_input->lr_ports = &northd_data->lr_ports;
lflow_input->port_groups = &northd_data->port_groups;
lflow_input->meter_groups = &northd_data->meter_groups;
lflow_input->lbs = &northd_data->lbs;
lflow_input->features = &northd_data->features;
lflow_input->ovn_internal_version_changed =
northd_data->ovn_internal_version_changed;
lflow_input->bfd_connections = NULL;
}

void en_lflow_run(struct engine_node *node, void *data)
{
const struct engine_context *eng_ctx = engine_get_context();

struct lflow_input lflow_input;
lflow_get_input_data(node, &lflow_input);

struct hmap bfd_connections = HMAP_INITIALIZER(&bfd_connections);
lflow_input.bfd_connections = &bfd_connections;

struct lflow_data *lflow_data = data;
lflow_data_destroy(lflow_data);
Expand All @@ -76,8 +82,8 @@ void en_lflow_run(struct engine_node *node, void *data)
build_bfd_table(eng_ctx->ovnsb_idl_txn,
lflow_input.nbrec_bfd_table,
lflow_input.sbrec_bfd_table,
&bfd_connections,
&northd_data->lr_ports);
lflow_input.lr_ports,
&bfd_connections);
build_lflows(eng_ctx->ovnsb_idl_txn, &lflow_input, &lflow_data->lflows);
bfd_cleanup_connections(lflow_input.nbrec_bfd_table,
&bfd_connections);
Expand All @@ -87,6 +93,30 @@ void en_lflow_run(struct engine_node *node, void *data)
engine_set_node_state(node, EN_UPDATED);
}

bool
lflow_northd_handler(struct engine_node *node,
void *data)
{
struct northd_data *northd_data = engine_get_input_data("northd", node);
if (!northd_data->change_tracked) {
return false;
}
const struct engine_context *eng_ctx = engine_get_context();
struct lflow_data *lflow_data = data;

struct lflow_input lflow_input;
lflow_get_input_data(node, &lflow_input);

if (!lflow_handle_northd_ls_changes(eng_ctx->ovnsb_idl_txn,
&northd_data->tracked_ls_changes,
&lflow_input, &lflow_data->lflows)) {
return false;
}

engine_set_node_state(node, EN_UPDATED);
return true;
}

void *en_lflow_init(struct engine_node *node OVS_UNUSED,
struct engine_arg *arg OVS_UNUSED)
{
Expand Down
1 change: 1 addition & 0 deletions northd/en-lflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
void en_lflow_run(struct engine_node *node, void *data);
void *en_lflow_init(struct engine_node *node, struct engine_arg *arg);
void en_lflow_cleanup(void *data);
bool lflow_northd_handler(struct engine_node *, void *data);

#endif /* EN_LFLOW_H */
2 changes: 1 addition & 1 deletion northd/inc-proc-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
engine_add_input(&en_lflow, &en_sb_logical_flow, NULL);
engine_add_input(&en_lflow, &en_sb_multicast_group, NULL);
engine_add_input(&en_lflow, &en_sb_igmp_group, NULL);
engine_add_input(&en_lflow, &en_northd, NULL);
engine_add_input(&en_lflow, &en_northd, lflow_northd_handler);

engine_add_input(&en_sync_to_sb_addr_set, &en_nb_address_set,
sync_to_sb_addr_set_nb_address_set_handler);
Expand Down

0 comments on commit 8bbd678

Please sign in to comment.