diff options
author | Damjan Marion <damarion@cisco.com> | 2021-09-20 13:39:37 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2021-09-20 17:44:10 +0200 |
commit | 3bb2da9cb115a489061ffb70332ac0801ce2551b (patch) | |
tree | 3112838d5d458d559ed3785028569b742542d8e0 /src/vnet/classify/vnet_classify.c | |
parent | 3d5e74172de146782244d7638a8b2c4efcb4006e (diff) |
classify: avoid dependent read of classify mask
Type: improvement
Change-Id: I176f08c74eb58a78f7fbdb48fd4592e6ddf74d34
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet/classify/vnet_classify.c')
-rw-r--r-- | src/vnet/classify/vnet_classify.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c index 48d444271c5..796250735e4 100644 --- a/src/vnet/classify/vnet_classify.c +++ b/src/vnet/classify/vnet_classify.c @@ -139,7 +139,7 @@ vnet_classify_new_table (vnet_classify_main_t *cm, const u8 *mask, pool_get_aligned_zero (cm->tables, t, CLIB_CACHE_LINE_BYTES); - vec_validate_aligned (t->mask, match_n_vectors - 1, sizeof (u32x4)); + clib_memset_u32 (t->mask, 0, 4 * ARRAY_LEN (t->mask)); clib_memcpy_fast (t->mask, mask, match_n_vectors * sizeof (u32x4)); t->next_table_index = ~0; @@ -175,7 +175,6 @@ vnet_classify_delete_table_index (vnet_classify_main_t * cm, /* Recursively delete the entire chain */ vnet_classify_delete_table_index (cm, t->next_table_index, del_chain); - vec_free (t->mask); vec_free (t->buckets); clib_mem_destroy_heap (t->mheap); pool_put (cm->tables, t); @@ -1649,13 +1648,13 @@ filter_table_mask_compare (void *a1, void *a2) m1 = (u8 *) (t1->mask); m2 = (u8 *) (t2->mask); - for (i = 0; i < vec_len (t1->mask) * sizeof (u32x4); i++) + for (i = 0; i < t1->match_n_vectors * sizeof (u32x4); i++) { n1 += count_set_bits (m1[0]); m1++; } - for (i = 0; i < vec_len (t2->mask) * sizeof (u32x4); i++) + for (i = 0; i < t2->match_n_vectors * sizeof (u32x4); i++) { n2 += count_set_bits (m2[0]); m2++; @@ -1815,11 +1814,11 @@ classify_lookup_chain (u32 table_index, u8 * mask, u32 n_skip, u32 n_match) continue; /* Masks aren't congruent, can't use this table. */ - if (vec_len (t->mask) * sizeof (u32x4) != vec_len (mask)) + if (t->match_n_vectors * sizeof (u32x4) != vec_len (mask)) continue; /* Masks aren't bit-for-bit identical, can't use this table. */ - if (memcmp (t->mask, mask, vec_len (mask))) + if (memcmp (t->mask, mask, t->match_n_vectors * sizeof (u32x4))) continue; /* Winner... */ |