mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
meta-flow: Fix and simplify mf_get_mask().
This function can be implemented as a trivial wrapper around mf_get_value(), which I hadn't noticed before, so it's better to do it that way. Also, examining the code that is removed, it had some bugs in it (for example, all MFF_TUN_* fields were treated as if they were MFF_TUN_ID) which mf_get_value() does not have, so this fixes bugs too. Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
122
lib/meta-flow.c
122
lib/meta-flow.c
@@ -719,127 +719,7 @@ void
|
||||
mf_get_mask(const struct mf_field *mf, const struct flow_wildcards *wc,
|
||||
union mf_value *mask)
|
||||
{
|
||||
switch (mf->id) {
|
||||
case MFF_TUN_ID:
|
||||
case MFF_TUN_SRC:
|
||||
case MFF_TUN_DST:
|
||||
case MFF_TUN_TOS:
|
||||
case MFF_TUN_TTL:
|
||||
case MFF_TUN_FLAGS:
|
||||
mask->be64 = wc->masks.tunnel.tun_id;
|
||||
break;
|
||||
case MFF_METADATA:
|
||||
mask->be64 = wc->masks.metadata;
|
||||
break;
|
||||
case MFF_IN_PORT:
|
||||
mask->be16 = htons(wc->masks.in_port);
|
||||
break;
|
||||
CASE_MFF_REGS:
|
||||
mask->be32 = htonl(wc->masks.regs[mf->id - MFF_REG0]);
|
||||
break;
|
||||
|
||||
case MFF_ETH_DST:
|
||||
memcpy(mask->mac, wc->masks.dl_dst, ETH_ADDR_LEN);
|
||||
break;
|
||||
case MFF_ETH_SRC:
|
||||
memcpy(mask->mac, wc->masks.dl_src, ETH_ADDR_LEN);
|
||||
break;
|
||||
case MFF_ETH_TYPE:
|
||||
mask->be16 = wc->masks.dl_type;
|
||||
break;
|
||||
|
||||
case MFF_VLAN_TCI:
|
||||
mask->be16 = wc->masks.vlan_tci;
|
||||
break;
|
||||
case MFF_DL_VLAN:
|
||||
mask->be16 = wc->masks.vlan_tci & htons(VLAN_VID_MASK);
|
||||
break;
|
||||
case MFF_VLAN_VID:
|
||||
mask->be16 = wc->masks.vlan_tci & htons(VLAN_VID_MASK | VLAN_CFI);
|
||||
break;
|
||||
case MFF_DL_VLAN_PCP:
|
||||
case MFF_VLAN_PCP:
|
||||
mask->u8 = vlan_tci_to_pcp(wc->masks.vlan_tci);
|
||||
break;
|
||||
|
||||
case MFF_IPV4_SRC:
|
||||
mask->be32 = wc->masks.nw_src;
|
||||
break;
|
||||
case MFF_IPV4_DST:
|
||||
mask->be32 = wc->masks.nw_dst;
|
||||
break;
|
||||
|
||||
case MFF_IPV6_SRC:
|
||||
mask->ipv6 = wc->masks.ipv6_src;
|
||||
break;
|
||||
case MFF_IPV6_DST:
|
||||
mask->ipv6 = wc->masks.ipv6_dst;
|
||||
break;
|
||||
case MFF_IPV6_LABEL:
|
||||
mask->be32 = wc->masks.ipv6_label;
|
||||
break;
|
||||
|
||||
case MFF_IP_PROTO:
|
||||
mask->u8 = wc->masks.nw_proto;
|
||||
break;
|
||||
case MFF_IP_DSCP:
|
||||
mask->u8 = wc->masks.nw_tos & IP_DSCP_MASK;
|
||||
break;
|
||||
case MFF_IP_ECN:
|
||||
mask->u8 = wc->masks.nw_tos & IP_ECN_MASK;
|
||||
break;
|
||||
|
||||
case MFF_ND_TARGET:
|
||||
mask->ipv6 = wc->masks.nd_target;
|
||||
break;
|
||||
|
||||
case MFF_IP_TTL:
|
||||
mask->u8 = wc->masks.nw_ttl;
|
||||
break;
|
||||
case MFF_IP_FRAG:
|
||||
mask->u8 = wc->masks.nw_frag & FLOW_NW_FRAG_MASK;
|
||||
break;
|
||||
|
||||
case MFF_ARP_OP:
|
||||
mask->u8 = wc->masks.nw_proto;
|
||||
break;
|
||||
case MFF_ARP_SPA:
|
||||
mask->be32 = wc->masks.nw_src;
|
||||
break;
|
||||
case MFF_ARP_TPA:
|
||||
mask->be32 = wc->masks.nw_dst;
|
||||
break;
|
||||
case MFF_ARP_SHA:
|
||||
case MFF_ND_SLL:
|
||||
memcpy(mask->mac, wc->masks.arp_sha, ETH_ADDR_LEN);
|
||||
break;
|
||||
case MFF_ARP_THA:
|
||||
case MFF_ND_TLL:
|
||||
memcpy(mask->mac, wc->masks.arp_tha, ETH_ADDR_LEN);
|
||||
break;
|
||||
|
||||
case MFF_TCP_SRC:
|
||||
case MFF_UDP_SRC:
|
||||
mask->be16 = wc->masks.tp_src;
|
||||
break;
|
||||
case MFF_TCP_DST:
|
||||
case MFF_UDP_DST:
|
||||
mask->be16 = wc->masks.tp_dst;
|
||||
break;
|
||||
|
||||
case MFF_ICMPV4_TYPE:
|
||||
case MFF_ICMPV6_TYPE:
|
||||
mask->u8 = ntohs(wc->masks.tp_src);
|
||||
break;
|
||||
case MFF_ICMPV4_CODE:
|
||||
case MFF_ICMPV6_CODE:
|
||||
mask->u8 = ntohs(wc->masks.tp_dst);
|
||||
break;
|
||||
|
||||
case MFF_N_IDS:
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
mf_get_value(mf, &wc->masks, mask);
|
||||
}
|
||||
|
||||
/* Tests whether 'mask' is a valid wildcard bit pattern for 'mf'. Returns true
|
||||
|
Reference in New Issue
Block a user