From 9137e5400699bed9f7c0095187839a8b38273100 Mon Sep 17 00:00:00 2001 From: Dave Barach Date: Fri, 13 Sep 2019 17:47:50 -0400 Subject: misc: classifier-based packet trace filter See .../src/vnet/classify/trace_classify.h for the business end of the scheme. It would be best to hash pkts, prefetch buckets, and do the primary table lookups two at a time. The inline as given works, but perf tuning will be required. "At least it works..." Add "classify filter" debug cli, for example: classify filter mask l3 ip4 src dst \ match l3 ip4 dst 192.168.2.10 src 192.168.1.10 Add "pcap rx | tx trace ... filter" to use the current classify filter chain Patch includes sphinx documentation and doxygen tags. Next step: device-driver integration Type: feature Signed-off-by: Dave Barach Change-Id: I05b1358a769f61e6d32470e0c87058f640486b26 --- src/vnet/ethernet/node.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/vnet/ethernet/node.c') diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c index 9bfaf182eb2..fb706551719 100755 --- a/src/vnet/ethernet/node.c +++ b/src/vnet/ethernet/node.c @@ -44,6 +44,7 @@ #include #include #include +#include #define foreach_ethernet_input_next \ _ (PUNT, "error-punt") \ @@ -1000,15 +1001,29 @@ ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node, if (PREDICT_FALSE (vlib_global_main.pcap[VLIB_RX].pcap_enable)) { u32 bi0; + vnet_main_t *vnm = vnet_get_main (); from = vlib_frame_vector_args (from_frame); n_left = from_frame->n_vectors; while (n_left > 0) { + int classify_filter_result; vlib_buffer_t *b0; bi0 = from[0]; from++; + n_left--; b0 = vlib_get_buffer (vm, bi0); + if (vec_len (vnm->classify_filter_table_indices)) + { + classify_filter_result = + vnet_is_packet_traced_inline + (b0, vnm->classify_filter_table_indices[0], + 0 /* full classify */ ); + if (classify_filter_result) + pcap_add_buffer (&vlib_global_main.pcap[VLIB_RX].pcap_main, + vm, bi0, 512); + continue; + } if (vlib_global_main.pcap[VLIB_RX].pcap_sw_if_index == 0 || vlib_global_main.pcap[VLIB_RX].pcap_sw_if_index @@ -1017,7 +1032,6 @@ ethernet_input_trace (vlib_main_t * vm, vlib_node_runtime_t * node, pcap_add_buffer (&vlib_global_main.pcap[VLIB_RX].pcap_main, vm, bi0, 512); } - n_left--; } } } -- cgit 1.2.3-korg