* @brief Fixup the adj rewrite post encap. Insert the packet's length
*/
static void
-pppoe_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b0)
+pppoe_fixup (vlib_main_t * vm,
+ ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
{
+ const pppoe_session_t *t;
pppoe_header_t *pppoe0;
+ /* update the rewrite string */
pppoe0 = vlib_buffer_get_current (b0) + sizeof (ethernet_header_t);
pppoe0->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0)
- sizeof (pppoe_header_t)
+ sizeof (pppoe0->ppp_proto)
- sizeof (ethernet_header_t));
+ /* Swap to the the packet's output interface to the encap (not the
+ * session) interface */
+ t = data;
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = t->encap_if_index;
}
static void
ASSERT (ADJ_INDEX_INVALID != ai);
adj = adj_get (ai);
+ session_id = pem->session_index_by_sw_if_index[sw_if_index];
+ t = pool_elt_at_index (pem->sessions, session_id);
switch (adj->lookup_next_index)
{
case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
- adj_nbr_midchain_update_rewrite (ai, pppoe_fixup,
+ adj_nbr_midchain_update_rewrite (ai, pppoe_fixup, t,
ADJ_FLAG_NONE,
pppoe_build_rewrite (vnm,
sw_if_index,
* Construct a partial rewrite from the known ethernet mcast dest MAC
* There's no MAC fixup, so the last 2 parameters are 0
*/
- adj_mcast_midchain_update_rewrite (ai, pppoe_fixup,
+ adj_mcast_midchain_update_rewrite (ai, pppoe_fixup, t,
ADJ_FLAG_NONE,
pppoe_build_rewrite (vnm,
sw_if_index,
break;
}
- session_id = pem->session_index_by_sw_if_index[sw_if_index];
- t = pool_elt_at_index (pem->sessions, session_id);
interface_tx_dpo_add_or_lock (vnet_link_to_dpo_proto (adj->ia_link),
t->encap_if_index, &dpo);
*/
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
* 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
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);
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;
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,
*/
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
{
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,
* @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,
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;
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);
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)
{
*/
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.
* @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);
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;
#define is_v4_packet(_h) ((*(u8*) _h) & 0xF0) == 0x40
-void
-gre4_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b0)
+static void
+gre4_fixup (vlib_main_t * vm,
+ ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
{
ip4_header_t *ip0;
ip0->checksum = ip4_header_checksum (ip0);
}
-void
-gre6_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b0)
+static void
+gre6_fixup (vlib_main_t * vm,
+ ip_adjacency_t * adj, vlib_buffer_t * b0, const void *data)
{
ip6_header_t *ip0;
is_ipv6 = t->tunnel_dst.fp_proto == FIB_PROTOCOL_IP6 ? 1 : 0;
adj_nbr_midchain_update_rewrite (ai, !is_ipv6 ? gre4_fixup : gre6_fixup,
+ NULL,
(VNET_LINK_ETHERNET ==
adj_get_link_type (ai) ?
ADJ_FLAG_MIDCHAIN_NO_COUNT :
if (is_midchain)
{
- adj0->sub_type.midchain.fixup_func (vm, adj0, p0);
- adj1->sub_type.midchain.fixup_func (vm, adj1, p1);
+ adj0->sub_type.midchain.fixup_func
+ (vm, adj0, p0, adj0->sub_type.midchain.fixup_data);
+ adj1->sub_type.midchain.fixup_func
+ (vm, adj1, p1, adj0->sub_type.midchain.fixup_data);
}
if (is_mcast)
{
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);
}
if (PREDICT_FALSE
if (is_midchain)
{
- adj0->sub_type.midchain.fixup_func (vm, adj0, p0);
- adj1->sub_type.midchain.fixup_func (vm, adj1, p1);
+ adj0->sub_type.midchain.fixup_func
+ (vm, adj0, p0, adj0->sub_type.midchain.fixup_data);
+ adj1->sub_type.midchain.fixup_func
+ (vm, adj1, p1, adj1->sub_type.midchain.fixup_data);
}
if (is_mcast)
{
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);
}
if (is_mcast)
{
}
static void
-lisp_gpe_fixup (vlib_main_t * vm, ip_adjacency_t * adj, vlib_buffer_t * b)
+lisp_gpe_fixup (vlib_main_t * vm,
+ ip_adjacency_t * adj, vlib_buffer_t * b, const void *data)
{
lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
linkt = adj_get_link_type (ai);
adj_nbr_midchain_update_rewrite
(ai, lisp_gpe_fixup,
+ NULL,
(VNET_LINK_ETHERNET == linkt ?
ADJ_FLAG_MIDCHAIN_NO_COUNT :
ADJ_FLAG_NONE),
}
if (is_midchain)
{
- adj0->sub_type.midchain.fixup_func(vm, adj0, p0);
- adj1->sub_type.midchain.fixup_func(vm, adj1, p1);
+ adj0->sub_type.midchain.fixup_func
+ (vm, adj0, p0,
+ adj0->sub_type.midchain.fixup_data);
+ adj1->sub_type.midchain.fixup_func
+ (vm, adj1, p1,
+ adj1->sub_type.midchain.fixup_data);
}
p0->error = error_node->errors[error0];
}
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);
}
p0->error = error_node->errors[error0];
static void
mpls_tunnel_fixup (vlib_main_t *vm,
ip_adjacency_t *adj,
- vlib_buffer_t *b0)
+ vlib_buffer_t *b0,
+ const void*data)
{
/*
* A no-op w.r.t. the header. but reset the 'have we pushed any
case IP_LOOKUP_NEXT_ARP:
case IP_LOOKUP_NEXT_GLEAN:
adj_nbr_midchain_update_rewrite(ai, mpls_tunnel_fixup,
+ NULL,
ADJ_FLAG_NONE,
mpls_tunnel_build_rewrite_i());
break;
* There's no MAC fixup, so the last 2 parameters are 0
*/
adj_mcast_midchain_update_rewrite(ai, mpls_tunnel_fixup,
+ NULL,
ADJ_FLAG_NONE,
mpls_tunnel_build_rewrite_i(),
0, 0);