summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-05-09 19:28:58 +0200
committerFlorin Coras <fcoras@cisco.com>2016-05-09 21:24:48 +0200
commit686a5a5b2b22bd7fa31fae134739530a5683b228 (patch)
tree231399cb2740ff886a85e65202bfac01a1d72f9a /vnet
parent05866a16c093124e4083d68c7f21f6f1d019959b (diff)
ONE-3: Delete dst route when src fib is empty
Properly check that src fib is empty. Change-Id: I4072169027a404cad66eaaa8450f7c18f1fa8073 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r--vnet/vnet/lisp-gpe/ip_forward.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/vnet/vnet/lisp-gpe/ip_forward.c b/vnet/vnet/lisp-gpe/ip_forward.c
index 83c52e346d8..1294e0e2423 100644
--- a/vnet/vnet/lisp-gpe/ip_forward.c
+++ b/vnet/vnet/lisp-gpe/ip_forward.c
@@ -174,6 +174,26 @@ ip4_sd_fib_clear_src_fib (lisp_gpe_main_t * lgm, ip4_fib_t * fib)
}
}
+static u8
+ip4_fib_is_empty (ip4_fib_t * fib)
+{
+ u8 fib_is_empty;
+ int i;
+
+ fib_is_empty = 1;
+ for (i = ARRAY_LEN (fib->adj_index_by_dst_address) - 1; i >= 0; i--)
+ {
+ uword * hash = fib->adj_index_by_dst_address[i];
+ uword n_elts = hash_elts (hash);
+ if (n_elts)
+ {
+ fib_is_empty = 0;
+ break;
+ }
+ }
+ return fib_is_empty;
+}
+
static int
ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
ip_prefix_t * src_prefix, u32 table_id,
@@ -273,7 +293,7 @@ ip4_sd_fib_add_del_route (lisp_gpe_main_t * lgm, ip_prefix_t * dst_prefix,
return 0;
/* if there's nothing left */
- if (ARRAY_LEN(src_fib->adj_index_by_dst_address) == 0)
+ if (ip4_fib_is_empty(src_fib))
{
/* remove the src fib .. */
pool_put(lgm->ip4_src_fibs, src_fib);