From: Ben Pfaff Date: Mon, 18 Jun 2012 21:12:52 +0000 (-0700) Subject: flow: Use bit-mask for IP protocol match, instead of FWW_* flag. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=851d3105c7a4166d0cd05f3f9198edea2623bcd7;p=openvswitch flow: Use bit-mask for IP protocol match, instead of FWW_* flag. Signed-off-by: Ben Pfaff --- diff --git a/lib/classifier.c b/lib/classifier.c index 5add1758..324bc141 100644 --- a/lib/classifier.c +++ b/lib/classifier.c @@ -351,8 +351,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 @@ -607,7 +607,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); @@ -616,7 +616,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,"); @@ -632,7 +632,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,"); @@ -737,7 +737,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 { @@ -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 == 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]) { @@ -1312,7 +1312,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 0844b3bc..d6d45277 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -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 == 15); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16); for (i = 0; i < FLOW_N_REGS; i++) { flow->regs[i] &= wildcards->reg_masks[i]; @@ -465,10 +465,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; @@ -487,7 +485,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->metadata = flow->metadata; @@ -575,7 +573,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); @@ -595,6 +593,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); @@ -605,7 +604,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); @@ -625,6 +624,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); @@ -637,7 +637,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) @@ -655,6 +655,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) { @@ -677,7 +678,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) @@ -695,6 +696,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) { @@ -720,7 +722,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; @@ -745,6 +747,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; } @@ -768,7 +771,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 @@ -787,6 +790,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; @@ -811,7 +815,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]) { @@ -863,6 +867,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 d7abe3b1..341c8422 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); @@ -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 == 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 *); @@ -143,11 +143,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". * @@ -168,6 +167,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. */ @@ -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[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 7bfdff31..7166a741 100644 --- a/lib/meta-flow.c +++ b/lib/meta-flow.c @@ -251,7 +251,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, @@ -298,7 +298,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, @@ -575,8 +575,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; @@ -624,6 +622,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: @@ -637,6 +637,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: @@ -672,8 +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: - 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; @@ -728,6 +728,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; @@ -746,6 +749,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; @@ -1463,7 +1469,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; @@ -1488,7 +1494,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 0eb65d8f..e82bb50d 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -495,7 +495,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); @@ -514,7 +513,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) { @@ -559,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 == 15); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16); /* Metadata. */ if (!(wc & FWW_IN_PORT)) { @@ -639,7 +638,7 @@ nx_put_raw(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 451f5537..cdfb5d51 100644 --- a/lib/ofp-util.c +++ b/lib/ofp-util.c @@ -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 == 15); + BUILD_ASSERT_DECL(FLOW_WC_SEQ == 16); /* Initialize most of rule->wc. */ flow_wildcards_init_catchall(wc); @@ -96,14 +96,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); @@ -196,7 +196,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) @@ -517,7 +517,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; @@ -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 == 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) @@ -3632,7 +3632,7 @@ ofputil_normalize_rule__(struct cls_rule *rule, bool may_log) 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 a978afb0..2fd9b98d 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(); }