From: Andy Zhou Date: Thu, 1 Aug 2013 17:49:46 +0000 (-0700) Subject: datapath: Accept any 802.2 eth_type mask but override to be exact match X-Git-Tag: sliver-openvswitch-2.0.90-1~33^2~52 X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=commitdiff_plain;h=33fd9f59afeda7955a8d63e57ac81cc2a0760531 datapath: Accept any 802.2 eth_type mask but override to be exact match When key.eth_type is absent it is interpreted to be 802.2, which is represented by a special value. In order to prevent inadvertant matches on this opaque value, the mask is forced to be either fully wildcarded or fully exact. Signed-off-by: Andy Zhou Signed-off-by: Jesse Gross --- diff --git a/datapath/flow.c b/datapath/flow.c index 4d18aad3d..0a6e040ad 100644 --- a/datapath/flow.c +++ b/datapath/flow.c @@ -137,11 +137,8 @@ static bool ovs_match_validate(const struct sw_flow_match *match, /* Always allowed mask fields. */ mask_allowed |= ((1ULL << OVS_KEY_ATTR_TUNNEL) - | (1ULL << OVS_KEY_ATTR_IN_PORT)); - - if (match->key->eth.type == htons(ETH_P_802_2) && - match->mask && (match->mask->key.eth.type == htons(0xffff))) - mask_allowed |= (1ULL << OVS_KEY_ATTR_ETHERTYPE); + | (1ULL << OVS_KEY_ATTR_IN_PORT) + | (11ULL << OVS_KEY_ATTR_ETHERTYPE)); /* Check key attributes. */ if (match->key->eth.type == htons(ETH_P_ARP) @@ -1386,7 +1383,10 @@ static int ovs_key_from_nlattrs(struct sw_flow_match *match, u64 attrs, __be16 eth_type; eth_type = nla_get_be16(a[OVS_KEY_ATTR_ETHERTYPE]); - if (!is_mask && ntohs(eth_type) < ETH_P_802_3_MIN) { + if (is_mask) { + /* Always exact match EtherType. */ + eth_type = htons(0xffff); + } else if (ntohs(eth_type) < ETH_P_802_3_MIN) { OVS_NLERR("EtherType is less than mimimum (type=%x, min=%x).\n", ntohs(eth_type), ETH_P_802_3_MIN); return -EINVAL;