[ovs-dev] [PATCH 1/2] ofp-print: ofp_packet_to_string() Do not emit extra trailing newline
Simon Horman
horms at verge.net.au
Fri May 17 03:26:25 UTC 2013
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.
The test-suite has be updated to exercise output of packet data
by ofp_packet_to_string()
Signed-off-by: Simon Horman <horms at verge.net.au>
---
lib/ofp-print.c | 3 +--
tests/ofp-print.at | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index 8d99844..a1d7f4e 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -184,9 +184,8 @@ ofp_print_packet_out(struct ds *string, const struct ofp_header *oh,
free(packet);
}
} else {
- ds_put_format(string, " buffer=0x%08"PRIx32, po.buffer_id);
+ ds_put_format(string, " buffer=0x%08"PRIx32"\n", po.buffer_id);
}
- ds_put_char(string, '\n');
ofpbuf_uninit(&ofpacts);
}
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 35f599c..d85d8d9 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])
--
1.8.2.1
More information about the dev
mailing list