|| (nexthdr == IPPROTO_DSTOPTS)) {
/* These headers, while different, have the fields we care about
* in the same location and with the same interpretation. */
- const struct ip6_ext *ext_hdr = (struct ip6_ext *)packet->data;
+ const struct ip6_ext *ext_hdr = packet->data;
nexthdr = ext_hdr->ip6e_nxt;
if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 1) * 8)) {
return EINVAL;
* we care about are in the same location as the generic
* option header--only the header length is calculated
* differently. */
- const struct ip6_ext *ext_hdr = (struct ip6_ext *)packet->data;
+ const struct ip6_ext *ext_hdr = packet->data;
nexthdr = ext_hdr->ip6e_nxt;
if (!ofpbuf_try_pull(packet, (ext_hdr->ip6e_len + 2) * 4)) {
return EINVAL;
}
} else if (nexthdr == IPPROTO_FRAGMENT) {
- const struct ip6_frag *frag_hdr = (struct ip6_frag *)packet->data;
+ const struct ip6_frag *frag_hdr = packet->data;
nexthdr = frag_hdr->ip6f_nxt;
if (!ofpbuf_try_pull(packet, sizeof *frag_hdr)) {
void
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 == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
for (i = 0; i < FLOW_N_REGS; i++) {
flow->regs[i] &= wildcards->reg_masks[i];
flow->metadata &= wildcards->metadata_mask;
flow->nw_src &= wildcards->nw_src_mask;
flow->nw_dst &= wildcards->nw_dst_mask;
- if (wc & FWW_IN_PORT) {
- flow->in_port = 0;
- }
+ flow->in_port &= wildcards->in_port_mask;
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);
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;
- if (wc & FWW_NW_DSCP) {
- flow->nw_tos &= ~IP_DSCP_MASK;
- }
- if (wc & FWW_NW_ECN) {
- flow->nw_tos &= ~IP_ECN_MASK;
- }
- if (wc & FWW_NW_TTL) {
- flow->nw_ttl = 0;
- }
+ 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;
eth_addr_bitand(flow->arp_sha, wildcards->arp_sha_mask, flow->arp_sha);
eth_addr_bitand(flow->arp_tha, wildcards->arp_tha_mask, flow->arp_tha);
void
flow_get_metadata(const struct flow *flow, struct flow_metadata *fmd)
{
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
fmd->tun_id = flow->tun_id;
- fmd->tun_id_mask = htonll(UINT64_MAX);
-
fmd->metadata = flow->metadata;
- fmd->metadata_mask = htonll(UINT64_MAX);
-
memcpy(fmd->regs, flow->regs, sizeof fmd->regs);
- memset(fmd->reg_masks, 0xff, sizeof fmd->reg_masks);
-
fmd->in_port = flow->in_port;
}
void
flow_wildcards_init_catchall(struct flow_wildcards *wc)
{
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
- wc->wildcards = FWW_ALL;
wc->tun_id_mask = htonll(0);
wc->nw_src_mask = htonl(0);
wc->nw_dst_mask = htonl(0);
wc->nd_target_mask = in6addr_any;
memset(wc->reg_masks, 0, sizeof wc->reg_masks);
wc->metadata_mask = htonll(0);
+ wc->in_port_mask = 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);
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);
}
void
flow_wildcards_init_exact(struct flow_wildcards *wc)
{
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
- wc->wildcards = 0;
wc->tun_id_mask = htonll(UINT64_MAX);
wc->nw_src_mask = htonl(UINT32_MAX);
wc->nw_dst_mask = htonl(UINT32_MAX);
wc->nd_target_mask = in6addr_exact;
memset(wc->reg_masks, 0xff, sizeof wc->reg_masks);
wc->metadata_mask = htonll(UINT64_MAX);
+ wc->in_port_mask = UINT16_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);
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);
}
{
int i;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
- if (wc->wildcards
- || wc->tun_id_mask != htonll(UINT64_MAX)
+ if (wc->tun_id_mask != htonll(UINT64_MAX)
|| wc->nw_src_mask != htonl(UINT32_MAX)
|| wc->nw_dst_mask != htonl(UINT32_MAX)
|| wc->tp_src_mask != htons(UINT16_MAX)
|| wc->tp_dst_mask != htons(UINT16_MAX)
+ || wc->in_port_mask != 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)
|| !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_proto_mask != UINT8_MAX
+ || wc->nw_frag_mask != UINT8_MAX
+ || wc->nw_tos_mask != UINT8_MAX
+ || wc->nw_ttl_mask != UINT8_MAX) {
return false;
}
{
int i;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
- if (wc->wildcards != FWW_ALL
- || wc->tun_id_mask != htonll(0)
+ if (wc->tun_id_mask != htonll(0)
|| wc->nw_src_mask != htonl(0)
|| wc->nw_dst_mask != htonl(0)
|| wc->tp_src_mask != htons(0)
|| wc->tp_dst_mask != htons(0)
+ || wc->in_port_mask != 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)
|| !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_proto_mask != 0
+ || wc->nw_frag_mask != 0
+ || wc->nw_tos_mask != 0
+ || wc->nw_ttl_mask != 0) {
return false;
}
{
int i;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ 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->nw_src_mask = src1->nw_src_mask & src2->nw_src_mask;
dst->nw_dst_mask = src1->nw_dst_mask & src2->nw_dst_mask;
dst->reg_masks[i] = src1->reg_masks[i] & src2->reg_masks[i];
}
dst->metadata_mask = src1->metadata_mask & src2->metadata_mask;
+ dst->in_port_mask = src1->in_port_mask & src2->in_port_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;
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;
}
/* Returns a hash of the wildcards in 'wc'. */
/* If you change struct flow_wildcards and thereby trigger this
* assertion, please check that the new struct flow_wildcards has no holes
* in it before you update the assertion. */
- BUILD_ASSERT_DECL(sizeof *wc == 112 + FLOW_N_REGS * 4);
+ BUILD_ASSERT_DECL(sizeof *wc == 120 + FLOW_N_REGS * 4);
return hash_bytes(wc, sizeof *wc, basis);
}
{
int i;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ BUILD_ASSERT_DECL(FLOW_WC_SEQ == 17);
- if (a->wildcards != b->wildcards
- || a->tun_id_mask != b->tun_id_mask
+ if (a->tun_id_mask != b->tun_id_mask
|| a->nw_src_mask != b->nw_src_mask
|| a->nw_dst_mask != b->nw_dst_mask
+ || a->in_port_mask != b->in_port_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
|| !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_proto_mask != b->nw_proto_mask
+ || a->nw_tos_mask != b->nw_tos_mask
+ || a->nw_ttl_mask != b->nw_ttl_mask) {
return false;
}
uint8_t eth_masked[ETH_ADDR_LEN];
struct in6_addr ipv6_masked;
- BUILD_ASSERT_DECL(FLOW_WC_SEQ == 14);
+ 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]) {
return true;
}
- return (a->wildcards & ~b->wildcards
- || (a->tun_id_mask & b->tun_id_mask) != b->tun_id_mask
+ return ((a->tun_id_mask & b->tun_id_mask) != b->tun_id_mask
|| (a->nw_src_mask & b->nw_src_mask) != b->nw_src_mask
|| (a->nw_dst_mask & b->nw_dst_mask) != b->nw_dst_mask
|| (a->ipv6_label_mask & b->ipv6_label_mask) != b->ipv6_label_mask
+ || (a->in_port_mask & b->in_port_mask) != b->in_port_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_frag_mask & b->nw_frag_mask) != b->nw_frag_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);
}
/* Sets the wildcard mask for register 'idx' in 'wc' to 'mask'.
b->l4 = icmp = ofpbuf_put_zeros(b, sizeof *icmp);
icmp->icmp_type = ntohs(flow->tp_src);
icmp->icmp_code = ntohs(flow->tp_dst);
+ icmp->icmp_csum = csum(icmp, ICMP_HEADER_LEN);
}
}