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 <az...@nicira.com>

---
v1->v2
        *Remove the fix for in_port.
        *Always set VLAN_TAG_PRESENT bit in the mask.
v2->v3
        *Move VLAN_TAG_PRESENT bit check back to ovs_key_from_nlattrs.
---
 datapath/flow.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/datapath/flow.c b/datapath/flow.c
index 7f69538..3acc743 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;
-- 
1.7.9.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to