aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/feature
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-11-26 11:04:45 -0500
committerDamjan Marion <dmarion@me.com>2018-11-26 19:52:42 +0000
commita25def7807fb46bd48462be3ec5c598fc79e2a13 (patch)
treeab66f41502fe6bac473274d99cf0af6ff51de919 /src/vnet/feature
parent37f44563637d2fa2fe454fd8c100958ec9b7a754 (diff)
Add a feature arc consistency check
Verify that last node in the computed feature order matches reality. This check doesn't make sense in all cases, so we skip it if the newly-added vnet_feature_arc_registration_t ".last_in_arc" datum is a NULL pointer. Change-Id: Ia99c3e2b2da2e4780a7d5bc71670c5742a66fef2 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vnet/feature')
-rw-r--r--src/vnet/feature/feature.c14
-rw-r--r--src/vnet/feature/feature.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/vnet/feature/feature.c b/src/vnet/feature/feature.c
index 2cdbcff88c8..f1afa3746f0 100644
--- a/src/vnet/feature/feature.c
+++ b/src/vnet/feature/feature.c
@@ -115,6 +115,7 @@ vnet_feature_init (vlib_main_t * vm)
clib_error_t *error;
vnet_feature_config_main_t *cm;
vnet_config_main_t *vcm;
+ char **features_in_order, *last_feature;
arc_index = areg->feature_arc_index;
cm = &fm->feature_config_mains[arc_index];
@@ -129,6 +130,19 @@ vnet_feature_init (vlib_main_t * vm)
os_exit (1);
}
+ features_in_order = fm->feature_nodes[arc_index];
+
+ /* If specificed, verify that the last node in the arc is actually last */
+ if (areg->last_in_arc && vec_len (features_in_order) > 0)
+ {
+ last_feature = features_in_order[vec_len (features_in_order) - 1];
+ if (strncmp (areg->last_in_arc, last_feature,
+ strlen (areg->last_in_arc)))
+ clib_warning
+ ("WARNING: %s arc: last node is %s, but expected %s!",
+ areg->arc_name, last_feature, areg->last_in_arc);
+ }
+
fm->next_feature_by_name[arc_index] =
hash_create_string (0, sizeof (uword));
freg = fm->next_feature_by_arc[arc_index];
diff --git a/src/vnet/feature/feature.h b/src/vnet/feature/feature.h
index 5c202dda274..2d1569b8cec 100644
--- a/src/vnet/feature/feature.h
+++ b/src/vnet/feature/feature.h
@@ -30,6 +30,8 @@ typedef struct _vnet_feature_arc_registration
/** Start nodes */
char **start_nodes;
int n_start_nodes;
+ /** End of the arc (optional, for consistency-checking) */
+ char *last_in_arc;
/* Feature arc index, assigned by init function */
u8 feature_arc_index;
u8 *arc_index_ptr;