aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2017-03-18 02:57:38 -0700
committerNeale Ranns <nranns@cisco.com>2017-03-18 02:57:38 -0700
commit898273fbb588811824bb27ad0ef203d358a7121a (patch)
tree53889b7d614f3262848564dc97e35ba5a4d0f390
parent112ee88c496a5acb4ac21a2d9b8deef5514abd8f (diff)
Check change in unnumbered setting before updating IP enabled state
Change-Id: I6424a083ec889961ba4d0cd1df8348f20436be14 Signed-off-by: Neale Ranns <nranns@cisco.com>
-rw-r--r--src/vnet/interface_api.c10
-rw-r--r--src/vnet/interface_cli.c19
2 files changed, 23 insertions, 6 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 44798c8b33b..39c062714bf 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -433,6 +433,7 @@ static void vl_api_sw_interface_set_unnumbered_t_handler
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ntohl (mp->sw_if_index);
u32 unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
+ u32 was_unnum;
/*
* The API message field names are backwards from
@@ -454,6 +455,7 @@ static void vl_api_sw_interface_set_unnumbered_t_handler
vnet_sw_interface_t *si =
vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
+ was_unnum = (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED);
if (mp->is_add)
{
@@ -480,8 +482,12 @@ static void vl_api_sw_interface_set_unnumbered_t_handler
ip6_main.lookup_main.if_address_pool_index_by_sw_if_index
[unnumbered_sw_if_index] = ~0;
}
- ip4_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
- ip6_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
+
+ if (was_unnum != (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
+ {
+ ip4_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
+ ip6_sw_interface_enable_disable (unnumbered_sw_if_index, mp->is_add);
+ }
done:
REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index ec8530da299..c1566551669 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -844,6 +844,7 @@ set_unnumbered (vlib_main_t * vm,
vnet_sw_interface_t *si;
int is_set = 0;
int is_del = 0;
+ u32 was_unnum;
if (unformat (input, "%U use %U",
unformat_vnet_sw_interface, vnm, &unnumbered_sw_if_index,
@@ -858,12 +859,13 @@ set_unnumbered (vlib_main_t * vm,
format_unformat_error, input);
si = vnet_get_sw_interface (vnm, unnumbered_sw_if_index);
+ was_unnum = (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED);
+
if (is_del)
{
si->flags &= ~(VNET_SW_INTERFACE_FLAG_UNNUMBERED);
si->unnumbered_sw_if_index = (u32) ~ 0;
- ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
- ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 0);
+
ip4_main.lookup_main.if_address_pool_index_by_sw_if_index
[unnumbered_sw_if_index] = ~0;
ip6_main.lookup_main.if_address_pool_index_by_sw_if_index
@@ -873,8 +875,7 @@ set_unnumbered (vlib_main_t * vm,
{
si->flags |= VNET_SW_INTERFACE_FLAG_UNNUMBERED;
si->unnumbered_sw_if_index = inherit_from_sw_if_index;
- ip4_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
- ip6_sw_interface_enable_disable (unnumbered_sw_if_index, 1);
+
ip4_main.lookup_main.if_address_pool_index_by_sw_if_index
[unnumbered_sw_if_index] =
ip4_main.lookup_main.if_address_pool_index_by_sw_if_index
@@ -884,6 +885,16 @@ set_unnumbered (vlib_main_t * vm,
ip6_main.lookup_main.if_address_pool_index_by_sw_if_index
[inherit_from_sw_if_index];
}
+ else
+ {
+ return (0);
+ }
+
+ if (was_unnum != (si->flags & VNET_SW_INTERFACE_FLAG_UNNUMBERED))
+ {
+ ip4_sw_interface_enable_disable (unnumbered_sw_if_index, !is_del);
+ ip6_sw_interface_enable_disable (unnumbered_sw_if_index, !is_del);
+ }
return 0;
}