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

Simon Horman horms at verge.net.au
Fri Oct 26 02:35:54 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                |    8 ++++++--
 lib/rconn.h                |    3 ++-
 ofproto/connmgr.c          |    9 +++++++--
 utilities/ovs-controller.c |    3 ++-
 4 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/lib/rconn.c b/lib/rconn.c
index 12356f8..6889c04 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;
+
+    uint32_t 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,
+             uint32_t allowed_versions)
 {
     struct rconn *rc = xzalloc(sizeof *rc);
 
@@ -203,6 +206,7 @@ rconn_create(int probe_interval, int max_backoff, uint8_t dscp)
     rconn_set_dscp(rc, dscp);
 
     rc->n_monitors = 0;
+    rc->allowed_versions = allowed_versions;
 
     return rc;
 }
@@ -354,7 +358,7 @@ reconnect(struct rconn *rc)
         VLOG_INFO("%s: connecting...", rc->name);
     }
     rc->n_attempted_connections++;
-    retval = vconn_open(rc->target, ofputil_get_allowed_versions_default(),
+    retval = vconn_open(rc->target, rc->allowed_versions,
                         &rc->vconn, rc->dscp);
     if (!retval) {
         rc->remote_ip = vconn_get_remote_ip(rc->vconn);
diff --git a/lib/rconn.h b/lib/rconn.h
index d10cef7..0592366 100644
--- a/lib/rconn.h
+++ b/lib/rconn.h
@@ -38,7 +38,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,
+			   uint32_t 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 aec20bd..4bcc816 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -296,7 +296,9 @@ connmgr_run(struct connmgr *mgr,
             char *name;
 
             /* Passing default value for creation of the rconn */
-            rconn = rconn_create(ofservice->probe_interval, 0, ofservice->dscp);
+            rconn = rconn_create(ofservice->probe_interval, 0,
+                                 ofservice->dscp,
+                                 ofputil_get_allowed_versions_default());
             name = ofconn_make_name(mgr, vconn_get_name(vconn));
             rconn_connect_unreliably(rconn, vconn, name);
             free(name);
@@ -616,7 +618,10 @@ add_controller(struct connmgr *mgr, const char *target, uint8_t dscp)
     char *name = ofconn_make_name(mgr, target);
     struct ofconn *ofconn;
 
-    ofconn = ofconn_create(mgr, rconn_create(5, 8, dscp), OFCONN_PRIMARY, true);
+    ofconn = ofconn_create(mgr,
+                           rconn_create(5, 8, dscp,
+                                        ofputil_get_allowed_versions_default()),
+                           OFCONN_PRIMARY, true);
     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 945592e..d0d31d6 100644
--- a/utilities/ovs-controller.c
+++ b/utilities/ovs-controller.c
@@ -205,7 +205,8 @@ new_switch(struct switch_ *sw, struct vconn *vconn)
     struct lswitch_config cfg;
     struct rconn *rconn;
 
-    rconn = rconn_create(60, 0, DSCP_DEFAULT);
+    rconn = rconn_create(60, 0, DSCP_DEFAULT,
+                         ofputil_get_allowed_versions_default());
     rconn_connect_unreliably(rconn, vconn, NULL);
 
     cfg.mode = (action_normal ? LSW_NORMAL
-- 
1.7.10.4




More information about the dev mailing list