flow: Improve flow_format() output.
[openvswitch] / utilities / ovs-ofctl.c
index ce9723b91eec68bc07b83f6a3917c888f4651429..7b20ba097ab957775a43672110b2a61a02619ac0 100644 (file)
@@ -187,10 +187,10 @@ usage(void)
            "  replace-flows SWITCH FILE   replace flows with those in FILE\n"
            "  monitor SWITCH [MISSLEN]    print packets received from SWITCH\n"
            "\nFor OpenFlow switches and controllers:\n"
-           "  probe VCONN                 probe whether VCONN is up\n"
-           "  ping VCONN [N]              latency of N-byte echos\n"
-           "  benchmark VCONN N COUNT     bandwidth of COUNT N-byte echos\n"
-           "where each SWITCH is an active OpenFlow connection method.\n",
+           "  probe TARGET                probe whether TARGET is up\n"
+           "  ping TARGET [N]             latency of N-byte echos\n"
+           "  benchmark TARGET N COUNT    bandwidth of COUNT N-byte echos\n"
+           "where SWITCH or TARGET is an active OpenFlow connection method.\n",
            program_name, program_name);
     vconn_usage(true, false, false);
     vlog_usage();
@@ -586,6 +586,9 @@ do_dump_flows__(int argc, char *argv[], bool aggregate)
 
     open_vconn(argv[1], &vconn);
     min_flow_format = ofputil_min_flow_format(&fsr.match);
+    if (fsr.cookie_mask != htonll(0)) {
+        min_flow_format = NXFF_NXM;
+    }
     flow_format = negotiate_highest_flow_format(vconn, min_flow_format);
     request = ofputil_encode_flow_stats_request(&fsr, flow_format);
     dump_stats_transaction(argv[1], request);
@@ -839,6 +842,11 @@ do_mod_port(int argc OVS_UNUSED, char *argv[])
     } else if (!strcasecmp(argv[3], "noflood")) {
         opm->mask |= htonl(OFPPC_NO_FLOOD);
         opm->config |= htonl(OFPPC_NO_FLOOD);
+    } else if (!strcasecmp(argv[3], "forward")) {
+        opm->mask |= htonl(OFPPC_NO_FWD);
+    } else if (!strcasecmp(argv[3], "noforward")) {
+        opm->mask |= htonl(OFPPC_NO_FWD);
+        opm->config |= htonl(OFPPC_NO_FWD);
     } else {
         ovs_fatal(0, "unknown mod-port command '%s'", argv[3]);
     }
@@ -1172,6 +1180,7 @@ read_flows_from_switch(struct vconn *vconn, enum nx_flow_format flow_format,
     cls_rule_init_catchall(&fsr.match, 0);
     fsr.out_port = OFPP_NONE;
     fsr.table_id = 0xff;
+    fsr.cookie = fsr.cookie_mask = htonll(0);
     request = ofputil_encode_flow_stats_request(&fsr, flow_format);
     send_xid = ((struct ofp_header *) request->data)->xid;
     send_openflow_buffer(vconn, request);
@@ -1421,7 +1430,7 @@ do_parse_flows(int argc OVS_UNUSED, char *argv[])
 
     file = fopen(argv[1], "r");
     if (file == NULL) {
-        ovs_fatal(errno, "%s: open", argv[2]);
+        ovs_fatal(errno, "%s: open", argv[1]);
     }
 
     flow_format = NXFF_OPENFLOW10;
@@ -1450,6 +1459,7 @@ do_parse_nx_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     while (!ds_get_line(&in, stdin)) {
         struct ofpbuf nx_match;
         struct cls_rule rule;
+        ovs_be64 cookie, cookie_mask;
         int match_len;
         int error;
         char *s;
@@ -1473,14 +1483,15 @@ do_parse_nx_match(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
         match_len = nx_match_from_string(ds_cstr(&in), &nx_match);
 
         /* Convert nx_match to cls_rule. */
-        error = nx_pull_match(&nx_match, match_len, 0, &rule);
+        error = nx_pull_match(&nx_match, match_len, 0, &rule,
+                              &cookie, &cookie_mask);
         if (!error) {
             char *out;
 
             /* Convert cls_rule back to nx_match. */
             ofpbuf_uninit(&nx_match);
             ofpbuf_init(&nx_match, 0);
-            match_len = nx_put_match(&nx_match, &rule);
+            match_len = nx_put_match(&nx_match, &rule, cookie, cookie_mask);
 
             /* Convert nx_match to string. */
             out = nx_match_to_string(nx_match.data, match_len);