Skip to content

Commit

Permalink
northd: Move the datapaths arrays to ovn_datapaths struct.
Browse files Browse the repository at this point in the history
In the current code, many functions depends on the global datapaths
arrays variables, which is convenient. However, for incremental
processing framework to track dependencies properly, we should avoid
using global variables and purely depends on engine inputs (and function
inputs, for the functions called by engine nodes' handlers).

This patch moves the datapaths arrays to a new ovn_datapaths struct,
which wraps the datapaths arrays together with the corresponding
datapaths hmap table, because they are in fact for the same data, and
the array is just an index of the data. The variable for the size of the
array is replaced by a helper function which simply reads the size of
the hmap.

Signed-off-by: Han Zhou <hzhou@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
hzhou8 committed Mar 24, 2023
1 parent 12487f2 commit 311b7da
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 247 deletions.
17 changes: 9 additions & 8 deletions northd/en-sync-sb.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ VLOG_DEFINE_THIS_MODULE(en_sync_to_sb);
static void sync_addr_set(struct ovsdb_idl_txn *ovnsb_txn, const char *name,
const char **addrs, size_t n_addrs,
struct shash *sb_address_sets);
static void sync_addr_sets(const struct nbrec_address_set_table *,
static void sync_addr_sets(struct ovsdb_idl_txn *ovnsb_txn,
const struct nbrec_address_set_table *,
const struct nbrec_port_group_table *,
const struct sbrec_address_set_table *,
struct ovsdb_idl_txn *ovnsb_txn,
struct hmap *datapaths);
const struct ovn_datapaths *lr_datapaths);
static const struct sbrec_address_set *sb_address_set_lookup_by_name(
struct ovsdb_idl_index *, const char *name);
static void update_sb_addr_set(const char **nb_addresses, size_t n_addresses,
Expand Down Expand Up @@ -89,8 +89,8 @@ en_sync_to_sb_addr_set_run(struct engine_node *node, void *data OVS_UNUSED)
const struct engine_context *eng_ctx = engine_get_context();
struct northd_data *northd_data = engine_get_input_data("northd", node);

sync_addr_sets(nb_address_set_table, nb_port_group_table,
sb_address_set_table, eng_ctx->ovnsb_idl_txn,
sync_addr_sets(eng_ctx->ovnsb_idl_txn, nb_address_set_table,
nb_port_group_table, sb_address_set_table,
&northd_data->lr_datapaths);

engine_set_node_state(node, EN_UPDATED);
Expand Down Expand Up @@ -228,10 +228,11 @@ sync_addr_set(struct ovsdb_idl_txn *ovnsb_txn, const char *name,
* in OVN_Northbound, so that the address sets used in Logical_Flows in
* OVN_Southbound is checked against the proper set.*/
static void
sync_addr_sets(const struct nbrec_address_set_table *nb_address_set_table,
sync_addr_sets(struct ovsdb_idl_txn *ovnsb_txn,
const struct nbrec_address_set_table *nb_address_set_table,
const struct nbrec_port_group_table *nb_port_group_table,
const struct sbrec_address_set_table *sb_address_set_table,
struct ovsdb_idl_txn *ovnsb_txn, struct hmap *datapaths)
const struct ovn_datapaths *lr_datapaths)
{
struct shash sb_address_sets = SHASH_INITIALIZER(&sb_address_sets);

Expand Down Expand Up @@ -271,7 +272,7 @@ sync_addr_sets(const struct nbrec_address_set_table *nb_address_set_table,

/* Sync router load balancer VIP generated address sets. */
struct ovn_datapath *od;
HMAP_FOR_EACH (od, key_node, datapaths) {
HMAP_FOR_EACH (od, key_node, &lr_datapaths->datapaths) {
if (!od->nbr) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion northd/mac-binding-aging.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ en_mac_binding_aging_run(struct engine_node *node, void *data OVS_UNUSED)
"sbrec_mac_binding_by_datapath");

struct ovn_datapath *od;
HMAP_FOR_EACH (od, key_node, &northd_data->lr_datapaths) {
HMAP_FOR_EACH (od, key_node, &northd_data->lr_datapaths.datapaths) {
if (od->sb && od->nbr) {
mac_binding_aging_run_for_datapath(od->sb, od->nbr,
sbrec_mac_binding_by_datapath,
Expand Down

0 comments on commit 311b7da

Please sign in to comment.