OXM: Allow masking of ARP SHA and THA
[openvswitch] / lib / ofp-util.c
index ecd0551344fc034a79fe5f5903efa21e326d9c15..faa0687c81461e86611a07de1eb2f2b8d1e8094c 100644 (file)
@@ -104,14 +104,14 @@ static const flow_wildcards_t WC_INVARIANTS = 0
 void
 ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 13);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
 
     /* Initialize most of rule->wc. */
     flow_wildcards_init_catchall(wc);
     wc->wildcards = (OVS_FORCE flow_wildcards_t) ofpfw & WC_INVARIANTS;
 
     /* Wildcard fields that aren't defined by ofp10_match or tun_id. */
-    wc->wildcards |= FWW_ARP_SHA | FWW_ARP_THA | FWW_NW_ECN | FWW_NW_TTL;
+    wc->wildcards |= FWW_NW_ECN | FWW_NW_TTL;
 
     if (ofpfw & OFPFW10_NW_TOS) {
         /* OpenFlow 1.0 defines a TOS wildcard, but it's much later in
@@ -1463,7 +1463,7 @@ ofputil_usable_protocols(const struct cls_rule *rule)
 {
     const struct flow_wildcards *wc = &rule->wc;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 13);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
 
     /* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
     if (!eth_mask_is_exact(wc->dl_src_mask)
@@ -1481,7 +1481,8 @@ ofputil_usable_protocols(const struct cls_rule *rule)
     }
 
     /* Only NXM supports matching ARP hardware addresses. */
-    if (!(wc->wildcards & FWW_ARP_SHA) || !(wc->wildcards & FWW_ARP_THA)) {
+    if (!eth_addr_is_zero(wc->arp_sha_mask) ||
+        !eth_addr_is_zero(wc->arp_tha_mask)) {
         return OFPUTIL_P_NXM_ANY;
     }
 
@@ -4109,10 +4110,10 @@ ofputil_normalize_rule(struct cls_rule *rule)
         wc.wildcards |= FWW_NW_TTL;
     }
     if (!(may_match & MAY_ARP_SHA)) {
-        wc.wildcards |= FWW_ARP_SHA;
+        memset(wc.arp_sha_mask, 0, ETH_ADDR_LEN);
     }
     if (!(may_match & MAY_ARP_THA)) {
-        wc.wildcards |= FWW_ARP_THA;
+        memset(wc.arp_tha_mask, 0, ETH_ADDR_LEN);
     }
     if (!(may_match & MAY_IPV6)) {
         wc.ipv6_src_mask = wc.ipv6_dst_mask = in6addr_any;