[ovs-dev] [PATCH 03/14] vonn: Allow snoops to use the OpenFlow version of the controller connection

Simon Horman horms at verge.net.au
Wed Nov 7 08:03:01 UTC 2012


Override the allowed versions of the snoop vconn so that
only the version of the controller connection is allowed.
This is because the snoop will see the same messages as the
controller.

Without this change the snoop will try to negotiate a connection
using the default allowed versions, or in other words only
allow OpenFlow 1.0. This breaks snoops for controller connections
using other OpenFlow versions, that is OpenFlow 1.2.

Signed-off-by: Simon Horman <horms at verge.net.au>

---

v4
* First post
---
 lib/ofp-util.c |    6 ------
 lib/ofp-util.h |    6 ++++++
 lib/rconn.c    |   14 ++++++++++++++
 lib/rconn.h    |    1 +
 lib/vconn.c    |    8 ++++++++
 lib/vconn.h    |    2 ++
 6 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 5703f8c..562531b 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -1112,12 +1112,6 @@ ofputil_decode_hello_bitmap(const struct ofp_hello_elem_header *oheh,
     return true;
 }
 
-static uint32_t
-version_bitmap_from_version(uint8_t ofp_version)
-{
-    return ((ofp_version < 32 ? 1u << ofp_version : 0) - 1) << 1;
-}
-
 /* Decodes OpenFlow OFPT_HELLO message 'oh', storing into '*allowed_versions'
  * the set of OpenFlow versions for which 'oh' announces support.
  *
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index 4bd5a00..35178aa 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -108,6 +108,12 @@ void ofputil_format_version_name(struct ds *, enum ofp_version);
  * is the mask for Open Flow 1.1.  If the bit for a version is set then it is
  * allowed, otherwise it is disallowed. */
 
+static inline uint32_t
+version_bitmap_from_version(uint8_t ofp_version)
+{
+    return ((ofp_version < 32 ? 1u << ofp_version : 0) - 1) << 1;
+}
+
 void ofputil_format_version_bitmap(struct ds *msg, uint32_t bitmap);
 void ofputil_format_version_bitmap_names(struct ds *msg, uint32_t bitmap);
 
diff --git a/lib/rconn.c b/lib/rconn.c
index c844a59..5e5d318 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -135,6 +135,11 @@ struct rconn {
     uint32_t allowed_versions;
 };
 
+uint32_t rconn_get_allowed_versions(const struct rconn *rconn)
+{
+    return rconn->allowed_versions;
+}
+
 static unsigned int elapsed_in_this_state(const struct rconn *);
 static unsigned int timeout(const struct rconn *);
 static bool timed_out(const struct rconn *);
@@ -671,6 +676,15 @@ void
 rconn_add_monitor(struct rconn *rc, struct vconn *vconn)
 {
     if (rc->n_monitors < ARRAY_SIZE(rc->monitors)) {
+        int version = vconn_get_version(rc->vconn);
+        uint32_t allowed_versions = version_bitmap_from_version(version);
+
+        /* Override the allowed versions of the snoop vconn so that
+         * only the version of the controller connection is allowed.
+         * This is because the snoop will see the same messages as the
+         * controller */
+        vconn_set_allowed_versions(vconn, allowed_versions);
+
         VLOG_INFO("new monitor connection from %s", vconn_get_name(vconn));
         rc->monitors[rc->n_monitors++] = vconn;
     } else {
diff --git a/lib/rconn.h b/lib/rconn.h
index 0592366..aa30238 100644
--- a/lib/rconn.h
+++ b/lib/rconn.h
@@ -41,6 +41,7 @@ struct rconn *rconn_create(int inactivity_probe_interval,
 			   int max_backoff, uint8_t dscp,
 			   uint32_t allowed_versions);
 void rconn_set_dscp(struct rconn *rc, uint8_t dscp);
+uint32_t rconn_get_allowed_versions(const struct rconn *);
 uint8_t rconn_get_dscp(const struct rconn *rc);
 void rconn_set_max_backoff(struct rconn *, int max_backoff);
 int rconn_get_max_backoff(const struct rconn *);
diff --git a/lib/vconn.c b/lib/vconn.c
index 6c77d06..4e92834 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -343,6 +343,14 @@ vconn_get_allowed_versions(const struct vconn *vconn)
     return vconn->allowed_versions;
 }
 
+/* Sets the allowed_versions of 'vconn', overriding
+ * the allowed_versions passed to vconn_open(). */
+void
+vconn_set_allowed_versions(struct vconn *vconn, uint32_t allowed_versions)
+{
+    vconn->allowed_versions = allowed_versions;
+}
+
 /* Returns the IP address of the peer, or 0 if the peer is not connected over
  * an IP-based protocol or if its IP address is not yet known. */
 ovs_be32
diff --git a/lib/vconn.h b/lib/vconn.h
index 46ff17f..3f69a51 100644
--- a/lib/vconn.h
+++ b/lib/vconn.h
@@ -39,6 +39,8 @@ int vconn_open(const char *name, uint32_t allowed_versions,
 void vconn_close(struct vconn *);
 const char *vconn_get_name(const struct vconn *);
 uint32_t vconn_get_allowed_versions(const struct vconn *vconn);
+void vconn_set_allowed_versions(struct vconn *vconn,
+                                uint32_t allowed_versions);
 ovs_be32 vconn_get_remote_ip(const struct vconn *);
 ovs_be16 vconn_get_remote_port(const struct vconn *);
 ovs_be32 vconn_get_local_ip(const struct vconn *);
-- 
1.7.10.4




More information about the dev mailing list