From: Simon Horman Date: Fri, 17 May 2013 05:14:13 +0000 (+0900) Subject: ofp-print: ofp_packet_to_string() Do not emit extra trailing newline X-Git-Tag: v2.0~739 X-Git-Url: http://git.cascardo.eti.br/?a=commitdiff_plain;h=4b2d9d113f8eb7ee4e6bf703e81d4169377fc26b;p=cascardo%2Fovs.git ofp-print: ofp_packet_to_string() Do not emit extra trailing newline The string produced by ofp_packet_to_string() includes a trailing newline, so in the case where packet data is formatted by ofp_print_packet_out() there is already a newline present. This patch updates ofp_print_packet_out() so that it does not add a second newline in this case. It is not necessary to update the case where there is packet data to ensure that the result it is terminated by a "\n" as the higher-level ofp_to_string() function will ensure that the result is "\n" terminated. The test-suite has be updated to exercise output of packet data by ofp_packet_to_string() Signed-off-by: Simon Horman Signed-off-by: Ben Pfaff --- diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 8d99844a5..ca4aa6120 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -186,7 +186,6 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh, } else { ds_put_format(string, " buffer=0x%08"PRIx32, po.buffer_id); } - ds_put_char(string, '\n'); ofpbuf_uninit(&ofpacts); } diff --git a/tests/ofp-print.at b/tests/ofp-print.at index 35f599cfd..d85d8d9d9 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -567,6 +567,21 @@ OFPT_PACKET_OUT (xid=0x0): in_port=1 actions=output:3 buffer=0x00000114 ]) AT_CLEANUP +AT_SETUP([OFPT_PACKET_OUT - OF1.0, with packet]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +01 0d 00 54 00 00 00 00 ff ff ff ff 00 01 00 08 \ +00 00 00 08 00 03 00 00 50 54 00 00 00 05 50 54 \ +00 00 00 06 08 00 45 00 00 28 00 00 40 00 40 06 \ +b9 7c c0 a8 00 02 c0 a8 00 01 00 00 2b 60 00 00 \ +00 00 6a 4f 2b 58 50 14 00 00 6d 75 00 00 00 00 \ +00 00 00 00 \ +"], [0], [dnl +OFPT_PACKET_OUT (xid=0x0): in_port=1 actions=output:3 data_len=60 +tcp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=11104 tcp_csum:6d75 +]) +AT_CLEANUP + AT_SETUP([OFPT_PACKET_OUT - OF1.1]) AT_KEYWORDS([ofp-print]) AT_CHECK([ovs-ofctl ofp-print "\ @@ -578,6 +593,22 @@ OFPT_PACKET_OUT (OF1.2) (xid=0x8858dfc5): in_port=LOCAL actions=FLOOD buffer=0xf ]) AT_CLEANUP +AT_SETUP([OFPT_PACKET_OUT - OF1.1, with packet]) +AT_KEYWORDS([ofp-print]) +AT_CHECK([ovs-ofctl ofp-print "\ +03 0d 00 64 88 58 df c5 ff ff ff ff ff ff ff fe \ +00 10 00 00 00 00 00 00 00 00 00 10 ff ff ff fb \ +05 dc 00 00 00 00 00 00 50 54 00 00 00 05 50 54 \ +00 00 00 06 08 00 45 00 00 28 00 00 40 00 40 06 \ +b9 7c c0 a8 00 02 c0 a8 00 01 00 00 2b 60 00 00 \ +00 00 6a 4f 2b 58 50 14 00 00 6d 75 00 00 00 00 \ +00 00 00 00 \ +"], [0], [dnl +OFPT_PACKET_OUT (OF1.2) (xid=0x8858dfc5): in_port=LOCAL actions=FLOOD data_len=60 +tcp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=50:54:00:00:00:06,dl_dst=50:54:00:00:00:05,nw_src=192.168.0.2,nw_dst=192.168.0.1,nw_tos=0,nw_ecn=0,nw_ttl=64,tp_src=0,tp_dst=11104 tcp_csum:6d75 +]) +AT_CLEANUP + # The flow is formatted with cls_rule_format() for the low-verbosity case. AT_SETUP([OFPT_FLOW_MOD - OF1.0 - low verbosity]) AT_KEYWORDS([ofp-print])