aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/classify
diff options
context:
space:
mode:
authorJon Loeliger <jdl@netgate.com>2020-09-21 16:48:54 -0500
committerMatthew Smith <mgsmith@netgate.com>2020-10-01 18:06:22 +0000
commit362c666df000e78589ba966a42edfa1ef0ee288e (patch)
tree52db2270dd65743cd448357663880c850c6fc6bd /src/vnet/classify
parent459a0c4e3be1473c4c2b93811280c738e60d0524 (diff)
classify: Fix a couple bugs in 'pcap filter' command.
- Assert a valid set prior to first use. - Sort tables by mask prior to selecting first table - Use actual table indices and not loop index when linking tables Type: fix Change-Id: I9c61c8b7fe97c38faed8f2fc1792d7232799f580 Signed-off-by: Jon Loeliger <jdl@netgate.com>
Diffstat (limited to 'src/vnet/classify')
-rw-r--r--src/vnet/classify/vnet_classify.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c
index 8e77d25d736..0b285acbb96 100644
--- a/src/vnet/classify/vnet_classify.c
+++ b/src/vnet/classify/vnet_classify.c
@@ -1811,9 +1811,11 @@ classify_filter_command_fn (vlib_main_t * vm,
else
set = pool_elt_at_index (cm->filter_sets, set_index);
+ ASSERT (set);
+
for (i = 0; i < vec_len (set->table_indices); i++)
{
- t = pool_elt_at_index (cm->tables, i);
+ t = pool_elt_at_index (cm->tables, set->table_indices[i]);
/* classifier geometry mismatch, can't use this table */
if (t->match_n_vectors != match || t->skip_n_vectors != skip)
continue;
@@ -1825,7 +1827,7 @@ classify_filter_command_fn (vlib_main_t * vm,
continue;
/* Winner... */
- table_index = i;
+ table_index = set->table_indices[i];
goto found_table;
}
}
@@ -1862,19 +1864,9 @@ classify_filter_command_fn (vlib_main_t * vm,
cm->filter_set_by_sw_if_index[sw_if_index] = set - cm->filter_sets;
}
- /* Put top table index where device drivers can find them */
- if (sw_if_index > 0 && pkt_trace == 0)
- {
- vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
- ASSERT (vec_len (set->table_indices) > 0);
- hi->trace_classify_table_index = set->table_indices[0];
- }
-
/* Sort filter tables from most-specific mask to least-specific mask */
vec_sort_with_function (set->table_indices, filter_table_mask_compare);
- ASSERT (set);
-
/* Setup next_table_index fields */
for (i = 0; i < vec_len (set->table_indices); i++)
{
@@ -1886,6 +1878,14 @@ classify_filter_command_fn (vlib_main_t * vm,
t->next_table_index = ~0;
}
+ /* Put top table index where device drivers can find them */
+ if (sw_if_index > 0 && pkt_trace == 0)
+ {
+ vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index);
+ ASSERT (vec_len (set->table_indices) > 0);
+ hi->trace_classify_table_index = set->table_indices[0];
+ }
+
found_table:
/* Now try to parse a session */