u8 packet_data[64 - 1*sizeof(u32)];
} mpls_output_trace_t;
+#define foreach_mpls_output_next \
+_(DROP, "error-drop")
+
+typedef enum {
+#define _(s,n) MPLS_OUTPUT_NEXT_##s,
+ foreach_mpls_output_next
+#undef _
+ MPLS_OUTPUT_N_NEXT,
+} mpls_output_next_t;
+
static u8 *
format_mpls_output_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
mpls_output_trace_t * t = va_arg (*args, mpls_output_trace_t *);
- vnet_main_t * vnm = vnet_get_main();
uword indent = format_get_indent (s);
s = format (s, "adj-idx %d : %U flow hash: 0x%08x",
s = format (s, "\n%U%U",
format_white_space, indent,
format_ip_adjacency_packet_data,
- vnm, t->adj_index,
- t->packet_data, sizeof (t->packet_data));
+ t->adj_index, t->packet_data, sizeof (t->packet_data));
return s;
}
vlib_frame_t * from_frame,
int is_midchain)
{
- u32 n_left_from, next_index, * from, * to_next, cpu_index;
+ u32 n_left_from, next_index, * from, * to_next, thread_index;
vlib_node_runtime_t * error_node;
u32 n_left_to_next;
+ mpls_main_t *mm;
- cpu_index = os_get_cpu_number();
+ thread_index = vlib_get_thread_index();
error_node = vlib_node_get_runtime (vm, mpls_output_node.index);
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
next_index = node->cached_next_index;
+ mm = &mpls_main;
while (n_left_from > 0)
{
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
adj_index1 = vnet_buffer (p1)->ip.adj_index[VLIB_TX];
- /* We should never rewrite a pkt using the MISS adjacency */
- ASSERT(adj_index0);
- ASSERT(adj_index1);
-
adj0 = adj_get(adj_index0);
adj1 = adj_get(adj_index1);
hdr0 = vlib_buffer_get_current (p0);
rw_len0 = adj0[0].rewrite_header.data_bytes;
rw_len1 = adj1[0].rewrite_header.data_bytes;
- if (PREDICT_FALSE (rw_len0 > sizeof(ethernet_header_t)))
- vlib_increment_combined_counter
- (&adjacency_counters,
- cpu_index, adj_index0,
- /* packet increment */ 0,
- /* byte increment */ rw_len0-sizeof(ethernet_header_t));
- if (PREDICT_FALSE (rw_len1 > sizeof(ethernet_header_t)))
- vlib_increment_combined_counter
- (&adjacency_counters,
- cpu_index, adj_index1,
- /* packet increment */ 0,
- /* byte increment */ rw_len1-sizeof(ethernet_header_t));
+ /* Bump the adj counters for packet and bytes */
+ vlib_increment_combined_counter
+ (&adjacency_counters,
+ thread_index,
+ adj_index0,
+ 1,
+ vlib_buffer_length_in_chain (vm, p0) + rw_len0);
+ vlib_increment_combined_counter
+ (&adjacency_counters,
+ thread_index,
+ adj_index1,
+ 1,
+ vlib_buffer_length_in_chain (vm, p1) + rw_len1);
/* Check MTU of outgoing interface. */
if (PREDICT_TRUE(vlib_buffer_length_in_chain (vm, p0) <=
next0 = adj0[0].rewrite_header.next_index;
error0 = IP4_ERROR_NONE;
- if (is_midchain)
- {
- adj0->sub_type.midchain.fixup_func(vm, adj0, p0);
- }
+ if (PREDICT_FALSE(adj0[0].rewrite_header.flags & VNET_REWRITE_HAS_FEATURES))
+ vnet_feature_arc_start (mm->output_feature_arc_index,
+ adj0[0].rewrite_header.sw_if_index,
+ &next0, p0);
}
else
{
next1 = adj1[0].rewrite_header.next_index;
error1 = IP4_ERROR_NONE;
- if (is_midchain)
- {
- adj1->sub_type.midchain.fixup_func(vm, adj1, p1);
- }
+ if (PREDICT_FALSE(adj1[0].rewrite_header.flags & VNET_REWRITE_HAS_FEATURES))
+ vnet_feature_arc_start (mm->output_feature_arc_index,
+ adj1[0].rewrite_header.sw_if_index,
+ &next1, p1);
}
else
{
error1 = IP4_ERROR_MTU_EXCEEDED;
next1 = MPLS_OUTPUT_NEXT_DROP;
}
+ if (is_midchain)
+ {
+ adj0->sub_type.midchain.fixup_func(vm, adj0, p0);
+ adj1->sub_type.midchain.fixup_func(vm, adj1, p1);
+ }
p0->error = error_node->errors[error0];
p1->error = error_node->errors[error1];
p0, sizeof (*tr));
tr->adj_index = vnet_buffer(p0)->ip.adj_index[VLIB_TX];
tr->flow_hash = vnet_buffer(p0)->ip.flow_hash;
+ clib_memcpy (tr->packet_data,
+ vlib_buffer_get_current (p0),
+ sizeof (tr->packet_data));
}
if (PREDICT_FALSE(p1->flags & VLIB_BUFFER_IS_TRACED))
{
p1, sizeof (*tr));
tr->adj_index = vnet_buffer(p1)->ip.adj_index[VLIB_TX];
tr->flow_hash = vnet_buffer(p1)->ip.flow_hash;
+ clib_memcpy (tr->packet_data,
+ vlib_buffer_get_current (p1),
+ sizeof (tr->packet_data));
}
vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- /* We should never rewrite a pkt using the MISS adjacency */
- ASSERT(adj_index0);
-
adj0 = adj_get(adj_index0);
hdr0 = vlib_buffer_get_current (p0);
/* Update packet buffer attributes/set output interface. */
rw_len0 = adj0[0].rewrite_header.data_bytes;
- if (PREDICT_FALSE (rw_len0 > sizeof(ethernet_header_t)))
- vlib_increment_combined_counter
- (&adjacency_counters,
- cpu_index, adj_index0,
- /* packet increment */ 0,
- /* byte increment */ rw_len0-sizeof(ethernet_header_t));
+ vlib_increment_combined_counter
+ (&adjacency_counters,
+ thread_index,
+ adj_index0,
+ 1,
+ vlib_buffer_length_in_chain (vm, p0) + rw_len0);
/* Check MTU of outgoing interface. */
if (PREDICT_TRUE(vlib_buffer_length_in_chain (vm, p0) <=
next0 = adj0[0].rewrite_header.next_index;
error0 = IP4_ERROR_NONE;
- if (is_midchain)
- {
- adj0->sub_type.midchain.fixup_func(vm, adj0, p0);
- }
+ if (PREDICT_FALSE(adj0[0].rewrite_header.flags & VNET_REWRITE_HAS_FEATURES))
+ vnet_feature_arc_start (mm->output_feature_arc_index,
+ adj0[0].rewrite_header.sw_if_index,
+ &next0, p0);
}
else
{
error0 = IP4_ERROR_MTU_EXCEEDED;
next0 = MPLS_OUTPUT_NEXT_DROP;
}
- p0->error = error_node->errors[error0];
+ if (is_midchain)
+ {
+ adj0->sub_type.midchain.fixup_func(vm, adj0, p0);
+ }
+
+ p0->error = error_node->errors[error0];
from += 1;
n_left_from -= 1;
n_left_to_next -= 1;
adj_index0 = vnet_buffer (p0)->ip.adj_index[VLIB_TX];
- ASSERT(adj_index0);
adj0 = adj_get(adj_index0);