datapath: Fix missing VLAN netlink attribute handling
authorAndy Zhou <azhou@nicira.com>
Mon, 29 Jul 2013 21:05:23 +0000 (14:05 -0700)
committerJesse Gross <jesse@nicira.com>
Mon, 29 Jul 2013 21:31:21 +0000 (14:31 -0700)
Missing VLAN netlink attribute should be interpreted as exact match
of no VLAN tag, instead of wildcarded match for all VLAN tags.

Bug #18736.

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

index 7f69538..3acc743 100644 (file)
@@ -1365,15 +1365,19 @@ static int ovs_key_from_nlattrs(struct sw_flow_match *match,  u64 attrs,
                __be16 tci;
 
                tci = nla_get_be16(a[OVS_KEY_ATTR_VLAN]);
-               if (!is_mask)
-                       if (!(tci & htons(VLAN_TAG_PRESENT))) {
+               if (!(tci & htons(VLAN_TAG_PRESENT))) {
+                       if (is_mask)
+                               OVS_NLERR("VLAN TCI mask does not have exact match for VLAN_TAG_PRESENT bit.\n");
+                       else
                                OVS_NLERR("VLAN TCI does not have VLAN_TAG_PRESENT bit set.\n");
-                               return -EINVAL;
-                       }
+
+                       return -EINVAL;
+               }
 
                SW_FLOW_KEY_PUT(match, eth.tci, tci, is_mask);
                attrs &= ~(1ULL << OVS_KEY_ATTR_VLAN);
-       }
+       } else if (!is_mask)
+               SW_FLOW_KEY_PUT(match, eth.tci, htons(0xffff), true);
 
        if (attrs & (1ULL << OVS_KEY_ATTR_ETHERTYPE)) {
                __be16 eth_type;