flow: Use bit-mask for Ethernet type match, instead of FWW_* flag.
authorBen Pfaff <blp@nicira.com>
Mon, 18 Jun 2012 20:33:13 +0000 (13:33 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 4 Sep 2012 18:19:15 +0000 (11:19 -0700)
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/classifier.c
lib/flow.c
lib/flow.h
lib/meta-flow.c
lib/nx-match.c
lib/ofp-util.c
tests/test-classifier.c

index 324bc14..af715d3 100644 (file)
@@ -156,7 +156,7 @@ cls_rule_set_in_port(struct cls_rule *rule, uint16_t ofp_port)
 void
 cls_rule_set_dl_type(struct cls_rule *rule, ovs_be16 dl_type)
 {
-    rule->wc.wildcards &= ~FWW_DL_TYPE;
+    rule->wc.dl_type_mask = htons(UINT16_MAX);
     rule->flow.dl_type = dl_type;
 }
 
@@ -607,13 +607,13 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
 
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     if (rule->priority != OFP_DEFAULT_PRIORITY) {
         ds_put_format(s, "priority=%d,", rule->priority);
     }
 
-    if (!(w & FWW_DL_TYPE)) {
+    if (wc->dl_type_mask) {
         skip_type = true;
         if (f->dl_type == htons(ETH_TYPE_IP)) {
             if (wc->nw_proto_mask) {
@@ -717,7 +717,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
     }
     format_eth_masked(s, "dl_src", f->dl_src, wc->dl_src_mask);
     format_eth_masked(s, "dl_dst", f->dl_dst, wc->dl_dst_mask);
-    if (!skip_type && !(w & FWW_DL_TYPE)) {
+    if (!skip_type && wc->dl_type_mask) {
         ds_put_format(s, "dl_type=0x%04"PRIx16",", ntohs(f->dl_type));
     }
     if (f->dl_type == htons(ETH_TYPE_IPV6)) {
@@ -1291,7 +1291,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
     const flow_wildcards_t wc = wildcards->wildcards;
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     for (i = 0; i < FLOW_N_REGS; i++) {
         if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
@@ -1305,7 +1305,7 @@ flow_equal_except(const struct flow *a, const struct flow *b,
             && !((a->nw_dst ^ b->nw_dst) & wildcards->nw_dst_mask)
             && (wc & FWW_IN_PORT || a->in_port == b->in_port)
             && !((a->vlan_tci ^ b->vlan_tci) & wildcards->vlan_tci_mask)
-            && (wc & FWW_DL_TYPE || a->dl_type == b->dl_type)
+            && !((a->dl_type ^ b->dl_type) & wildcards->dl_type_mask)
             && !((a->tp_src ^ b->tp_src) & wildcards->tp_src_mask)
             && !((a->tp_dst ^ b->tp_dst) & wildcards->tp_dst_mask)
             && eth_addr_equal_except(a->dl_src, b->dl_src,
index d6d4527..5f4cdcd 100644 (file)
@@ -445,7 +445,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
     const flow_wildcards_t wc = wildcards->wildcards;
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     for (i = 0; i < FLOW_N_REGS; i++) {
         flow->regs[i] &= wildcards->reg_masks[i];
@@ -458,9 +458,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
         flow->in_port = 0;
     }
     flow->vlan_tci &= wildcards->vlan_tci_mask;
-    if (wc & FWW_DL_TYPE) {
-        flow->dl_type = htons(0);
-    }
+    flow->dl_type &= wildcards->dl_type_mask;
     flow->tp_src &= wildcards->tp_src_mask;
     flow->tp_dst &= wildcards->tp_dst_mask;
     eth_addr_bitand(flow->dl_src, wildcards->dl_src_mask, flow->dl_src);
@@ -485,7 +483,7 @@ flow_zero_wildcards(struct flow *flow, const struct flow_wildcards *wildcards)
 void
 flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     fmd->tun_id = flow->tun_id;
     fmd->metadata = flow->metadata;
@@ -573,7 +571,7 @@ flow_print(FILE *stream, const struct flow *flow)
 void
 flow_wildcards_init_catchall(struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     wc->wildcards = FWW_ALL;
     wc->tun_id_mask = htonll(0);
@@ -587,6 +585,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
     wc->metadata_mask = htonll(0);
     wc->vlan_tci_mask = htons(0);
     wc->nw_frag_mask = 0;
+    wc->dl_type_mask = htons(0);
     wc->tp_src_mask = htons(0);
     wc->tp_dst_mask = htons(0);
     memset(wc->dl_src_mask, 0, ETH_ADDR_LEN);
@@ -604,7 +603,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
 void
 flow_wildcards_init_exact(struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     wc->wildcards = 0;
     wc->tun_id_mask = htonll(UINT64_MAX);
@@ -618,6 +617,7 @@ flow_wildcards_init_exact(struct flow_wildcards *wc)
     wc->metadata_mask = htonll(UINT64_MAX);
     wc->vlan_tci_mask = htons(UINT16_MAX);
     wc->nw_frag_mask = UINT8_MAX;
+    wc->dl_type_mask = htons(UINT16_MAX);
     wc->tp_src_mask = htons(UINT16_MAX);
     wc->tp_dst_mask = htons(UINT16_MAX);
     memset(wc->dl_src_mask, 0xff, ETH_ADDR_LEN);
@@ -637,7 +637,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
 {
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     if (wc->wildcards
         || wc->tun_id_mask != htonll(UINT64_MAX)
@@ -647,6 +647,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
         || wc->tp_dst_mask != htons(UINT16_MAX)
         || wc->vlan_tci_mask != htons(UINT16_MAX)
         || wc->metadata_mask != htonll(UINT64_MAX)
+        || wc->dl_type_mask != htons(UINT16_MAX)
         || !eth_mask_is_exact(wc->dl_src_mask)
         || !eth_mask_is_exact(wc->dl_dst_mask)
         || !eth_mask_is_exact(wc->arp_sha_mask)
@@ -678,7 +679,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc)
 {
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     if (wc->wildcards != FWW_ALL
         || wc->tun_id_mask != htonll(0)
@@ -688,6 +689,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards *wc)
         || wc->tp_dst_mask != htons(0)
         || wc->vlan_tci_mask != htons(0)
         || wc->metadata_mask != htonll(0)
+        || wc->dl_type_mask != htons(0)
         || !eth_addr_is_zero(wc->dl_src_mask)
         || !eth_addr_is_zero(wc->dl_dst_mask)
         || !eth_addr_is_zero(wc->arp_sha_mask)
@@ -722,7 +724,7 @@ flow_wildcards_combine(struct flow_wildcards *dst,
 {
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     dst->wildcards = src1->wildcards | src2->wildcards;
     dst->tun_id_mask = src1->tun_id_mask & src2->tun_id_mask;
@@ -740,6 +742,7 @@ flow_wildcards_combine(struct flow_wildcards *dst,
     }
     dst->metadata_mask = src1->metadata_mask & src2->metadata_mask;
     dst->vlan_tci_mask = src1->vlan_tci_mask & src2->vlan_tci_mask;
+    dst->dl_type_mask = src1->dl_type_mask & src2->dl_type_mask;
     dst->tp_src_mask = src1->tp_src_mask & src2->tp_src_mask;
     dst->tp_dst_mask = src1->tp_dst_mask & src2->tp_dst_mask;
     dst->nw_frag_mask = src1->nw_frag_mask & src2->nw_frag_mask;
@@ -771,7 +774,7 @@ flow_wildcards_equal(const struct flow_wildcards *a,
 {
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     if (a->wildcards != b->wildcards
         || a->tun_id_mask != b->tun_id_mask
@@ -779,6 +782,7 @@ flow_wildcards_equal(const struct flow_wildcards *a,
         || a->nw_dst_mask != b->nw_dst_mask
         || a->vlan_tci_mask != b->vlan_tci_mask
         || a->metadata_mask != b->metadata_mask
+        || a->dl_type_mask != b->dl_type_mask
         || !ipv6_addr_equals(&a->ipv6_src_mask, &b->ipv6_src_mask)
         || !ipv6_addr_equals(&a->ipv6_dst_mask, &b->ipv6_dst_mask)
         || a->ipv6_label_mask != b->ipv6_label_mask
@@ -815,7 +819,7 @@ flow_wildcards_has_extra(const struct flow_wildcards *a,
     uint8_t eth_masked[ETH_ADDR_LEN];
     struct in6_addr ipv6_masked;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     for (i = 0; i < FLOW_N_REGS; i++) {
         if ((a->reg_masks[i] & b->reg_masks[i]) != b->reg_masks[i]) {
@@ -865,6 +869,7 @@ flow_wildcards_has_extra(const struct flow_wildcards *a,
             || (a->ipv6_label_mask & b->ipv6_label_mask) != b->ipv6_label_mask
             || (a->vlan_tci_mask & b->vlan_tci_mask) != b->vlan_tci_mask
             || (a->metadata_mask & b->metadata_mask) != b->metadata_mask
+            || (a->dl_type_mask & b->dl_type_mask) != b->dl_type_mask
             || (a->tp_src_mask & b->tp_src_mask) != b->tp_src_mask
             || (a->tp_dst_mask & b->tp_dst_mask) != b->tp_dst_mask
             || (a->nw_proto_mask & b->nw_proto_mask) != b->nw_proto_mask
index 341c842..4320bd6 100644 (file)
@@ -34,7 +34,7 @@ struct ofpbuf;
 /* This sequence number should be incremented whenever anything involving flows
  * or the wildcarding of flows changes.  This will cause build assertion
  * failures in places which likely need to be updated. */
-#define FLOW_WC_SEQ 16
+#define FLOW_WC_SEQ 17
 
 #define FLOW_N_REGS 8
 BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS);
@@ -95,7 +95,7 @@ BUILD_ASSERT_DECL(sizeof(((struct flow *)0)->nw_frag) == 1);
 BUILD_ASSERT_DECL(sizeof(struct flow) == FLOW_SIG_SIZE + FLOW_PAD_SIZE);
 
 /* Remember to update FLOW_WC_SEQ when changing 'struct flow'. */
-BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 150 && FLOW_WC_SEQ == 16);
+BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 150 && FLOW_WC_SEQ == 17);
 
 void flow_extract(struct ofpbuf *, uint32_t priority, ovs_be64 tun_id,
                   uint16_t in_port, struct flow *);
@@ -142,11 +142,10 @@ flow_hash(const struct flow *flow, uint32_t basis)
 typedef unsigned int OVS_BITWISE flow_wildcards_t;
 
 #define FWW_IN_PORT     ((OVS_FORCE flow_wildcards_t) (1 << 0))
-#define FWW_DL_TYPE     ((OVS_FORCE flow_wildcards_t) (1 << 1))
-#define FWW_ALL         ((OVS_FORCE flow_wildcards_t) (((1 << 2)) - 1))
+#define FWW_ALL         ((OVS_FORCE flow_wildcards_t) (((1 << 1)) - 1))
 
 /* Remember to update FLOW_WC_SEQ when adding or removing FWW_*. */
-BUILD_ASSERT_DECL(FWW_ALL == ((1 << 2) - 1) && FLOW_WC_SEQ == 16);
+BUILD_ASSERT_DECL(FWW_ALL == ((1 << 1) - 1) && FLOW_WC_SEQ == 17);
 
 /* Information on wildcards for a flow, as a supplement to "struct flow".
  *
@@ -165,6 +164,7 @@ struct flow_wildcards {
                                        nd_target bit. */
     ovs_be32 ipv6_label_mask;   /* 1 bit in each significant ipv6_label bit. */
     ovs_be16 vlan_tci_mask;     /* 1-bit in each significant vlan_tci bit. */
+    ovs_be16 dl_type_mask;      /* 1-bit in each significant dl_type bit. */
     ovs_be16 tp_src_mask;       /* 1-bit in each significant tp_src bit. */
     ovs_be16 tp_dst_mask;       /* 1-bit in each significant tp_dst bit. */
     uint8_t nw_proto_mask;      /* 1-bit in each significant nw_proto bit. */
@@ -175,11 +175,11 @@ struct flow_wildcards {
     uint8_t arp_tha_mask[6];    /* 1-bit in each significant dl_dst bit. */
     uint8_t nw_tos_mask;        /* 1-bit in each significant nw_tos bit. */
     uint8_t nw_ttl_mask;        /* 1-bit in each significant nw_ttl bit. */
-    uint8_t zeros[6];           /* Padding field set to zero. */
+    uint8_t zeros[4];           /* Padding field set to zero. */
 };
 
 /* Remember to update FLOW_WC_SEQ when updating struct flow_wildcards. */
-BUILD_ASSERT_DECL(sizeof(struct flow_wildcards) == 152 && FLOW_WC_SEQ == 16);
+BUILD_ASSERT_DECL(sizeof(struct flow_wildcards) == 152 && FLOW_WC_SEQ == 17);
 
 void flow_wildcards_init_catchall(struct flow_wildcards *);
 void flow_wildcards_init_exact(struct flow_wildcards *);
index 7166a74..99a9772 100644 (file)
@@ -139,7 +139,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
     }, {
         MFF_ETH_TYPE, "eth_type", "dl_type",
         MF_FIELD_SIZES(be16),
-        MFM_NONE, FWW_DL_TYPE,
+        MFM_NONE, 0,
         MFS_HEXADECIMAL,
         MFP_NONE,
         false,
@@ -574,7 +574,6 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
 {
     switch (mf->id) {
     case MFF_IN_PORT:
-    case MFF_ETH_TYPE:
         assert(mf->fww_bit != 0);
         return (wc->wildcards & mf->fww_bit) != 0;
 
@@ -590,6 +589,8 @@ mf_is_all_wild(const struct mf_field *mf, const struct flow_wildcards *wc)
         return eth_addr_is_zero(wc->dl_src_mask);
     case MFF_ETH_DST:
         return eth_addr_is_zero(wc->dl_dst_mask);
+    case MFF_ETH_TYPE:
+        return !wc->dl_type_mask;
 
     case MFF_ARP_SHA:
     case MFF_ND_SLL:
@@ -673,7 +674,6 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
 {
     switch (mf->id) {
     case MFF_IN_PORT:
-    case MFF_ETH_TYPE:
         assert(mf->fww_bit != 0);
         memset(mask, wc->wildcards & mf->fww_bit ? 0x00 : 0xff, mf->n_bytes);
         break;
@@ -692,10 +692,12 @@ mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
     case MFF_ETH_DST:
         memcpy(mask->mac, wc->dl_dst_mask, ETH_ADDR_LEN);
         break;
-
     case MFF_ETH_SRC:
         memcpy(mask->mac, wc->dl_src_mask, ETH_ADDR_LEN);
         break;
+    case MFF_ETH_TYPE:
+        mask->be16 = wc->dl_type_mask;
+        break;
 
     case MFF_VLAN_TCI:
         mask->be16 = wc->vlan_tci_mask;
@@ -1425,8 +1427,8 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule *rule)
         break;
 
     case MFF_ETH_TYPE:
-        rule->wc.wildcards |= FWW_DL_TYPE;
         rule->flow.dl_type = htons(0);
+        rule->wc.dl_type_mask = htons(0);
         break;
 
     case MFF_VLAN_TCI:
index e82bb50..511cd7c 100644 (file)
@@ -558,7 +558,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct cls_rule *cr,
     int match_len;
     int i;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     /* Metadata. */
     if (!(wc & FWW_IN_PORT)) {
@@ -575,10 +575,9 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct cls_rule *cr,
                        flow->dl_src, cr->wc.dl_src_mask);
     nxm_put_eth_masked(b, oxm ? OXM_OF_ETH_DST : NXM_OF_ETH_DST,
                        flow->dl_dst, cr->wc.dl_dst_mask);
-    if (!(wc & FWW_DL_TYPE)) {
-        nxm_put_16(b, oxm ? OXM_OF_ETH_TYPE : NXM_OF_ETH_TYPE,
-                   ofputil_dl_type_to_openflow(flow->dl_type));
-    }
+    nxm_put_16m(b, oxm ? OXM_OF_ETH_TYPE : NXM_OF_ETH_TYPE,
+                ofputil_dl_type_to_openflow(flow->dl_type),
+                cr->wc.dl_type_mask);
 
     /* 802.1Q. */
     if (oxm) {
@@ -600,7 +599,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct cls_rule *cr,
     }
 
     /* L3. */
-    if (!(wc & FWW_DL_TYPE) && flow->dl_type == htons(ETH_TYPE_IP)) {
+    if (flow->dl_type == htons(ETH_TYPE_IP)) {
         /* IP. */
         nxm_put_32m(b, oxm ? OXM_OF_IPV4_SRC : NXM_OF_IP_SRC,
                     flow->nw_src, cr->wc.nw_src_mask);
@@ -609,7 +608,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct cls_rule *cr,
         nxm_put_ip(b, cr, IPPROTO_ICMP,
                    oxm ? OXM_OF_ICMPV4_TYPE : NXM_OF_ICMP_TYPE,
                    oxm ? OXM_OF_ICMPV4_CODE : NXM_OF_ICMP_CODE, oxm);
-    } else if (!(wc & FWW_DL_TYPE) && flow->dl_type == htons(ETH_TYPE_IPV6)) {
+    } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
         /* IPv6. */
         nxm_put_ipv6(b, oxm ? OXM_OF_IPV6_SRC : NXM_NX_IPV6_SRC,
                      &flow->ipv6_src, &cr->wc.ipv6_src_mask);
@@ -636,7 +635,7 @@ nx_put_raw(struct ofpbuf *b, bool oxm, const struct cls_rule *cr,
                                    flow->arp_tha, cr->wc.arp_tha_mask);
             }
         }
-    } else if (!(wc & FWW_DL_TYPE) && flow->dl_type == htons(ETH_TYPE_ARP)) {
+    } else if (flow->dl_type == htons(ETH_TYPE_ARP)) {
         /* ARP. */
         if (cr->wc.nw_proto_mask) {
             nxm_put_16(b, oxm ? OXM_OF_ARP_OP : NXM_OF_ARP_OP,
index cdfb5d5..8413c37 100644 (file)
@@ -84,7 +84,7 @@ ofputil_netmask_to_wcbits(ovs_be32 netmask)
 void
 ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
 {
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     /* Initialize most of rule->wc. */
     flow_wildcards_init_catchall(wc);
@@ -93,9 +93,6 @@ ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
     if (ofpfw & OFPFW10_IN_PORT) {
         wc->wildcards |= FWW_IN_PORT;
     }
-    if (ofpfw & OFPFW10_DL_TYPE) {
-        wc->wildcards |= FWW_DL_TYPE;
-    }
 
     if (!(ofpfw & OFPFW10_NW_TOS)) {
         wc->nw_tos_mask |= IP_DSCP_MASK;
@@ -120,6 +117,9 @@ ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct flow_wildcards *wc)
     if (!(ofpfw & OFPFW10_DL_DST)) {
         memset(wc->dl_dst_mask, 0xff, ETH_ADDR_LEN);
     }
+    if (!(ofpfw & OFPFW10_DL_TYPE)) {
+        wc->dl_type_mask = htons(UINT16_MAX);
+    }
 
     /* VLAN TCI mask. */
     if (!(ofpfw & OFPFW10_DL_VLAN_PCP)) {
@@ -193,7 +193,7 @@ ofputil_cls_rule_to_ofp10_match(const struct cls_rule *rule,
     if (wc->wildcards & FWW_IN_PORT) {
         ofpfw |= OFPFW10_IN_PORT;
     }
-    if (wc->wildcards & FWW_DL_TYPE) {
+    if (!wc->dl_type_mask) {
         ofpfw |= OFPFW10_DL_TYPE;
     }
     if (!wc->nw_proto_mask) {
@@ -505,7 +505,7 @@ ofputil_cls_rule_to_ofp11_match(const struct cls_rule *rule,
         }
     }
 
-    if (rule->wc.wildcards & FWW_DL_TYPE) {
+    if (!rule->wc.dl_type_mask) {
         wc |= OFPFW11_DL_TYPE;
     } else {
         match->dl_type = ofputil_dl_type_to_openflow(rule->flow.dl_type);
@@ -903,7 +903,7 @@ ofputil_usable_protocols(const struct cls_rule *rule)
 {
     const struct flow_wildcards *wc = &rule->wc;
 
-    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
+    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
 
     /* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
     if (!eth_mask_is_exact(wc->dl_src_mask)
@@ -927,8 +927,7 @@ ofputil_usable_protocols(const struct cls_rule *rule)
     }
 
     /* Only NXM supports matching IPv6 traffic. */
-    if (!(wc->wildcards & FWW_DL_TYPE)
-            && (rule->flow.dl_type == htons(ETH_TYPE_IPV6))) {
+    if (rule->flow.dl_type == htons(ETH_TYPE_IPV6)) {
         return OFPUTIL_P_NXM_ANY;
     }
 
index 2fd9b98..97e8f3f 100644 (file)
@@ -50,7 +50,7 @@
     CLS_FIELD(0,                          nw_dst,      NW_DST)      \
     CLS_FIELD(FWW_IN_PORT,                in_port,     IN_PORT)     \
     CLS_FIELD(0,                          vlan_tci,    VLAN_TCI)    \
-    CLS_FIELD(FWW_DL_TYPE,                dl_type,     DL_TYPE)     \
+    CLS_FIELD(0,                          dl_type,     DL_TYPE)     \
     CLS_FIELD(0,                          tp_src,      TP_SRC)      \
     CLS_FIELD(0,                          tp_dst,      TP_DST)      \
     CLS_FIELD(0,                          dl_src,      DL_SRC)      \
@@ -223,6 +223,9 @@ match(const struct cls_rule *wild, const struct flow *fixed)
         } else if (f_idx == CLS_F_IDX_NW_PROTO) {
             eq = !((fixed->nw_proto ^ wild->flow.nw_proto)
                    & wild->wc.nw_proto_mask);
+        } else if (f_idx == CLS_F_IDX_DL_TYPE) {
+            eq = !((fixed->dl_type ^ wild->flow.dl_type)
+                   & wild->wc.dl_type_mask);
         } else {
             NOT_REACHED();
         }
@@ -507,6 +510,8 @@ make_rule(int wc_fields, unsigned int priority, int value_pat)
             rule->cls_rule.wc.nw_tos_mask |= IP_DSCP_MASK;
         } else if (f_idx == CLS_F_IDX_NW_PROTO) {
             rule->cls_rule.wc.nw_proto_mask = UINT8_MAX;
+        } else if (f_idx == CLS_F_IDX_DL_TYPE) {
+            rule->cls_rule.wc.dl_type_mask = htons(UINT16_MAX);
         } else {
             NOT_REACHED();
         }