Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
VPP-1294: add missing feature arc constraint
[vpp.git]
/
src
/
vnet
/
feature
/
feature.c
diff --git
a/src/vnet/feature/feature.c
b/src/vnet/feature/feature.c
index
f0e9004
..
e1cea21
100644
(file)
--- a/
src/vnet/feature/feature.c
+++ b/
src/vnet/feature/feature.c
@@
-65,14
+65,17
@@
vnet_feature_init (vlib_main_t * vm)
vnet_feature_registration_t *next;
uword *p = hash_get_mem (fm->arc_index_by_name, freg->arc_name);
if (p == 0)
vnet_feature_registration_t *next;
uword *p = hash_get_mem (fm->arc_index_by_name, freg->arc_name);
if (p == 0)
- return clib_error_return (0, "Unknown feature arc '%s'",
- freg->arc_name);
+ {
+ /* Don't start vpp with broken features arcs */
+ clib_warning ("Unknown feature arc '%s'", freg->arc_name);
+ os_exit (1);
+ }
areg = uword_to_pointer (p[0], vnet_feature_arc_registration_t *);
arc_index = areg->feature_arc_index;
next = freg->next;
areg = uword_to_pointer (p[0], vnet_feature_arc_registration_t *);
arc_index = areg->feature_arc_index;
next = freg->next;
- freg->next = fm->next_feature_by_arc[arc_index];
+ freg->next
_in_arc
= fm->next_feature_by_arc[arc_index];
fm->next_feature_by_arc[arc_index] = freg;
/* next */
fm->next_feature_by_arc[arc_index] = freg;
/* next */
@@
-95,7
+98,8
@@
vnet_feature_init (vlib_main_t * vm)
fm->next_feature_by_arc[arc_index],
&fm->feature_nodes[arc_index])))
{
fm->next_feature_by_arc[arc_index],
&fm->feature_nodes[arc_index])))
{
- return error;
+ clib_error_report (error);
+ os_exit (1);
}
fm->next_feature_by_name[arc_index] =
}
fm->next_feature_by_name[arc_index] =
@@
-106,7
+110,7
@@
vnet_feature_init (vlib_main_t * vm)
{
hash_set_mem (fm->next_feature_by_name[arc_index],
freg->node_name, pointer_to_uword (freg));
{
hash_set_mem (fm->next_feature_by_name[arc_index],
freg->node_name, pointer_to_uword (freg));
- freg = freg->next;
+ freg = freg->next
_in_arc
;
}
/* next */
}
/* next */
@@
-205,6
+209,10
@@
vnet_feature_enable_disable_with_index (u8 arc_index, u32 feature_index,
: vnet_config_del_feature)
(vlib_get_main (), &cm->config_main, ci, feature_index, feature_config,
n_feature_config_bytes);
: vnet_config_del_feature)
(vlib_get_main (), &cm->config_main, ci, feature_index, feature_config,
n_feature_config_bytes);
+ if (ci == ~0)
+ {
+ return 0;
+ }
cm->config_index_by_sw_if_index[sw_if_index] = ci;
/* update feature count */
cm->config_index_by_sw_if_index[sw_if_index] = ci;
/* update feature count */
@@
-242,6
+250,14
@@
vnet_feature_enable_disable (const char *arc_name, const char *node_name,
n_feature_config_bytes);
}
n_feature_config_bytes);
}
+static int
+feature_cmp (void *a1, void *a2)
+{
+ vnet_feature_registration_t *reg1 = a1;
+ vnet_feature_registration_t *reg2 = a2;
+
+ return (int) reg1->feature_index - reg2->feature_index;
+}
/** Display the set of available driver features.
Useful for verifying that expected features are present
/** Display the set of available driver features.
Useful for verifying that expected features are present
@@
-254,24
+270,45
@@
show_features_command_fn (vlib_main_t * vm,
vnet_feature_main_t *fm = &feature_main;
vnet_feature_arc_registration_t *areg;
vnet_feature_registration_t *freg;
vnet_feature_main_t *fm = &feature_main;
vnet_feature_arc_registration_t *areg;
vnet_feature_registration_t *freg;
+ vnet_feature_registration_t *feature_regs = 0;
+ int verbose = 0;
+
+ if (unformat (input, "verbose"))
+ verbose = 1;
vlib_cli_output (vm, "Available feature paths");
areg = fm->next_arc;
while (areg)
{
vlib_cli_output (vm, "Available feature paths");
areg = fm->next_arc;
while (areg)
{
- vlib_cli_output (vm, "%s:", areg->arc_name);
+ if (verbose)
+ vlib_cli_output (vm, "[%2d] %s:", areg->feature_arc_index,
+ areg->arc_name);
+ else
+ vlib_cli_output (vm, "%s:", areg->arc_name);
+
freg = fm->next_feature_by_arc[areg->feature_arc_index];
while (freg)
{
freg = fm->next_feature_by_arc[areg->feature_arc_index];
while (freg)
{
- v
lib_cli_output (vm, " %s\n", freg->node_name
);
- freg = freg->next;
+ v
ec_add1 (feature_regs, freg[0]
);
+ freg = freg->next
_in_arc
;
}
}
+ vec_sort_with_function (feature_regs, feature_cmp);
+ vec_foreach (freg, feature_regs)
+ {
+ if (verbose)
+ vlib_cli_output (vm, " [%2d]: %s\n", freg->feature_index,
+ freg->node_name);
+ else
+ vlib_cli_output (vm, " %s\n", freg->node_name);
+ }
+ vec_reset_length (feature_regs);
/* next */
areg = areg->next;
}
/* next */
areg = areg->next;
}
+ vec_free (feature_regs);
return 0;
}
return 0;
}
@@
-281,7
+318,7
@@
show_features_command_fn (vlib_main_t * vm,
*
* @cliexpar
* Example:
*
* @cliexpar
* Example:
- * @cliexcmd{show
ip features
}
+ * @cliexcmd{show
features [verbose]
}
* @cliexend
* @endparblock
?*/
* @cliexend
* @endparblock
?*/
@@
-298,7
+335,7
@@
VLIB_CLI_COMMAND (show_features_command, static) = {
*/
void
*/
void
-vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index)
+vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index
, int verbose
)
{
vnet_feature_main_t *fm = &feature_main;
u32 node_index, current_config_index;
{
vnet_feature_main_t *fm = &feature_main;
u32 node_index, current_config_index;
@@
-312,7
+349,7
@@
vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index)
vlib_node_t *n;
int i;
vlib_node_t *n;
int i;
- vlib_cli_output (vm, "
Driver f
eature paths configured on %U...",
+ vlib_cli_output (vm, "
F
eature paths configured on %U...",
format_vnet_sw_if_index_name,
vnet_get_main (), sw_if_index);
format_vnet_sw_if_index_name,
vnet_get_main (), sw_if_index);
@@
-353,7
+390,10
@@
vnet_interface_features_show (vlib_main_t * vm, u32 sw_if_index)
feat = cfg->features + i;
node_index = feat->node_index;
n = vlib_get_node (vm, node_index);
feat = cfg->features + i;
node_index = feat->node_index;
n = vlib_get_node (vm, node_index);
- vlib_cli_output (vm, " %v", n->name);
+ if (verbose)
+ vlib_cli_output (vm, " [%2d] %v", feat->feature_index, n->name);
+ else
+ vlib_cli_output (vm, " %v", n->name);
}
}
}
}
}
}
@@
-388,6
+428,8
@@
set_interface_features_command_fn (vlib_main_t * vm,
enable = 0;
else
{
enable = 0;
else
{
+ if (feature_name && arc_name)
+ break;
error = unformat_parse_error (line_input);
goto done;
}
error = unformat_parse_error (line_input);
goto done;
}
@@
-437,7
+479,8
@@
done:
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_feature_command, static) = {
.path = "set interface feature",
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (set_interface_feature_command, static) = {
.path = "set interface feature",
- .short_help = "set interface feature <intfc> <feature_name> arc <arc_name>",
+ .short_help = "set interface feature <intfc> <feature_name> arc <arc_name> "
+ "[disable]",
.function = set_interface_features_command_fn,
};
/* *INDENT-ON* */
.function = set_interface_features_command_fn,
};
/* *INDENT-ON* */