[ovs-dev] [ofp-print 09/15] ofp-print: Always print priority exactly once.
Justin Pettit
jpettit at nicira.com
Tue Dec 14 22:29:48 UTC 2010
Looks good.
--Justin
On Dec 14, 2010, at 12:23 PM, Ben Pfaff wrote:
> Reported-by: Paul Ingram <paul at nicira.com>
> ---
> lib/ofp-print.c | 18 ++++++++++++++----
> tests/ofproto.at | 4 ++--
> 2 files changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/lib/ofp-print.c b/lib/ofp-print.c
> index 2d9e026..e565569 100644
> --- a/lib/ofp-print.c
> +++ b/lib/ofp-print.c
> @@ -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));
> diff --git a/tests/ofproto.at b/tests/ofproto.at
> index 907ac13..6b430e5 100644
> --- a/tests/ofproto.at
> +++ b/tests/ofproto.at
> @@ -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:
> --
> 1.7.1
>
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org
More information about the dev
mailing list