From 1a126c0c6803db4e6c16ddc0a3369a6ad197d238 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Wed, 1 Aug 2012 16:01:50 +0900 Subject: [PATCH] ofp-util: Make make_echo_request() aware of different OpenFlow versions. Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- 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 c1e8ce4e..59a4bd66 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -2973,9 +2973,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(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); } diff --git a/lib/ofp-util.h b/lib/ofp-util.h index 18cee7a3..64f6c39c 100644 --- a/lib/ofp-util.h +++ b/lib/ofp-util.h @@ -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); diff --git a/lib/rconn.c b/lib/rconn.c index eae6a7e8..ddf578c1 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -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; } diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c index 13dd0e3c..2343240b 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"); -- 2.30.2