diff options
author | Neale Ranns <nranns@cisco.com> | 2019-07-02 14:33:29 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2019-07-03 11:27:44 +0000 |
commit | c2ac2357fb0ff598ca1cb650a5766a552e017833 (patch) | |
tree | f487a2b96ed9c9d8586c95df2b5472159832d630 /src/vnet/fib/fib_api.c | |
parent | eaacce4753c33342a6512039fe4153b15b476fb3 (diff) |
fib: allow route delete with no paths and multipath=0 to remove the
whole route
Type: fix
Fixes: 097fa66b
Change-Id: I017ab5797670eb278c27c6e306cd8cadaacddf9d
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/fib/fib_api.c')
-rw-r--r-- | src/vnet/fib/fib_api.c | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c index 5aa5c4ec875..e776235bc00 100644 --- a/src/vnet/fib/fib_api.c +++ b/src/vnet/fib/fib_api.c @@ -449,7 +449,7 @@ fib_api_path_encode (const fib_route_path_t * rpath, } } -void +int fib_api_route_add_del (u8 is_add, u8 is_multipath, u32 fib_index, @@ -457,36 +457,46 @@ fib_api_route_add_del (u8 is_add, fib_entry_flag_t entry_flags, fib_route_path_t *rpaths) { - if (is_multipath) + if (is_multipath) { - /* Iterative path add/remove */ - if (is_add) - fib_table_entry_path_add2 (fib_index, - prefix, - FIB_SOURCE_API, - entry_flags, - rpaths); - else - fib_table_entry_path_remove2 (fib_index, - prefix, - FIB_SOURCE_API, - rpaths); + if (vec_len(rpaths) == 0) + return (VNET_API_ERROR_NO_PATHS_IN_ROUTE); + + /* Iterative path add/remove */ + if (is_add) + fib_table_entry_path_add2 (fib_index, + prefix, + FIB_SOURCE_API, + entry_flags, + rpaths); + else + fib_table_entry_path_remove2 (fib_index, + prefix, + FIB_SOURCE_API, + rpaths); } - else + else { - if (is_add) - /* path replacement */ - fib_table_entry_update (fib_index, - prefix, - FIB_SOURCE_API, - entry_flags, - rpaths); - else - /* entry delete */ - fib_table_entry_delete (fib_index, - prefix, - FIB_SOURCE_API); + if (is_add) + { + if (vec_len(rpaths) == 0) + return (VNET_API_ERROR_NO_PATHS_IN_ROUTE); + + /* path replacement */ + fib_table_entry_update (fib_index, + prefix, + FIB_SOURCE_API, + entry_flags, + rpaths); + } + else + /* entry delete */ + fib_table_entry_delete (fib_index, + prefix, + FIB_SOURCE_API); } + + return (0); } u8* |