X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fclassifier.c;h=38f1a4feaf27838928c810ccd3a272bad854b8f3;hb=5b289eaf9f880c5284510a45db8e13f55f4968f3;hp=33245aeab0c4613165b1dea9d12f102ad47e1088;hpb=e878338bf1409f0dd6d23cb57822a2c4c1a69e0f;p=openvswitch diff --git a/lib/classifier.c b/lib/classifier.c index 33245aea..38f1a4fe 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -266,7 +266,7 @@ cls_rule_set_any_vid(struct cls_rule *rule) void cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan) { - flow_set_vlan_vid(&rule->flow, dl_vlan); + flow_set_dl_vlan(&rule->flow, dl_vlan); if (dl_vlan == htons(OFP10_VLAN_NONE)) { rule->wc.vlan_tci_mask = htons(UINT16_MAX); } else { @@ -274,6 +274,31 @@ cls_rule_set_dl_vlan(struct cls_rule *rule, ovs_be16 dl_vlan) } } +/* Sets the VLAN VID that 'flow' matches to 'vid', which is interpreted as an + * OpenFlow 1.2 "vlan_vid" value, that is, the low 13 bits of 'vlan_tci' (VID + * plus CFI). */ +void +cls_rule_set_vlan_vid(struct cls_rule *rule, ovs_be16 vid) +{ + cls_rule_set_vlan_vid_masked(rule, vid, htons(VLAN_VID_MASK | VLAN_CFI)); +} + + +/* Sets the VLAN VID that 'flow' matches to 'vid', which is interpreted as an + * OpenFlow 1.2 "vlan_vid" value, that is, the low 13 bits of 'vlan_tci' (VID + * plus CFI), with the corresponding 'mask'. */ +void +cls_rule_set_vlan_vid_masked(struct cls_rule *rule, + ovs_be16 vid, ovs_be16 mask) +{ + ovs_be16 pcp_mask = htons(VLAN_PCP_MASK); + ovs_be16 vid_mask = htons(VLAN_VID_MASK | VLAN_CFI); + + mask &= vid_mask; + flow_set_vlan_vid(&rule->flow, vid & mask); + rule->wc.vlan_tci_mask = mask | (rule->wc.vlan_tci_mask & pcp_mask); +} + /* 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 * 802.1Q header or not. */