From c7f6a82ce857748a165007b45cc06f2140cd95a7 Mon Sep 17 00:00:00 2001 From: Michael <30360508+jasonlittledragon@users.noreply.github.com> Date: Wed, 17 Jun 2020 14:36:21 +0800 Subject: [PATCH] Classify: fix the way of finding a suitable classify table We should compare two masks by the length of mask memory, or 'if statement' will never be true even if the mask is completely suitable. Also variable 'i' is not the table_index we want, table_index is in the vector table_indices. michaelsi@tencent.com --- src/vnet/classify/vnet_classify.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c index bf030241f68b..e93068156ff7 100644 --- a/src/vnet/classify/vnet_classify.c +++ b/src/vnet/classify/vnet_classify.c @@ -1810,19 +1810,19 @@ classify_filter_command_fn (vlib_main_t * vm, 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; /* Masks aren't congruent, can't use this table */ - if (vec_len (t->mask) != vec_len (mask)) + if (vec_len (t->mask) * sizeof(t->mask[0]) != vec_len (mask) * sizeof(mask[0])) continue; /* Masks aren't bit-for-bit identical, can't use this table */ if (memcmp (t->mask, mask, vec_len (mask))) continue; /* Winner... */ - table_index = i; + table_index = set->table_indices[i]; goto found_table; } }