diff options
author | Jon Loeliger <jdl@netgate.com> | 2020-10-15 14:41:36 -0400 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2020-12-15 15:14:05 +0000 |
commit | 5c1e48c01b50ddbd7623228e3dbc94d835d23813 (patch) | |
tree | c38d75e9f471b5dbee8968230c5f0bf538f2d53e /src/vlib/trace.c | |
parent | 510aaa8911843206f7b9ff48b41e3c7b8c4a99fe (diff) |
classify: add pcap/trace classfier mgmt API calls
Add lookup/get/set API calls to manage both PCAP and Trace
filtering Classifier tables.
The "lookup" call may be used to identify a Classifier table
within a chain of tables taht matches a particular mask vector.
For efficiency, this call should be used to determine to which
table a match vector should be added.
The "get" calls return the first table within a chain (either
a PCAP or the Trace) set of tables. The "set" call may be
used to add a new table to one such chain. If the "sort_masks"
flag is set, the tables within the chain are ordered such that
the most-specific mask is first, and the least-specific mask
is last. A call that "sets" a chain to ~0 will delete and free
all the tables with a chain.
The PCAP filters are per-interface, with "local0", (that is,
sw_if_index == 0) holding the system-wide PCAP filter.
The Classifier used a reference-counted "set" for each PCAP
or trace filter that it stored. The ref counts were not used,
and the vector of tables was only used temporarily to establish
a sorted order for tables based on masks. None of that
complexity was actually warranted, and where it was used,
the same could be achieved more simply.
Type: refactor
Signed-off-by: Jon Loeliger <jdl@netgate.com>
Change-Id: Icc56116cca91b91c631ca0628e814fb53f3677d2
Diffstat (limited to 'src/vlib/trace.c')
-rw-r--r-- | src/vlib/trace.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/vlib/trace.c b/src/vlib/trace.c index 152744432c5..156378af8e3 100644 --- a/src/vlib/trace.c +++ b/src/vlib/trace.c @@ -39,6 +39,7 @@ #include <vlib/vlib.h> #include <vlib/threads.h> +#include <vnet/classify/vnet_classify.h> u8 *vnet_trace_placeholder; @@ -110,7 +111,7 @@ vlib_trace_frame_buffers_only (vlib_main_t * vm, } /* Free up all trace buffer memory. */ -always_inline void +void clear_trace_buffer (void) { int i; @@ -416,6 +417,8 @@ trace_update_capture_options (u32 add, u32 node_index, u32 filter, u8 verbose) tm->trace_enable = 1; })); /* *INDENT-ON* */ + + vlib_enable_disable_pkt_trace_filter (! !filter); } static clib_error_t * @@ -464,13 +467,11 @@ cli_add_trace_buffer (vlib_main_t * vm, goto done; } - if (filter) + u32 filter_table = classify_get_trace_chain (); + if (filter && filter_table == ~0) { - if (vlib_enable_disable_pkt_trace_filter (1 /* enable */ )) - { - error = clib_error_create ("No packet trace filter configured..."); - goto done; - } + error = clib_error_create ("No packet trace filter configured..."); + goto done; } trace_update_capture_options (add, node_index, filter, verbose); |