aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/ip/ip6_forward.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-06-14 18:38:02 -0400
committerKeith Burns <alagalah@gmail.com>2016-06-17 16:24:16 +0000
commitd65346098daf8967e882d0299679a131769c9be9 (patch)
tree50a9bb16a3f2c1ef8a9ef6b5e2623564a8453a5d /vnet/vnet/ip/ip6_forward.c
parent378893a485d0e0dd331cebcb2ebefdeca073b1ab (diff)
Dynamically compute ip feature subgraph order
This change-set enables plugins to add themselves to the ip4/ip6 feature subgraphs without having to modify core vpp engine code at all. Add VNET_IP4/IP6_UNICAST/MULTICAST_FEATURE_INIT macros which express the required ordering constraints, and off you go. Along the way, added an implementation of Warshall's algorithm to vppinfra; to compute the positive transitive closure of a relation. In this case, the relation is "feature A runs before feature B." With that in hand, ip_feature_init_cast(...) computes a partial order across the set of configured feature subgraph nodes. In unit-testing, we discovered VPP-145 - ip4/6 inacl wiped out vnet_buffer(b)->ip>current_config_index, which exists in main. So, we fixed that by moving b->trace_index, adding b->current_config_index, and removing the ip opaque union current_config_index. Change-Id: Iff132116f66413dc6b31ac3377198c7a32d51f48 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vnet/vnet/ip/ip6_forward.c')
-rw-r--r--vnet/vnet/ip/ip6_forward.c97
1 files changed, 79 insertions, 18 deletions
diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c
index e49d242e6f3..f77b99ef31b 100644
--- a/vnet/vnet/ip/ip6_forward.c
+++ b/vnet/vnet/ip/ip6_forward.c
@@ -1200,6 +1200,75 @@ ip6_sw_interface_admin_up_down (vnet_main_t * vnm,
VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (ip6_sw_interface_admin_up_down);
+/* Built-in ip6 unicast rx feature path definition */
+VNET_IP6_UNICAST_FEATURE_INIT (ip6_inacl, static) = {
+ .node_name = "ip6-inacl",
+ .runs_before = {"ipsec-input-ip6", 0},
+ .feature_index = &ip6_main.ip6_unicast_rx_feature_check_access,
+};
+
+VNET_IP6_UNICAST_FEATURE_INIT (ip6_ipsec, static) = {
+ .node_name = "ipsec-input-ip6",
+ .runs_before = {"l2tp-decap", 0},
+ .feature_index = &ip6_main.ip6_unicast_rx_feature_ipsec,
+};
+
+VNET_IP6_UNICAST_FEATURE_INIT (ip6_l2tp, static) = {
+ .node_name = "l2tp-decap",
+ .runs_before = {"vpath-input-ip6", 0},
+ .feature_index = &ip6_main.ip6_unicast_rx_feature_l2tp_decap,
+};
+
+VNET_IP6_UNICAST_FEATURE_INIT (ip6_vpath, static) = {
+ .node_name = "vpath-input-ip6",
+ .runs_before = {"ip6-lookup", 0},
+ .feature_index = &ip6_main.ip6_unicast_rx_feature_vpath,
+};
+
+VNET_IP6_UNICAST_FEATURE_INIT (ip6_lookup, static) = {
+ .node_name = "ip6-lookup",
+ .runs_before = {0}, /* not before any other features */
+ .feature_index = &ip6_main.ip6_unicast_rx_feature_lookup,
+};
+
+/* Built-in ip6 multicast rx feature path definition (none now) */
+VNET_IP6_MULTICAST_FEATURE_INIT (ip4_vpath_mc, static) = {
+ .node_name = "vpath-input-ip6",
+ .runs_before = {"ip6-lookup", 0},
+ .feature_index = &ip6_main.ip6_multicast_rx_feature_vpath,
+};
+
+VNET_IP6_MULTICAST_FEATURE_INIT (ip6_lookup, static) = {
+ .node_name = "ip6-lookup",
+ .runs_before = {0}, /* not before any other features */
+ .feature_index = &ip6_main.ip6_multicast_rx_feature_lookup,
+};
+
+static char * feature_start_nodes[] =
+ {"ip6-input"};
+
+static clib_error_t *
+ip6_feature_init (vlib_main_t * vm, ip6_main_t * im)
+{
+ ip_lookup_main_t * lm = &im->lookup_main;
+ clib_error_t * error;
+ vnet_cast_t cast;
+
+ for (cast = 0; cast < VNET_N_CAST; cast++)
+ {
+ ip_config_main_t * cm = &lm->rx_config_mains[cast];
+ vnet_config_main_t * vcm = &cm->config_main;
+
+ if ((error = ip_feature_init_cast (vm, cm, vcm,
+ feature_start_nodes,
+ ARRAY_LEN(feature_start_nodes),
+ cast,
+ 0 /* is_ip4 */)))
+ return error;
+ }
+ return 0;
+}
+
clib_error_t *
ip6_sw_interface_add_del (vnet_main_t * vnm,
u32 sw_if_index,
@@ -1209,41 +1278,31 @@ ip6_sw_interface_add_del (vnet_main_t * vnm,
ip6_main_t * im = &ip6_main;
ip_lookup_main_t * lm = &im->lookup_main;
u32 ci, cast;
+ u32 feature_index;
for (cast = 0; cast < VNET_N_CAST; cast++)
{
ip_config_main_t * cm = &lm->rx_config_mains[cast];
vnet_config_main_t * vcm = &cm->config_main;
- /* FIXME multicast. */
- if (! vcm->node_index_by_feature_index)
- {
- char * start_nodes[] = { "ip6-input", };
- char * feature_nodes[] = {
- [IP6_RX_FEATURE_CHECK_ACCESS] = "ip6-inacl",
- [IP6_RX_FEATURE_IPSEC] = "ipsec-input-ip6",
- [IP6_RX_FEATURE_L2TPV3] = "l2tp-decap",
- [IP6_RX_FEATURE_VPATH] = "vpath-input-ip6",
- [IP6_RX_FEATURE_LOOKUP] = "ip6-lookup",
- };
- vnet_config_init (vm, vcm,
- start_nodes, ARRAY_LEN (start_nodes),
- feature_nodes, ARRAY_LEN (feature_nodes));
- }
-
vec_validate_init_empty (cm->config_index_by_sw_if_index, sw_if_index, ~0);
ci = cm->config_index_by_sw_if_index[sw_if_index];
+ if (cast == VNET_UNICAST)
+ feature_index = im->ip6_unicast_rx_feature_lookup;
+ else
+ feature_index = im->ip6_multicast_rx_feature_lookup;
+
if (is_add)
ci = vnet_config_add_feature (vm, vcm,
ci,
- IP6_RX_FEATURE_LOOKUP,
+ feature_index,
/* config data */ 0,
/* # bytes of config data */ 0);
else
ci = vnet_config_del_feature (vm, vcm,
ci,
- IP6_RX_FEATURE_LOOKUP,
+ feature_index,
/* config data */ 0,
/* # bytes of config data */ 0);
@@ -2857,6 +2916,8 @@ ip6_lookup_init (vlib_main_t * vm)
"ip6 neighbor discovery");
}
+ ip6_feature_init (vm, im);
+
return 0;
}