void
cls_rule_set_nw_dscp(struct cls_rule *rule, uint8_t nw_dscp)
{
- rule->wc.wildcards &= ~FWW_NW_DSCP;
+ rule->wc.nw_tos_mask |= IP_DSCP_MASK;
rule->flow.nw_tos &= ~IP_DSCP_MASK;
rule->flow.nw_tos |= nw_dscp & IP_DSCP_MASK;
}
void
cls_rule_set_nw_ecn(struct cls_rule *rule, uint8_t nw_ecn)
{
- rule->wc.wildcards &= ~FWW_NW_ECN;
+ rule->wc.nw_tos_mask |= IP_ECN_MASK;
rule->flow.nw_tos &= ~IP_ECN_MASK;
rule->flow.nw_tos |= nw_ecn & IP_ECN_MASK;
}
format_eth_masked(s, "arp_sha", f->arp_sha, wc->arp_sha_mask);
format_eth_masked(s, "arp_tha", f->arp_tha, wc->arp_tha_mask);
}
- if (!(w & FWW_NW_DSCP)) {
+ if (wc->nw_tos_mask & IP_DSCP_MASK) {
ds_put_format(s, "nw_tos=%"PRIu8",", f->nw_tos & IP_DSCP_MASK);
}
- if (!(w & FWW_NW_ECN)) {
+ if (wc->nw_tos_mask & IP_ECN_MASK) {
ds_put_format(s, "nw_ecn=%"PRIu8",", f->nw_tos & IP_ECN_MASK);
}
if (!(w & FWW_NW_TTL)) {
wildcards->dl_dst_mask)
&& (wc & FWW_NW_PROTO || a->nw_proto == b->nw_proto)
&& (wc & FWW_NW_TTL || a->nw_ttl == b->nw_ttl)
- && (wc & FWW_NW_DSCP || !((a->nw_tos ^ b->nw_tos) & IP_DSCP_MASK))
- && (wc & FWW_NW_ECN || !((a->nw_tos ^ b->nw_tos) & IP_ECN_MASK))
+ && !((a->nw_tos ^ b->nw_tos) & wildcards->nw_tos_mask)
&& !((a->nw_frag ^ b->nw_frag) & wildcards->nw_frag_mask)
&& eth_addr_equal_except(a->arp_sha, b->arp_sha,
wildcards->arp_sha_mask)
flow->nw_proto = 0;
}
flow->ipv6_label &= wildcards->ipv6_label_mask;
- if (wc & FWW_NW_DSCP) {
- flow->nw_tos &= ~IP_DSCP_MASK;
- }
- if (wc & FWW_NW_ECN) {
- flow->nw_tos &= ~IP_ECN_MASK;
- }
+ flow->nw_tos &= wildcards->nw_tos_mask;
if (wc & FWW_NW_TTL) {
flow->nw_ttl = 0;
}
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);
- memset(wc->zeros, 0, sizeof wc->zeros);
+ wc->nw_tos_mask = 0;
}
/* Initializes 'wc' as an exact-match set of wildcards; that is, 'wc' does not
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);
- memset(wc->zeros, 0, sizeof wc->zeros);
+ wc->nw_tos_mask = UINT8_MAX;
}
/* Returns true if 'wc' is exact-match, false if 'wc' wildcards any bits or
|| !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_frag_mask != UINT8_MAX) {
+ || wc->nw_frag_mask != UINT8_MAX
+ || wc->nw_tos_mask != UINT8_MAX) {
return false;
}
|| !ipv6_mask_is_any(&wc->ipv6_dst_mask)
|| wc->ipv6_label_mask != htonl(0)
|| !ipv6_mask_is_any(&wc->nd_target_mask)
- || wc->nw_frag_mask != 0) {
+ || wc->nw_frag_mask != 0
+ || wc->nw_tos_mask != 0) {
return false;
}
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_tos_mask = src1->nw_tos_mask & src2->nw_tos_mask;
}
/* Returns a hash of the wildcards in 'wc'. */
|| !eth_addr_equals(a->dl_src_mask, b->dl_src_mask)
|| !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)) {
+ || !eth_addr_equals(a->arp_tha_mask, b->arp_tha_mask)
+ || a->nw_tos_mask != b->nw_tos_mask) {
return false;
}
|| (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_frag_mask & b->nw_frag_mask) != b->nw_frag_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);
}
/* Sets the wildcard mask for register 'idx' in 'wc' to 'mask'.
#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_NW_DSCP ((OVS_FORCE flow_wildcards_t) (1 << 3))
-#define FWW_NW_ECN ((OVS_FORCE flow_wildcards_t) (1 << 4))
-#define FWW_NW_TTL ((OVS_FORCE flow_wildcards_t) (1 << 5))
-#define FWW_ALL ((OVS_FORCE flow_wildcards_t) (((1 << 6)) - 1))
+#define FWW_NW_TTL ((OVS_FORCE flow_wildcards_t) (1 << 3))
+#define FWW_ALL ((OVS_FORCE flow_wildcards_t) (((1 << 4)) - 1))
/* Remember to update FLOW_WC_SEQ when adding or removing FWW_*. */
-BUILD_ASSERT_DECL(FWW_ALL == ((1 << 6) - 1) && FLOW_WC_SEQ == 14);
+BUILD_ASSERT_DECL(FWW_ALL == ((1 << 4) - 1) && FLOW_WC_SEQ == 14);
/* Information on wildcards for a flow, as a supplement to "struct flow".
*
uint8_t dl_dst_mask[6]; /* 1-bit in each significant dl_dst bit. */
uint8_t arp_sha_mask[6]; /* 1-bit in each significant dl_dst bit. */
uint8_t arp_tha_mask[6]; /* 1-bit in each significant dl_dst bit. */
- uint8_t zeros[1]; /* Padding field set to zero. */
+ uint8_t nw_tos_mask; /* 1-bit in each significant nw_tos bit. */
};
/* Remember to update FLOW_WC_SEQ when updating struct flow_wildcards. */
}, {
MFF_IP_DSCP, "nw_tos", NULL,
MF_FIELD_SIZES(u8),
- MFM_NONE, FWW_NW_DSCP,
+ MFM_NONE, 0,
MFS_DECIMAL,
MFP_IP_ANY,
true,
}, {
MFF_IP_ECN, "nw_ecn", NULL,
1, 2,
- MFM_NONE, FWW_NW_ECN,
+ MFM_NONE, 0,
MFS_DECIMAL,
MFP_IP_ANY,
true,
case MFF_IN_PORT:
case MFF_ETH_TYPE:
case MFF_IP_PROTO:
- case MFF_IP_DSCP:
- case MFF_IP_ECN:
case MFF_IP_TTL:
case MFF_ARP_OP:
assert(mf->fww_bit != 0);
case MFF_IPV6_LABEL:
return !wc->ipv6_label_mask;
+ case MFF_IP_DSCP:
+ return !(wc->nw_tos_mask & IP_DSCP_MASK);
+ case MFF_IP_ECN:
+ return !(wc->nw_tos_mask & IP_ECN_MASK);
+
case MFF_ND_TARGET:
return ipv6_mask_is_any(&wc->nd_target_mask);
case MFF_IN_PORT:
case MFF_ETH_TYPE:
case MFF_IP_PROTO:
- case MFF_IP_DSCP:
- case MFF_IP_ECN:
case MFF_IP_TTL:
case MFF_ARP_OP:
assert(mf->fww_bit != 0);
mask->be32 = wc->ipv6_label_mask;
break;
+ case MFF_IP_DSCP:
+ mask->u8 = wc->nw_tos_mask & IP_DSCP_MASK;
+ break;
+ case MFF_IP_ECN:
+ mask->u8 = wc->nw_tos_mask & IP_ECN_MASK;
+ break;
+
case MFF_ND_TARGET:
mask->ipv6 = wc->nd_target_mask;
break;
break;
case MFF_IP_DSCP:
- rule->wc.wildcards |= FWW_NW_DSCP;
+ rule->wc.nw_tos_mask &= ~IP_DSCP_MASK;
rule->flow.nw_tos &= ~IP_DSCP_MASK;
break;
case MFF_IP_ECN:
- rule->wc.wildcards |= FWW_NW_ECN;
+ rule->wc.nw_tos_mask &= ~IP_ECN_MASK;
rule->flow.nw_tos &= ~IP_ECN_MASK;
break;
nxm_put_frag(b, cr);
- if (!(wc & FWW_NW_DSCP)) {
+ if (cr->wc.nw_tos_mask & IP_DSCP_MASK) {
nxm_put_8(b, oxm ? OXM_OF_IP_DSCP : NXM_OF_IP_TOS,
flow->nw_tos & IP_DSCP_MASK);
}
- if (!(wc & FWW_NW_ECN)) {
+ if (cr->wc.nw_tos_mask & IP_ECN_MASK) {
nxm_put_8(b, oxm ? OXM_OF_IP_ECN : NXM_NX_IP_ECN,
flow->nw_tos & IP_ECN_MASK);
}
flow_wildcards_init_catchall(wc);
/* Start with wildcard fields that aren't defined by ofp10_match. */
- wc->wildcards = FWW_NW_ECN | FWW_NW_TTL;
+ wc->wildcards = FWW_NW_TTL;
if (ofpfw & OFPFW10_IN_PORT) {
wc->wildcards |= FWW_IN_PORT;
if (ofpfw & OFPFW10_NW_PROTO) {
wc->wildcards |= FWW_NW_PROTO;
}
- if (ofpfw & OFPFW10_NW_TOS) {
- wc->wildcards |= FWW_NW_DSCP;
+
+ if (!(ofpfw & OFPFW10_NW_TOS)) {
+ wc->nw_tos_mask |= IP_DSCP_MASK;
}
wc->nw_src_mask = ofputil_wcbits_to_netmask(ofpfw >> OFPFW10_NW_SRC_SHIFT);
<< OFPFW10_NW_SRC_SHIFT);
ofpfw |= (ofputil_netmask_to_wcbits(wc->nw_dst_mask)
<< OFPFW10_NW_DST_SHIFT);
- if (wc->wildcards & FWW_NW_DSCP) {
+ if (!(wc->nw_tos_mask & IP_DSCP_MASK)) {
ofpfw |= OFPFW10_NW_TOS;
}
if (!wc->tp_src_mask) {
match->dl_type = ofputil_dl_type_to_openflow(rule->flow.dl_type);
}
- if (rule->wc.wildcards & FWW_NW_DSCP) {
+ if (!(rule->wc.nw_tos_mask & IP_DSCP_MASK)) {
wc |= OFPFW11_NW_TOS;
} else {
match->nw_tos = rule->flow.nw_tos & IP_DSCP_MASK;
}
/* Only NXM supports matching IP ECN bits. */
- if (!(wc->wildcards & FWW_NW_ECN)) {
+ if (wc->nw_tos_mask & IP_ECN_MASK) {
return OFPUTIL_P_NXM_ANY;
}
wc.wildcards |= FWW_NW_PROTO;
}
if (!(may_match & MAY_IPVx)) {
- wc.wildcards |= FWW_NW_DSCP;
- wc.wildcards |= FWW_NW_ECN;
+ wc.nw_tos_mask = 0;
wc.wildcards |= FWW_NW_TTL;
}
if (!(may_match & MAY_ARP_SHA)) {
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(FWW_NW_DSCP, nw_tos, NW_DSCP)
+ CLS_FIELD(0, nw_tos, NW_DSCP)
/* Field indexes.
*
eq = !((fixed->metadata ^ wild->flow.metadata)
& wild->wc.metadata_mask);
} else if (f_idx == CLS_F_IDX_NW_DSCP) {
- eq = !((fixed->nw_tos ^ wild->flow.nw_tos) & IP_DSCP_MASK);
+ eq = !((fixed->nw_tos ^ wild->flow.nw_tos) &
+ (wild->wc.nw_tos_mask & IP_DSCP_MASK));
} else {
NOT_REACHED();
}
rule->cls_rule.wc.tun_id_mask = htonll(UINT64_MAX);
} else if (f_idx == CLS_F_IDX_METADATA) {
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 {
NOT_REACHED();
}