Signed-off-by: Simon Horman <[email protected]>
---
lib/classifier.c | 14 ++++++++++++--
lib/classifier.h | 1 +
lib/meta-flow.c | 7 +++++--
tests/ovs-ofctl.at | 16 ++++++++++++++++
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/lib/classifier.c b/lib/classifier.c
index 6e8f4d2..8bff7a4 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -244,15 +244,25 @@ cls_rule_set_any_vid(struct cls_rule *rule)
* VID equals the low 12 bits of 'dl_vlan'.
*/
void
-cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan)
+cls_rule_set_dl_vlan_masked(struct cls_rule *rule, ovs_be16 dl_vlan,
+ ovs_be16 mask)
{
+ if (!(mask & htons(VLAN_CFI))) {
+ dl_vlan = htons(OFP10_VLAN_NONE);
+ }
flow_set_vlan_vid(&rule->flow, dl_vlan);
if (dl_vlan == htons(OFP10_VLAN_NONE)) {
rule->wc.vlan_tci_mask = htons(UINT16_MAX);
} else {
- rule->wc.vlan_tci_mask |= htons(VLAN_VID_MASK | VLAN_CFI);
+ rule->wc.vlan_tci_mask |= mask & htons(VLAN_VID_MASK | VLAN_CFI);
}
}
+void
+cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan)
+{
+ cls_rule_set_dl_vlan_masked(rule, dl_vlan,
+ htons(VLAN_VID_MASK | VLAN_CFI));
+}
/* Modifies 'rule' so that the VLAN PCP is wildcarded. If the VID is already
* wildcarded, then 'rule' will match a packet regardless of whether it has an
diff --git a/lib/classifier.h b/lib/classifier.h
index ec7316c..ed89311 100644
--- a/lib/classifier.h
+++ b/lib/classifier.h
@@ -108,6 +108,7 @@ void cls_rule_set_dl_tci(struct cls_rule *, ovs_be16 tci);
void cls_rule_set_dl_tci_masked(struct cls_rule *,
ovs_be16 tci, ovs_be16 mask);
void cls_rule_set_any_vid(struct cls_rule *);
+void cls_rule_set_dl_vlan_masked(struct cls_rule *, ovs_be16, ovs_be16);
void cls_rule_set_dl_vlan(struct cls_rule *, ovs_be16);
void cls_rule_set_any_pcp(struct cls_rule *);
void cls_rule_set_dl_vlan_pcp(struct cls_rule *, uint8_t);
diff --git a/lib/meta-flow.c b/lib/meta-flow.c
index b52db4d..b84181d 100644
--- a/lib/meta-flow.c
+++ b/lib/meta-flow.c
@@ -159,7 +159,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
}, {
MFF_VLAN_VID, "dl_vlan", NULL,
sizeof(ovs_be16), 12,
- MFM_NONE, 0,
+ MFM_FULLY, 0,
MFS_DECIMAL,
MFP_NONE,
true,
@@ -1505,7 +1505,6 @@ mf_set(const struct mf_field *mf,
switch (mf->id) {
case MFF_IN_PORT:
case MFF_ETH_TYPE:
- case MFF_VLAN_VID:
case MFF_VLAN_PCP:
case MFF_IPV6_LABEL:
case MFF_IP_PROTO:
@@ -1543,6 +1542,10 @@ mf_set(const struct mf_field *mf,
cls_rule_set_dl_src_masked(rule, value->mac, mask->mac);
break;
+ case MFF_VLAN_VID:
+ cls_rule_set_dl_vlan_masked(rule, value->be16, mask->be16);
+ break;
+
case MFF_VLAN_TCI:
cls_rule_set_dl_tci_masked(rule, value->be16, mask->be16);
break;
diff --git a/tests/ovs-ofctl.at b/tests/ovs-ofctl.at
index b438a08..2110e8c 100644
--- a/tests/ovs-ofctl.at
+++ b/tests/ovs-ofctl.at
@@ -1023,7 +1023,15 @@ OXM_OF_VLAN_VID(0000) # Packets without 802.1Q
header or with VID=0
OXM_OF_VLAN_VID(1123) # Packets with VID=123, any PCP
OXM_OF_VLAN_VID(1123) OXM_OF_VLAN_PCP(01) # Packets with VID=123, PCP=1.
OXM_OF_VLAN_VID(0123) # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(0123/0123) # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(1123/0123) # Does not make sense (but supported anyway)
+OXM_OF_VLAN_VID_W(0123/1123) # Does not make sense (but supported anyway)
OXM_OF_VLAN_VID(0123) OXM_OF_VLAN_PCP(01) #Bad Pre-Requisite
+OXM_OF_VLAN_VID_W(1123/1fff) # Packets with VID=123, any PCP.
+OXM_OF_VLAN_VID_W(1123/1f0f), # Packets with # VID=123 (masked)
+OXM_OF_VLAN_VID_W(1123/1f0f), OXM_OF_VLAN_PCP(01) # Packets with VID=123
(masked), any PCP.
+OXM_OF_VLAN_VID_W(1000/1000) # Packets with any VID, any PCP
+OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01) # Packets with any VID,
PCP=1.
# IP ECN
OXM_OF_ETH_TYPE(0800) OXM_OF_IP_ECN(03)
@@ -1169,7 +1177,15 @@ OXM_OF_VLAN_VID(0000)
OXM_OF_VLAN_VID(1123)
OXM_OF_VLAN_VID(1123), OXM_OF_VLAN_PCP(01)
OXM_OF_VLAN_VID(0000)
+OXM_OF_VLAN_VID(0000)
+OXM_OF_VLAN_VID(0000)
+OXM_OF_VLAN_VID(0000)
nx_pull_match() returned error OFPBMC_BAD_PREREQ
+OXM_OF_VLAN_VID(1123)
+OXM_OF_VLAN_VID_W(1123/1f0f)
+OXM_OF_VLAN_VID_W(1123/1f0f), OXM_OF_VLAN_PCP(01)
+OXM_OF_VLAN_VID_W(1000/1000)
+OXM_OF_VLAN_VID_W(1000/1000), OXM_OF_VLAN_PCP(01)
# IP ECN
OXM_OF_ETH_TYPE(0800), OXM_OF_IP_ECN(03)
--
1.7.10.2.484.gcd07cc5
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev