Paramatise the allowed OpenFlow verion for snoops. This is in preparation for making the allow OpenFlow verions to be configured.
Signed-off-by: Simon Horman <ho...@verge.net.au> --- ofproto/connmgr.c | 19 ++++++++++--------- ofproto/connmgr.h | 2 +- ofproto/ofproto.c | 2 +- ofproto/ofproto.h | 7 ++++++- vswitchd/bridge.c | 17 +++++++++++------ 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c index b3c94db..aec20bd 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -404,7 +404,7 @@ static struct ofconn *find_controller_by_target(struct connmgr *, const char *target); static void update_fail_open(struct connmgr *); static int set_pvconns(struct pvconn ***pvconnsp, size_t *n_pvconnsp, - const struct sset *); + const struct shash *); /* Returns true if 'mgr' has any configured primary controllers. * @@ -585,7 +585,7 @@ connmgr_reconnect(const struct connmgr *mgr) * A "snoop" is a pvconn to which every OpenFlow message to or from the most * important controller on 'mgr' is mirrored. */ int -connmgr_set_snoops(struct connmgr *mgr, const struct sset *snoops) +connmgr_set_snoops(struct connmgr *mgr, const struct shash *snoops) { return set_pvconns(&mgr->snoops, &mgr->n_snoops, snoops); } @@ -705,11 +705,11 @@ update_fail_open(struct connmgr *mgr) static int set_pvconns(struct pvconn ***pvconnsp, size_t *n_pvconnsp, - const struct sset *sset) + const struct shash *shash) { struct pvconn **pvconns = *pvconnsp; size_t n_pvconns = *n_pvconnsp; - const char *name; + struct shash_node *node; int retval = 0; size_t i; @@ -718,17 +718,18 @@ set_pvconns(struct pvconn ***pvconnsp, size_t *n_pvconnsp, } free(pvconns); - pvconns = xmalloc(sset_count(sset) * sizeof *pvconns); + pvconns = xmalloc(shash_count(shash) * sizeof *pvconns); n_pvconns = 0; - SSET_FOR_EACH (name, sset) { + SHASH_FOR_EACH (node, shash) { + const struct ofproto_name_and_versions *nv = node->data; struct pvconn *pvconn; int error; - error = pvconn_open(name, ofputil_get_allowed_versions_default(), - &pvconn, 0); + + error = pvconn_open(nv->name, nv->allowed_versions, &pvconn, 0); if (!error) { pvconns[n_pvconns++] = pvconn; } else { - VLOG_ERR("failed to listen on %s: %s", name, strerror(error)); + VLOG_ERR("failed to listen on %s: %s", nv->name, strerror(error)); if (!retval) { retval = error; } diff --git a/ofproto/connmgr.h b/ofproto/connmgr.h index 9a080f2..3a508ca 100644 --- a/ofproto/connmgr.h +++ b/ofproto/connmgr.h @@ -88,7 +88,7 @@ void connmgr_set_controllers(struct connmgr *, const struct ofproto_controller[], size_t n); void connmgr_reconnect(const struct connmgr *); -int connmgr_set_snoops(struct connmgr *, const struct sset *snoops); +int connmgr_set_snoops(struct connmgr *mgr, const struct shash *snoops); bool connmgr_has_snoops(const struct connmgr *); void connmgr_get_snoops(const struct connmgr *, struct sset *snoops); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 2fb2fc8..568f9bb 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -606,7 +606,7 @@ ofproto_set_desc(struct ofproto *p, } int -ofproto_set_snoops(struct ofproto *ofproto, const struct sset *snoops) +ofproto_set_snoops(struct ofproto *ofproto, const struct shash *snoops) { return connmgr_set_snoops(ofproto->connmgr, snoops); } diff --git a/ofproto/ofproto.h b/ofproto/ofproto.h index 5599cd6..6d44c5a 100644 --- a/ofproto/ofproto.h +++ b/ofproto/ofproto.h @@ -132,6 +132,11 @@ struct ofproto_controller { uint8_t dscp; /* DSCP value for controller connection. */ }; +struct ofproto_name_and_versions { + char *name; + uint32_t allowed_versions; +}; + #define DEFAULT_MFR_DESC "Nicira, Inc." #define DEFAULT_HW_DESC "Open vSwitch" #define DEFAULT_SW_DESC VERSION @@ -217,7 +222,7 @@ void ofproto_set_desc(struct ofproto *, const char *mfr_desc, const char *hw_desc, const char *sw_desc, const char *serial_desc, const char *dp_desc); -int ofproto_set_snoops(struct ofproto *, const struct sset *snoops); +int ofproto_set_snoops(struct ofproto *ofproto, const struct shash *snoops); int ofproto_set_netflow(struct ofproto *, const struct netflow_options *nf_options); int ofproto_set_sflow(struct ofproto *, const struct ofproto_sflow_options *); diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index a481f06..38dd92b 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -36,6 +36,7 @@ #include "meta-flow.h" #include "netdev.h" #include "ofp-print.h" +#include "ofp-util.h" #include "ofpbuf.h" #include "ofproto/ofproto.h" #include "poll-loop.h" @@ -2731,13 +2732,17 @@ bridge_configure_remotes(struct bridge *br, /* Configure OpenFlow controller connection snooping. */ if (!ofproto_has_snoops(br->ofproto)) { - struct sset snoops; - - sset_init(&snoops); - sset_add_and_free(&snoops, xasprintf("punix:%s/%s.snoop", - ovs_rundir(), br->name)); + 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(), + }; + + shash_init(&snoops); + shash_add(&snoops, nv.name, &nv); ofproto_set_snoops(br->ofproto, &snoops); - sset_destroy(&snoops); + shash_destroy(&snoops); + free(nv.name); } } -- 1.7.10.4 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev