summaryrefslogtreecommitdiffstats
path: root/src/vnet/fib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/fib')
-rw-r--r--src/vnet/fib/fib_api.c64
-rw-r--r--src/vnet/fib/fib_api.h12
2 files changed, 43 insertions, 33 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*
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h
index ffff2289b37..27335211df7 100644
--- a/src/vnet/fib/fib_api.h
+++ b/src/vnet/fib/fib_api.h
@@ -40,12 +40,12 @@ extern int fib_api_table_id_decode(fib_protocol_t fproto,
/**
* Adding routes from the API
*/
-extern void fib_api_route_add_del (u8 is_add,
- u8 is_multipath,
- u32 fib_index,
- const fib_prefix_t * prefix,
- fib_entry_flag_t entry_flags,
- fib_route_path_t *rpaths);
+extern int fib_api_route_add_del (u8 is_add,
+ u8 is_multipath,
+ u32 fib_index,
+ const fib_prefix_t * prefix,
+ fib_entry_flag_t entry_flags,
+ fib_route_path_t *rpaths);
extern u8* format_vl_api_fib_path(u8 * s, va_list * args);