From: Simon Horman Date: Wed, 7 Nov 2012 08:03:01 +0000 (+0900) Subject: vonn: Allow snoops to use the OpenFlow version of the controller connection X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e182670b0262e58a982a659dc5248aa5874264e2;p=openvswitch vonn: Allow snoops to use the OpenFlow version of the controller connection Override the allowed versions of the snoop vconn so that only the version of the controller connection is allowed. This is because the snoop will see the same messages as the controller. Without this change the snoop will try to negotiate a connection using the default allowed versions, or in other words only allow OpenFlow 1.0. This breaks snoops for controller connections using other OpenFlow versions, that is OpenFlow 1.2. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/rconn.c b/lib/rconn.c index 28c23b57..a6b634bc 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -135,6 +135,11 @@ struct rconn { uint32_t allowed_versions; }; +uint32_t rconn_get_allowed_versions(const struct rconn *rconn) +{ + return rconn->allowed_versions; +} + static unsigned int elapsed_in_this_state(const struct rconn *); static unsigned int timeout(const struct rconn *); static bool timed_out(const struct rconn *); @@ -671,6 +676,14 @@ void rconn_add_monitor(struct rconn *rc, struct vconn *vconn) { if (rc->n_monitors < ARRAY_SIZE(rc->monitors)) { + int version = vconn_get_version(rc->vconn); + + /* Override the allowed versions of the snoop vconn so that + * only the version of the controller connection is allowed. + * This is because the snoop will see the same messages as the + * controller */ + vconn_set_allowed_versions(vconn, 1u << version); + VLOG_INFO("new monitor connection from %s", vconn_get_name(vconn)); rc->monitors[rc->n_monitors++] = vconn; } else { diff --git a/lib/rconn.h b/lib/rconn.h index 05923668..aa302383 100644 --- a/lib/rconn.h +++ b/lib/rconn.h @@ -41,6 +41,7 @@ struct rconn *rconn_create(int inactivity_probe_interval, int max_backoff, uint8_t dscp, uint32_t allowed_versions); void rconn_set_dscp(struct rconn *rc, uint8_t dscp); +uint32_t rconn_get_allowed_versions(const struct rconn *); uint8_t rconn_get_dscp(const struct rconn *rc); void rconn_set_max_backoff(struct rconn *, int max_backoff); int rconn_get_max_backoff(const struct rconn *); diff --git a/lib/vconn.c b/lib/vconn.c index 6c77d060..4e92834e 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -343,6 +343,14 @@ vconn_get_allowed_versions(const struct vconn *vconn) return vconn->allowed_versions; } +/* Sets the allowed_versions of 'vconn', overriding + * the allowed_versions passed to vconn_open(). */ +void +vconn_set_allowed_versions(struct vconn *vconn, uint32_t allowed_versions) +{ + vconn->allowed_versions = allowed_versions; +} + /* Returns the IP address of the peer, or 0 if the peer is not connected over * an IP-based protocol or if its IP address is not yet known. */ ovs_be32 diff --git a/lib/vconn.h b/lib/vconn.h index 46ff17fa..3f69a511 100644 --- a/lib/vconn.h +++ b/lib/vconn.h @@ -39,6 +39,8 @@ int vconn_open(const char *name, uint32_t allowed_versions, void vconn_close(struct vconn *); const char *vconn_get_name(const struct vconn *); uint32_t vconn_get_allowed_versions(const struct vconn *vconn); +void vconn_set_allowed_versions(struct vconn *vconn, + uint32_t allowed_versions); ovs_be32 vconn_get_remote_ip(const struct vconn *); ovs_be16 vconn_get_remote_port(const struct vconn *); ovs_be32 vconn_get_local_ip(const struct vconn *);