summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/fib/fib_api.c64
-rw-r--r--src/vnet/fib/fib_api.h12
-rw-r--r--src/vnet/ip/ip_api.c15
-rw-r--r--src/vnet/mpls/mpls_api.c14
4 files changed, 55 insertions, 50 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);
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 4d2f0704ca3..bcb53888621 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -667,13 +667,8 @@ ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
if (0 != rv)
goto out;
- if (0 == mp->route.n_paths)
- {
- rv = VNET_API_ERROR_NO_PATHS_IN_ROUTE;
- goto out;
- }
-
- vec_validate (rpaths, mp->route.n_paths - 1);
+ if (0 != mp->route.n_paths)
+ vec_validate (rpaths, mp->route.n_paths - 1);
for (ii = 0; ii < mp->route.n_paths; ii++)
{
@@ -690,9 +685,9 @@ ip_route_add_del_t_handler (vl_api_ip_route_add_del_t * mp, u32 * stats_index)
goto out;
}
- fib_api_route_add_del (mp->is_add,
- mp->is_multipath,
- fib_index, &pfx, entry_flags, rpaths);
+ rv = fib_api_route_add_del (mp->is_add,
+ mp->is_multipath,
+ fib_index, &pfx, entry_flags, rpaths);
if (mp->is_add && 0 == rv)
*stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);
diff --git a/src/vnet/mpls/mpls_api.c b/src/vnet/mpls/mpls_api.c
index cb20df5695b..530ceec31c4 100644
--- a/src/vnet/mpls/mpls_api.c
+++ b/src/vnet/mpls/mpls_api.c
@@ -192,13 +192,13 @@ mpls_route_add_del_t_handler (vnet_main_t * vnm,
goto out;
}
- fib_api_route_add_del (mp->mr_is_add,
- mp->mr_is_multipath,
- fib_index,
- &pfx,
- (mp->mr_route.mr_is_multicast ?
- FIB_ENTRY_FLAG_MULTICAST :
- FIB_ENTRY_FLAG_NONE), rpaths);
+ rv = fib_api_route_add_del (mp->mr_is_add,
+ mp->mr_is_multipath,
+ fib_index,
+ &pfx,
+ (mp->mr_route.mr_is_multicast ?
+ FIB_ENTRY_FLAG_MULTICAST :
+ FIB_ENTRY_FLAG_NONE), rpaths);
if (mp->mr_is_add && 0 == rv)
*stats_index = fib_table_entry_get_stats_index (fib_index, &pfx);