This creates an alternative to lflow_table_add_lflow(). This alternative,
lflow_table_add_lflow_(), takes its arguments in a structure, rather
than as individual function parameters.

This provides the basis for redefining the many ovn_lflow_add() macro
variations. In this commit, we define ovn_lflow_add() as taking seven
mandatory parameters, plus some variadic number of additional
parameters.

We do not touch northd.c in this commit, but this implicitly converts
all pre-existing calls to ovn_lflow_add() to the new version which uses
the struct argument.

Upcoming commits will convert the other ovn_lflow_add()-related macros
to use ovn_lflow_add(), where the __VA_ARGS__ will help to fill in
additional structure elements..

Signed-off-by: Mark Michelson <[email protected]>
---
 northd/lflow-mgr.c | 10 ++++++++++
 northd/lflow-mgr.h | 37 +++++++++++++++++++++++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/northd/lflow-mgr.c b/northd/lflow-mgr.c
index 43dd1d947..bdd290814 100644
--- a/northd/lflow-mgr.c
+++ b/northd/lflow-mgr.c
@@ -773,6 +773,16 @@ lflow_table_add_lflow(struct lflow_table *lflow_table,
     lflow_hash_unlock(hash_lock);
 }
 
+void
+lflow_table_add_lflow__(struct lflow_table_add_args *args)
+{
+    lflow_table_add_lflow(args->table, args->od, args->dp_bitmap,
+                          args->dp_bitmap_len, args->stage, args->priority,
+                          args->match, args->actions, args->io_port,
+                          args->ctrl_meter, args->stage_hint, args->where,
+                          args->flow_desc, args->lflow_ref);
+}
+
 struct ovn_dp_group *
 ovn_dp_group_get(struct hmap *dp_groups,
                  const struct dynamic_bitmap *desired_bitmap,
diff --git a/northd/lflow-mgr.h b/northd/lflow-mgr.h
index c1e72d1be..4bb585f4e 100644
--- a/northd/lflow-mgr.h
+++ b/northd/lflow-mgr.h
@@ -76,6 +76,24 @@ bool lflow_ref_sync_lflows(struct lflow_ref *,
                            const struct sbrec_logical_flow_table *,
                            const struct sbrec_logical_dp_group_table *);
 
+struct lflow_table_add_args {
+    struct lflow_table *table;
+    const struct ovn_datapath *od;
+    const unsigned long *dp_bitmap;
+    size_t dp_bitmap_len;
+    enum ovn_stage stage;
+    uint16_t priority;
+    const char *match;
+    const char *actions;
+    const char *io_port;
+    const char *ctrl_meter;
+    const struct ovsdb_idl_row *stage_hint;
+    const char *flow_desc;
+    struct lflow_ref *lflow_ref;
+    const char *where;
+};
+
+void lflow_table_add_lflow__(struct lflow_table_add_args *args);
 
 void lflow_table_add_lflow(struct lflow_table *, const struct ovn_datapath *,
                            const unsigned long *dp_bitmap,
@@ -132,10 +150,21 @@ void lflow_table_add_lflow(struct lflow_table *, const 
struct ovn_datapath *,
                           OVS_SOURCE_LOCATOR, NULL, LFLOW_REF)
 
 #define ovn_lflow_add(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, ACTIONS, \
-                      LFLOW_REF) \
-    lflow_table_add_lflow(LFLOW_TABLE, OD, NULL, 0, STAGE, PRIORITY, MATCH, \
-                          ACTIONS, NULL, NULL, NULL, OVS_SOURCE_LOCATOR, \
-                          NULL, LFLOW_REF)
+                      LFLOW_REF, ...) \
+    lflow_table_add_lflow__( \
+        &(struct lflow_table_add_args) { \
+            .table = LFLOW_TABLE, \
+            .od = OD, \
+            .stage = STAGE, \
+            .priority = PRIORITY, \
+            .match = MATCH, \
+            .actions = ACTIONS, \
+            .lflow_ref = LFLOW_REF, \
+            .where = OVS_SOURCE_LOCATOR, \
+            __VA_ARGS__ \
+        } \
+    )
+
 
 #define ovn_lflow_add_drop_with_desc(LFLOW_TABLE, OD, STAGE, PRIORITY, MATCH, \
                                      DESCRIPTION, LFLOW_REF) \
-- 
2.51.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to