summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-11-29 17:14:06 -0800
committerFlorin Coras <fcoras@cisco.com>2016-11-29 17:25:44 -0800
commit847944046c50cabd0d457d446d2c199a71abf049 (patch)
tree33bdddd0056a909413badd69e2c9e3e9a33324f1
parente2e95ce6550a28a6ba5870c9c550acb619883f1a (diff)
Improve test for unlocking LISP src FIB
Check that either src FIB is empty or only default is present. In some situations we may overwrite/delete default. Change-Id: I4a90804cc30ea8e3aa24e36a07f8096b8d3e46bc Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c b/vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
index cae2eb91363..1f2b2863695 100644
--- a/vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
+++ b/vnet/vnet/lisp-gpe/lisp_gpe_fwd_entry.c
@@ -141,6 +141,8 @@ ip_src_dst_fib_del_route (u32 src_fib_index,
u32 dst_fib_index, const ip_prefix_t * dst_prefix)
{
fib_prefix_t dst_fib_prefix, src_fib_prefix;
+ u8 have_default = 0;
+ u32 n_entries;
ASSERT (NULL != dst_prefix);
ASSERT (NULL != src_prefix);
@@ -150,19 +152,26 @@ ip_src_dst_fib_del_route (u32 src_fib_index,
fib_table_entry_delete (src_fib_index, &src_fib_prefix, FIB_SOURCE_LISP);
- /* check if only default left */
- if (1 == fib_table_get_num_entries (src_fib_index,
- src_fib_prefix.fp_proto,
- FIB_SOURCE_LISP))
+ /* check if only default left or empty */
+ fib_prefix_t default_pref = {
+ .fp_proto = dst_fib_prefix.fp_proto
+ };
+
+ if (fib_table_lookup_exact_match (src_fib_index,
+ &default_pref) != FIB_NODE_INDEX_INVALID)
+ have_default = 1;
+
+ n_entries = fib_table_get_num_entries (src_fib_index,
+ src_fib_prefix.fp_proto,
+ FIB_SOURCE_LISP);
+ if (n_entries == 0 || (have_default && n_entries == 1))
{
/*
* remove src FIB default route
*/
- fib_prefix_t prefix = {
- .fp_proto = dst_fib_prefix.fp_proto,
- };
- fib_table_entry_special_remove (src_fib_index, &prefix,
- FIB_SOURCE_LISP);
+ if (have_default)
+ fib_table_entry_special_remove (src_fib_index, &default_pref,
+ FIB_SOURCE_LISP);
/*
* there's nothing left now, unlock the source FIB and the