Looks good, thanks.

Ethan

On Fri, Jul 20, 2012 at 4:25 PM, Ben Pfaff <b...@nicira.com> wrote:
> Signed-off-by: Ben Pfaff <b...@nicira.com>
> ---
>  lib/classifier.c        |   14 +++++++-------
>  lib/flow.c              |   29 +++++++++++++++++------------
>  lib/flow.h              |   14 +++++++-------
>  lib/meta-flow.c         |   22 ++++++++++++++--------
>  lib/nx-match.c          |    7 +++----
>  lib/ofp-util.c          |   16 ++++++++--------
>  tests/test-classifier.c |    7 ++++++-
>  7 files changed, 62 insertions(+), 47 deletions(-)
>
> diff --git a/lib/classifier.c b/lib/classifier.c
> index a8fd0fd..c032815 100644
> --- a/lib/classifier.c
> +++ b/lib/classifier.c
> @@ -326,8 +326,8 @@ cls_rule_set_tp_dst_masked(struct cls_rule *rule, 
> ovs_be16 port, ovs_be16 mask)
>  void
>  cls_rule_set_nw_proto(struct cls_rule *rule, uint8_t nw_proto)
>  {
> -    rule->wc.wildcards &= ~FWW_NW_PROTO;
>      rule->flow.nw_proto = nw_proto;
> +    rule->wc.nw_proto_mask = UINT8_MAX;
>  }
>
>  void
> @@ -582,7 +582,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
>
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      if (rule->priority != OFP_DEFAULT_PRIORITY) {
>          ds_put_format(s, "priority=%d,", rule->priority);
> @@ -591,7 +591,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
>      if (!(w & FWW_DL_TYPE)) {
>          skip_type = true;
>          if (f->dl_type == htons(ETH_TYPE_IP)) {
> -            if (!(w & FWW_NW_PROTO)) {
> +            if (wc->nw_proto_mask) {
>                  skip_proto = true;
>                  if (f->nw_proto == IPPROTO_ICMP) {
>                      ds_put_cstr(s, "icmp,");
> @@ -607,7 +607,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
>                  ds_put_cstr(s, "ip,");
>              }
>          } else if (f->dl_type == htons(ETH_TYPE_IPV6)) {
> -            if (!(w & FWW_NW_PROTO)) {
> +            if (wc->nw_proto_mask) {
>                  skip_proto = true;
>                  if (f->nw_proto == IPPROTO_ICMPV6) {
>                      ds_put_cstr(s, "icmp6,");
> @@ -712,7 +712,7 @@ cls_rule_format(const struct cls_rule *rule, struct ds *s)
>          format_ip_netmask(s, "nw_src", f->nw_src, wc->nw_src_mask);
>          format_ip_netmask(s, "nw_dst", f->nw_dst, wc->nw_dst_mask);
>      }
> -    if (!skip_proto && !(w & FWW_NW_PROTO)) {
> +    if (!skip_proto && wc->nw_proto_mask) {
>          if (f->dl_type == htons(ETH_TYPE_ARP)) {
>              ds_put_format(s, "arp_op=%"PRIu8",", f->nw_proto);
>          } else {
> @@ -1266,7 +1266,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 == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      for (i = 0; i < FLOW_N_REGS; i++) {
>          if ((a->regs[i] ^ b->regs[i]) & wildcards->reg_masks[i]) {
> @@ -1287,7 +1287,7 @@ flow_equal_except(const struct flow *a, const struct 
> flow *b,
>                                       wildcards->dl_src_mask)
>              && eth_addr_equal_except(a->dl_dst, b->dl_dst,
>                                       wildcards->dl_dst_mask)
> -            && (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto)
> +            && !((a->nw_proto ^ b->nw_proto) & wildcards->nw_proto_mask)
>              && !((a->nw_ttl ^ b->nw_ttl) & wildcards->nw_ttl_mask)
>              && !((a->nw_tos ^ b->nw_tos) & wildcards->nw_tos_mask)
>              && !((a->nw_frag ^ b->nw_frag) & wildcards->nw_frag_mask)
> diff --git a/lib/flow.c b/lib/flow.c
> index ab1711e..2fd1c7d 100644
> --- a/lib/flow.c
> +++ b/lib/flow.c
> @@ -444,7 +444,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 == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      for (i = 0; i < FLOW_N_REGS; i++) {
>          flow->regs[i] &= wildcards->reg_masks[i];
> @@ -464,10 +464,8 @@ flow_zero_wildcards(struct flow *flow, const struct 
> flow_wildcards *wildcards)
>      flow->tp_dst &= wildcards->tp_dst_mask;
>      eth_addr_bitand(flow->dl_src, wildcards->dl_src_mask, flow->dl_src);
>      eth_addr_bitand(flow->dl_dst, wildcards->dl_dst_mask, flow->dl_dst);
> -    if (wc & FWW_NW_PROTO) {
> -        flow->nw_proto = 0;
> -    }
>      flow->ipv6_label &= wildcards->ipv6_label_mask;
> +    flow->nw_proto &= wildcards->nw_proto_mask;
>      flow->nw_tos &= wildcards->nw_tos_mask;
>      flow->nw_ttl &= wildcards->nw_ttl_mask;
>      flow->nw_frag &= wildcards->nw_frag_mask;
> @@ -486,7 +484,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 == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      fmd->tun_id = flow->tun_id;
>      fmd->tun_id_mask = htonll(UINT64_MAX);
> @@ -580,7 +578,7 @@ flow_print(FILE *stream, const struct flow *flow)
>  void
>  flow_wildcards_init_catchall(struct flow_wildcards *wc)
>  {
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      wc->wildcards = FWW_ALL;
>      wc->tun_id_mask = htonll(0);
> @@ -600,6 +598,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
>      memset(wc->dl_dst_mask, 0, ETH_ADDR_LEN);
>      memset(wc->arp_sha_mask, 0, ETH_ADDR_LEN);
>      memset(wc->arp_tha_mask, 0, ETH_ADDR_LEN);
> +    wc->nw_proto_mask = 0;
>      wc->nw_tos_mask = 0;
>      wc->nw_ttl_mask = 0;
>      memset(wc->zeros, 0, sizeof wc->zeros);
> @@ -610,7 +609,7 @@ flow_wildcards_init_catchall(struct flow_wildcards *wc)
>  void
>  flow_wildcards_init_exact(struct flow_wildcards *wc)
>  {
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      wc->wildcards = 0;
>      wc->tun_id_mask = htonll(UINT64_MAX);
> @@ -630,6 +629,7 @@ flow_wildcards_init_exact(struct flow_wildcards *wc)
>      memset(wc->dl_dst_mask, 0xff, ETH_ADDR_LEN);
>      memset(wc->arp_sha_mask, 0xff, ETH_ADDR_LEN);
>      memset(wc->arp_tha_mask, 0xff, ETH_ADDR_LEN);
> +    wc->nw_proto_mask = UINT8_MAX;
>      wc->nw_tos_mask = UINT8_MAX;
>      wc->nw_ttl_mask = UINT8_MAX;
>      memset(wc->zeros, 0, sizeof wc->zeros);
> @@ -642,7 +642,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
>  {
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      if (wc->wildcards
>          || wc->tun_id_mask != htonll(UINT64_MAX)
> @@ -660,6 +660,7 @@ flow_wildcards_is_exact(const struct flow_wildcards *wc)
>          || !ipv6_mask_is_exact(&wc->ipv6_dst_mask)
>          || wc->ipv6_label_mask != htonl(UINT32_MAX)
>          || !ipv6_mask_is_exact(&wc->nd_target_mask)
> +        || wc->nw_proto_mask != UINT8_MAX
>          || wc->nw_frag_mask != UINT8_MAX
>          || wc->nw_tos_mask != UINT8_MAX
>          || wc->nw_ttl_mask != UINT8_MAX) {
> @@ -682,7 +683,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards 
> *wc)
>  {
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      if (wc->wildcards != FWW_ALL
>          || wc->tun_id_mask != htonll(0)
> @@ -700,6 +701,7 @@ flow_wildcards_is_catchall(const struct flow_wildcards 
> *wc)
>          || !ipv6_mask_is_any(&wc->ipv6_dst_mask)
>          || wc->ipv6_label_mask != htonl(0)
>          || !ipv6_mask_is_any(&wc->nd_target_mask)
> +        || wc->nw_proto_mask != 0
>          || wc->nw_frag_mask != 0
>          || wc->nw_tos_mask != 0
>          || wc->nw_ttl_mask != 0) {
> @@ -725,7 +727,7 @@ flow_wildcards_combine(struct flow_wildcards *dst,
>  {
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      dst->wildcards = src1->wildcards | src2->wildcards;
>      dst->tun_id_mask = src1->tun_id_mask & src2->tun_id_mask;
> @@ -750,6 +752,7 @@ flow_wildcards_combine(struct flow_wildcards *dst,
>      eth_addr_bitand(src1->dl_dst_mask, src2->dl_dst_mask, dst->dl_dst_mask);
>      eth_addr_bitand(src1->arp_sha_mask, src2->arp_sha_mask, 
> dst->arp_sha_mask);
>      eth_addr_bitand(src1->arp_tha_mask, src2->arp_tha_mask, 
> dst->arp_tha_mask);
> +    dst->nw_proto_mask = src1->nw_proto_mask & src2->nw_proto_mask;
>      dst->nw_tos_mask = src1->nw_tos_mask & src2->nw_tos_mask;
>      dst->nw_ttl_mask = src1->nw_ttl_mask & src2->nw_ttl_mask;
>  }
> @@ -773,7 +776,7 @@ flow_wildcards_equal(const struct flow_wildcards *a,
>  {
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      if (a->wildcards != b->wildcards
>          || a->tun_id_mask != b->tun_id_mask
> @@ -792,6 +795,7 @@ flow_wildcards_equal(const struct flow_wildcards *a,
>          || !eth_addr_equals(a->dl_dst_mask, b->dl_dst_mask)
>          || !eth_addr_equals(a->arp_sha_mask, b->arp_sha_mask)
>          || !eth_addr_equals(a->arp_tha_mask, b->arp_tha_mask)
> +        || a->nw_proto_mask != b->nw_proto_mask
>          || a->nw_tos_mask != b->nw_tos_mask
>          || a->nw_ttl_mask != b->nw_ttl_mask) {
>          return false;
> @@ -816,7 +820,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 == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      for (i = 0; i < FLOW_N_REGS; i++) {
>          if ((a->reg_masks[i] & b->reg_masks[i]) != b->reg_masks[i]) {
> @@ -868,6 +872,7 @@ flow_wildcards_has_extra(const struct flow_wildcards *a,
>              || (a->metadata_mask & b->metadata_mask) != b->metadata_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
>              || (a->nw_frag_mask & b->nw_frag_mask) != b->nw_frag_mask
>              || (a->nw_tos_mask & b->nw_tos_mask) != b->nw_tos_mask
>              || (a->nw_ttl_mask & b->nw_ttl_mask) != b->nw_ttl_mask);
> diff --git a/lib/flow.h b/lib/flow.h
> index bf65e27..3da8c12 100644
> --- a/lib/flow.h
> +++ b/lib/flow.h
> @@ -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 15
> +#define FLOW_WC_SEQ 16
>
>  #define FLOW_N_REGS 8
>  BUILD_ASSERT_DECL(FLOW_N_REGS <= NXM_NX_MAX_REGS);
> @@ -103,7 +103,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 == 15);
> +BUILD_ASSERT_DECL(FLOW_SIG_SIZE == 150 && FLOW_WC_SEQ == 16);
>
>  void flow_extract(struct ofpbuf *, uint32_t priority, ovs_be64 tun_id,
>                    uint16_t in_port, struct flow *);
> @@ -150,11 +150,10 @@ 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_NW_PROTO    ((OVS_FORCE flow_wildcards_t) (1 << 2))
> -#define FWW_ALL         ((OVS_FORCE flow_wildcards_t) (((1 << 3)) - 1))
> +#define FWW_ALL         ((OVS_FORCE flow_wildcards_t) (((1 << 2)) - 1))
>
>  /* Remember to update FLOW_WC_SEQ when adding or removing FWW_*. */
> -BUILD_ASSERT_DECL(FWW_ALL == ((1 << 3) - 1) && FLOW_WC_SEQ == 15);
> +BUILD_ASSERT_DECL(FWW_ALL == ((1 << 2) - 1) && FLOW_WC_SEQ == 16);
>
>  /* Information on wildcards for a flow, as a supplement to "struct flow".
>   *
> @@ -175,6 +174,7 @@ struct flow_wildcards {
>      ovs_be16 vlan_tci_mask;     /* 1-bit in each significant vlan_tci 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. */
>      uint8_t nw_frag_mask;       /* 1-bit in each significant nw_frag bit. */
>      uint8_t dl_src_mask[6];     /* 1-bit in each significant dl_src bit. */
>      uint8_t dl_dst_mask[6];     /* 1-bit in each significant dl_dst bit. */
> @@ -182,11 +182,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[7];           /* Padding field set to zero. */
> +    uint8_t zeros[6];           /* 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 == 15);
> +BUILD_ASSERT_DECL(sizeof(struct flow_wildcards) == 152 && FLOW_WC_SEQ == 16);
>
>  void flow_wildcards_init_catchall(struct flow_wildcards *);
>  void flow_wildcards_init_exact(struct flow_wildcards *);
> diff --git a/lib/meta-flow.c b/lib/meta-flow.c
> index 1497401..ce49239 100644
> --- a/lib/meta-flow.c
> +++ b/lib/meta-flow.c
> @@ -233,7 +233,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
>      {
>          MFF_IP_PROTO, "nw_proto", NULL,
>          MF_FIELD_SIZES(u8),
> -        MFM_NONE, FWW_NW_PROTO,
> +        MFM_NONE, 0,
>          MFS_DECIMAL,
>          MFP_IP_ANY,
>          false,
> @@ -280,7 +280,7 @@ static const struct mf_field mf_fields[MFF_N_IDS] = {
>      {
>          MFF_ARP_OP, "arp_op", NULL,
>          MF_FIELD_SIZES(be16),
> -        MFM_NONE, FWW_NW_PROTO,
> +        MFM_NONE, 0,
>          MFS_DECIMAL,
>          MFP_ARP,
>          false,
> @@ -557,8 +557,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:
> -    case MFF_IP_PROTO:
> -    case MFF_ARP_OP:
>          assert(mf->fww_bit != 0);
>          return (wc->wildcards & mf->fww_bit) != 0;
>
> @@ -603,6 +601,8 @@ mf_is_all_wild(const struct mf_field *mf, const struct 
> flow_wildcards *wc)
>      case MFF_IPV6_LABEL:
>          return !wc->ipv6_label_mask;
>
> +    case MFF_IP_PROTO:
> +        return !wc->nw_proto_mask;
>      case MFF_IP_DSCP:
>          return !(wc->nw_tos_mask & IP_DSCP_MASK);
>      case MFF_IP_ECN:
> @@ -616,6 +616,8 @@ mf_is_all_wild(const struct mf_field *mf, const struct 
> flow_wildcards *wc)
>      case MFF_IP_FRAG:
>          return !(wc->nw_frag_mask & FLOW_NW_FRAG_MASK);
>
> +    case MFF_ARP_OP:
> +        return !wc->nw_proto_mask;
>      case MFF_ARP_SPA:
>          return !wc->nw_src_mask;
>      case MFF_ARP_TPA:
> @@ -651,8 +653,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:
> -    case MFF_IP_PROTO:
> -    case MFF_ARP_OP:
>          assert(mf->fww_bit != 0);
>          memset(mask, wc->wildcards & mf->fww_bit ? 0x00 : 0xff, mf->n_bytes);
>          break;
> @@ -703,6 +703,9 @@ mf_get_mask(const struct mf_field *mf, const struct 
> flow_wildcards *wc,
>          mask->be32 = wc->ipv6_label_mask;
>          break;
>
> +    case MFF_IP_PROTO:
> +        mask->u8 = wc->nw_proto_mask;
> +        break;
>      case MFF_IP_DSCP:
>          mask->u8 = wc->nw_tos_mask & IP_DSCP_MASK;
>          break;
> @@ -721,6 +724,9 @@ mf_get_mask(const struct mf_field *mf, const struct 
> flow_wildcards *wc,
>          mask->u8 = wc->nw_frag_mask & FLOW_NW_FRAG_MASK;
>          break;
>
> +    case MFF_ARP_OP:
> +        mask->u8 = wc->nw_proto_mask;
> +        break;
>      case MFF_ARP_SPA:
>          mask->be32 = wc->nw_src_mask;
>          break;
> @@ -1419,7 +1425,7 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule 
> *rule)
>          break;
>
>      case MFF_IP_PROTO:
> -        rule->wc.wildcards |= FWW_NW_PROTO;
> +        rule->wc.nw_proto_mask = 0;
>          rule->flow.nw_proto = 0;
>          break;
>
> @@ -1444,7 +1450,7 @@ mf_set_wild(const struct mf_field *mf, struct cls_rule 
> *rule)
>          break;
>
>      case MFF_ARP_OP:
> -        rule->wc.wildcards |= FWW_NW_PROTO;
> +        rule->wc.nw_proto_mask = 0;
>          rule->flow.nw_proto = 0;
>          break;
>
> diff --git a/lib/nx-match.c b/lib/nx-match.c
> index 2dfb351..b342111 100644
> --- a/lib/nx-match.c
> +++ b/lib/nx-match.c
> @@ -428,7 +428,6 @@ nxm_put_ip(struct ofpbuf *b, const struct cls_rule *cr,
>             uint8_t icmp_proto, uint32_t icmp_type, uint32_t icmp_code,
>             bool oxm)
>  {
> -    const flow_wildcards_t wc = cr->wc.wildcards;
>      const struct flow *flow = &cr->flow;
>
>      nxm_put_frag(b, cr);
> @@ -447,7 +446,7 @@ nxm_put_ip(struct ofpbuf *b, const struct cls_rule *cr,
>          nxm_put_8(b, NXM_NX_IP_TTL, flow->nw_ttl);
>      }
>
> -    if (!(wc & FWW_NW_PROTO)) {
> +    if (cr->wc.nw_proto_mask) {
>          nxm_put_8(b, oxm ? OXM_OF_IP_PROTO : NXM_OF_IP_PROTO, 
> flow->nw_proto);
>
>          if (flow->nw_proto == IPPROTO_TCP) {
> @@ -493,7 +492,7 @@ nx_put_match(struct ofpbuf *b, bool oxm, const struct 
> cls_rule *cr,
>      int match_len;
>      int i;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      /* Metadata. */
>      if (!(wc & FWW_IN_PORT)) {
> @@ -559,7 +558,7 @@ nx_put_match(struct ofpbuf *b, bool oxm, const struct 
> cls_rule *cr,
>          }
>      } else if (!(wc & FWW_DL_TYPE) && flow->dl_type == htons(ETH_TYPE_ARP)) {
>          /* ARP. */
> -        if (!(wc & FWW_NW_PROTO)) {
> +        if (cr->wc.nw_proto_mask) {
>              nxm_put_16(b, oxm ? OXM_OF_ARP_OP : NXM_OF_ARP_OP,
>                         htons(flow->nw_proto));
>          }
> diff --git a/lib/ofp-util.c b/lib/ofp-util.c
> index d82ab2a..9b0da8f 100644
> --- a/lib/ofp-util.c
> +++ b/lib/ofp-util.c
> @@ -83,7 +83,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 == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      /* Initialize most of rule->wc. */
>      flow_wildcards_init_catchall(wc);
> @@ -95,14 +95,14 @@ ofputil_wildcard_from_ofpfw10(uint32_t ofpfw, struct 
> flow_wildcards *wc)
>      if (ofpfw & OFPFW10_DL_TYPE) {
>          wc->wildcards |= FWW_DL_TYPE;
>      }
> -    if (ofpfw & OFPFW10_NW_PROTO) {
> -        wc->wildcards |= FWW_NW_PROTO;
> -    }
>
>      if (!(ofpfw & OFPFW10_NW_TOS)) {
>          wc->nw_tos_mask |= IP_DSCP_MASK;
>      }
>
> +    if (!(ofpfw & OFPFW10_NW_PROTO)) {
> +        wc->nw_proto_mask = UINT8_MAX;
> +    }
>      wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> 
> OFPFW10_NW_SRC_SHIFT);
>      wc->nw_dst_mask = ofputil_wcbits_to_netmask(ofpfw >> 
> OFPFW10_NW_DST_SHIFT);
>
> @@ -195,7 +195,7 @@ ofputil_cls_rule_to_ofp10_match(const struct cls_rule 
> *rule,
>      if (wc->wildcards & FWW_DL_TYPE) {
>          ofpfw |= OFPFW10_DL_TYPE;
>      }
> -    if (wc->wildcards & FWW_NW_PROTO) {
> +    if (!wc->nw_proto_mask) {
>          ofpfw |= OFPFW10_NW_PROTO;
>      }
>      ofpfw |= (ofputil_netmask_to_wcbits(wc->nw_src_mask)
> @@ -478,7 +478,7 @@ ofputil_cls_rule_to_ofp11_match(const struct cls_rule 
> *rule,
>          match->nw_tos = rule->flow.nw_tos & IP_DSCP_MASK;
>      }
>
> -    if (rule->wc.wildcards & FWW_NW_PROTO) {
> +    if (!rule->wc.nw_proto_mask) {
>          wc |= OFPFW11_NW_PROTO;
>      } else {
>          match->nw_proto = rule->flow.nw_proto;
> @@ -1455,7 +1455,7 @@ ofputil_usable_protocols(const struct cls_rule *rule)
>  {
>      const struct flow_wildcards *wc = &rule->wc;
>
> -    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 15);
> +    BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16);
>
>      /* NXM and OF1.1+ supports bitwise matching on ethernet addresses. */
>      if (!eth_mask_is_exact(wc->dl_src_mask)
> @@ -4094,7 +4094,7 @@ ofputil_normalize_rule(struct cls_rule *rule)
>          wc.tp_src_mask = wc.tp_dst_mask = htons(0);
>      }
>      if (!(may_match & MAY_NW_PROTO)) {
> -        wc.wildcards |= FWW_NW_PROTO;
> +        wc.nw_proto_mask = 0;
>      }
>      if (!(may_match & MAY_IPVx)) {
>          wc.nw_tos_mask = 0;
> diff --git a/tests/test-classifier.c b/tests/test-classifier.c
> index a978afb..2fd9b98 100644
> --- a/tests/test-classifier.c
> +++ b/tests/test-classifier.c
> @@ -55,7 +55,7 @@
>      CLS_FIELD(0,                          tp_dst,      TP_DST)      \
>      CLS_FIELD(0,                          dl_src,      DL_SRC)      \
>      CLS_FIELD(0,                          dl_dst,      DL_DST)      \
> -    CLS_FIELD(FWW_NW_PROTO,               nw_proto,    NW_PROTO)    \
> +    CLS_FIELD(0,                          nw_proto,    NW_PROTO)    \
>      CLS_FIELD(0,                          nw_tos,      NW_DSCP)
>
>  /* Field indexes.
> @@ -220,6 +220,9 @@ match(const struct cls_rule *wild, const struct flow 
> *fixed)
>          } else if (f_idx == CLS_F_IDX_NW_DSCP) {
>              eq = !((fixed->nw_tos ^ wild->flow.nw_tos) &
>                     (wild->wc.nw_tos_mask & IP_DSCP_MASK));
> +        } else if (f_idx == CLS_F_IDX_NW_PROTO) {
> +            eq = !((fixed->nw_proto ^ wild->flow.nw_proto)
> +                   & wild->wc.nw_proto_mask);
>          } else {
>              NOT_REACHED();
>          }
> @@ -502,6 +505,8 @@ make_rule(int wc_fields, unsigned int priority, int 
> value_pat)
>              rule->cls_rule.wc.metadata_mask = htonll(UINT64_MAX);
>          } else if (f_idx == CLS_F_IDX_NW_DSCP) {
>              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 {
>              NOT_REACHED();
>          }
> --
> 1.7.2.5
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to