flow: Rename flow_set_vlan_vid() to flow_set_dl_vlan().
[openvswitch] / lib / meta-flow.c
index a5505c961e8576301e4d07a40d09b49fdd09f160..27f3bca73ba128c543af5dee5b374ef9cff9f37a 100644 (file)
@@ -157,7 +157,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
         NXM_OF_VLAN_TCI, "NXM_OF_VLAN_TCI",
         NXM_OF_VLAN_TCI, "NXM_OF_VLAN_TCI",
     }, {
-        MFF_VLAN_VID, "dl_vlan", NULL,
+        MFF_DL_VLAN, "dl_vlan", NULL,
         sizeof(ovs_be16), 12,
         MFM_NONE, 0,
         MFS_DECIMAL,
@@ -166,7 +166,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
         OXM_OF_VLAN_VID, "OXM_OF_VLAN_VID",
         OXM_OF_VLAN_VID, "OXM_OF_VLAN_VID",
     }, {
-        MFF_VLAN_PCP, "dl_vlan_pcp", NULL,
+        MFF_DL_VLAN_PCP, "dl_vlan_pcp", NULL,
         1, 3,
         MFM_NONE, 0,
         MFS_DECIMAL,
@@ -307,7 +307,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
     }, {
         MFF_ARP_SHA, "arp_sha", NULL,
         MF_FIELD_SIZES(mac),
-        MFM_NONE, FWW_ARP_SHA,
+        MFM_FULLY, 0,
         MFS_ETHERNET,
         MFP_ARP,
         false,
@@ -316,7 +316,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
     }, {
         MFF_ARP_THA, "arp_tha", NULL,
         MF_FIELD_SIZES(mac),
-        MFM_NONE, FWW_ARP_THA,
+        MFM_FULLY, 0,
         MFS_ETHERNET,
         MFP_ARP,
         false,
@@ -424,7 +424,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
     }, {
         MFF_ND_SLL, "nd_sll", NULL,
         MF_FIELD_SIZES(mac),
-        MFM_NONE, FWW_ARP_SHA,
+        MFM_FULLY, 0,
         MFS_ETHERNET,
         MFP_ND_SOLICIT,
         false,
@@ -433,7 +433,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
     }, {
         MFF_ND_TLL, "nd_tll", NULL,
         MF_FIELD_SIZES(mac),
-        MFM_NONE, FWW_ARP_THA,
+        MFM_FULLY, 0,
         MFS_ETHERNET,
         MFP_ND_ADVERT,
         false,
@@ -562,10 +562,6 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
     case MFF_IP_ECN:
     case MFF_IP_TTL:
     case MFF_ARP_OP:
-    case MFF_ARP_SHA:
-    case MFF_ARP_THA:
-    case MFF_ND_SLL:
-    case MFF_ND_TLL:
         assert(mf->fww_bit != 0);
         return (wc->wildcards & mf->fww_bit) != 0;
 
@@ -582,11 +578,19 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
     case MFF_ETH_DST:
         return eth_addr_is_zero(wc->dl_dst_mask);
 
+    case MFF_ARP_SHA:
+    case MFF_ND_SLL:
+        return eth_addr_is_zero(wc->arp_sha_mask);
+
+    case MFF_ARP_THA:
+    case MFF_ND_TLL:
+        return eth_addr_is_zero(wc->arp_tha_mask);
+
     case MFF_VLAN_TCI:
         return !wc->vlan_tci_mask;
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         return !(wc->vlan_tci_mask & htons(VLAN_VID_MASK));
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         return !(wc->vlan_tci_mask & htons(VLAN_PCP_MASK));
 
     case MFF_IPV4_SRC:
@@ -648,10 +652,6 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
     case MFF_IP_ECN:
     case MFF_IP_TTL:
     case MFF_ARP_OP:
-    case MFF_ARP_SHA:
-    case MFF_ARP_THA:
-    case MFF_ND_SLL:
-    case MFF_ND_TLL:
         assert(mf->fww_bit != 0);
         memset(mask, wc->wildcards & mf->fww_bit ? 0x00 : 0xff, mf->n_bytes);
         break;
@@ -678,10 +678,10 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
     case MFF_VLAN_TCI:
         mask->be16 = wc->vlan_tci_mask;
         break;
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         mask->be16 = wc->vlan_tci_mask & htons(VLAN_VID_MASK);
         break;
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         mask->u8 = vlan_tci_to_pcp(wc->vlan_tci_mask);
         break;
 
@@ -716,6 +716,14 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
     case MFF_ARP_TPA:
         mask->be32 = wc->nw_dst_mask;
         break;
+    case MFF_ARP_SHA:
+    case MFF_ND_SLL:
+        memcpy(mask->mac, wc->arp_sha_mask, ETH_ADDR_LEN);
+        break;
+    case MFF_ARP_THA:
+    case MFF_ND_TLL:
+        memcpy(mask->mac, wc->arp_tha_mask, ETH_ADDR_LEN);
+        break;
 
     case MFF_TCP_SRC:
     case MFF_UDP_SRC:
@@ -878,10 +886,10 @@ mf_is_value_valid(const struct mf_field *mf, const union mf_value *value)
     case MFF_ARP_OP:
         return !(value->be16 & htons(0xff00));
 
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         return !(value->be16 & htons(VLAN_CFI | VLAN_PCP_MASK));
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         return !(value->u8 & ~(VLAN_PCP_MASK >> VLAN_PCP_SHIFT));
 
     case MFF_IPV6_LABEL:
@@ -931,11 +939,11 @@ mf_get_value(const struct mf_field *mf, const struct flow *flow,
         value->be16 = flow->vlan_tci;
         break;
 
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         value->be16 = flow->vlan_tci & htons(VLAN_VID_MASK);
         break;
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         value->u8 = vlan_tci_to_pcp(flow->vlan_tci);
         break;
 
@@ -1070,11 +1078,11 @@ mf_set_value(const struct mf_field *mf,
         cls_rule_set_dl_tci(rule, value->be16);
         break;
 
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         cls_rule_set_dl_vlan(rule, value->be16);
         break;
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         cls_rule_set_dl_vlan_pcp(rule, value->u8);
         break;
 
@@ -1209,11 +1217,11 @@ mf_set_flow_value(const struct mf_field *mf,
         flow->vlan_tci = value->be16;
         break;
 
-    case MFF_VLAN_VID:
-        flow_set_vlan_vid(flow, value->be16);
+    case MFF_DL_VLAN:
+        flow_set_dl_vlan(flow, value->be16);
         break;
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         flow_set_vlan_pcp(flow, value->u8);
         break;
 
@@ -1366,11 +1374,11 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule)
         cls_rule_set_dl_tci_masked(rule, htons(0), htons(0));
         break;
 
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         cls_rule_set_any_vid(rule);
         break;
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         cls_rule_set_any_pcp(rule);
         break;
 
@@ -1431,14 +1439,14 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule)
 
     case MFF_ARP_SHA:
     case MFF_ND_SLL:
-        rule->wc.wildcards |= FWW_ARP_SHA;
-        memset(rule->flow.arp_sha, 0, sizeof rule->flow.arp_sha);
+        memset(rule->flow.arp_sha, 0, ETH_ADDR_LEN);
+        memset(rule->wc.arp_sha_mask, 0, ETH_ADDR_LEN);
         break;
 
     case MFF_ARP_THA:
     case MFF_ND_TLL:
-        rule->wc.wildcards |= FWW_ARP_THA;
-        memset(rule->flow.arp_tha, 0, sizeof rule->flow.arp_tha);
+        memset(rule->flow.arp_tha, 0, ETH_ADDR_LEN);
+        memset(rule->wc.arp_tha_mask, 0, ETH_ADDR_LEN);
         break;
 
     case MFF_TCP_SRC:
@@ -1495,21 +1503,17 @@ 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_DL_VLAN:
+    case MFF_DL_VLAN_PCP:
     case MFF_IP_PROTO:
     case MFF_IP_TTL:
     case MFF_IP_DSCP:
     case MFF_IP_ECN:
     case MFF_ARP_OP:
-    case MFF_ARP_SHA:
-    case MFF_ARP_THA:
     case MFF_ICMPV4_TYPE:
     case MFF_ICMPV4_CODE:
     case MFF_ICMPV6_TYPE:
     case MFF_ICMPV6_CODE:
-    case MFF_ND_SLL:
-    case MFF_ND_TLL:
         NOT_REACHED();
 
     case MFF_TUN_ID:
@@ -1532,6 +1536,16 @@ mf_set(const struct mf_field *mf,
         cls_rule_set_dl_src_masked(rule, value->mac, mask->mac);
         break;
 
+    case MFF_ARP_SHA:
+    case MFF_ND_SLL:
+        cls_rule_set_arp_sha_masked(rule, value->mac, mask->mac);
+        break;
+
+    case MFF_ARP_THA:
+    case MFF_ND_TLL:
+        cls_rule_set_arp_tha_masked(rule, value->mac, mask->mac);
+        break;
+
     case MFF_VLAN_TCI:
         cls_rule_set_dl_tci_masked(rule, value->be16, mask->be16);
         break;
@@ -1709,11 +1723,11 @@ mf_random_value(const struct mf_field *mf, union mf_value *value)
         value->be16 &= htons(0xff);
         break;
 
-    case MFF_VLAN_VID:
+    case MFF_DL_VLAN:
         value->be16 &= htons(VLAN_VID_MASK);
         break;
 
-    case MFF_VLAN_PCP:
+    case MFF_DL_VLAN_PCP:
         value->u8 &= 0x07;
         break;