odp-util: Always serialize tunnel mask attributes.
authorJesse Gross <jesse@nicira.com>
Thu, 1 Aug 2013 23:17:47 +0000 (16:17 -0700)
committerJesse Gross <jesse@nicira.com>
Fri, 2 Aug 2013 02:06:08 +0000 (19:06 -0700)
A tunnel value attribute is not allowed to have an empty IP destination
address but this is legal for masks. This drops both the checks for
serializing masks and also the sanity checks on them.

Signed-off-by: Jesse Gross <jesse@nicira.com>
Acked-by: Andy Zhou <azhou@nicira.com>
datapath/flow.c
lib/odp-util.c

index fb462ab..06ceafa 100644 (file)
@@ -1246,14 +1246,16 @@ int ipv4_tun_from_nlattr(const struct nlattr *attr,
                return -EINVAL;
        }
 
-       if (!match->key->tun_key.ipv4_dst) {
-               OVS_NLERR("IPv4 tunnel destination address is zero.\n");
-               return -EINVAL;
-       }
+       if (!is_mask) {
+               if (!match->key->tun_key.ipv4_dst) {
+                       OVS_NLERR("IPv4 tunnel destination address is zero.\n");
+                       return -EINVAL;
+               }
 
-       if (!ttl) {
-               OVS_NLERR("IPv4 tunnel TTL not specified.\n");
-               return -EINVAL;
+               if (!ttl) {
+                       OVS_NLERR("IPv4 tunnel TTL not specified.\n");
+                       return -EINVAL;
+               }
        }
 
        return 0;
@@ -1699,7 +1701,7 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey,
        if (nla_put_u32(skb, OVS_KEY_ATTR_PRIORITY, output->phy.priority))
                goto nla_put_failure;
 
-       if (swkey->tun_key.ipv4_dst &&
+       if ((swkey->tun_key.ipv4_dst || is_mask) &&
            ipv4_tun_to_nlattr(skb, &swkey->tun_key, &output->tun_key))
                goto nla_put_failure;
 
index 04ccce0..e29d3af 100644 (file)
@@ -2333,7 +2333,7 @@ odp_flow_key_from_flow__(struct ofpbuf *buf, const struct flow *data,
         nl_msg_put_u32(buf, OVS_KEY_ATTR_PRIORITY, data->skb_priority);
     }
 
-    if (flow->tunnel.ip_dst) {
+    if (flow->tunnel.ip_dst || is_mask) {
         tun_key_to_attr(buf, &data->tunnel);
     }