From eb19e5f0781cdf3caec1a0ba172fcaf32da5e481 Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Mon, 15 Jul 2013 17:25:34 -0700 Subject: [PATCH] ovs-ofctl: Bug fix in flow_format() Fix a corner case bug where ARP packet with ARP opcode value of 1 would cause tp_src and tp_dst to appear in the output string. This bug caused some output from flow_format() to not be accepted by 'ovs-appctl ofproto/trace' Added test coverage by using ARP opcode 1 in one unit test case, that would have exposed the bug. Bug #18334 Signed-off-by: Andy Zhou Signed-off-by: Ben Pfaff --- lib/match.c | 25 +++++++++++++------------ tests/ofp-print.at | 4 ++-- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/match.c b/lib/match.c index 6d66ebaab..91c05a764 100644 --- a/lib/match.c +++ b/lib/match.c @@ -111,21 +111,22 @@ match_wc_init(struct match *match, const struct flow *flow) if (is_ip_any(flow)) { memset(&wc->masks.nw_tos, 0xff, sizeof wc->masks.nw_tos); memset(&wc->masks.nw_ttl, 0xff, sizeof wc->masks.nw_ttl); - } - if (flow->nw_frag) { - memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag); - } + if (flow->nw_frag) { + memset(&wc->masks.nw_frag, 0xff, sizeof wc->masks.nw_frag); + } - if (flow->nw_proto == IPPROTO_ICMP || flow->nw_proto == IPPROTO_ICMPV6 || - (flow->tp_src || flow->tp_dst)) { - memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src); - memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst); - } + if (flow->nw_proto == IPPROTO_ICMP || + flow->nw_proto == IPPROTO_ICMPV6 || + (flow->tp_src || flow->tp_dst)) { + memset(&wc->masks.tp_src, 0xff, sizeof wc->masks.tp_src); + memset(&wc->masks.tp_dst, 0xff, sizeof wc->masks.tp_dst); + } - if (flow->nw_proto == IPPROTO_ICMPV6) { - memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha); - memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha); + if (flow->nw_proto == IPPROTO_ICMPV6) { + memset(&wc->masks.arp_sha, 0xff, sizeof wc->masks.arp_sha); + memset(&wc->masks.arp_tha, 0xff, sizeof wc->masks.arp_tha); + } } return; diff --git a/tests/ofp-print.at b/tests/ofp-print.at index d61c024c2..22886fc49 100644 --- a/tests/ofp-print.at +++ b/tests/ofp-print.at @@ -475,11 +475,11 @@ AT_CHECK([ovs-ofctl ofp-print "\ 03 0a 00 4c 00 00 00 00 ff ff ff 00 00 2a 00 00 \ 00 01 00 0c 80 00 00 04 ff ff ff fe 00 00 00 00 \ 00 00 ff ff ff ff ff ff 00 23 20 83 c1 5f 80 35 \ -00 01 08 00 06 04 00 03 00 23 20 83 c1 5f 00 00 \ +00 01 08 00 06 04 00 01 00 23 20 83 c1 5f 00 00 \ 00 00 00 23 20 83 c1 5f 00 00 00 00 \ "], [0], [dnl OFPT_PACKET_IN (OF1.2) (xid=0x0): total_len=42 in_port=LOCAL (via no_match) data_len=42 buffer=0xffffff00 -rarp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:23:20:83:c1:5f,dl_dst=ff:ff:ff:ff:ff:ff,arp_spa=0.0.0.0,arp_tpa=0.0.0.0,arp_op=3,arp_sha=00:23:20:83:c1:5f,arp_tha=00:23:20:83:c1:5f +rarp,metadata=0,in_port=0,vlan_tci=0x0000,dl_src=00:23:20:83:c1:5f,dl_dst=ff:ff:ff:ff:ff:ff,arp_spa=0.0.0.0,arp_tpa=0.0.0.0,arp_op=1,arp_sha=00:23:20:83:c1:5f,arp_tha=00:23:20:83:c1:5f ]) AT_CLEANUP -- 2.43.0