[ovs-dev] [PATCH 1/2] ovs-ofctl: Fix handling of unexpected replies in dump_stats_transaction().
Ben Pfaff
blp at nicira.com
Mon Jun 11 11:26:36 PDT 2012
dump_stats_transaction() ignored errors and other non-stats replies to
its request and would continue to wait forever. This fixes the problem.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
utilities/ovs-ofctl.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/utilities/ovs-ofctl.c b/utilities/ovs-ofctl.c
index 8f02192..8f5a3f0 100644
--- a/utilities/ovs-ofctl.c
+++ b/utilities/ovs-ofctl.c
@@ -392,12 +392,23 @@ dump_stats_transaction(const char *vconn_name, struct ofpbuf *request)
run(vconn_recv_block(vconn, &reply), "OpenFlow packet receive failed");
recv_xid = ((struct ofp_header *) reply->data)->xid;
if (send_xid == recv_xid) {
- struct ofp_stats_msg *osm;
+ const struct ofputil_msg_type *type;
+ enum ofputil_msg_code code;
ofp_print(stdout, reply->data, reply->size, verbosity + 1);
- osm = ofpbuf_at(reply, 0, sizeof *osm);
- done = !osm || !(ntohs(osm->flags) & OFPSF_REPLY_MORE);
+ ofputil_decode_msg_type(reply->data, &type);
+ code = ofputil_msg_type_code(type);
+ if (code == OFPUTIL_OFPST_QUEUE_REPLY) {
+ struct ofp_stats_msg *osm = reply->data;
+ done = !(ntohs(osm->flags) & OFPSF_REPLY_MORE);
+ } else if (code == OFPUTIL_OFPT_ERROR) {
+ done = true;
+ } else {
+ ovs_fatal(0, "received bad reply: %s",
+ ofp_to_string(reply->data, reply->size,
+ verbosity + 1));
+ }
} else {
VLOG_DBG("received reply with xid %08"PRIx32" "
"!= expected %08"PRIx32, recv_xid, send_xid);
--
1.7.2.5
More information about the dev
mailing list