aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-06-13 10:28:09 +0100
committerPierre Pfister <ppfister@cisco.com>2016-06-13 14:33:22 +0000
commita38c3df5fd2bf1bf8b3389e882f6dcd5ac533202 (patch)
tree07fb761afe32f0bb2ae77b97c26a10cfb25e04bc
parent51e332ab83169e4c3b6874ae1c7149fe869becfc (diff)
VPP-117: Fix ip4 and ip6 lookup and rewrite traces
Previous patch was printing wrong data since rewrite node traces an ethernet packet while other ip nodes trace an IP packet. This patch introduces different tracing functions for: - lookup node (where the fib index is valid) - rewrite node (where an ethernet frame is available) - other ip nodes (only the ip header is traced) Change-Id: I5971a2e89ae8668f5aed4a410565a5f27e01fc22 Signed-off-by: Pierre Pfister <ppfister@cisco.com> (cherry picked from commit 584b99a0120778108bd019b697639fbf3c1505d1)
-rw-r--r--vnet/vnet/ip/ip4_forward.c83
-rw-r--r--vnet/vnet/ip/ip6_forward.c80
2 files changed, 95 insertions, 68 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,
diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c
index 43d83507cce..398d0926e83 100644
--- a/vnet/vnet/ip/ip6_forward.c
+++ b/vnet/vnet/ip/ip6_forward.c
@@ -676,9 +676,6 @@ ip6_lookup_inline (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next = node->cached_next_index;
- if (node->flags & VLIB_NODE_FLAG_TRACE)
- ip6_forward_next_trace(vm, node, frame, VLIB_TX);
-
while (n_left_from > 0)
{
vlib_get_next_frame (vm, node, next,
@@ -937,6 +934,9 @@ ip6_lookup_inline (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next, n_left_to_next);
}
+ if (node->flags & VLIB_NODE_FLAG_TRACE)
+ ip6_forward_next_trace(vm, node, frame, VLIB_TX);
+
return frame->n_vectors;
}
@@ -1260,14 +1260,14 @@ ip6_lookup (vlib_main_t * vm,
return ip6_lookup_inline (vm, node, frame, /* is_indirect */ 0);
}
-static u8 * format_ip6_forward_next_trace (u8 * s, va_list * args);
+static u8 * format_ip6_lookup_trace (u8 * s, va_list * args);
VLIB_REGISTER_NODE (ip6_lookup_node) = {
.function = ip6_lookup,
.name = "ip6-lookup",
.vector_size = sizeof (u32),
- .format_trace = format_ip6_forward_next_trace,
+ .format_trace = format_ip6_lookup_trace,
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP6_LOOKUP_NEXT_NODES,
@@ -1289,7 +1289,7 @@ VLIB_REGISTER_NODE (ip6_indirect_node) = {
.name = "ip6-indirect",
.vector_size = sizeof (u32),
- .format_trace = format_ip6_forward_next_trace,
+ .format_trace = format_ip6_lookup_trace,
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP6_LOOKUP_NEXT_NODES,
@@ -1309,39 +1309,53 @@ typedef struct {
static u8 * format_ip6_forward_next_trace (u8 * s, va_list * args)
{
- vlib_main_t * vm = va_arg (*args, vlib_main_t *);
- vlib_node_t * node = va_arg (*args, vlib_node_t *);
+ CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
+ CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
+ ip6_forward_next_trace_t * t = va_arg (*args, ip6_forward_next_trace_t *);
+ uword indent = format_get_indent (s);
+
+ s = format(s, "%U%U",
+ format_white_space, indent,
+ format_ip6_header, t->packet_data);
+ return s;
+}
+
+static u8 * format_ip6_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 *);
ip6_forward_next_trace_t * t = va_arg (*args, ip6_forward_next_trace_t *);
vnet_main_t * vnm = vnet_get_main();
ip6_main_t * im = &ip6_main;
- ip_adjacency_t * adj;
uword indent = format_get_indent (s);
- char *fib_or_interface = "fib";
- if ((node == vlib_get_node(vm, ip6_rewrite_node.index)) ||
- (node == vlib_get_node(vm, ip6_rewrite_local_node.index))) {
- fib_or_interface = "tx_sw_if_index";
- }
+ 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_ip6_header, t->packet_data);
+ return s;
+}
- 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;
- default:
- break;
- }
+static u8 * format_ip6_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 *);
+ ip6_forward_next_trace_t * t = va_arg (*args, ip6_forward_next_trace_t *);
+ vnet_main_t * vnm = vnet_get_main();
+ ip6_main_t * im = &ip6_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;
}
@@ -2459,7 +2473,7 @@ VLIB_REGISTER_NODE (ip6_rewrite_node) = {
.name = "ip6-rewrite",
.vector_size = sizeof (u32),
- .format_trace = format_ip6_forward_next_trace,
+ .format_trace = format_ip6_rewrite_trace,
.n_next_nodes = 1,
.next_nodes = {
@@ -2476,7 +2490,7 @@ VLIB_REGISTER_NODE (ip6_rewrite_local_node) = {
.sibling_of = "ip6-rewrite",
- .format_trace = format_ip6_forward_next_trace,
+ .format_trace = format_ip6_rewrite_trace,
.n_next_nodes = 1,
.next_nodes = {