aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/lisp-cp/gid_dictionary.c26
-rw-r--r--src/vnet/lisp-cp/gid_dictionary.h3
2 files changed, 24 insertions, 5 deletions
diff --git a/src/vnet/lisp-cp/gid_dictionary.c b/src/vnet/lisp-cp/gid_dictionary.c
index d238124ecd8..b01bb0e0684 100644
--- a/src/vnet/lisp-cp/gid_dictionary.c
+++ b/src/vnet/lisp-cp/gid_dictionary.c
@@ -464,11 +464,15 @@ add_del_ip4_key (gid_ip4_table_t * db, u32 vni, ip_prefix_t * pref, u32 val,
old_val = value.value;
if (!is_add)
- BV (clib_bihash_add_del) (&db->ip4_lookup_table, &kv, 0 /* is_add */ );
+ {
+ BV (clib_bihash_add_del) (&db->ip4_lookup_table, &kv, 0 /* is_add */ );
+ db->count--;
+ }
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->ip4_lookup_table, &kv, 1 /* is_add */ );
+ db->count++;
}
return old_val;
}
@@ -553,7 +557,6 @@ add_del_sd_ip4_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
{
if (GID_LOOKUP_MISS != sfi)
{
- add_del_ip4_key (&db->dst_ip4_table, vni, dst_pref, 0, is_add);
sfib = pool_elt_at_index (db->src_ip4_table_pool, sfi);
if (src_pref)
old_val = add_del_ip4_key (sfib, 0, src_pref, 0, is_add);
@@ -563,6 +566,9 @@ add_del_sd_ip4_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
memset (&sp, 0, sizeof (sp));
old_val = add_del_ip4_key (sfib, 0, &sp, 0, is_add);
}
+
+ if (sfib->count == 0)
+ add_del_ip4_key (&db->dst_ip4_table, vni, dst_pref, 0, is_add);
}
else
clib_warning ("cannot delete dst mapping %U!", format_ip_prefix,
@@ -630,11 +636,15 @@ add_del_ip6_key (gid_ip6_table_t * db, u32 vni, ip_prefix_t * pref, u32 val,
old_val = value.value;
if (!is_add)
- BV (clib_bihash_add_del) (&db->ip6_lookup_table, &kv, 0 /* is_add */ );
+ {
+ BV (clib_bihash_add_del) (&db->ip6_lookup_table, &kv, 0 /* is_add */ );
+ db->count--;
+ }
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->ip6_lookup_table, &kv, 1 /* is_add */ );
+ db->count++;
}
return old_val;
}
@@ -652,11 +662,15 @@ add_del_mac (gid_mac_table_t * db, u32 vni, u8 * dst_mac, u8 * src_mac,
old_val = value.value;
if (!is_add)
- BV (clib_bihash_add_del) (&db->mac_lookup_table, &kv, 0 /* is_add */ );
+ {
+ BV (clib_bihash_add_del) (&db->mac_lookup_table, &kv, 0 /* is_add */ );
+ db->count--;
+ }
else
{
kv.value = val;
BV (clib_bihash_add_del) (&db->mac_lookup_table, &kv, 1 /* is_add */ );
+ db->count++;
}
return old_val;
}
@@ -748,7 +762,6 @@ add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
{
if (GID_LOOKUP_MISS != sfi)
{
- add_del_ip6_key (&db->dst_ip6_table, vni, dst_pref, 0, is_add);
sfib = pool_elt_at_index (db->src_ip6_table_pool, sfi);
if (src_pref)
old_val = add_del_ip6_key (sfib, 0, src_pref, 0, is_add);
@@ -759,6 +772,9 @@ add_del_sd_ip6_key (gid_dictionary_t * db, u32 vni, ip_prefix_t * dst_pref,
ip_prefix_version (&sp) = IP6;
old_val = add_del_ip6_key (sfib, 0, &sp, 0, is_add);
}
+
+ if (sfib->count == 0)
+ add_del_ip6_key (&db->dst_ip6_table, vni, dst_pref, 0, is_add);
}
else
clib_warning ("cannot delete dst mapping %U!", format_ip_prefix,
diff --git a/src/vnet/lisp-cp/gid_dictionary.h b/src/vnet/lisp-cp/gid_dictionary.h
index c5aaf8cb30d..825e9856e7a 100644
--- a/src/vnet/lisp-cp/gid_dictionary.h
+++ b/src/vnet/lisp-cp/gid_dictionary.h
@@ -50,6 +50,7 @@ typedef struct
/* ip4 lookup table config parameters */
u32 ip4_lookup_table_nbuckets;
uword ip4_lookup_table_size;
+ u32 count;
} gid_ip4_table_t;
typedef struct
@@ -65,6 +66,7 @@ typedef struct
/* ip6 lookup table config parameters */
u32 ip6_lookup_table_nbuckets;
uword ip6_lookup_table_size;
+ u64 count;
} gid_ip6_table_t;
typedef struct gid_mac_table
@@ -74,6 +76,7 @@ typedef struct gid_mac_table
/* mac lookup table config parameters */
u32 mac_lookup_table_nbuckets;
uword mac_lookup_table_size;
+ u64 count;
} gid_mac_table_t;
typedef struct