ovs-ofctl: Use the prepared connection to dump flows in do_dump_flows__().
authorBen Pfaff <blp@nicira.com>
Tue, 3 Jul 2012 17:25:35 +0000 (10:25 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 12 Jul 2012 19:56:01 +0000 (12:56 -0700)
The logic in do_dump_flows__() went to some trouble to open an OpenFlow
connection and set the correct protocol, but then it allowed
dump_stats_transaction() to create and use a completely different OpenFlow
connection that hadn't been prepared that way.  This commit fixes the
problem.

I don't think that there is a real bug here because currently the set of
protocols doesn't influence flow stats replies.  But that could change in
the future.

Signed-off-by: Ben Pfaff <blp@nicira.com>
utilities/ovs-ofctl.c

index 77a1434ecb1a8aa5d5c224540dcc924528d7fba1..f7b94dcc02f00d401fa17832be24f54a917fcefc 100644 (file)
@@ -377,14 +377,12 @@ dump_trivial_transaction(const char *vconn_name, uint8_t request_type)
 }
 
 static void
-dump_stats_transaction(const char *vconn_name, struct ofpbuf *request)
+dump_stats_transaction__(struct vconn *vconn, struct ofpbuf *request)
 {
     ovs_be32 send_xid = ((struct ofp_header *) request->data)->xid;
     ovs_be16 stats_type = ((struct ofp_stats_msg *) request->data)->type;
-    struct vconn *vconn;
     bool done = false;
 
-    open_vconn(vconn_name, &vconn);
     send_openflow_buffer(vconn, request);
     while (!done) {
         ovs_be32 recv_xid;
@@ -414,6 +412,15 @@ dump_stats_transaction(const char *vconn_name, struct ofpbuf *request)
         }
         ofpbuf_delete(reply);
     }
+}
+
+static void
+dump_stats_transaction(const char *vconn_name, struct ofpbuf *request)
+{
+    struct vconn *vconn;
+
+    open_vconn(vconn_name, &vconn);
+    dump_stats_transaction__(vconn, request);
     vconn_close(vconn);
 }
 
@@ -777,7 +784,7 @@ ofctl_dump_flows__(int argc, char *argv[], bool aggregate)
     protocol = open_vconn(argv[1], &vconn);
     protocol = set_protocol_for_flow_dump(vconn, protocol, usable_protocols);
     request = ofputil_encode_flow_stats_request(&fsr, protocol);
-    dump_stats_transaction(argv[1], request);
+    dump_stats_transaction__(vconn, request);
     vconn_close(vconn);
 }