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;
}
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) {
}
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)) {
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]) {
&& !((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,
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];
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);
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;
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);
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);
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);
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);
{
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)
|| 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)
{
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)
|| 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)
{
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;
}
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;
{
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
|| 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
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]) {
|| (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
/* 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);
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 *);
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".
*
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. */
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 *);
}, {
MFF_ETH_TYPE, "eth_type", "dl_type",
MF_FIELD_SIZES(be16),
- MFM_NONE, FWW_DL_TYPE,
+ MFM_NONE, 0,
MFS_HEXADECIMAL,
MFP_NONE,
false,
{
switch (mf->id) {
case MFF_IN_PORT:
- case MFF_ETH_TYPE:
assert(mf->fww_bit != 0);
return (wc->wildcards & mf->fww_bit) != 0;
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:
{
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;
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;
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:
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)) {
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) {
}
/* 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);
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);
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,
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);
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;
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)) {
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) {
}
}
- 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);
{
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)
}
/* 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;
}
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) \
} 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();
}
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();
}