aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoryedg <yedg@wangsu.com>2020-05-14 10:51:53 +0800
committerNeale Ranns <nranns@cisco.com>2020-05-14 07:39:25 +0000
commitdbd366b239c0506b0d9984e7481967e038f10a23 (patch)
treee419a199da828fde705cd67ee742b2d0e05ebe32 /src
parentb163bbb7482a0a4b4685016eda4d2b2d3a9fcbb4 (diff)
ip: fix interface ip address del sw_if_index check
Type: fix Signed-off-by: Ye donggang <yedg@wangsu.com> Change-Id: Ia9f72ff2be455ecd4ff3d16e884c5a50f9df69fe
Diffstat (limited to 'src')
-rw-r--r--src/vnet/ip/ip4_forward.c5
-rw-r--r--src/vnet/ip/ip6_forward.c5
-rw-r--r--src/vnet/ip/ip_interface.c17
-rw-r--r--src/vnet/ip/ip_interface.h6
4 files changed, 27 insertions, 6 deletions
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index ea78d550789..4691e27c3e3 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -779,7 +779,10 @@ ip4_add_del_interface_address_internal (vlib_main_t * vm,
goto done;
}
- ip_interface_address_del (lm, if_address_index, addr_fib);
+ error = ip_interface_address_del (lm, vnm, if_address_index, addr_fib,
+ address_length, sw_if_index);
+ if (error)
+ goto done;
}
else
{
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index 1d6c1b7f105..207d968a650 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -428,7 +428,10 @@ ip6_add_del_interface_address (vlib_main_t * vm,
goto done;
}
- ip_interface_address_del (lm, if_address_index, addr_fib);
+ error = ip_interface_address_del (lm, vnm, if_address_index, addr_fib,
+ address_length, sw_if_index);
+ if (error)
+ goto done;
}
else
{
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
diff --git a/src/vnet/ip/ip_interface.h b/src/vnet/ip/ip_interface.h
index f95b8deb07b..b48eebdbc90 100644
--- a/src/vnet/ip/ip_interface.h
+++ b/src/vnet/ip/ip_interface.h
@@ -28,8 +28,10 @@ clib_error_t *ip_interface_address_add (ip_lookup_main_t * lm,
void *address,
u32 address_length,
u32 * result_index);
-void ip_interface_address_del (ip_lookup_main_t * lm,
- u32 addr_index, void *address);
+clib_error_t *ip_interface_address_del (ip_lookup_main_t * lm,
+ vnet_main_t * vnm,
+ u32 addr_index, void *address,
+ u32 address_length, u32 sw_if_index);
void *ip_interface_get_first_ip (u32 sw_if_index, u8 is_ip4);
void ip_interface_address_mark (void);
void ip_interface_address_sweep (void);