diff options
author | Dave Barach <dave@barachs.net> | 2016-12-23 15:15:48 -0500 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2016-12-23 21:52:47 +0000 |
commit | 0f3b680f406fddd1b5ef6776aeb0c6fb363b1702 (patch) | |
tree | 07374d6ddc3a1a4610449f506aff16ce0d6262b6 /plugins/flowperpkt-plugin | |
parent | 3eec9b458338e923dfd8826fa3a1f686bf7c9be0 (diff) |
Make test support for the ipfix flow-per-pkt plugin
Change-Id: I7a0d37fc2bc21dbbff1cea1b92dc24d43f971eec
Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'plugins/flowperpkt-plugin')
-rw-r--r-- | plugins/flowperpkt-plugin/flowperpkt/l2_node.c | 25 | ||||
-rw-r--r-- | plugins/flowperpkt-plugin/flowperpkt/node.c | 29 |
2 files changed, 46 insertions, 8 deletions
diff --git a/plugins/flowperpkt-plugin/flowperpkt/l2_node.c b/plugins/flowperpkt-plugin/flowperpkt/l2_node.c index ba87d431..1c2f681e 100644 --- a/plugins/flowperpkt-plugin/flowperpkt/l2_node.c +++ b/plugins/flowperpkt-plugin/flowperpkt/l2_node.c @@ -79,6 +79,7 @@ static char *flowperpkt_l2_error_strings[] = { typedef enum { FLOWPERPKT_L2_NEXT_DROP, + FLOWPERPKT_L2_NEXT_IP4_LOOKUP, FLOWPERPKT_L2_N_NEXT, } flowperpkt_l2_next_t; @@ -95,6 +96,7 @@ typedef enum static inline void add_to_flow_record_l2 (vlib_main_t * vm, + vlib_node_runtime_t * node, flowperpkt_main_t * fm, u32 rx_sw_if_index, u32 tx_sw_if_index, u8 * src_mac, u8 * dst_mac, @@ -284,6 +286,18 @@ add_to_flow_record_l2 (vlib_main_t * vm, ASSERT (ip->checksum == ip4_header_checksum (ip)); + if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) + { + vlib_trace_buffer (vm, node, FLOWPERPKT_L2_NEXT_IP4_LOOKUP, b0, + 0 /* follow chain */ ); + flowperpkt_l2_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + memset (t, 0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->buffer_size = b0->current_length; + } + vlib_put_frame_to_node (vm, ip4_lookup_node.index, fm->l2_frames_per_worker[my_cpu_number]); fm->l2_frames_per_worker[my_cpu_number] = 0; @@ -299,8 +313,10 @@ flowperpkt_flush_callback_l2 (void) { vlib_main_t *vm = vlib_get_main (); flowperpkt_main_t *fm = &flowperpkt_main; + vlib_node_runtime_t *node; + node = vlib_node_get_runtime (vm, flowperpkt_l2_node.index); - add_to_flow_record_l2 (vm, fm, 0 /* rx_sw_if_index */ , + add_to_flow_record_l2 (vm, node, fm, 0 /* rx_sw_if_index */ , 0 /* tx_sw_if_index */ , 0 /* src mac */ , 0 /* dst mac */ , @@ -376,7 +392,7 @@ flowperpkt_l2_node_fn (vlib_main_t * vm, len0 = vlib_buffer_length_in_chain (vm, b0); if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, fm, + add_to_flow_record_l2 (vm, node, fm, vnet_buffer (b0)->sw_if_index[VLIB_RX], vnet_buffer (b0)->sw_if_index[VLIB_TX], eh0->src_address, @@ -387,7 +403,7 @@ flowperpkt_l2_node_fn (vlib_main_t * vm, len1 = vlib_buffer_length_in_chain (vm, b0); if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, fm, + add_to_flow_record_l2 (vm, node, fm, vnet_buffer (b1)->sw_if_index[VLIB_RX], vnet_buffer (b1)->sw_if_index[VLIB_TX], eh1->src_address, @@ -453,7 +469,7 @@ flowperpkt_l2_node_fn (vlib_main_t * vm, len0 = vlib_buffer_length_in_chain (vm, b0); if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_l2 (vm, fm, + add_to_flow_record_l2 (vm, node, fm, vnet_buffer (b0)->sw_if_index[VLIB_RX], vnet_buffer (b0)->sw_if_index[VLIB_TX], eh0->src_address, @@ -531,6 +547,7 @@ VLIB_REGISTER_NODE (flowperpkt_l2_node) = { /* edit / add dispositions here */ .next_nodes = { [FLOWPERPKT_L2_NEXT_DROP] = "error-drop", + [FLOWPERPKT_L2_NEXT_IP4_LOOKUP] = "ip4-lookup", }, }; /* *INDENT-ON* */ diff --git a/plugins/flowperpkt-plugin/flowperpkt/node.c b/plugins/flowperpkt-plugin/flowperpkt/node.c index 460aa3be..f77f087d 100644 --- a/plugins/flowperpkt-plugin/flowperpkt/node.c +++ b/plugins/flowperpkt-plugin/flowperpkt/node.c @@ -78,6 +78,7 @@ static char *flowperpkt_ipv4_error_strings[] = { typedef enum { FLOWPERPKT_IPV4_NEXT_DROP, + FLOWPERPKT_IPV4_NEXT_LOOKUP, FLOWPERPKT_IPV4_N_NEXT, } flowperpkt_ipv4_next_t; @@ -94,6 +95,7 @@ typedef enum static inline void add_to_flow_record_ipv4 (vlib_main_t * vm, + vlib_node_runtime_t * node, flowperpkt_main_t * fm, u32 rx_sw_if_index, u32 tx_sw_if_index, u32 src_address, u32 dst_address, @@ -282,6 +284,21 @@ add_to_flow_record_ipv4 (vlib_main_t * vm, ASSERT (ip->checksum == ip4_header_checksum (ip)); + if (PREDICT_FALSE (vlib_get_trace_count (vm, node) > 0)) + { + vlib_trace_buffer (vm, node, FLOWPERPKT_IPV4_NEXT_LOOKUP, b0, + 0 /* follow chain */ ); + flowperpkt_ipv4_trace_t *t = + vlib_add_trace (vm, node, b0, sizeof (*t)); + t->rx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; + t->tx_sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_TX]; + t->src_address = 0; + t->dst_address = 0; + t->tos = 0; + t->timestamp = 0; + t->buffer_size = b0->current_length; + } + vlib_put_frame_to_node (vm, ip4_lookup_node.index, fm->ipv4_frames_per_worker[my_cpu_number]); fm->ipv4_frames_per_worker[my_cpu_number] = 0; @@ -297,8 +314,10 @@ flowperpkt_flush_callback_ipv4 (void) { vlib_main_t *vm = vlib_get_main (); flowperpkt_main_t *fm = &flowperpkt_main; + vlib_node_runtime_t *node; + node = vlib_node_get_runtime (vm, flowperpkt_ipv4_node.index); - add_to_flow_record_ipv4 (vm, fm, 0 /* rx_sw_if_index */ , + add_to_flow_record_ipv4 (vm, node, fm, 0 /* rx_sw_if_index */ , 0 /* tx_sw_if_index */ , 0 /* src_address */ , 0 /* dst_address */ , @@ -376,7 +395,7 @@ flowperpkt_ipv4_node_fn (vlib_main_t * vm, len0 = vlib_buffer_length_in_chain (vm, b0); if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, fm, + add_to_flow_record_ipv4 (vm, node, fm, vnet_buffer (b0)->sw_if_index[VLIB_RX], vnet_buffer (b0)->sw_if_index[VLIB_TX], ip0->src_address.as_u32, @@ -388,7 +407,7 @@ flowperpkt_ipv4_node_fn (vlib_main_t * vm, len1 = vlib_buffer_length_in_chain (vm, b1); if (PREDICT_TRUE ((b1->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, fm, + add_to_flow_record_ipv4 (vm, node, fm, vnet_buffer (b1)->sw_if_index[VLIB_RX], vnet_buffer (b1)->sw_if_index[VLIB_TX], ip1->src_address.as_u32, @@ -462,7 +481,7 @@ flowperpkt_ipv4_node_fn (vlib_main_t * vm, len0 = vlib_buffer_length_in_chain (vm, b0); if (PREDICT_TRUE ((b0->flags & VLIB_BUFFER_FLOW_REPORT) == 0)) - add_to_flow_record_ipv4 (vm, fm, + add_to_flow_record_ipv4 (vm, node, fm, vnet_buffer (b0)->sw_if_index[VLIB_RX], vnet_buffer (b0)->sw_if_index[VLIB_TX], ip0->src_address.as_u32, @@ -540,6 +559,8 @@ VLIB_REGISTER_NODE (flowperpkt_ipv4_node) = { /* edit / add dispositions here */ .next_nodes = { [FLOWPERPKT_IPV4_NEXT_DROP] = "error-drop", + /* Used only to trace ipfix data packets */ + [FLOWPERPKT_IPV4_NEXT_LOOKUP] = "ip4-lookup", }, }; /* *INDENT-ON* */ |