[ovs-dev] [PATCH 07/18] rconn: Add allowed OpenFlow versions

Simon Horman horms at verge.net.au
Thu Oct 18 05:58:07 UTC 2012


Add allowed OpenFlow versions to struct rconn to allow
reconnect to use these parameters rather than hard-coded defaults.

This is in preparation for allowing configuration of the
allowed OpenFlow versions.

Signed-off-by: Simon Horman <horms at verge.net.au>
---
 lib/rconn.c                |   15 ++++++++++-----
 lib/rconn.h                |    5 ++++-
 ofproto/connmgr.c          |   13 +++++++++++--
 utilities/ovs-controller.c |    5 ++++-
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/lib/rconn.c b/lib/rconn.c
index 904e01f..d0e9d34 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -131,6 +131,8 @@ struct rconn {
 #define MAX_MONITORS 8
     struct vconn *monitors[8];
     size_t n_monitors;
+
+    struct ofputil_version_bitmap allowed_versions;
 };
 
 static unsigned int elapsed_in_this_state(const struct rconn *);
@@ -165,7 +167,8 @@ static bool rconn_logging_connection_attempts__(const struct rconn *);
  * The new rconn is initially unconnected.  Use rconn_connect() or
  * rconn_connect_unreliably() to connect it. */
 struct rconn *
-rconn_create(int probe_interval, int max_backoff, uint8_t dscp)
+rconn_create(int probe_interval, int max_backoff, uint8_t dscp,
+             const struct ofputil_version_bitmap *allowed_versions)
 {
     struct rconn *rc = xzalloc(sizeof *rc);
 
@@ -204,6 +207,9 @@ rconn_create(int probe_interval, int max_backoff, uint8_t dscp)
 
     rc->n_monitors = 0;
 
+    ofputil_version_bitmap_clone_data(allowed_versions,
+                                      &rc->allowed_versions);
+
     return rc;
 }
 
@@ -329,6 +335,7 @@ rconn_destroy(struct rconn *rc)
         for (i = 0; i < rc->n_monitors; i++) {
             vconn_close(rc->monitors[i]);
         }
+        ofputil_version_bitmap_free_data(&rc->allowed_versions);
         free(rc);
     }
 }
@@ -349,15 +356,13 @@ static void
 reconnect(struct rconn *rc)
 {
     int retval;
-    struct ofputil_version_bitmap ovb = OFPUTIL_VERSION_BITMAP_INITIALIZER;
 
     if (rconn_logging_connection_attempts__(rc)) {
         VLOG_INFO("%s: connecting...", rc->name);
     }
     rc->n_attempted_connections++;
-    ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
-    retval = vconn_open(rc->target, &ovb, &rc->vconn, rc->dscp);
-    ofputil_version_bitmap_free_data(&ovb);
+    retval = vconn_open(rc->target, &rc->allowed_versions,
+                        &rc->vconn, rc->dscp);
     if (!retval) {
         rc->remote_ip = vconn_get_remote_ip(rc->vconn);
         rc->local_ip = vconn_get_local_ip(rc->vconn);
diff --git a/lib/rconn.h b/lib/rconn.h
index d10cef7..2471fe0 100644
--- a/lib/rconn.h
+++ b/lib/rconn.h
@@ -21,6 +21,8 @@
 #include <stdint.h>
 #include <time.h>
 #include "openvswitch/types.h"
+#include "openflow/openflow-common.h"
+#include "lib/ofp-util.h"
 
 /* A wrapper around vconn that provides queuing and optionally reliability.
  *
@@ -38,7 +40,8 @@ struct vconn;
 struct rconn_packet_counter;
 
 struct rconn *rconn_create(int inactivity_probe_interval,
-			   int max_backoff, uint8_t dscp);
+			   int max_backoff, uint8_t dscp,
+			   const struct ofputil_version_bitmap *allowed_versions);
 void rconn_set_dscp(struct rconn *rc, uint8_t dscp);
 uint8_t rconn_get_dscp(const struct rconn *rc);
 void rconn_set_max_backoff(struct rconn *, int max_backoff);
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 4db038d..bab6f44 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -293,11 +293,16 @@ connmgr_run(struct connmgr *mgr,
 
         retval = pvconn_accept(ofservice->pvconn, &vconn);
         if (!retval) {
+            struct ofputil_version_bitmap ovb =
+                OFPUTIL_VERSION_BITMAP_INITIALIZER;
             struct rconn *rconn;
             char *name;
 
             /* Passing default value for creation of the rconn */
-            rconn = rconn_create(ofservice->probe_interval, 0, ofservice->dscp);
+            ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
+            rconn = rconn_create(ofservice->probe_interval, 0,
+                                 ofservice->dscp, &ovb);
+            ofputil_version_bitmap_free_data(&ovb);
             name = ofconn_make_name(mgr, vconn_get_name(vconn));
             rconn_connect_unreliably(rconn, vconn, name);
             free(name);
@@ -616,10 +621,14 @@ connmgr_has_snoops(const struct connmgr *mgr)
 static void
 add_controller(struct connmgr *mgr, const char *target, uint8_t dscp)
 {
+    struct ofputil_version_bitmap ovb = OFPUTIL_VERSION_BITMAP_INITIALIZER;
     char *name = ofconn_make_name(mgr, target);
     struct ofconn *ofconn;
 
-    ofconn = ofconn_create(mgr, rconn_create(5, 8, dscp), OFCONN_PRIMARY, true);
+    ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
+    ofconn = ofconn_create(mgr, rconn_create(5, 8, dscp, &ovb),
+                           OFCONN_PRIMARY, true);
+    ofputil_version_bitmap_free_data(&ovb);
     ofconn->pktbuf = pktbuf_create();
     rconn_connect(ofconn->rconn, target, name);
     hmap_insert(&mgr->controllers, &ofconn->hmap_node, hash_string(target, 0));
diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c
index 4adf61f..7a72a0a 100644
--- a/utilities/ovs-controller.c
+++ b/utilities/ovs-controller.c
@@ -203,10 +203,13 @@ main(int argc, char *argv[])
 static void
 new_switch(struct switch_ *sw, struct vconn *vconn)
 {
+    struct ofputil_version_bitmap ovb = OFPUTIL_VERSION_BITMAP_INITIALIZER;
     struct lswitch_config cfg;
     struct rconn *rconn;
 
-    rconn = rconn_create(60, 0, DSCP_DEFAULT);
+    ofputil_version_bitmap_set1(&ovb, OFP10_VERSION);
+    rconn = rconn_create(60, 0, DSCP_DEFAULT, &ovb);
+    ofputil_version_bitmap_free_data(&ovb);
     rconn_connect_unreliably(rconn, vconn, NULL);
 
     cfg.mode = (action_normal ? LSW_NORMAL
-- 
1.7.10.4




More information about the dev mailing list