summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_cli.c
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2020-10-15 14:41:36 -0400
committerDamjan Marion <dmarion@me.com>2020-12-15 15:14:05 +0000
commit5c1e48c01b50ddbd7623228e3dbc94d835d23813 (patch)
treec38d75e9f471b5dbee8968230c5f0bf538f2d53e /src/vnet/interface_cli.c
parent510aaa8911843206f7b9ff48b41e3c7b8c4a99fe (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/vnet/interface_cli.c')
-rw-r--r--src/vnet/interface_cli.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index c9f11546b31..a5b9d63205f 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -1992,7 +1992,6 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
vnet_pcap_t *pp = &vm->pcap;
pcap_main_t *pm = &pp->pcap_main;
vnet_classify_main_t *cm = &vnet_classify_main;
- vnet_classify_filter_set_t *set = 0;
if (a->status)
{
@@ -2028,11 +2027,9 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
&& (pm->n_packets_to_capture != a->packets_to_capture))
return VNET_API_ERROR_INVALID_VALUE_2;
- set = pool_elt_at_index (cm->filter_sets, cm->filter_set_by_sw_if_index[0]);
-
/* Classify filter specified, but no classify filter configured */
if ((a->rx_enable + a->tx_enable + a->drop_enable) && a->filter &&
- (set->table_indices == 0 || set->table_indices[0] == ~0))
+ cm->classify_table_index_by_sw_if_index[0] == ~0)
return VNET_API_ERROR_NO_SUCH_LABEL;
if (a->rx_enable + a->tx_enable + a->drop_enable)
@@ -2089,7 +2086,8 @@ vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t * a)
pm->n_packets_to_capture = a->packets_to_capture;
pp->pcap_sw_if_index = a->sw_if_index;
if (a->filter)
- pp->filter_classify_table_index = set->table_indices[0];
+ pp->filter_classify_table_index =
+ cm->classify_table_index_by_sw_if_index[0];
else
pp->filter_classify_table_index = ~0;
pp->pcap_rx_enable = a->rx_enable;