From: Simon Horman Date: Wed, 7 Nov 2012 08:03:00 +0000 (+0900) Subject: rconn: Add allowed OpenFlow versions X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6042457bd537a2b5140e17e4abceacbaafff6b57;p=openvswitch rconn: Add allowed OpenFlow versions 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 Signed-off-by: Ben Pfaff --- diff --git a/lib/rconn.c b/lib/rconn.c index 5e5533ff..28c23b57 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 *); @@ -163,9 +165,17 @@ static bool rconn_logging_connection_attempts__(const struct rconn *); * 8 seconds is used. * * The new rconn is initially unconnected. Use rconn_connect() or - * rconn_connect_unreliably() to connect it. */ + * rconn_connect_unreliably() to connect it. + * + * Connections made by the rconn will automatically negotiate an OpenFlow + * protocol version acceptable to both peers on the connection. The version + * negotiated will be one of those in the 'allowed_versions' bitmap: + * version 'x' is allowed if allowed_versions & (1 << x) is nonzero. If + * 'allowed_versions' is zero, then OFPUTIL_DEFAULT_VERSIONS are allowed. + **/ 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 +213,9 @@ 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 + ? allowed_versions + : OFPUTIL_DEFAULT_VERSIONS; return rc; } @@ -354,7 +367,8 @@ reconnect(struct rconn *rc) VLOG_INFO("%s: connecting...", rc->name); } rc->n_attempted_connections++; - retval = vconn_open(rc->target, 0, &rc->vconn, rc->dscp); + 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 d10cef7f..05923668 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 7897bb7f..c96616e0 100644 --- a/ofproto/connmgr.c +++ b/ofproto/connmgr.c @@ -296,7 +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); + rconn = rconn_create(ofservice->probe_interval, 0, + ofservice->dscp, 0); name = ofconn_make_name(mgr, vconn_get_name(vconn)); rconn_connect_unreliably(rconn, vconn, name); free(name); @@ -614,7 +615,8 @@ 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, 0), + 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 b1ba7c32..af8d725a 100644 --- a/utilities/ovs-controller.c +++ b/utilities/ovs-controller.c @@ -203,7 +203,7 @@ 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, 0); rconn_connect_unreliably(rconn, vconn, NULL); cfg.mode = (action_normal ? LSW_NORMAL