odp-util: Fix a bug in conversion between flow/mask and flow key
authorGuolin Yang <gyang@nicira.com>
Fri, 30 Aug 2013 20:45:56 +0000 (13:45 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 10 Sep 2013 20:57:17 +0000 (13:57 -0700)
In odp_flow_key_from_flow__(), when converting ICMPv6 flow/mask
to flow/mask key, we should always use flow to check for whether
ND informaition is present or not. In mask case, both type and code
field should be masked, otherwise ND fields can be masked.

This patch is an abridged version of the same patch committed on master.
This patch only contains necessary bug fix, but dropped extra protocol
sanity checks.

Signed-off-by: Guolin Yang <gyang@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/odp-util.c

index dcd4b6f..89035f1 100644 (file)
@@ -2462,8 +2462,11 @@ odp_flow_key_from_flow__(struct ofpbuf *buf, const struct flow *data,
             icmpv6_key->icmpv6_type = ntohs(data->tp_src);
             icmpv6_key->icmpv6_code = ntohs(data->tp_dst);
 
-            if (icmpv6_key->icmpv6_type == ND_NEIGHBOR_SOLICIT
-                    || icmpv6_key->icmpv6_type == ND_NEIGHBOR_ADVERT) {
+            if (flow->tp_dst == htons(0) &&
+                (flow->tp_src == htons(ND_NEIGHBOR_SOLICIT) ||
+                 flow->tp_src == htons(ND_NEIGHBOR_ADVERT)) &&
+                (!is_mask || (data->tp_src == htons(0xffff) &&
+                              data->tp_dst == htons(0xffff)))) {
                 struct ovs_key_nd *nd_key;
 
                 nd_key = nl_msg_put_unspec_uninit(buf, OVS_KEY_ATTR_ND,