summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/vnet/devices/devices.c1
-rw-r--r--src/vnet/ethernet/init.c1
-rw-r--r--src/vnet/feature/feature.c14
-rw-r--r--src/vnet/feature/feature.h2
-rw-r--r--src/vnet/interface_output.c1
-rw-r--r--src/vnet/ip/ip4_forward.c4
-rw-r--r--src/vnet/ip/ip6_forward.c3
-rw-r--r--src/vnet/mpls/mpls_features.c2
8 files changed, 28 insertions, 0 deletions
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index 99011dabc7a..e78c5cbe45b 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -66,6 +66,7 @@ VNET_FEATURE_ARC_INIT (device_input, static) =
{
.arc_name = "device-input",
.start_nodes = VNET_FEATURES ("device-input"),
+ .last_in_arc = "ethernet-input",
.arc_index_ptr = &feature_main.device_input_feature_arc_index,
};
diff --git a/src/vnet/ethernet/init.c b/src/vnet/ethernet/init.c
index a4689593ad7..5d10c60fd5f 100644
--- a/src/vnet/ethernet/init.c
+++ b/src/vnet/ethernet/init.c
@@ -66,6 +66,7 @@ add_type (ethernet_main_t * em, ethernet_type_t type, char *type_name)
VNET_FEATURE_ARC_INIT (ethernet_output, static) =
{
.arc_name = "ethernet-output",
+ .last_in_arc = "error-drop",
.start_nodes = VNET_FEATURES ("adj-l2-midchain"),
.arc_index_ptr = &ethernet_main.output_feature_arc_index,
};
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;
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index b09f7996e18..34f0a977131 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -1080,6 +1080,7 @@ VNET_FEATURE_ARC_INIT (interface_output, static) =
{
.arc_name = "interface-output",
.start_nodes = VNET_FEATURES (0),
+ .last_in_arc = "interface-tx",
.arc_index_ptr = &vnet_main.interface_main.output_feature_arc_index,
};
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index e011e5134d8..9963f6b1e26 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -711,6 +711,7 @@ VNET_FEATURE_ARC_INIT (ip4_unicast, static) =
{
.arc_name = "ip4-unicast",
.start_nodes = VNET_FEATURES ("ip4-input", "ip4-input-no-checksum"),
+ .last_in_arc = "ip4-lookup",
.arc_index_ptr = &ip4_main.lookup_main.ucast_feature_arc_index,
};
@@ -796,6 +797,7 @@ VNET_FEATURE_ARC_INIT (ip4_multicast, static) =
{
.arc_name = "ip4-multicast",
.start_nodes = VNET_FEATURES ("ip4-input", "ip4-input-no-checksum"),
+ .last_in_arc = "ip4-mfib-forward-lookup",
.arc_index_ptr = &ip4_main.lookup_main.mcast_feature_arc_index,
};
@@ -825,6 +827,7 @@ VNET_FEATURE_ARC_INIT (ip4_output, static) =
{
.arc_name = "ip4-output",
.start_nodes = VNET_FEATURES ("ip4-rewrite", "ip4-midchain", "ip4-dvr-dpo"),
+ .last_in_arc = "interface-output",
.arc_index_ptr = &ip4_main.lookup_main.output_feature_arc_index,
};
@@ -1212,6 +1215,7 @@ VNET_FEATURE_ARC_INIT (ip4_local) =
{
.arc_name = "ip4-local",
.start_nodes = VNET_FEATURES ("ip4-local"),
+ .last_in_arc = "ip4-local-end-of-arc",
};
/* *INDENT-ON* */
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index 5a176435510..3c0dcbf031c 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -371,6 +371,7 @@ VNET_FEATURE_ARC_INIT (ip6_unicast, static) =
{
.arc_name = "ip6-unicast",
.start_nodes = VNET_FEATURES ("ip6-input"),
+ .last_in_arc = "ip6-lookup",
.arc_index_ptr = &ip6_main.lookup_main.ucast_feature_arc_index,
};
@@ -442,6 +443,7 @@ VNET_FEATURE_ARC_INIT (ip6_multicast, static) =
{
.arc_name = "ip6-multicast",
.start_nodes = VNET_FEATURES ("ip6-input"),
+ .last_in_arc = "ip6-mfib-forward-lookup",
.arc_index_ptr = &ip6_main.lookup_main.mcast_feature_arc_index,
};
@@ -468,6 +470,7 @@ VNET_FEATURE_ARC_INIT (ip6_output, static) =
{
.arc_name = "ip6-output",
.start_nodes = VNET_FEATURES ("ip6-rewrite", "ip6-midchain", "ip6-dvr-dpo"),
+ .last_in_arc = "interface-output",
.arc_index_ptr = &ip6_main.lookup_main.output_feature_arc_index,
};
diff --git a/src/vnet/mpls/mpls_features.c b/src/vnet/mpls/mpls_features.c
index 0281d0c2f63..9ed56dff554 100644
--- a/src/vnet/mpls/mpls_features.c
+++ b/src/vnet/mpls/mpls_features.c
@@ -104,6 +104,7 @@ VNET_FEATURE_ARC_INIT (mpls_input, static) =
{
.arc_name = "mpls-input",
.start_nodes = VNET_FEATURES ("mpls-input"),
+ .last_in_arc = "mpls-lookup",
.arc_index_ptr = &mpls_main.input_feature_arc_index,
};
@@ -123,6 +124,7 @@ VNET_FEATURE_ARC_INIT (mpls_output, static) =
{
.arc_name = "mpls-output",
.start_nodes = VNET_FEATURES ("mpls-output", "mpls-midchain"),
+ .last_in_arc = "interface-output",
.arc_index_ptr = &mpls_main.output_feature_arc_index,
};