ovs-ofctl: Bug fix in flow_format()
authorAndy Zhou <azhou@nicira.com>
Tue, 16 Jul 2013 00:25:34 +0000 (17:25 -0700)
committerJustin Pettit <jpettit@nicira.com>
Wed, 17 Jul 2013 21:06:50 +0000 (14:06 -0700)
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 <azhou@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/match.c
tests/ofp-print.at

index fc3c540..0a97cff 100644 (file)
@@ -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;
index 35f599c..1db007f 100644 (file)
@@ -457,11 +457,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