aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/arp/arp.c13
-rw-r--r--src/vnet/config.c8
-rw-r--r--src/vnet/config.h2
-rw-r--r--src/vnet/feature/feature.c67
-rw-r--r--src/vnet/interface.h2
5 files changed, 65 insertions, 27 deletions
diff --git a/src/vnet/arp/arp.c b/src/vnet/arp/arp.c
index 8b57376522d..e02f3d8b52a 100644
--- a/src/vnet/arp/arp.c
+++ b/src/vnet/arp/arp.c
@@ -855,17 +855,8 @@ static clib_error_t *
vnet_arp_add_del_sw_interface (vnet_main_t * vnm, u32 sw_if_index, u32 is_add)
{
ethernet_arp_main_t *am = &ethernet_arp_main;
-
- if (!is_add && sw_if_index != ~0)
- {
- arp_disable (am, sw_if_index);
- }
- else if (is_add)
- {
- vnet_feature_enable_disable ("arp", "arp-disabled",
- sw_if_index, 1, NULL, 0);
- }
-
+ if (is_add)
+ arp_disable (am, sw_if_index);
return (NULL);
}
diff --git a/src/vnet/config.c b/src/vnet/config.c
index 4e9fa36dfc3..c9d4909cdeb 100644
--- a/src/vnet/config.c
+++ b/src/vnet/config.c
@@ -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);
}
+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
vnet_config_modify_end_node (vlib_main_t * vm,
vnet_config_main_t * cm,
diff --git a/src/vnet/config.h b/src/vnet/config.h
index 7eb3cf0ae1f..ccbbbf433e2 100644
--- a/src/vnet/config.h
+++ b/src/vnet/config.h
@@ -147,6 +147,8 @@ void vnet_config_init (vlib_main_t * vm,
int n_start_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. */
u32 vnet_config_add_feature (vlib_main_t * vm,
vnet_config_main_t * cm,
diff --git a/src/vnet/feature/feature.c b/src/vnet/feature/feature.c
index 1bdd695e1de..c93f586c349 100644
--- a/src/vnet/feature/feature.c
+++ b/src/vnet/feature/feature.c
@@ -37,7 +37,7 @@ vnet_feature_register (vnet_feature_update_cb_t cb, void *data)
}
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;
@@ -293,7 +293,7 @@ vnet_feature_enable_disable_with_index (u8 arc_index, u32 feature_index,
fm->sw_if_index_has_features[arc_index] =
clib_bitmap_set (fm->sw_if_index_has_features[arc_index], sw_if_index,
(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;
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);
areg = areg->next;
- if (NULL == cm[feature_arc].config_index_by_sw_if_index ||
- vec_len (cm[feature_arc].config_index_by_sw_if_index) <=
- sw_if_index)
+ if (!vnet_have_features (feature_arc, sw_if_index))
{
vlib_cli_output (vm, " none configured");
continue;
@@ -525,17 +523,8 @@ vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index, int verbose)
current_config_index =
vec_elt (cm[feature_arc].config_index_by_sw_if_index, sw_if_index);
-
- if (current_config_index == ~0)
- {
- 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_index =
+ vec_elt (vcm->config_pool_index_by_user_index, current_config_index);
cfg = pool_elt_at_index (vcm->config_pool, cfg_index);
for (i = 0; i < vec_len (cfg->features); i++)
@@ -662,6 +651,52 @@ VLIB_CLI_COMMAND (set_interface_feature_command, static) = {
};
/* *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
*
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index 5c04c5dc3bb..155e4fc1f0e 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -179,6 +179,8 @@ static __clib_unused void * __clib_unused_##f = f;
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_mtu_change)
#define VNET_SW_INTERFACE_ADD_DEL_FUNCTION(f) \
_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) \
_VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down)
#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(f,p) \