diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-04-29 22:23:05 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-05-02 23:30:35 +0200 |
commit | 5ec5c706d993a68502801433c3bb2bcbb078efff (patch) | |
tree | b8ee369020eade4690b1ebc78144737ba4864dee /include | |
parent | 29b332e906eea98b4e1299c0da931874ef8e08db (diff) |
cache: add hashtable cache for table
Add a hashtable for fast table lookups.
Tables that reside in the cache use the table->cache_hlist and
table->cache_list heads.
Table that are created from command line / ruleset are also added
to the cache.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/cache.h | 20 | ||||
-rw-r--r-- | include/rule.h | 4 |
2 files changed, 14 insertions, 10 deletions
diff --git a/include/cache.h b/include/cache.h index f5b4876a..fddb843b 100644 --- a/include/cache.h +++ b/include/cache.h @@ -37,13 +37,7 @@ enum cache_level_flags { NFT_CACHE_FLUSHED = (1 << 31), }; -struct nft_cache { - uint32_t genid; - struct list_head list; - uint32_t seqnum; - uint32_t flags; -}; - +struct nft_cache; enum cmd_ops; unsigned int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds); @@ -88,6 +82,11 @@ void cache_free(struct cache *cache); void cache_add(struct cache_item *item, struct cache *cache, uint32_t hash); void cache_del(struct cache_item *item); +void table_cache_add(struct table *table, struct nft_cache *cache); +void table_cache_del(struct table *table); +struct table *table_cache_find(const struct cache *cache, const char *name, + uint32_t family); + void obj_cache_add(struct obj *obj, struct table *table); void obj_cache_del(struct obj *obj); struct obj *obj_cache_find(const struct table *table, const char *name, @@ -97,4 +96,11 @@ struct flowtable; void ft_cache_add(struct flowtable *ft, struct table *table); struct flowtable *ft_cache_find(const struct table *table, const char *name); +struct nft_cache { + uint32_t genid; + struct cache table_cache; + uint32_t seqnum; + uint32_t flags; +}; + #endif /* _NFT_CACHE_H_ */ diff --git a/include/rule.h b/include/rule.h index c6fd4c4c..fbd2c9a7 100644 --- a/include/rule.h +++ b/include/rule.h @@ -152,6 +152,7 @@ const char *table_flag_name(uint32_t flag); */ struct table { struct list_head list; + struct cache_item cache; struct handle handle; struct location location; struct scope scope; @@ -173,9 +174,6 @@ struct table { extern struct table *table_alloc(void); extern struct table *table_get(struct table *table); extern void table_free(struct table *table); -extern void table_add_hash(struct table *table, struct nft_cache *cache); -extern struct table *table_lookup(const struct handle *h, - const struct nft_cache *cache); extern struct table *table_lookup_fuzzy(const struct handle *h, const struct nft_cache *cache); |