Skip to content

Commit

Permalink
inc-proc-eng: Allow definition of engine_node with global scope
Browse files Browse the repository at this point in the history
Refactor ENGINE_NODE() macro to not assign function pointers. This
allows ENGINE_NODE() to be used outside functions, creating an
engine_node with global scope (but can be statically defined within a file).
This allows more flexibility in how the I-P engine can be used.
Although this is not explicitly required for I-P it does allow for a cleaner
code base as the node definitions can be kept together outside any functions.

Additional function pointers (e.g. is_valid(), clear_tracked_data()),
may be assigned later, if required.

Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Signed-off-by: Han Zhou <hzhou@ovn.org>
  • Loading branch information
markdgray authored and hzhou8 committed Nov 4, 2021
1 parent ccbbbd0 commit cd1a0c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion controller/ovn-controller.c
Expand Up @@ -3196,7 +3196,7 @@ main(int argc, char *argv[])
stopwatch_create(BFD_RUN_STOPWATCH_NAME, SW_MS);

/* Define inc-proc-engine nodes. */
ENGINE_NODE_CUSTOM_WITH_CLEAR_TRACK_DATA(ct_zones, "ct_zones");
ENGINE_NODE_WITH_CLEAR_TRACK_DATA_IS_VALID(ct_zones, "ct_zones");
ENGINE_NODE_WITH_CLEAR_TRACK_DATA(runtime_data, "runtime_data");
ENGINE_NODE(non_vif_data, "non_vif_data");
ENGINE_NODE(mff_ovn_geneve, "mff_ovn_geneve");
Expand Down
13 changes: 5 additions & 8 deletions lib/inc-proc-eng.h
Expand Up @@ -295,19 +295,16 @@ void engine_ovsdb_node_add_index(struct engine_node *, const char *name,
.init = en_##NAME##_init, \
.run = en_##NAME##_run, \
.cleanup = en_##NAME##_cleanup, \
.is_valid = en_##NAME##_is_valid, \
.is_valid = NULL, \
.clear_tracked_data = NULL, \
};

#define ENGINE_NODE_CUSTOM_DATA(NAME, NAME_STR) \
ENGINE_NODE_DEF(NAME, NAME_STR)

#define ENGINE_NODE_CUSTOM_WITH_CLEAR_TRACK_DATA(NAME, NAME_STR) \
ENGINE_NODE_CUSTOM_DATA(NAME, NAME_STR) \
en_##NAME.clear_tracked_data = en_##NAME##_clear_tracked_data;
#define ENGINE_NODE_WITH_CLEAR_TRACK_DATA_IS_VALID(NAME, NAME_STR) \
ENGINE_NODE(NAME, NAME_STR) \
en_##NAME.clear_tracked_data = en_##NAME##_clear_tracked_data; \
en_##NAME.is_valid = en_##NAME##_is_valid;

#define ENGINE_NODE(NAME, NAME_STR) \
static bool (*en_##NAME##_is_valid)(struct engine_node *node) = NULL; \
ENGINE_NODE_DEF(NAME, NAME_STR)

#define ENGINE_NODE_WITH_CLEAR_TRACK_DATA(NAME, NAME_STR) \
Expand Down

0 comments on commit cd1a0c7

Please sign in to comment.