[ovs-dev] [PATCH 07/47] ofp-util: Make make_echo_request() aware of different OpenFlow versions.

Simon Horman horms at verge.net.au
Wed Aug 1 07:01:50 UTC 2012


Signed-off-by: Simon Horman <horms at verge.net.au>

---

v9
* No change

v8
* Manual Rebase

v7
* Manual Rebase

v6
* No change

v5
* No change

v4
* Initial post
---
 lib/ofp-util.c        | 4 ++--
 lib/ofp-util.h        | 2 +-
 lib/rconn.c           | 7 ++++++-
 utilities/ovs-ofctl.c | 2 +-
 4 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index 0b865cd..07ca1af 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -3006,9 +3006,9 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po)
 
 /* Creates and returns an OFPT_ECHO_REQUEST message with an empty payload. */
 struct ofpbuf *
-make_echo_request(void)
+make_echo_request(uint8_t ofp_version)
 {
-    return ofpraw_alloc_xid(OFPRAW_OFPT_ECHO_REQUEST, OFP10_VERSION,
+    return ofpraw_alloc_xid(OFPRAW_OFPT_ECHO_REQUEST, ofp_version,
                             htonl(0), 0);
 }
 
diff --git a/lib/ofp-util.h b/lib/ofp-util.h
index dfbbaf3..28db008 100644
--- a/lib/ofp-util.h
+++ b/lib/ofp-util.h
@@ -499,7 +499,7 @@ void ofputil_append_port_desc_stats_reply(enum ofp_version ofp_version,
                                           struct list *replies);
 
 /* Encoding simple OpenFlow messages. */
-struct ofpbuf *make_echo_request(void);
+struct ofpbuf *make_echo_request(uint8_t ofp_version);
 struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
 
 struct ofpbuf *ofputil_encode_barrier_request(uint8_t ofp_version);
diff --git a/lib/rconn.c b/lib/rconn.c
index b84cda6..cfa72bc 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -441,14 +441,19 @@ run_ACTIVE(struct rconn *rc)
 {
     if (timed_out(rc)) {
         unsigned int base = MAX(rc->last_received, rc->state_entered);
+        int version;
+
         VLOG_DBG("%s: idle %u seconds, sending inactivity probe",
                  rc->name, (unsigned int) (time_now() - base));
 
+        version = rconn_get_version(rc);
+        assert(version >= 0 && version <= 0xff);
+
         /* Ordering is important here: rconn_send() can transition to BACKOFF,
          * and we don't want to transition back to IDLE if so, because then we
          * can end up queuing a packet with vconn == NULL and then *boom*. */
         state_transition(rc, S_IDLE);
-        rconn_send(rc, make_echo_request(), NULL);
+        rconn_send(rc, make_echo_request(version), NULL);
         return;
     }
 
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 13dd0e3..2343240 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -1440,8 +1440,8 @@ ofctl_probe(int argc OVS_UNUSED, char *argv[])
     struct vconn *vconn;
     struct ofpbuf *reply;
 
-    request = make_echo_request();
     open_vconn(argv[1], &vconn);
+    request = make_echo_request(vconn_get_version(vconn));
     run(vconn_transact(vconn, request, &reply), "talking to %s", argv[1]);
     if (reply->size != sizeof(struct ofp_header)) {
         ovs_fatal(0, "reply does not match request");
-- 
1.7.10.2.484.gcd07cc5




More information about the dev mailing list