ofp-util: Make make_echo_request() aware of different OpenFlow versions.
authorSimon Horman <horms@verge.net.au>
Wed, 1 Aug 2012 07:01:50 +0000 (16:01 +0900)
committerBen Pfaff <blp@nicira.com>
Tue, 7 Aug 2012 05:50:21 +0000 (22:50 -0700)
Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/ofp-util.c
lib/ofp-util.h
lib/rconn.c
utilities/ovs-ofctl.c

index c1e8ce4ec121a7fce37a326076d7838392c0af6a..59a4bd66e0b6e813b21109b69caa3ae77adf11d5 100644 (file)
@@ -2973,9 +2973,9 @@ ofputil_encode_packet_out(const struct ofputil_packet_out *po)
 \f
 /* Creates and returns an OFPT_ECHO_REQUEST message with an empty payload. */
 struct ofpbuf *
-make_echo_request(void)
+make_echo_request(enum ofp_version 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);
 }
 
index 18cee7a32b6bd389b6debc24763a66431acff9f9..64f6c39c3d71351d1758f9aed2dd15c01c968edf 100644 (file)
@@ -494,7 +494,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(enum ofp_version);
 struct ofpbuf *make_echo_reply(const struct ofp_header *rq);
 
 struct ofpbuf *ofputil_encode_barrier_request(enum ofp_version);
index eae6a7e8faaea82b11c97f240e48620284ffd395..ddf578c185aded6b2440d9b18e5b8141c46b41a8 100644 (file)
@@ -446,14 +446,19 @@ run_ACTIVE(struct rconn *rc)
 {
     if (timed_out(rc)) {
         unsigned int base = MAX(rc->last_activity, 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;
     }
 
index 13dd0e3c339a0f9ff6659cfa4cb1f708e46c4184..2343240bb87095a0681ac445ee75a3a8f6685e30 100644 (file)
@@ -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");