From: Andy Zhou <azhou@nicira.com>
Date: Mon, 29 Jul 2013 21:05:23 +0000 (-0700)
Subject: datapath: Fix missing VLAN netlink attribute handling
X-Git-Tag: sliver-openvswitch-2.0.90-1~34^2~21
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=62f13eb2a1ef5dfa6a2069568356bd4657916d61;p=sliver-openvswitch.git

datapath: Fix missing VLAN netlink attribute handling

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>
---

diff --git a/datapath/flow.c b/datapath/flow.c
index 7f69538e2..3acc74321 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -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;