struct port_lookup_key is getting extra 4 bytes due to alignment on x86_64.
That is messing with hash calculation which uses sizeof operator to
calculate key length. Following patch fixes tunnel hashing by using correct
key length.
This bug was introduced by commit
f686a33af8cb41ee228e6a35410c9a488fba3eb1
"datapath: Streamline tunnel port lookup"
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #7622
static u32 port_hash(const struct port_lookup_key *key)
{
- return jhash2((u32*)key, (sizeof(*key) / sizeof(u32)), 0);
+ return jhash2((u32*)key, (PORT_KEY_LEN / sizeof(u32)), 0);
}
static inline struct hlist_head *find_bucket(u32 hash)
struct tnl_mutable_config *mutable;
mutable = rcu_dereference_rtnl(tnl_vport->mutable);
- if (!memcmp(&mutable->key, key, sizeof(*key))) {
+ if (!memcmp(&mutable->key, key, PORT_KEY_LEN)) {
*pmutable = mutable;
return tnl_vport;
}
u32 tunnel_type;
};
+#define PORT_KEY_LEN (offsetof(struct port_lookup_key, tunnel_type) + \
+ FIELD_SIZEOF(struct port_lookup_key, tunnel_type))
+
/**
* struct tnl_mutable_config - modifiable configuration for a tunnel.
* @key: Used as key for tunnel port. Configured via OVS_TUNNEL_ATTR_*