From: Simon Horman Date: Wed, 7 Nov 2012 08:03:02 +0000 (+0900) Subject: ofproto, connmgr: Parameterise OpenFlow versions for adding controller X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d9ffc175a68bf05c57797fa3715476f9e426b55;p=openvswitch ofproto, connmgr: Parameterise OpenFlow versions for adding controller 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 Signed-off-by: Ben Pfaff --- diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index c96616e0..ba93a1d5 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -296,8 +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, 0); + 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); @@ -400,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 *); @@ -491,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; @@ -509,13 +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, 0, c->dscp); + ofservice_create(mgr, c->target, allowed_versions, c->dscp); } } else { VLOG_WARN_RL(&rl, "%s: unsupported controller \"%s\"", @@ -610,12 +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, 0), + 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 9a080f28..6d6842d5 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 *, const struct sset *snoops); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 1f34bbae..0aeb07e2 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -518,9 +518,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 20335a2e..0366c89f 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -218,7 +218,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 8f544a99..9fe77504 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2797,7 +2797,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, 0); free(ocs[0].target); /* From bridge_ofproto_controller_for_mgmt(). */ free(ocs);