From df48e56e987f84bb32ea53dfe98569dfe3fb7e37 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 2 Apr 2021 20:26:15 +0200 Subject: cache: add hashtable cache for sets This patch adds a hashtable for set lookups. This patch also splits table->sets in two: - Sets that reside in the cache are stored in the new tables->cache_set and tables->cache_set_ht. - Set that defined via command line / ruleset file reside in tables->set. Sets in the cache (already in the kernel) are not placed in the table->sets list. By keeping separated lists, sets defined via command line / ruleset file can be added to cache. Adding 10000 sets, before: # time nft -f x real 0m6,415s user 0m3,126s sys 0m3,284s After: # time nft -f x real 0m3,949s user 0m0,743s sys 0m3,205s Signed-off-by: Pablo Neira Ayuso --- include/cache.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/cache.h') diff --git a/include/cache.h b/include/cache.h index 087f9ba9..f500e1b1 100644 --- a/include/cache.h +++ b/include/cache.h @@ -59,5 +59,7 @@ void cache_release(struct nft_cache *cache); void chain_cache_add(struct chain *chain, struct table *table); struct chain *chain_cache_find(const struct table *table, const struct handle *handle); +void set_cache_add(struct set *set, struct table *table); +struct set *set_cache_find(const struct table *table, const char *name); #endif /* _NFT_CACHE_H_ */ -- cgit v1.2.3