diff mbox series

[ovs-dev,1/7] inc-proc-eng: Allow definition of engine_node with global scope

Message ID 20210929172341.719131-2-mark.d.gray@redhat.com
State Superseded
Delegated to: Han Zhou
Headers show
Series northd: Introduce incremental processing framework | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Mark Gray Sept. 29, 2021, 5:23 p.m. UTC
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 as
engine nodes can be defined. Allow 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>
---
 controller/ovn-controller.c | 2 +-
 lib/inc-proc-eng.h          | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index a719beb0e615..1071966c321d 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -3218,7 +3218,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_CUSTOM_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");
diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h
index 859b30a71c86..1ccae559dff6 100644
--- a/lib/inc-proc-eng.h
+++ b/lib/inc-proc-eng.h
@@ -295,19 +295,19 @@  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) \
+#define ENGINE_NODE_CUSTOM_WITH_CLEAR_TRACK_DATA_IS_VALID(NAME, NAME_STR) \
     ENGINE_NODE_CUSTOM_DATA(NAME, NAME_STR) \
-    en_##NAME.clear_tracked_data = en_##NAME##_clear_tracked_data;
+    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) \