aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/vxlan/vxlan.c
diff options
context:
space:
mode:
authorChris Luke <chrisy@flirble.org>2016-05-31 10:42:14 -0400
committerDave Wallace <dwallacelf@gmail.com>2016-06-01 19:55:56 +0000
commitc79491571fcdb3c77fc7c07c6ea247c14ba3e406 (patch)
tree01c8baea0bac5ceb00eb2ccca8c3ffdc2ace7d3f /vnet/vnet/vxlan/vxlan.c
parent9d6c0ab31158f78976a6ba614a5de09f05305a74 (diff)
VPP-98 Dedicated storage for VXLAN over IPv6 hash keys
When creating VXLAN over IPv6 the code was using storage for the hash key that could later be moved. Since the key is larger than the word size this was being referenced as a pointer; when the storage moves that breaks the hash. Instead allocate dedicated storage for the key. This patch also includes other minor cleanups, including using clib_memcpy in places it should be used and some whitespace fixes. Change-Id: I579f2cb515853ef56dedcca350fcad08aa6111a9 Signed-off-by: Chris Luke <chrisy@flirble.org>
Diffstat (limited to 'vnet/vnet/vxlan/vxlan.c')
-rw-r--r--vnet/vnet/vxlan/vxlan.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/vnet/vnet/vxlan/vxlan.c b/vnet/vnet/vxlan/vxlan.c
index 9e0d0a5e418..da893d5ddbb 100644
--- a/vnet/vnet/vxlan/vxlan.c
+++ b/vnet/vnet/vxlan/vxlan.c
@@ -218,7 +218,7 @@ int vnet_vxlan_add_del_tunnel
key6.src.as_u64[1] = a->dst.ip6.as_u64[1];
key6.vni = clib_host_to_net_u32 (a->vni << 8);
- p = hash_get (vxm->vxlan6_tunnel_by_key, pointer_to_uword(&key6));
+ p = hash_get_mem (vxm->vxlan6_tunnel_by_key, &key6);
}
if (a->is_add)
@@ -243,10 +243,16 @@ int vnet_vxlan_add_del_tunnel
else foreach_copy_ipv6
#undef _
- if (a->is_ip6) {
- /* copy the key */
- t->key6 = key6;
- }
+ /* copy the key */
+ if (a->is_ip6)
+ {
+ t->key6 = clib_mem_alloc (sizeof(vxlan6_tunnel_key_t));
+ clib_memcpy (t->key6, &key6, sizeof(key6));
+ }
+ else
+ {
+ t->key4 = 0; /* not yet used */
+ }
if (!a->is_ip6) t->flags |= VXLAN_TUNNEL_IS_IPV4;
@@ -265,7 +271,7 @@ int vnet_vxlan_add_del_tunnel
if (!a->is_ip6)
hash_set (vxm->vxlan4_tunnel_by_key, key4.as_u64, t - vxm->tunnels);
else
- hash_set (vxm->vxlan6_tunnel_by_key, pointer_to_uword(&t->key6), t - vxm->tunnels);
+ hash_set_mem (vxm->vxlan6_tunnel_by_key, t->key6, t - vxm->tunnels);
if (vec_len (vxm->free_vxlan_tunnel_hw_if_indices) > 0)
{
@@ -340,14 +346,21 @@ int vnet_vxlan_add_del_tunnel
if (!a->is_ip6)
hash_unset (vxm->vxlan4_tunnel_by_key, key4.as_u64);
else
- hash_unset (vxm->vxlan6_tunnel_by_key, pointer_to_uword(&key6));
+ hash_unset_mem (vxm->vxlan6_tunnel_by_key, t->key6);
vec_free (t->rewrite);
- if (!a->is_ip6) {
- t->rewrite = vxlan4_dummy_rewrite;
- } else {
- t->rewrite = vxlan6_dummy_rewrite;
- }
+ if (!a->is_ip6)
+ {
+ t->rewrite = vxlan4_dummy_rewrite;
+ t->key4 = 0;
+ }
+ else
+ {
+ t->rewrite = vxlan6_dummy_rewrite;
+ clib_mem_free (t->key6);
+ t->key6 = 0;
+ }
+
pool_put (vxm->tunnels, t);
}