ovs-ofctl: Support large number of ports with "show" command.
authorJustin Pettit <jpettit@nicira.com>
Sat, 5 May 2012 00:27:16 +0000 (17:27 -0700)
committerJustin Pettit <jpettit@nicira.com>
Tue, 8 May 2012 16:51:46 +0000 (09:51 -0700)
OpenFlow Features Reply messages prior to 1.3 can give users the wrong
impression about how many ports are on the system.  With this commit,
the command will check if the number of ports may be truncated.  If so,
it will send a Port Description stats request to get the complete list
and ignore the Features Reply port list.

Bug #11087

Signed-off-by: Justin Pettit <jpettit@nicira.com>
utilities/ovs-ofctl.c

index 4a37067f37c786eba5291f09c380df985e23a633..d94ad6405087c23a08d57eeec1e3c3d4469d757b 100644 (file)
@@ -496,8 +496,30 @@ set_switch_config(struct vconn *vconn, struct ofp_switch_config *config_)
 static void
 do_show(int argc OVS_UNUSED, char *argv[])
 {
-    dump_trivial_transaction(argv[1], OFPT_FEATURES_REQUEST);
-    dump_trivial_transaction(argv[1], OFPT_GET_CONFIG_REQUEST);
+    const char *vconn_name = argv[1];
+    struct vconn *vconn;
+    struct ofpbuf *request;
+    struct ofpbuf *reply;
+    bool trunc;
+
+    make_openflow(sizeof(struct ofp_header), OFPT_FEATURES_REQUEST,
+                  &request);
+    open_vconn(vconn_name, &vconn);
+    run(vconn_transact(vconn, request, &reply), "talking to %s", vconn_name);
+
+    trunc = ofputil_switch_features_ports_trunc(reply);
+    ofp_print(stdout, reply->data, reply->size, verbosity + 1);
+
+    ofpbuf_delete(reply);
+    vconn_close(vconn);
+
+    if (trunc) {
+        /* The Features Reply may not contain all the ports, so send a
+         * Port Description stats request, which doesn't have size
+         * constraints. */
+        dump_trivial_stats_transaction(vconn_name, OFPST_PORT_DESC);
+    }
+    dump_trivial_transaction(vconn_name, OFPT_GET_CONFIG_REQUEST);
 }
 
 static void