summaryrefslogtreecommitdiffstats
path: root/src/vnet/feature/feature.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-11-19 09:31:48 -0500
committerFlorin Coras <florin.coras@gmail.com>2018-11-19 22:58:46 +0000
commit2dd192b76774beb9c7960527fb3f397a2848f679 (patch)
treec6a424f4734cceb7cd9f51705d065871d3224568 /src/vnet/feature/feature.c
parent6c01dceea5c612373453db7f1ccda589a2cd782e (diff)
Improve feature arc order constraint specification
Add the VNET_FEATURE_ARC_ORDER macro, which allows specification of bulk order constraints. Here's an example: VNET_FEATURE_ARC_ORDER(ip4_unicast_arc_order, static) = { .arc_name = "ip4-unicast", .node_names = VNET_FEATURES ("ip4-flow-classify", "ip4-inacl", "ip4-source-check-via-rx", "ip4-source-check-via-any", "ip4-source-and-port-range-check-rx", "ip4-policer-classify", "ipsec4-input", "vpath-input-ip4", "ip4-vxlan-bypass", "ip4-not-enabled", "ip4-lookup"), }; Simply list feature nodes in the desired order, and you're done. Multiple macro instances per are are fine / expected / tested. Under the covers: generate "a before b" tuples by chain-dragging across the ordered list. No need to touch existing per-feature constraints. Fixed a long-broken "you lose!" error message. Change-Id: I259282e426fd305e22c8d65886787c41a1d348d3 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/feature/feature.c')
-rw-r--r--src/vnet/feature/feature.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/vnet/feature/feature.c b/src/vnet/feature/feature.c
index 6525bcbdce5..2cdbcff88c8 100644
--- a/src/vnet/feature/feature.c
+++ b/src/vnet/feature/feature.c
@@ -24,6 +24,7 @@ vnet_feature_init (vlib_main_t * vm)
vnet_feature_main_t *fm = &feature_main;
vnet_feature_registration_t *freg;
vnet_feature_arc_registration_t *areg;
+ vnet_feature_constraint_registration_t *creg;
u32 arc_index = 0;
fm->arc_index_by_name = hash_create_string (0, sizeof (uword));
@@ -58,6 +59,7 @@ vnet_feature_init (vlib_main_t * vm)
vec_validate (fm->next_feature_by_name, arc_index - 1);
vec_validate (fm->sw_if_index_has_features, arc_index - 1);
vec_validate (fm->feature_count_by_sw_if_index, arc_index - 1);
+ vec_validate (fm->next_constraint_by_arc, arc_index - 1);
freg = fm->next_feature;
while (freg)
@@ -82,6 +84,31 @@ vnet_feature_init (vlib_main_t * vm)
freg = next;
}
+ /* Move bulk constraints to the constraint by arc lists */
+ creg = fm->next_constraint;
+ while (creg)
+ {
+ vnet_feature_constraint_registration_t *next;
+ uword *p = hash_get_mem (fm->arc_index_by_name, creg->arc_name);
+ if (p == 0)
+ {
+ /* Don't start vpp with broken features arcs */
+ clib_warning ("Unknown feature arc '%s'", creg->arc_name);
+ os_exit (1);
+ }
+
+ areg = uword_to_pointer (p[0], vnet_feature_arc_registration_t *);
+ arc_index = areg->feature_arc_index;
+
+ next = creg->next;
+ creg->next_in_arc = fm->next_constraint_by_arc[arc_index];
+ fm->next_constraint_by_arc[arc_index] = creg;
+
+ /* next */
+ creg = next;
+ }
+
+
areg = fm->next_arc;
while (areg)
{
@@ -92,11 +119,11 @@ vnet_feature_init (vlib_main_t * vm)
arc_index = areg->feature_arc_index;
cm = &fm->feature_config_mains[arc_index];
vcm = &cm->config_main;
- if ((error = vnet_feature_arc_init (vm, vcm,
- areg->start_nodes,
- areg->n_start_nodes,
- fm->next_feature_by_arc[arc_index],
- &fm->feature_nodes[arc_index])))
+ if ((error = vnet_feature_arc_init
+ (vm, vcm, areg->start_nodes, areg->n_start_nodes,
+ fm->next_feature_by_arc[arc_index],
+ fm->next_constraint_by_arc[arc_index],
+ &fm->feature_nodes[arc_index])))
{
clib_error_report (error);
os_exit (1);