From 05b8f1c2b47a64d1eee5d3fa4ab325b0784c5003 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 22 Sep 2011 14:35:05 -0700 Subject: [PATCH] ofp-print: Avoid double space before "actions" for catch-all flows. Bug #7434. Reported-by: Michael Mao --- lib/ofp-print.c | 4 +++- tests/ofp-print.at | 15 +++++++++++++-- tests/ovs-ofctl.at | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 23110920b..a9f90df0a 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -1053,7 +1053,9 @@ ofp_print_flow_stats_reply(struct ds *string, const struct ofp_header *oh) } cls_rule_format(&fs.rule, string); - ds_put_char(string, ' '); + if (string->string[string->length - 1] != ' ') { + ds_put_char(string, ' '); + } ofp_print_actions(string, fs.actions, fs.n_actions); } } diff --git a/tests/ofp-print.at b/tests/ofp-print.at index c2018c77c..4c190a11b 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -436,7 +436,7 @@ AT_CLEANUP AT_SETUP([OFPST_FLOW reply]) AT_KEYWORDS([ofp-print OFPT_STATS_REPLY]) AT_CHECK([ovs-ofctl ofp-print "\ -01 11 01 8c 00 00 00 04 00 01 00 00 00 60 00 00 \ +01 11 01 e4 00 00 00 04 00 01 00 00 00 60 00 00 \ 00 00 00 00 00 03 50 54 00 00 00 05 50 54 00 00 \ 00 06 ff ff 00 00 08 06 00 02 00 00 c0 a8 00 01 \ c0 a8 00 02 00 00 00 00 00 00 00 04 0b eb c2 00 \ @@ -461,12 +461,19 @@ c0 a8 00 02 00 08 00 00 00 00 00 09 05 b8 d8 00 \ 80 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 \ 00 00 00 00 00 00 00 00 00 00 00 0d 00 00 00 00 \ 00 00 04 fa 00 00 00 08 00 01 00 00 \ +00 58 02 00 00 3f ff ff 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00 00 00 \ "], [0], [dnl OFPST_FLOW reply (xid=0x4): cookie=0x0, duration=4.2s, table=0, n_packets=1, n_bytes=60, idle_timeout=5,priority=65535,arp,in_port=3,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,arp_op=2,nw_tos=0,tp_src=0,tp_dst=0 actions=output:1 cookie=0x0, duration=8.9s, table=0, n_packets=13, n_bytes=1274, idle_timeout=5,priority=65535,icmp,in_port=1,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,icmp_type=0,icmp_code=0 actions=output:3 cookie=0x0, duration=4.28s, table=0, n_packets=1, n_bytes=60, idle_timeout=5,priority=65535,arp,in_port=1,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,arp_op=1,nw_tos=0,icmp_type=0,icmp_code=0 actions=output:3 cookie=0x0, duration=9.096s, table=0, n_packets=13, n_bytes=1274, idle_timeout=5,icmp,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,icmp_type=8,icmp_code=0 actions=output:1 + cookie=0x0, duration=0s, table=2, n_packets=0, n_bytes=0, actions=drop ]) AT_CLEANUP @@ -718,7 +725,7 @@ AT_CLEANUP AT_SETUP([NXST_FLOW reply]) AT_KEYWORDS([ofp-print OFPT_STATS_REPLY]) AT_CHECK([ovs-ofctl ofp-print "\ -01 11 07 e8 00 00 00 04 ff ff 00 00 00 00 23 20 \ +01 11 08 18 00 00 00 04 ff ff 00 00 00 00 23 20 \ 00 00 00 00 00 00 00 00 00 88 00 00 00 00 00 01 \ 02 dc 6c 00 ff ff 00 05 00 00 00 4c 00 00 00 00 \ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 \ @@ -845,6 +852,9 @@ a8 00 01 00 00 10 04 c0 a8 00 02 00 00 0c 01 06 \ 00 00 01 c8 00 01 00 04 00 00 00 7b 00 00 00 00 \ ff ff 00 18 00 00 23 20 00 07 00 1f 00 01 00 04 \ 00 00 00 00 00 00 00 05 \ +00 30 01 00 00 00 0e 10 00 07 a1 20 80 00 00 00 \ +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ +00 00 00 00 00 00 00 64 00 00 00 00 00 00 19 00 \ "], [0], [[NXST_FLOW reply (xid=0x4): cookie=0x0, duration=1.048s, table=0, n_packets=1, n_bytes=60, idle_timeout=5,priority=65535,tcp,in_port=3,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,tp_src=2535,tp_dst=0 actions=output:1 @@ -862,6 +872,7 @@ ff ff 00 18 00 00 23 20 00 07 00 1f 00 01 00 04 \ cookie=0x0, duration=0.08s, table=0, n_packets=1, n_bytes=60, idle_timeout=5,priority=65535,tcp,in_port=1,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,tp_src=0,tp_dst=2536 actions=output:3 cookie=0x0, duration=1.96s, table=0, n_packets=1, n_bytes=60, idle_timeout=5,priority=65535,tcp,in_port=3,vlan_tci=0x0000,dl_src=50:54:00:00:00:05,dl_dst=50:54:00:00:00:06,nw_src=192.168.0.1,nw_dst=192.168.0.2,nw_tos=0,tp_src=2534,tp_dst=0 actions=output:1 cookie=0x0, duration=228.78s, table=0, n_packets=0, n_bytes=0, reg0=0x7b,tun_id=0x1c8 actions=load:0x5->NXM_NX_REG0[] + cookie=0x0, duration=3600.0005s, table=1, n_packets=100, n_bytes=6400, actions=drop ]]) AT_CLEANUP diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at index d1acb6b32..9dcd2493b 100644 --- a/tests/ovs-ofctl.at +++ b/tests/ovs-ofctl.at @@ -504,7 +504,7 @@ OFPROTO_START AT_CHECK([ovs-ofctl add-flow br0 reg0=0x12345,actions=drop]) AT_CHECK([ovs-ofctl -F openflow10 dump-flows br0 | STRIP_XIDS | STRIP_DURATION], [0], [dnl OFPST_FLOW reply: - cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, actions=drop + cookie=0x0, duration=?s, table=0, n_packets=0, n_bytes=0, actions=drop ]) OFPROTO_STOP AT_CLEANUP -- 2.43.0