ofp-print: Always print priority exactly once.
authorBen Pfaff <blp@nicira.com>
Tue, 14 Dec 2010 19:36:04 +0000 (11:36 -0800)
committerBen Pfaff <blp@nicira.com>
Wed, 15 Dec 2010 17:48:18 +0000 (09:48 -0800)
Reported-by: Paul Ingram <paul@nicira.com>
lib/ofp-print.c
tests/ofproto.at

index 2d9e02657d7dd6f034bff7340a97930cb12649d2..e565569789742de5862445010966c9ad725417d5 100644 (file)
@@ -798,6 +798,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh,
                    enum ofputil_msg_code code, int verbosity)
 {
     struct flow_mod fm;
+    bool need_priority;
     int error;
 
     error = ofputil_decode_flow_mod(&fm, oh, NXFF_OPENFLOW10);
@@ -830,16 +831,26 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh,
     ds_put_char(s, ' ');
     if (verbosity >= 3 && code == OFPUTIL_OFPT_FLOW_MOD) {
         const struct ofp_flow_mod *ofm = (const struct ofp_flow_mod *) oh;
-
         ofp_print_match(s, &ofm->match, verbosity);
+
+        /* ofp_print_match() doesn't print priority. */
+        need_priority = true;
     } else if (verbosity >= 3 && code == OFPUTIL_NXT_FLOW_MOD) {
         const struct nx_flow_mod *nfm = (const struct nx_flow_mod *) oh;
         const void *nxm = nfm + 1;
-        char *nxm_s = nx_match_to_string(nxm, ntohs(nfm->match_len));
+        char *nxm_s;
+
+        nxm_s = nx_match_to_string(nxm, ntohs(nfm->match_len));
         ds_put_cstr(s, nxm_s);
         free(nxm_s);
+
+        /* nx_match_to_string() doesn't print priority. */
+        need_priority = true;
     } else {
         cls_rule_format(&fm.cr, s);
+
+        /* cls_rule_format() does print priority. */
+        need_priority = false;
     }
 
     if (ds_last(s) != ' ') {
@@ -854,7 +865,7 @@ ofp_print_flow_mod(struct ds *s, const struct ofp_header *oh,
     if (fm.hard_timeout != OFP_FLOW_PERMANENT) {
         ds_put_format(s, "hard:%"PRIu16" ", fm.hard_timeout);
     }
-    if (fm.cr.priority != OFP_DEFAULT_PRIORITY && verbosity >= 3) {
+    if (fm.cr.priority != OFP_DEFAULT_PRIORITY && need_priority) {
         ds_put_format(s, "pri:%"PRIu16" ", fm.cr.priority);
     }
     if (fm.buffer_id != UINT32_MAX) {
@@ -1256,7 +1267,6 @@ ofp_print_nxst_flow_reply(struct ds *string, const struct ofp_header *oh)
         ofp_print_duration(string, ntohl(fs->duration_sec),
                            ntohl(fs->duration_nsec));
         ds_put_format(string, ", table_id=%"PRIu8", ", fs->table_id);
-        ds_put_format(string, "priority=%"PRIu16", ", ntohs(fs->priority));
         ds_put_format(string, "n_packets=%"PRIu64", ",
                     ntohll(fs->packet_count));
         ds_put_format(string, "n_bytes=%"PRIu64", ", ntohll(fs->byte_count));
index 907ac13bc9c351d2a4533b69c7cd603d4cf84062..6b430e56f8a85713b77fcf889af5aa37138abfae 100644 (file)
@@ -67,8 +67,8 @@ AT_CHECK([ovs-ofctl add-flow br0 in_port=1,actions=0])
 AT_CHECK([ovs-ofctl add-flow br0 in_port=0,actions=1])
 AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS | STRIP_DURATION], [0], [dnl
 NXST_FLOW reply:
- cookie=0x0, duration=?s, table_id=0, priority=32768, n_packets=0, n_bytes=0, in_port=1 actions=output:0
- cookie=0x0, duration=?s, table_id=0, priority=32768, n_packets=0, n_bytes=0, in_port=65534 actions=output:1
+ cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=1 actions=output:0
+ cookie=0x0, duration=?s, table_id=0, n_packets=0, n_bytes=0, in_port=65534 actions=output:1
 ])
 AT_CHECK([ovs-ofctl del-flows br0])
 AT_CHECK([ovs-ofctl dump-flows br0 | STRIP_XIDS], [0], [NXST_FLOW reply: