diff options
Diffstat (limited to 'vnet/vnet/ip/ip4_forward.c')
-rw-r--r-- | vnet/vnet/ip/ip4_forward.c | 83 |
1 files changed, 48 insertions, 35 deletions
diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c index 6dbc6d21afc..46b3a97b7c1 100644 --- a/vnet/vnet/ip/ip4_forward.c +++ b/vnet/vnet/ip/ip4_forward.c @@ -656,9 +656,6 @@ ip4_lookup_inline (vlib_main_t * vm, n_left_from = frame->n_vectors; next = node->cached_next_index; - if (node->flags & VLIB_NODE_FLAG_TRACE) - ip4_forward_next_trace(vm, node, frame, VLIB_TX); - while (n_left_from > 0) { vlib_get_next_frame (vm, node, next, @@ -986,6 +983,9 @@ ip4_lookup_inline (vlib_main_t * vm, vlib_put_next_frame (vm, node, next, n_left_to_next); } + if (node->flags & VLIB_NODE_FLAG_TRACE) + ip4_forward_next_trace(vm, node, frame, VLIB_TX); + return frame->n_vectors; } @@ -1353,14 +1353,14 @@ ip4_sw_interface_add_del (vnet_main_t * vnm, VNET_SW_INTERFACE_ADD_DEL_FUNCTION (ip4_sw_interface_add_del); -static u8 * format_ip4_forward_next_trace (u8 * s, va_list * args); +static u8 * format_ip4_lookup_trace (u8 * s, va_list * args); VLIB_REGISTER_NODE (ip4_lookup_node) = { .function = ip4_lookup, .name = "ip4-lookup", .vector_size = sizeof (u32), - .format_trace = format_ip4_forward_next_trace, + .format_trace = format_ip4_lookup_trace, .n_next_nodes = IP_LOOKUP_N_NEXT, .next_nodes = IP4_LOOKUP_NEXT_NODES, @@ -1383,7 +1383,7 @@ VLIB_REGISTER_NODE (ip4_indirect_node) = { .name = "ip4-indirect", .vector_size = sizeof (u32), - .format_trace = format_ip4_forward_next_trace, + .format_trace = format_ip4_lookup_trace, .n_next_nodes = IP_LOOKUP_N_NEXT, .next_nodes = IP4_LOOKUP_NEXT_NODES, @@ -1469,35 +1469,48 @@ static u8 * format_ip4_forward_next_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 *); ip4_forward_next_trace_t * t = va_arg (*args, ip4_forward_next_trace_t *); + uword indent = format_get_indent (s); + s = format (s, "%U%U", + format_white_space, indent, + format_ip4_header, t->packet_data); + return s; +} + +static u8 * format_ip4_lookup_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 *); + ip4_forward_next_trace_t * t = va_arg (*args, ip4_forward_next_trace_t *); vnet_main_t * vnm = vnet_get_main(); ip4_main_t * im = &ip4_main; - ip_adjacency_t * adj; uword indent = format_get_indent (s); - char *fib_or_interface = "fib"; - if ((node == vlib_get_node(vm, ip4_rewrite_node.index)) || - (node == vlib_get_node(vm, ip4_rewrite_local_node.index))) { - fib_or_interface = "tx_sw_if_index"; - } - adj = ip_get_adjacency (&im->lookup_main, t->adj_index); - s = format (s, "%s %d adj-idx %d : %U flow hash: 0x%08x", - fib_or_interface, - t->fib_index, t->adj_index, format_ip_adjacency, - vnm, &im->lookup_main, t->adj_index, t->flow_hash); - switch (adj->lookup_next_index) - { - case IP_LOOKUP_NEXT_REWRITE: - s = format (s, "\n%U%U", - format_white_space, indent, - format_ip_adjacency_packet_data, - vnm, &im->lookup_main, t->adj_index, - t->packet_data, sizeof (t->packet_data)); - break; + s = format (s, "fib %d adj-idx %d : %U flow hash: 0x%08x", + t->fib_index, t->adj_index, format_ip_adjacency, + vnm, &im->lookup_main, t->adj_index, t->flow_hash); + s = format (s, "\n%U%U", + format_white_space, indent, + format_ip4_header, t->packet_data); + return s; +} - default: - break; - } +static u8 * format_ip4_rewrite_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 *); + ip4_forward_next_trace_t * t = va_arg (*args, ip4_forward_next_trace_t *); + vnet_main_t * vnm = vnet_get_main(); + ip4_main_t * im = &ip4_main; + uword indent = format_get_indent (s); + s = format (s, "tx_sw_if_index %d adj-idx %d : %U flow hash: 0x%08x", + t->fib_index, t->adj_index, format_ip_adjacency, + vnm, &im->lookup_main, t->adj_index, t->flow_hash); + s = format (s, "\n%U%U", + format_white_space, indent, + format_ip_adjacency_packet_data, + vnm, &im->lookup_main, t->adj_index, + t->packet_data, sizeof (t->packet_data)); return s; } @@ -2777,7 +2790,7 @@ VLIB_REGISTER_NODE (ip4_rewrite_node) = { .name = "ip4-rewrite-transit", .vector_size = sizeof (u32), - .format_trace = format_ip4_forward_next_trace, + .format_trace = format_ip4_rewrite_trace, .n_next_nodes = 2, .next_nodes = { @@ -2795,7 +2808,7 @@ VLIB_REGISTER_NODE (ip4_rewrite_local_node) = { .sibling_of = "ip4-rewrite-transit", - .format_trace = format_ip4_forward_next_trace, + .format_trace = format_ip4_rewrite_trace, .n_next_nodes = 2, .next_nodes = { @@ -2871,9 +2884,6 @@ ip4_lookup_multicast (vlib_main_t * vm, n_left_from = frame->n_vectors; next = node->cached_next_index; - if (node->flags & VLIB_NODE_FLAG_TRACE) - ip4_forward_next_trace(vm, node, frame, VLIB_TX); - while (n_left_from > 0) { vlib_get_next_frame (vm, node, next, @@ -3070,6 +3080,9 @@ ip4_lookup_multicast (vlib_main_t * vm, vlib_put_next_frame (vm, node, next, n_left_to_next); } + if (node->flags & VLIB_NODE_FLAG_TRACE) + ip4_forward_next_trace(vm, node, frame, VLIB_TX); + return frame->n_vectors; } @@ -3078,7 +3091,7 @@ VLIB_REGISTER_NODE (ip4_lookup_multicast_node,static) = { .name = "ip4-lookup-multicast", .vector_size = sizeof (u32), - .format_trace = format_ip4_forward_next_trace, + .format_trace = format_ip4_lookup_trace, .n_next_nodes = IP_LOOKUP_N_NEXT, .next_nodes = IP4_LOOKUP_NEXT_NODES, |