[ovs-dev] [PATCH 07/18] ofproto, connmgr: Parameterise OpenFlow versions for adding controller

Simon Horman horms at verge.net.au
Fri Oct 26 02:35:55 UTC 2012


Allow allowed Open Flow versions to be passed rather
than relying on 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>
---
 ofproto/connmgr.c |   23 ++++++++++-------------
 ofproto/connmgr.h |    3 ++-
 ofproto/ofproto.c |    5 +++--
 ofproto/ofproto.h |    3 ++-
 vswitchd/bridge.c |    6 ++++--
 5 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 4bcc816..d64c7b4 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -296,9 +296,8 @@ connmgr_run(struct connmgr *mgr,
             char *name;
 
             /* Passing default value for creation of the rconn */
-            rconn = rconn_create(ofservice->probe_interval, 0,
-                                 ofservice->dscp,
-                                 ofputil_get_allowed_versions_default());
+            rconn = rconn_create(ofservice->probe_interval, 0, ofservice->dscp,
+                                 vconn_get_allowed_versions(vconn));
             name = ofconn_make_name(mgr, vconn_get_name(vconn));
             rconn_connect_unreliably(rconn, vconn, name);
             free(name);
@@ -401,7 +400,8 @@ connmgr_retry(struct connmgr *mgr)
 
 /* OpenFlow configuration. */
 
-static void add_controller(struct connmgr *, const char *target, uint8_t dscp);
+static void add_controller(struct connmgr *, const char *target, uint8_t dscp,
+                           uint32_t allowed_versions);
 static struct ofconn *find_controller_by_target(struct connmgr *,
                                                 const char *target);
 static void update_fail_open(struct connmgr *);
@@ -492,7 +492,7 @@ connmgr_free_controller_info(struct shash *info)
 void
 connmgr_set_controllers(struct connmgr *mgr,
                         const struct ofproto_controller *controllers,
-                        size_t n_controllers)
+                        size_t n_controllers, uint32_t allowed_versions)
 {
     bool had_controllers = connmgr_has_controllers(mgr);
     struct shash new_controllers;
@@ -510,15 +510,13 @@ connmgr_set_controllers(struct connmgr *mgr,
             if (!find_controller_by_target(mgr, c->target)) {
                 VLOG_INFO("%s: added primary controller \"%s\"",
                           mgr->name, c->target);
-                add_controller(mgr, c->target, c->dscp);
+                add_controller(mgr, c->target, c->dscp, allowed_versions);
             }
         } else if (!pvconn_verify_name(c->target)) {
             if (!ofservice_lookup(mgr, c->target)) {
                 VLOG_INFO("%s: added service controller \"%s\"",
                           mgr->name, c->target);
-                ofservice_create(mgr, c->target,
-                                 ofputil_get_allowed_versions_default(),
-                                 c->dscp);
+                ofservice_create(mgr, c->target, allowed_versions, c->dscp);
             }
         } else {
             VLOG_WARN_RL(&rl, "%s: unsupported controller \"%s\"",
@@ -613,14 +611,13 @@ connmgr_has_snoops(const struct connmgr *mgr)
 /* Creates a new controller for 'target' in 'mgr'.  update_controller() needs
  * to be called later to finish the new ofconn's configuration. */
 static void
-add_controller(struct connmgr *mgr, const char *target, uint8_t dscp)
+add_controller(struct connmgr *mgr, const char *target, uint8_t dscp,
+               uint32_t allowed_versions)
 {
     char *name = ofconn_make_name(mgr, target);
     struct ofconn *ofconn;
 
-    ofconn = ofconn_create(mgr,
-                           rconn_create(5, 8, dscp,
-                                        ofputil_get_allowed_versions_default()),
+    ofconn = ofconn_create(mgr, rconn_create(5, 8, dscp, allowed_versions),
                            OFCONN_PRIMARY, true);
     ofconn->pktbuf = pktbuf_create();
     rconn_connect(ofconn->rconn, target, name);
diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h
index 3a508ca..f8f7d75 100644
--- a/ofproto/connmgr.h
+++ b/ofproto/connmgr.h
@@ -85,7 +85,8 @@ bool connmgr_has_controllers(const struct connmgr *);
 void connmgr_get_controller_info(struct connmgr *, struct shash *);
 void connmgr_free_controller_info(struct shash *);
 void connmgr_set_controllers(struct connmgr *,
-                             const struct ofproto_controller[], size_t n);
+                             const struct ofproto_controller[], size_t n,
+                             uint32_t allowed_versions);
 void connmgr_reconnect(const struct connmgr *);
 
 int connmgr_set_snoops(struct connmgr *mgr, const struct shash *snoops);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 568f9bb..6c081dd 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -480,9 +480,10 @@ ofproto_set_datapath_id(struct ofproto *p, uint64_t datapath_id)
 void
 ofproto_set_controllers(struct ofproto *p,
                         const struct ofproto_controller *controllers,
-                        size_t n_controllers)
+                        size_t n_controllers, uint32_t allowed_versions)
 {
-    connmgr_set_controllers(p->connmgr, controllers, n_controllers);
+    connmgr_set_controllers(p->connmgr, controllers, n_controllers,
+                            allowed_versions);
 }
 
 void
diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h
index 6d44c5a..0cb57d7 100644
--- a/ofproto/ofproto.h
+++ b/ofproto/ofproto.h
@@ -209,7 +209,8 @@ int ofproto_port_query_by_name(const struct ofproto *, const char *devname,
 uint64_t ofproto_get_datapath_id(const struct ofproto *);
 void ofproto_set_datapath_id(struct ofproto *, uint64_t datapath_id);
 void ofproto_set_controllers(struct ofproto *,
-                             const struct ofproto_controller *, size_t n);
+                             const struct ofproto_controller *, size_t n,
+                             uint32_t allowed_versions);
 void ofproto_set_fail_mode(struct ofproto *, enum ofproto_fail_mode fail_mode);
 void ofproto_reconnect_controllers(struct ofproto *);
 void ofproto_set_extra_in_band_remotes(struct ofproto *,
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 38dd92b..0f26231 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2662,6 +2662,8 @@ bridge_configure_remotes(struct bridge *br,
     size_t n_ocs;
     size_t i;
 
+    uint32_t allowed_versions = ofputil_get_allowed_versions_default();
+
     /* Check if we should disable in-band control on this bridge. */
     disable_in_band = smap_get_bool(&br->cfg->other_config, "disable-in-band",
                                     false);
@@ -2719,7 +2721,7 @@ bridge_configure_remotes(struct bridge *br,
         n_ocs++;
     }
 
-    ofproto_set_controllers(br->ofproto, ocs, n_ocs);
+    ofproto_set_controllers(br->ofproto, ocs, n_ocs, allowed_versions);
     free(ocs[0].target); /* From bridge_ofproto_controller_for_mgmt(). */
     free(ocs);
 
@@ -2735,7 +2737,7 @@ bridge_configure_remotes(struct bridge *br,
         struct shash snoops;
         struct ofproto_name_and_versions nv = {
             .name = xasprintf("punix:%s/%s.snoop", ovs_rundir(), br->name),
-            .allowed_versions = ofputil_get_allowed_versions_default(),
+            .allowed_versions = allowed_versions,
         };
 
         shash_init(&snoops);
-- 
1.7.10.4




More information about the dev mailing list