Skip to content

Commit

Permalink
tnl-neigh-cache: Unwildcard flow members before inspecting them.
Browse files Browse the repository at this point in the history
tnl_neigh_snoop() is part of the translation.  During translation we
have to unwildcard all the fields we examine to make a decision.

tnl_arp_snoop() and tnl_nd_snoop() failed to unwildcard fileds in case
of failure.  The solution is to do unwildcarding before the field is
inspected.

Signed-off-by: Daniele Di Proietto <diproiettod@vmware.com>
Acked-by: Jarno Rajahalme <jarno@ovn.org>
  • Loading branch information
ddiproietto committed Sep 22, 2016
1 parent 337b9ea commit db79d7a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 7 additions & 0 deletions lib/flow.h
Expand Up @@ -998,6 +998,13 @@ pkt_metadata_from_flow(struct pkt_metadata *md, const struct flow *flow)
md->ct_label = flow->ct_label;
}

/* Often, during translation we need to read a value from a flow('FLOW') and
* unwildcard the corresponding bits in the wildcards('WC'). This macro makes
* it easier to do that. */

#define FLOW_WC_GET_AND_MASK_WC(FLOW, WC, FIELD) \
(((WC) ? WC_MASK_FIELD(WC, FIELD) : NULL), ((FLOW)->FIELD))

static inline bool is_ip_any(const struct flow *flow)
{
return dl_type_is_ip_any(flow->dl_type);
Expand Down
13 changes: 7 additions & 6 deletions lib/tnl-neigh-cache.c
Expand Up @@ -111,7 +111,7 @@ tnl_neigh_delete(struct tnl_neigh_entry *neigh)

static void
tnl_neigh_set__(const char name[IFNAMSIZ], const struct in6_addr *dst,
const struct eth_addr mac)
const struct eth_addr mac)
{
ovs_mutex_lock(&mutex);
struct tnl_neigh_entry *neigh = tnl_neigh_lookup__(name, dst);
Expand Down Expand Up @@ -162,12 +162,13 @@ tnl_arp_snoop(const struct flow *flow, struct flow_wildcards *wc,

static int
tnl_nd_snoop(const struct flow *flow, struct flow_wildcards *wc,
const char name[IFNAMSIZ])
const char name[IFNAMSIZ])
{
if (flow->dl_type != htons(ETH_TYPE_IPV6) ||
flow->nw_proto != IPPROTO_ICMPV6 ||
flow->tp_dst != htons(0) ||
flow->tp_src != htons(ND_NEIGHBOR_ADVERT)) {
if (flow->dl_type != htons(ETH_TYPE_IPV6)
|| FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_proto) != IPPROTO_ICMPV6
|| FLOW_WC_GET_AND_MASK_WC(flow, wc, tp_dst) != htons(0)
|| FLOW_WC_GET_AND_MASK_WC(flow, wc, tp_src)
!= htons(ND_NEIGHBOR_ADVERT)) {
return EINVAL;
}

Expand Down

0 comments on commit db79d7a

Please sign in to comment.