[ovs-dev] [PATCH 1/2] lib: Move lib/rconn.h to include/openvswitch

Xiao Liang shaw.leon at gmail.com
Wed Aug 16 16:06:24 UTC 2017


Rconn provides useful features over vconn. Make it available to library
users.

Signed-off-by: Xiao Liang <shaw.leon at gmail.com>
---
 include/openvswitch/automake.mk      |  1 +
 {lib => include/openvswitch}/rconn.h | 17 ++++++++---------
 lib/automake.mk                      |  1 -
 lib/learning-switch.c                |  2 +-
 lib/rconn.c                          | 11 ++++++++++-
 ofproto/bundles.c                    |  2 +-
 ofproto/connmgr.c                    |  2 +-
 ofproto/fail-open.c                  |  2 +-
 ofproto/pinsched.c                   |  2 +-
 ovn/controller/ofctrl.c              |  2 +-
 ovn/controller/pinctrl.c             |  2 +-
 utilities/ovs-testcontroller.c       |  2 +-
 12 files changed, 27 insertions(+), 19 deletions(-)
 rename {lib => include/openvswitch}/rconn.h (91%)

diff --git a/include/openvswitch/automake.mk b/include/openvswitch/automake.mk
index eabeb1e97..cb0080d53 100644
--- a/include/openvswitch/automake.mk
+++ b/include/openvswitch/automake.mk
@@ -20,6 +20,7 @@ openvswitchinclude_HEADERS = \
 	include/openvswitch/ofp-prop.h \
 	include/openvswitch/ofp-util.h \
 	include/openvswitch/packets.h \
+	include/openvswitch/rconn.h \
 	include/openvswitch/shash.h \
 	include/openvswitch/thread.h \
 	include/openvswitch/token-bucket.h \
diff --git a/lib/rconn.h b/include/openvswitch/rconn.h
similarity index 91%
rename from lib/rconn.h
rename to include/openvswitch/rconn.h
index fd5df126d..176c5f641 100644
--- a/lib/rconn.h
+++ b/include/openvswitch/rconn.h
@@ -21,7 +21,6 @@
 #include <stdint.h>
 #include <time.h>
 #include "openvswitch/types.h"
-#include "ovs-thread.h"
 
 /* A wrapper around vconn that provides queuing and optionally reliability.
  *
@@ -41,6 +40,10 @@
  * Fully thread-safe.
  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct vconn;
 struct rconn_packet_counter;
 
@@ -90,14 +93,6 @@ unsigned int rconn_get_connection_seqno(const struct rconn *);
 int rconn_get_last_error(const struct rconn *);
 unsigned int rconn_count_txqlen(const struct rconn *);
 
-/* Counts packets and bytes queued into an rconn by a given source. */
-struct rconn_packet_counter {
-    struct ovs_mutex mutex;
-    unsigned int n_packets OVS_GUARDED; /* Number of packets queued. */
-    unsigned int n_bytes OVS_GUARDED;   /* Number of bytes queued. */
-    int ref_cnt OVS_GUARDED;            /* Number of owners. */
-};
-
 struct rconn_packet_counter *rconn_packet_counter_create(void);
 void rconn_packet_counter_destroy(struct rconn_packet_counter *);
 void rconn_packet_counter_inc(struct rconn_packet_counter *, unsigned n_bytes);
@@ -107,4 +102,8 @@ unsigned int rconn_packet_counter_n_packets(
     const struct rconn_packet_counter *);
 unsigned int rconn_packet_counter_n_bytes(const struct rconn_packet_counter *);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* rconn.h */
diff --git a/lib/automake.mk b/lib/automake.mk
index 2415f4cd6..c0a8a2471 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -213,7 +213,6 @@ lib_libopenvswitch_la_SOURCES = \
 	lib/random.c \
 	lib/random.h \
 	lib/rconn.c \
-	lib/rconn.h \
 	lib/rculist.h \
 	lib/reconnect.c \
 	lib/reconnect.h \
diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index a9cb95a57..16d1feadf 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -40,7 +40,7 @@
 #include "openvswitch/vconn.h"
 #include "openvswitch/vlog.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "openvswitch/shash.h"
 #include "simap.h"
 #include "timeval.h"
diff --git a/lib/rconn.c b/lib/rconn.c
index 8a2986403..673ee1cea 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -15,7 +15,7 @@
  */
 
 #include <config.h>
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -32,6 +32,7 @@
 #include "stream.h"
 #include "timeval.h"
 #include "util.h"
+#include "ovs-thread.h"
 
 VLOG_DEFINE_THIS_MODULE(rconn);
 
@@ -143,6 +144,14 @@ struct rconn {
     uint32_t allowed_versions;
 };
 
+/* Counts packets and bytes queued into an rconn by a given source. */
+struct rconn_packet_counter {
+    struct ovs_mutex mutex;
+    unsigned int n_packets OVS_GUARDED; /* Number of packets queued. */
+    unsigned int n_bytes OVS_GUARDED;   /* Number of bytes queued. */
+    int ref_cnt OVS_GUARDED;            /* Number of owners. */
+};
+
 uint32_t rconn_get_allowed_versions(const struct rconn *rconn)
 {
     return rconn->allowed_versions;
diff --git a/ofproto/bundles.c b/ofproto/bundles.c
index 24ea1ae7a..2fcc32369 100644
--- a/ofproto/bundles.c
+++ b/ofproto/bundles.c
@@ -32,7 +32,7 @@
 #include "openvswitch/vlog.h"
 #include "pinsched.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "openvswitch/shash.h"
 #include "simap.h"
 #include "stream.h"
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index c0ce828ce..5c908f605 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -35,7 +35,7 @@
 #include "ovs-atomic.h"
 #include "pinsched.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "openvswitch/shash.h"
 #include "simap.h"
 #include "stream.h"
diff --git a/ofproto/fail-open.c b/ofproto/fail-open.c
index 914a51b4b..be993249f 100644
--- a/ofproto/fail-open.c
+++ b/ofproto/fail-open.c
@@ -32,7 +32,7 @@
 #include "ofproto.h"
 #include "ofproto-provider.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "timeval.h"
 
 VLOG_DEFINE_THIS_MODULE(fail_open);
diff --git a/ofproto/pinsched.c b/ofproto/pinsched.c
index 500115ad2..35716ea89 100644
--- a/ofproto/pinsched.c
+++ b/ofproto/pinsched.c
@@ -28,7 +28,7 @@
 #include "openflow/openflow.h"
 #include "poll-loop.h"
 #include "random.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "sat-math.h"
 #include "timeval.h"
 #include "openvswitch/token-bucket.h"
diff --git a/ovn/controller/ofctrl.c b/ovn/controller/ofctrl.c
index fc88a410b..436df8d5a 100644
--- a/ovn/controller/ofctrl.c
+++ b/ovn/controller/ofctrl.c
@@ -38,7 +38,7 @@
 #include "ovn/actions.h"
 #include "poll-loop.h"
 #include "physical.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "socket-util.h"
 #include "util.h"
 #include "vswitch-idl.h"
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 469a35586..f9b2e0caf 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -44,7 +44,7 @@
 #include "ovn/lib/ovn-dhcp.h"
 #include "ovn/lib/ovn-util.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "socket-util.h"
 #include "timeval.h"
 #include "vswitch-idl.h"
diff --git a/utilities/ovs-testcontroller.c b/utilities/ovs-testcontroller.c
index b4a451286..9b9903ba5 100644
--- a/utilities/ovs-testcontroller.c
+++ b/utilities/ovs-testcontroller.c
@@ -33,7 +33,7 @@
 #include "openvswitch/ofpbuf.h"
 #include "openflow/openflow.h"
 #include "poll-loop.h"
-#include "rconn.h"
+#include "openvswitch/rconn.h"
 #include "simap.h"
 #include "stream-ssl.h"
 #include "timeval.h"
-- 
2.14.1



More information about the dev mailing list