diff mbox series

[ovs-dev,v7,08/12] ovn-controller: Move shared functions to ovn-util.

Message ID 20211019101348.3833652-9-frode.nordahl@canonical.com
State Handled Elsewhere
Headers show
Series [ovs-dev,v7,01/12] ovn-sb: Add requested_chassis column to Port_Binding. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning

Commit Message

Frode Nordahl Oct. 19, 2021, 10:13 a.m. UTC
The `get_tunnel_type` (and associated enum) and `get_bridge`
functions are used in modules other than the `ovn-controller`
module.

Since the `ovn-controller` module also has the `main` function
this organization makes it hard or impossible to unit test.

Signed-off-by: Frode Nordahl <frode.nordahl@canonical.com>
---
 controller/local_data.h     | 11 +++--------
 controller/ovn-controller.c | 26 --------------------------
 lib/ovn-util.c              | 27 +++++++++++++++++++++++++++
 lib/ovn-util.h              | 18 +++++++++++++++++-
 4 files changed, 47 insertions(+), 35 deletions(-)

Comments

0-day Robot Oct. 19, 2021, 10:33 a.m. UTC | #1
Bleep bloop.  Greetings Frode Nordahl, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


Patch skipped due to previous failure.

Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/controller/local_data.h b/controller/local_data.h
index f6317e9ca..c790bc722 100644
--- a/controller/local_data.h
+++ b/controller/local_data.h
@@ -21,6 +21,9 @@ 
 #include "lib/smap.h"
 #include "lib/simap.h"
 
+/* OVN includes. */
+#include "lib/ovn-util.h"
+
 struct sbrec_datapath_binding;
 struct sbrec_port_binding;
 struct sbrec_chassis;
@@ -120,14 +123,6 @@  void tracked_datapath_lport_add(const struct sbrec_port_binding *,
                                 struct hmap *tracked_datapaths);
 void tracked_datapaths_destroy(struct hmap *tracked_datapaths);
 
-/* Must be a bit-field ordered from most-preferred (higher number) to
- * least-preferred (lower number). */
-enum chassis_tunnel_type {
-    GENEVE = 1 << 2,
-    STT    = 1 << 1,
-    VXLAN  = 1 << 0
-};
-
 /* Maps from a chassis to the OpenFlow port number of the tunnel that can be
  * used to reach that chassis. */
 struct chassis_tunnel {
diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index a1382a67b..c015f936c 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -140,32 +140,6 @@  struct pending_pkt {
 /* Registered ofctrl seqno type for nb_cfg propagation. */
 static size_t ofctrl_seq_type_nb_cfg;
 
-uint32_t
-get_tunnel_type(const char *name)
-{
-    if (!strcmp(name, "geneve")) {
-        return GENEVE;
-    } else if (!strcmp(name, "stt")) {
-        return STT;
-    } else if (!strcmp(name, "vxlan")) {
-        return VXLAN;
-    }
-
-    return 0;
-}
-
-const struct ovsrec_bridge *
-get_bridge(const struct ovsrec_bridge_table *bridge_table, const char *br_name)
-{
-    const struct ovsrec_bridge *br;
-    OVSREC_BRIDGE_TABLE_FOR_EACH (br, bridge_table) {
-        if (!strcmp(br->name, br_name)) {
-            return br;
-        }
-    }
-    return NULL;
-}
-
 static unsigned int
 update_sb_monitors(struct ovsdb_idl *ovnsb_idl,
                    const struct sbrec_chassis *chassis,
diff --git a/lib/ovn-util.c b/lib/ovn-util.c
index 683ca37d9..19e3c2343 100644
--- a/lib/ovn-util.c
+++ b/lib/ovn-util.c
@@ -23,6 +23,7 @@ 
 #include "include/ovn/actions.h"
 #include "openvswitch/ofp-parse.h"
 #include "openvswitch/vlog.h"
+#include "lib/vswitch-idl.h"
 #include "ovn-dirs.h"
 #include "ovn-nb-idl.h"
 #include "ovn-sb-idl.h"
@@ -791,3 +792,29 @@  ddlog_err(const char *msg)
     VLOG_ERR("%s", msg);
 }
 #endif
+
+uint32_t
+get_tunnel_type(const char *name)
+{
+    if (!strcmp(name, "geneve")) {
+        return GENEVE;
+    } else if (!strcmp(name, "stt")) {
+        return STT;
+    } else if (!strcmp(name, "vxlan")) {
+        return VXLAN;
+    }
+
+    return 0;
+}
+
+const struct ovsrec_bridge *
+get_bridge(const struct ovsrec_bridge_table *bridge_table, const char *br_name)
+{
+    const struct ovsrec_bridge *br;
+    OVSREC_BRIDGE_TABLE_FOR_EACH (br, bridge_table) {
+        if (!strcmp(br->name, br_name)) {
+            return br;
+        }
+    }
+    return NULL;
+}
diff --git a/lib/ovn-util.h b/lib/ovn-util.h
index b0bc70a16..2fa92e069 100644
--- a/lib/ovn-util.h
+++ b/lib/ovn-util.h
@@ -285,4 +285,20 @@  void ddlog_warn(const char *msg);
 void ddlog_err(const char *msg);
 #endif
 
-#endif
+
+/* Must be a bit-field ordered from most-preferred (higher number) to
+ * least-preferred (lower number). */
+enum chassis_tunnel_type {
+    GENEVE = 1 << 2,
+    STT    = 1 << 1,
+    VXLAN  = 1 << 0
+};
+
+uint32_t get_tunnel_type(const char *name);
+
+struct ovsrec_bridge_table;
+const struct ovsrec_bridge *get_bridge(const struct ovsrec_bridge_table *,
+                                       const char *br_name);
+
+
+#endif /* OVN_UTIL_H */