aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2016-06-08 12:23:21 +0100
committerDave Barach <openvpp@barachs.net>2016-06-09 13:38:05 +0000
commit363db8809514dad0dc657c55aaf79139a45830f8 (patch)
tree3b33a69eb3b749f84a87794a62c066cbcc2b2321
parent419e65629c83552bcc3142a09f0856d7fe3f6584 (diff)
VPP-117: Add trace to ip4 and ip6 lookup nodes
The absence of trace in ip lookup nodes is misleading to many people. This patch adds ip lookup tracing and therefore contribute to worldwide happiness. In addition, this patch makes sure sw_if_index[VLIB_TX] is considered when tracing the fib_index value. In ip4/6-rewrite, the value corresponds to the tx interface index. The formatting function is therefore modified to take that case into account. Change-Id: I5915f0446a15c45e391eedfdfcedd9057aa6a237 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
-rw-r--r--vnet/vnet/ip/ip4.h1
-rw-r--r--vnet/vnet/ip/ip4_forward.c48
-rw-r--r--vnet/vnet/ip/ip6.h1
-rw-r--r--vnet/vnet/ip/ip6_forward.c53
4 files changed, 84 insertions, 19 deletions
diff --git a/vnet/vnet/ip/ip4.h b/vnet/vnet/ip/ip4.h
index b14541eb2ef..59ef685bc57 100644
--- a/vnet/vnet/ip/ip4.h
+++ b/vnet/vnet/ip/ip4.h
@@ -173,6 +173,7 @@ extern ip4_main_t ip4_main;
extern vlib_node_registration_t ip4_input_node;
extern vlib_node_registration_t ip4_lookup_node;
extern vlib_node_registration_t ip4_rewrite_node;
+extern vlib_node_registration_t ip4_rewrite_local_node;
extern vlib_node_registration_t ip4_arp_node;
u32 ip4_fib_lookup_with_table (ip4_main_t * im, u32 fib_index, ip4_address_t * dst,
diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c
index cb29d30ad37..012aab0d09e 100644
--- a/vnet/vnet/ip/ip4_forward.c
+++ b/vnet/vnet/ip/ip4_forward.c
@@ -632,6 +632,12 @@ void ip4_delete_matching_routes (ip4_main_t * im,
ip4_maybe_remap_adjacencies (im, table_index_or_table_id, flags);
}
+void
+ip4_forward_next_trace (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame,
+ vlib_rx_or_tx_t which_adj_index);
+
always_inline uword
ip4_lookup_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -650,6 +656,9 @@ 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,
@@ -1344,12 +1353,15 @@ 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);
VLIB_REGISTER_NODE (ip4_lookup_node) = {
.function = ip4_lookup,
.name = "ip4-lookup",
.vector_size = sizeof (u32),
+ .format_trace = format_ip4_forward_next_trace,
+
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP4_LOOKUP_NEXT_NODES,
};
@@ -1369,6 +1381,8 @@ VLIB_REGISTER_NODE (ip4_indirect_node) = {
.name = "ip4-indirect",
.vector_size = sizeof (u32),
+ .format_trace = format_ip4_forward_next_trace,
+
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP4_LOOKUP_NEXT_NODES,
};
@@ -1455,9 +1469,15 @@ static u8 * format_ip4_forward_next_trace (u8 * s, va_list * args)
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, "fib %d adj-idx %d : %U flow hash: 0x%08x",
+ 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)
@@ -1511,8 +1531,11 @@ ip4_forward_next_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
- t0->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+ t0->fib_index = (vnet_buffer(b0)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+
clib_memcpy (t0->packet_data,
vlib_buffer_get_current (b0),
sizeof (t0->packet_data));
@@ -1522,8 +1545,10 @@ ip4_forward_next_trace (vlib_main_t * vm,
t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
t1->adj_index = vnet_buffer (b1)->ip.adj_index[which_adj_index];
t1->flow_hash = vnet_buffer (b1)->ip.flow_hash;
- t1->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b1)->sw_if_index[VLIB_RX]);
+ t1->fib_index = (vnet_buffer(b1)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b1)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b1)->sw_if_index[VLIB_RX]);
clib_memcpy (t1->packet_data,
vlib_buffer_get_current (b1),
sizeof (t1->packet_data));
@@ -1547,8 +1572,10 @@ ip4_forward_next_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
- t0->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+ t0->fib_index = (vnet_buffer(b0)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b0)->sw_if_index[VLIB_RX]);
clib_memcpy (t0->packet_data,
vlib_buffer_get_current (b0),
sizeof (t0->packet_data));
@@ -2747,7 +2774,7 @@ VLIB_REGISTER_NODE (ip4_rewrite_node) = {
},
};
-VLIB_REGISTER_NODE (ip4_rewrite_local_node,static) = {
+VLIB_REGISTER_NODE (ip4_rewrite_local_node) = {
.function = ip4_rewrite_local,
.name = "ip4-rewrite-local",
.vector_size = sizeof (u32),
@@ -2828,6 +2855,9 @@ 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,
@@ -3032,6 +3062,8 @@ VLIB_REGISTER_NODE (ip4_lookup_multicast_node,static) = {
.name = "ip4-lookup-multicast",
.vector_size = sizeof (u32),
+ .format_trace = format_ip4_forward_next_trace,
+
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP4_LOOKUP_NEXT_NODES,
};
diff --git a/vnet/vnet/ip/ip6.h b/vnet/vnet/ip/ip6.h
index 4d0e8564aa2..3ce2ef4766d 100644
--- a/vnet/vnet/ip/ip6.h
+++ b/vnet/vnet/ip/ip6.h
@@ -184,6 +184,7 @@ extern ip6_main_t ip6_main;
/* Global ip6 input node. Errors get attached to ip6 input node. */
extern vlib_node_registration_t ip6_input_node;
extern vlib_node_registration_t ip6_rewrite_node;
+extern vlib_node_registration_t ip6_rewrite_local_node;
extern vlib_node_registration_t ip6_discover_neighbor_node;
extern vlib_node_registration_t ip6_icmp_neighbor_discovery_event_node;
diff --git a/vnet/vnet/ip/ip6_forward.c b/vnet/vnet/ip/ip6_forward.c
index a136da3e142..27905cd2d0c 100644
--- a/vnet/vnet/ip/ip6_forward.c
+++ b/vnet/vnet/ip/ip6_forward.c
@@ -653,6 +653,12 @@ void ip6_delete_matching_routes (ip6_main_t * im,
ip6_maybe_remap_adjacencies (im, table_index_or_table_id, flags);
}
+void
+ip6_forward_next_trace (vlib_main_t * vm,
+ vlib_node_runtime_t * node,
+ vlib_frame_t * frame,
+ vlib_rx_or_tx_t which_adj_index);
+
always_inline uword
ip6_lookup_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -670,6 +676,9 @@ 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,
@@ -1251,11 +1260,15 @@ 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);
+
VLIB_REGISTER_NODE (ip6_lookup_node) = {
.function = ip6_lookup,
.name = "ip6-lookup",
.vector_size = sizeof (u32),
+ .format_trace = format_ip6_forward_next_trace,
+
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP6_LOOKUP_NEXT_NODES,
};
@@ -1274,6 +1287,8 @@ VLIB_REGISTER_NODE (ip6_indirect_node) = {
.name = "ip6-indirect",
.vector_size = sizeof (u32),
+ .format_trace = format_ip6_forward_next_trace,
+
.n_next_nodes = IP_LOOKUP_N_NEXT,
.next_nodes = IP6_LOOKUP_NEXT_NODES,
};
@@ -1290,16 +1305,23 @@ typedef struct {
static u8 * format_ip6_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 *);
+ vlib_main_t * vm = va_arg (*args, vlib_main_t *);
+ 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";
+ }
+
adj = ip_get_adjacency (&im->lookup_main, t->adj_index);
- s = format (s, "fib %d adj-idx %d : %U flow hash: 0x%08x",
+ 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)
@@ -1331,7 +1353,7 @@ ip6_forward_next_trace (vlib_main_t * vm,
n_left = frame->n_vectors;
from = vlib_frame_vector_args (frame);
-
+
while (n_left >= 4)
{
u32 bi0, bi1;
@@ -1353,8 +1375,11 @@ ip6_forward_next_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
- t0->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+ t0->fib_index = (vnet_buffer(b0)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+
clib_memcpy (t0->packet_data,
vlib_buffer_get_current (b0),
sizeof (t0->packet_data));
@@ -1364,8 +1389,11 @@ ip6_forward_next_trace (vlib_main_t * vm,
t1 = vlib_add_trace (vm, node, b1, sizeof (t1[0]));
t1->adj_index = vnet_buffer (b1)->ip.adj_index[which_adj_index];
t1->flow_hash = vnet_buffer (b1)->ip.flow_hash;
- t1->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b1)->sw_if_index[VLIB_RX]);
+ t1->fib_index = (vnet_buffer(b1)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b1)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b1)->sw_if_index[VLIB_RX]);
+
clib_memcpy (t1->packet_data,
vlib_buffer_get_current (b1),
sizeof (t1->packet_data));
@@ -1389,8 +1417,11 @@ ip6_forward_next_trace (vlib_main_t * vm,
t0 = vlib_add_trace (vm, node, b0, sizeof (t0[0]));
t0->adj_index = vnet_buffer (b0)->ip.adj_index[which_adj_index];
t0->flow_hash = vnet_buffer (b0)->ip.flow_hash;
- t0->fib_index = vec_elt (im->fib_index_by_sw_if_index,
- vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+ t0->fib_index = (vnet_buffer(b0)->sw_if_index[VLIB_TX] != (u32)~0) ?
+ vnet_buffer(b0)->sw_if_index[VLIB_TX] :
+ vec_elt (im->fib_index_by_sw_if_index,
+ vnet_buffer(b0)->sw_if_index[VLIB_RX]);
+
clib_memcpy (t0->packet_data,
vlib_buffer_get_current (b0),
sizeof (t0->packet_data));
@@ -2424,7 +2455,7 @@ VLIB_REGISTER_NODE (ip6_rewrite_node) = {
},
};
-VLIB_REGISTER_NODE (ip6_rewrite_local_node,static) = {
+VLIB_REGISTER_NODE (ip6_rewrite_local_node) = {
.function = ip6_rewrite_local,
.name = "ip6-rewrite-local",
.vector_size = sizeof (u32),