From 560963c4d41e153344850e8c98eaac4f131d05cb Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 29 Apr 2021 22:19:07 +0200 Subject: cache: add hashtable cache for flowtable Add flowtable hashtable cache. Actually I am not expecting that many flowtables to benefit from the hashtable to be created by streamline this code with tables, chains, sets and policy objects. Signed-off-by: Pablo Neira Ayuso --- include/cache.h | 4 ++++ include/netlink.h | 2 ++ include/rule.h | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/cache.h b/include/cache.h index 9605ef96..992f993c 100644 --- a/include/cache.h +++ b/include/cache.h @@ -92,4 +92,8 @@ void obj_cache_del(struct obj *obj); struct obj *obj_cache_find(const struct table *table, const char *name, uint32_t obj_type); +struct flowtable; +void ft_cache_add(struct flowtable *ft, struct table *table); +struct flowtable *ft_cache_find(const struct table *table, const char *name); + #endif /* _NFT_CACHE_H_ */ diff --git a/include/netlink.h b/include/netlink.h index f93c5322..a7c524ca 100644 --- a/include/netlink.h +++ b/include/netlink.h @@ -163,6 +163,8 @@ extern struct obj *netlink_delinearize_obj(struct netlink_ctx *ctx, extern int netlink_list_flowtables(struct netlink_ctx *ctx, const struct handle *h); +extern struct flowtable *netlink_delinearize_flowtable(struct netlink_ctx *ctx, + struct nftnl_flowtable *nlo); extern void netlink_dump_chain(const struct nftnl_chain *nlc, struct netlink_ctx *ctx); diff --git a/include/rule.h b/include/rule.h index f264bc8a..c6fd4c4c 100644 --- a/include/rule.h +++ b/include/rule.h @@ -158,6 +158,7 @@ struct table { struct cache chain_cache; struct cache set_cache; struct cache obj_cache; + struct cache ft_cache; struct list_head chains; struct list_head sets; struct list_head objs; @@ -516,6 +517,7 @@ uint32_t obj_type_to_cmd(uint32_t type); struct flowtable { struct list_head list; + struct cache_item cache; struct handle handle; struct scope scope; struct location location; @@ -531,8 +533,6 @@ struct flowtable { extern struct flowtable *flowtable_alloc(const struct location *loc); extern struct flowtable *flowtable_get(struct flowtable *flowtable); extern void flowtable_free(struct flowtable *flowtable); -extern void flowtable_add_hash(struct flowtable *flowtable, struct table *table); -extern struct flowtable *flowtable_lookup(const struct table *table, const char *name); extern struct flowtable *flowtable_lookup_fuzzy(const char *ft_name, const struct nft_cache *cache, const struct table **table); -- cgit v1.2.3