aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_interface.c
diff options
context:
space:
mode:
authoryedg <yedg@wangsu.com>2020-05-14 10:51:53 +0800
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-05-20 16:34:42 +0000
commitd3088e94ec7b8745686af0ca838fd1048b0837a8 (patch)
tree4a5c4e92069539d3246a93f79d29027c01b2f334 /src/vnet/ip/ip_interface.c
parentd6572034438a984a9d8cb2f74124d526041b93f3 (diff)
ip: fix interface ip address del sw_if_index check
Type: fix Signed-off-by: Ye donggang <yedg@wangsu.com> Change-Id: Ia9f72ff2be455ecd4ff3d16e884c5a50f9df69fe (cherry picked from commit dbd366b239c0506b0d9984e7481967e038f10a23)
Diffstat (limited to 'src/vnet/ip/ip_interface.c')
-rw-r--r--src/vnet/ip/ip_interface.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/vnet/ip/ip_interface.c b/src/vnet/ip/ip_interface.c
index 23c3df81638..48c20a6cf34 100644
--- a/src/vnet/ip/ip_interface.c
+++ b/src/vnet/ip/ip_interface.c
@@ -90,14 +90,26 @@ ip_interface_address_add (ip_lookup_main_t * lm,
return (NULL);
}
-void
+clib_error_t *
ip_interface_address_del (ip_lookup_main_t * lm,
- u32 address_index, void *addr_fib)
+ vnet_main_t * vnm,
+ u32 address_index, void *addr_fib,
+ u32 address_length, u32 sw_if_index)
{
ip_interface_address_t *a, *prev, *next;
a = pool_elt_at_index (lm->if_address_pool, address_index);
+ if (a->sw_if_index != sw_if_index)
+ {
+ vnm->api_errno = VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
+ return clib_error_create ("%U not found for interface %U",
+ lm->format_address_and_length,
+ addr_fib, address_length,
+ format_vnet_sw_if_index_name,
+ vnet_get_main (), sw_if_index);
+ }
+
if (a->prev_this_sw_interface != ~0)
{
prev = pool_elt_at_index (lm->if_address_pool,
@@ -121,6 +133,7 @@ ip_interface_address_del (ip_lookup_main_t * lm,
mhash_unset (&lm->address_to_if_address_index, addr_fib,
/* old_value */ 0);
pool_put (lm->if_address_pool, a);
+ return NULL;
}
u8