From 6233111b0e36f23d3d269834127aae1b3f77cdf1 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Thu, 14 Mar 2019 08:06:48 -0700 Subject: GBP: update semantics for subnets Change-Id: I895c03b365619e6c66613242f4a97c79ce579879 Signed-off-by: Neale Ranns --- src/plugins/gbp/gbp_subnet.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/plugins/gbp') diff --git a/src/plugins/gbp/gbp_subnet.c b/src/plugins/gbp/gbp_subnet.c index 5e56c8200b9..a7bee55fa10 100644 --- a/src/plugins/gbp/gbp_subnet.c +++ b/src/plugins/gbp/gbp_subnet.c @@ -199,12 +199,29 @@ gbp_subnet_l3_out_add (gbp_subnet_t * gs, u32 sw_if_index, sclass_t sclass) return (0); } +static void +gbp_subnet_del_i (index_t gsi) +{ + gbp_subnet_t *gs; + + gs = pool_elt_at_index (gbp_subnet_pool, gsi); + + if (GBP_SUBNET_L3_OUT == gs->gs_type) + fib_table_entry_delete_index (gs->gs_fei, FIB_SOURCE_SPECIAL); + else + fib_table_entry_delete_index (gs->gs_fei, FIB_SOURCE_PLUGIN_HI); + + gbp_subnet_db_del (gs); + gbp_route_domain_unlock (gs->gs_rd); + + pool_put (gbp_subnet_pool, gs); +} + int gbp_subnet_del (u32 rd_id, const fib_prefix_t * pfx) { gbp_route_domain_t *grd; index_t gsi, grdi; - gbp_subnet_t *gs; u32 fib_index; grdi = gbp_route_domain_find (rd_id); @@ -220,17 +237,7 @@ gbp_subnet_del (u32 rd_id, const fib_prefix_t * pfx) if (INDEX_INVALID == gsi) return (VNET_API_ERROR_NO_SUCH_ENTRY); - gs = pool_elt_at_index (gbp_subnet_pool, gsi); - - if (GBP_SUBNET_L3_OUT == gs->gs_type) - fib_table_entry_delete (fib_index, pfx, FIB_SOURCE_SPECIAL); - else - fib_table_entry_delete (fib_index, pfx, FIB_SOURCE_PLUGIN_HI); - - gbp_subnet_db_del (gs); - gbp_route_domain_unlock (gs->gs_rd); - - pool_put (gbp_subnet_pool, gs); + gbp_subnet_del_i (gsi); return (0); } @@ -256,8 +263,11 @@ gbp_subnet_add (u32 rd_id, gsi = gbp_subnet_db_find (fib_index, pfx); + /* + * this is an update if the subnet already exists, so remove the old + */ if (INDEX_INVALID != gsi) - return (VNET_API_ERROR_ENTRY_ALREADY_EXISTS); + gbp_subnet_del_i (gsi); rv = -2; -- cgit 1.2.3-korg