diff options
author | Neale Ranns <nranns@cisco.com> | 2018-01-29 10:43:33 -0800 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2018-01-30 08:54:29 +0000 |
commit | db14f5aff69311d13a0a90baa3567e92f3faa783 (patch) | |
tree | 2ee6edb0d8b82b840fdc90b62f782ea0b95bc8f0 /src/vnet/adj | |
parent | bb16d3ffecd357907d01f2785ac78edf0292cfd3 (diff) |
Allow the provider of a midchain adjacency to pass context data that is returned in the fixup function
Change-Id: I458e6e03b03e27775df33a2fd302743126d6ac44
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/adj')
-rw-r--r-- | src/vnet/adj/adj.h | 7 | ||||
-rw-r--r-- | src/vnet/adj/adj_internal.h | 1 | ||||
-rw-r--r-- | src/vnet/adj/adj_l2.c | 4 | ||||
-rw-r--r-- | src/vnet/adj/adj_mcast.c | 6 | ||||
-rw-r--r-- | src/vnet/adj/adj_mcast.h | 11 | ||||
-rw-r--r-- | src/vnet/adj/adj_midchain.c | 5 | ||||
-rw-r--r-- | src/vnet/adj/adj_midchain.h | 13 | ||||
-rw-r--r-- | src/vnet/adj/adj_nsh.c | 4 |
8 files changed, 41 insertions, 10 deletions
diff --git a/src/vnet/adj/adj.h b/src/vnet/adj/adj.h index ed5eb1f1e88..fe77d1634e0 100644 --- a/src/vnet/adj/adj.h +++ b/src/vnet/adj/adj.h @@ -141,7 +141,8 @@ struct ip_adjacency_t_; */ typedef void (*adj_midchain_fixup_t) (vlib_main_t * vm, struct ip_adjacency_t_ * adj, - vlib_buffer_t * b0); + vlib_buffer_t * b0, + const void *data); /** * @brief Flags on an IP adjacency @@ -242,6 +243,10 @@ typedef struct ip_adjacency_t_ * A function to perform the post-rewrite fixup */ adj_midchain_fixup_t fixup_func; + /** + * Fixup data passed back to the client in the fixup function + */ + const void *fixup_data; } midchain; /** * IP_LOOKUP_NEXT_GLEAN diff --git a/src/vnet/adj/adj_internal.h b/src/vnet/adj/adj_internal.h index ca41cb21d9e..e6d276e4d02 100644 --- a/src/vnet/adj/adj_internal.h +++ b/src/vnet/adj/adj_internal.h @@ -95,6 +95,7 @@ extern void adj_nbr_update_rewrite_internal(ip_adjacency_t *adj, u8 *rewrite); extern void adj_midchain_setup(adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *data, adj_flags_t flags); extern ip_adjacency_t * adj_alloc(fib_protocol_t proto); diff --git a/src/vnet/adj/adj_l2.c b/src/vnet/adj/adj_l2.c index 20d70dd4cd1..132ceb28168 100644 --- a/src/vnet/adj/adj_l2.c +++ b/src/vnet/adj/adj_l2.c @@ -110,7 +110,9 @@ adj_l2_rewrite_inline (vlib_main_t * vm, if (is_midchain) { - adj0->sub_type.midchain.fixup_func(vm, adj0, p0); + adj0->sub_type.midchain.fixup_func( + vm, adj0, p0, + adj0->sub_type.midchain.fixup_data); } vnet_buffer (p0)->sw_if_index[VLIB_TX] = tx_sw_if_index0; diff --git a/src/vnet/adj/adj_mcast.c b/src/vnet/adj/adj_mcast.c index 00a12ad330b..efc781de989 100644 --- a/src/vnet/adj/adj_mcast.c +++ b/src/vnet/adj/adj_mcast.c @@ -139,6 +139,7 @@ adj_mcast_update_rewrite (adj_index_t adj_index, void adj_mcast_midchain_update_rewrite (adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *fixup_data, adj_flags_t flags, u8 *rewrite, u8 offset, @@ -160,7 +161,7 @@ adj_mcast_midchain_update_rewrite (adj_index_t adj_index, */ ASSERT(NULL != rewrite); - adj_midchain_setup(adj_index, fixup, flags); + adj_midchain_setup(adj_index, fixup, fixup_data, flags); /* * update the adj's rewrite string and build the arc @@ -354,14 +355,13 @@ format_adj_mcast_midchain (u8* s, va_list *ap) { index_t index = va_arg(*ap, index_t); CLIB_UNUSED(u32 indent) = va_arg(*ap, u32); - vnet_main_t * vnm = vnet_get_main(); ip_adjacency_t * adj = adj_get(index); s = format(s, "%U-mcast-midchain: ", format_fib_protocol, adj->ia_nh_proto); s = format (s, "%U", format_vnet_rewrite, - vnm->vlib_main, &adj->rewrite_header, + &adj->rewrite_header, sizeof (adj->rewrite_data), 0); s = format (s, "\n%Ustacked-on:\n%U%U", format_white_space, indent, diff --git a/src/vnet/adj/adj_mcast.h b/src/vnet/adj/adj_mcast.h index bfb0d6f6d11..55e2ec03d09 100644 --- a/src/vnet/adj/adj_mcast.h +++ b/src/vnet/adj/adj_mcast.h @@ -77,11 +77,22 @@ extern void adj_mcast_update_rewrite(adj_index_t adj_index, * @param * The index of the adj to update * + * @param fixup + * The function that will be invoked at paket switch time to 'fixup' + * the rewrite applied with necessary per-packet info (i.e. length, checksums). + * @param fixup_data + * Context data set by the caller that is provided as an argument in the + * fixup function. + * + * @param flags + * Flags controlling the adjacency behaviour + * * @param * The new rewrite */ extern void adj_mcast_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *fixup_data, adj_flags_t flags, u8 *rewrite, u8 offset, diff --git a/src/vnet/adj/adj_midchain.c b/src/vnet/adj/adj_midchain.c index 370fa4652f8..9fd3246b15a 100644 --- a/src/vnet/adj/adj_midchain.c +++ b/src/vnet/adj/adj_midchain.c @@ -460,6 +460,7 @@ adj_nbr_midchain_get_feature_node (ip_adjacency_t *adj) void adj_midchain_setup (adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *data, adj_flags_t flags) { u32 feature_index, tx_node; @@ -471,6 +472,7 @@ adj_midchain_setup (adj_index_t adj_index, adj = adj_get(adj_index); adj->sub_type.midchain.fixup_func = fixup; + adj->sub_type.midchain.fixup_data = data; adj->ia_flags |= flags; arc_index = adj_midchain_get_feature_arc_index_for_link_type (adj); @@ -503,6 +505,7 @@ adj_midchain_setup (adj_index_t adj_index, void adj_nbr_midchain_update_rewrite (adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *fixup_data, adj_flags_t flags, u8 *rewrite) { @@ -522,7 +525,7 @@ adj_nbr_midchain_update_rewrite (adj_index_t adj_index, */ ASSERT(NULL != rewrite); - adj_midchain_setup(adj_index, fixup, flags); + adj_midchain_setup(adj_index, fixup, fixup_data, flags); /* * update the rewirte with the workers paused. diff --git a/src/vnet/adj/adj_midchain.h b/src/vnet/adj/adj_midchain.h index 27ca1d3398d..65892314f40 100644 --- a/src/vnet/adj/adj_midchain.h +++ b/src/vnet/adj/adj_midchain.h @@ -31,15 +31,22 @@ * @param adj_index * The index of the neighbour adjacency. * - * @param post_rewrite_node - * The VLIB graph node that provides the post-encap fixup. - * where 'fixup' is e.g., correcting chksum, length, etc. + * @param fixup + * The function that will be invoked at paket switch time to 'fixup' + * the rewrite applied with necessary per-packet info (i.e. length, checksums). + * @param fixup_data + * Context data set by the caller that is provided as an argument in the + * fixup function. + * + * @param flags + * Flags controlling the adjacency behaviour * * @param rewrite * The rewrite. */ extern void adj_nbr_midchain_update_rewrite(adj_index_t adj_index, adj_midchain_fixup_t fixup, + const void *fixup_data, adj_flags_t flags, u8 *rewrite); diff --git a/src/vnet/adj/adj_nsh.c b/src/vnet/adj/adj_nsh.c index 128570b02a9..76503f59309 100644 --- a/src/vnet/adj/adj_nsh.c +++ b/src/vnet/adj/adj_nsh.c @@ -111,7 +111,9 @@ adj_nsh_rewrite_inline (vlib_main_t * vm, if (is_midchain) { - adj0->sub_type.midchain.fixup_func(vm, adj0, p0); + adj0->sub_type.midchain.fixup_func( + vm, adj0, p0, + adj0->sub_type.midchain.fixup_data); } vnet_buffer (p0)->sw_if_index[VLIB_TX] = tx_sw_if_index0; |