feature: reset interface feature arc on interface deletion
When removing an interface we must reset all per-interface per-feature
arc data to ensure we do not get wrong feature arc config data when the
sw_if_index is recycled.
Type: fix
Change-Id: I8c9d850d7c62b7b77193da4258ab5fb9bdda85a6
Signed-off-by: Benoît Ganne <bganne@cisco.com>
(cherry picked from commit 6178bdafa6
)
This commit is contained in:

committed by
Andrew Yourtchenko

parent
087d81dafa
commit
e36b854a72
@ -852,17 +852,8 @@ static clib_error_t *
|
|||||||
vnet_arp_add_del_sw_interface (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
|
vnet_arp_add_del_sw_interface (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
|
||||||
{
|
{
|
||||||
ethernet_arp_main_t *am = ðernet_arp_main;
|
ethernet_arp_main_t *am = ðernet_arp_main;
|
||||||
|
if (is_add)
|
||||||
if (!is_add && sw_if_index != ~0)
|
arp_disable (am, sw_if_index);
|
||||||
{
|
|
||||||
arp_disable (am, sw_if_index);
|
|
||||||
}
|
|
||||||
else if (is_add)
|
|
||||||
{
|
|
||||||
vnet_feature_enable_disable ("arp", "arp-disabled",
|
|
||||||
sw_if_index, 1, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +241,14 @@ vnet_get_config_heap (vnet_config_main_t * cm, u32 ci)
|
|||||||
return heap_elt_at_index (cm->config_string_heap, ci);
|
return heap_elt_at_index (cm->config_string_heap, ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
vnet_config_del (vnet_config_main_t * cm, u32 config_id)
|
||||||
|
{
|
||||||
|
u32 *p = vnet_get_config_heap (cm, config_id);
|
||||||
|
vnet_config_t *old = pool_elt_at_index (cm->config_pool, p[-1]);
|
||||||
|
remove_reference (cm, old);
|
||||||
|
}
|
||||||
|
|
||||||
u32
|
u32
|
||||||
vnet_config_modify_end_node (vlib_main_t * vm,
|
vnet_config_modify_end_node (vlib_main_t * vm,
|
||||||
vnet_config_main_t * cm,
|
vnet_config_main_t * cm,
|
||||||
|
@ -147,6 +147,8 @@ void vnet_config_init (vlib_main_t * vm,
|
|||||||
int n_start_node_names,
|
int n_start_node_names,
|
||||||
char *feature_node_names[], int n_feature_node_names);
|
char *feature_node_names[], int n_feature_node_names);
|
||||||
|
|
||||||
|
void vnet_config_del (vnet_config_main_t * cm, u32 config_id);
|
||||||
|
|
||||||
/* Calls to add/delete features from configurations. */
|
/* Calls to add/delete features from configurations. */
|
||||||
u32 vnet_config_add_feature (vlib_main_t * vm,
|
u32 vnet_config_add_feature (vlib_main_t * vm,
|
||||||
vnet_config_main_t * cm,
|
vnet_config_main_t * cm,
|
||||||
|
@ -37,7 +37,7 @@ vnet_feature_register (vnet_feature_update_cb_t cb, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vent_feature_reg_invoke (u32 sw_if_index, u8 arc_index, u8 is_enable)
|
vnet_feature_reg_invoke (u32 sw_if_index, u8 arc_index, u8 is_enable)
|
||||||
{
|
{
|
||||||
vnet_feature_upd_registration_t *reg;
|
vnet_feature_upd_registration_t *reg;
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ vnet_feature_enable_disable_with_index (u8 arc_index, u32 feature_index,
|
|||||||
fm->sw_if_index_has_features[arc_index] =
|
fm->sw_if_index_has_features[arc_index] =
|
||||||
clib_bitmap_set (fm->sw_if_index_has_features[arc_index], sw_if_index,
|
clib_bitmap_set (fm->sw_if_index_has_features[arc_index], sw_if_index,
|
||||||
(feature_count > 0));
|
(feature_count > 0));
|
||||||
vent_feature_reg_invoke (sw_if_index, arc_index, (feature_count > 0));
|
vnet_feature_reg_invoke (sw_if_index, arc_index, (feature_count > 0));
|
||||||
|
|
||||||
fm->feature_count_by_sw_if_index[arc_index][sw_if_index] = feature_count;
|
fm->feature_count_by_sw_if_index[arc_index][sw_if_index] = feature_count;
|
||||||
return 0;
|
return 0;
|
||||||
@ -515,9 +515,7 @@ vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index, int verbose)
|
|||||||
vlib_cli_output (vm, "\n%s:", areg->arc_name);
|
vlib_cli_output (vm, "\n%s:", areg->arc_name);
|
||||||
areg = areg->next;
|
areg = areg->next;
|
||||||
|
|
||||||
if (NULL == cm[feature_arc].config_index_by_sw_if_index ||
|
if (!vnet_have_features (feature_arc, sw_if_index))
|
||||||
vec_len (cm[feature_arc].config_index_by_sw_if_index) <=
|
|
||||||
sw_if_index)
|
|
||||||
{
|
{
|
||||||
vlib_cli_output (vm, " none configured");
|
vlib_cli_output (vm, " none configured");
|
||||||
continue;
|
continue;
|
||||||
@ -525,17 +523,8 @@ vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index, int verbose)
|
|||||||
|
|
||||||
current_config_index =
|
current_config_index =
|
||||||
vec_elt (cm[feature_arc].config_index_by_sw_if_index, sw_if_index);
|
vec_elt (cm[feature_arc].config_index_by_sw_if_index, sw_if_index);
|
||||||
|
cfg_index =
|
||||||
if (current_config_index == ~0)
|
vec_elt (vcm->config_pool_index_by_user_index, current_config_index);
|
||||||
{
|
|
||||||
vlib_cli_output (vm, " none configured");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT (current_config_index
|
|
||||||
< vec_len (vcm->config_pool_index_by_user_index));
|
|
||||||
|
|
||||||
cfg_index = vcm->config_pool_index_by_user_index[current_config_index];
|
|
||||||
cfg = pool_elt_at_index (vcm->config_pool, cfg_index);
|
cfg = pool_elt_at_index (vcm->config_pool, cfg_index);
|
||||||
|
|
||||||
for (i = 0; i < vec_len (cfg->features); i++)
|
for (i = 0; i < vec_len (cfg->features); i++)
|
||||||
@ -662,6 +651,52 @@ VLIB_CLI_COMMAND (set_interface_feature_command, static) = {
|
|||||||
};
|
};
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
|
|
||||||
|
static clib_error_t *
|
||||||
|
vnet_feature_add_del_sw_interface (vnet_main_t * vnm, u32 sw_if_index,
|
||||||
|
u32 is_add)
|
||||||
|
{
|
||||||
|
vnet_feature_main_t *fm = &feature_main;
|
||||||
|
const vnet_feature_arc_registration_t *far;
|
||||||
|
|
||||||
|
if (is_add)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* remove all enabled features from an interface on deletion
|
||||||
|
*/
|
||||||
|
for (far = fm->next_arc; far != 0; far = far->next)
|
||||||
|
{
|
||||||
|
const u8 arc_index = far->feature_arc_index;
|
||||||
|
vnet_feature_config_main_t *cm =
|
||||||
|
vec_elt_at_index (fm->feature_config_mains, arc_index);
|
||||||
|
const u32 ci =
|
||||||
|
vec_len (cm->config_index_by_sw_if_index) <=
|
||||||
|
sw_if_index ? ~0 : vec_elt (cm->config_index_by_sw_if_index,
|
||||||
|
sw_if_index);
|
||||||
|
|
||||||
|
if (~0 == ci)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fm->sw_if_index_has_features[arc_index] =
|
||||||
|
clib_bitmap_set (fm->sw_if_index_has_features[arc_index], sw_if_index,
|
||||||
|
0);
|
||||||
|
|
||||||
|
vnet_feature_reg_invoke (sw_if_index, arc_index, 0);
|
||||||
|
|
||||||
|
if (vec_len (fm->feature_count_by_sw_if_index[arc_index]) > sw_if_index)
|
||||||
|
vec_elt (fm->feature_count_by_sw_if_index[arc_index], sw_if_index) =
|
||||||
|
0;
|
||||||
|
|
||||||
|
vec_elt (cm->config_index_by_sw_if_index, sw_if_index) = ~0;
|
||||||
|
vnet_config_del (&cm->config_main, ci);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
VNET_SW_INTERFACE_ADD_DEL_FUNCTION_PRIO (vnet_feature_add_del_sw_interface,
|
||||||
|
VNET_ITF_FUNC_PRIORITY_HIGH);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fd.io coding-style-patch-verification: ON
|
* fd.io coding-style-patch-verification: ON
|
||||||
*
|
*
|
||||||
|
@ -179,6 +179,8 @@ static __clib_unused void * __clib_unused_##f = f;
|
|||||||
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_mtu_change)
|
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_mtu_change)
|
||||||
#define VNET_SW_INTERFACE_ADD_DEL_FUNCTION(f) \
|
#define VNET_SW_INTERFACE_ADD_DEL_FUNCTION(f) \
|
||||||
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_add_del)
|
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_add_del)
|
||||||
|
#define VNET_SW_INTERFACE_ADD_DEL_FUNCTION_PRIO(f,p) \
|
||||||
|
_VNET_INTERFACE_FUNCTION_DECL_PRIO(f,sw_interface_add_del,p)
|
||||||
#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(f) \
|
#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(f) \
|
||||||
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down)
|
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down)
|
||||||
#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(f,p) \
|
#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(f,p) \
|
||||||
|
Reference in New Issue
Block a user