From 1f4b36a18d945fced71bdfc0a2e369c44b8d8fe3 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 29 Apr 2021 20:29:09 +0200 Subject: src: consolidate nft_cache infrastructure - prepend nft_ prefix to nft_cache API and internal functions - move declarations to cache.h (and remove redundant declarations) - move struct nft_cache definition to cache.h Signed-off-by: Pablo Neira Ayuso --- include/cache.h | 23 +++++++++++++++++------ include/nftables.h | 8 +------- include/rule.h | 6 ------ 3 files changed, 18 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/cache.h b/include/cache.h index 00092767..987b122b 100644 --- a/include/cache.h +++ b/include/cache.h @@ -1,6 +1,8 @@ #ifndef _NFT_CACHE_H_ #define _NFT_CACHE_H_ +#include + enum cache_level_bits { NFT_CACHE_TABLE_BIT = (1 << 0), NFT_CACHE_CHAIN_BIT = (1 << 1), @@ -35,6 +37,21 @@ 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; +}; + +enum cmd_ops; + +unsigned int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds); +int nft_cache_update(struct nft_ctx *ctx, enum cmd_ops cmd, + struct list_head *msgs); +bool nft_cache_needs_update(struct nft_cache *cache); +void nft_cache_release(struct nft_cache *cache); + static inline uint32_t djb_hash(const char *key) { uint32_t i, hash = 5381; @@ -47,14 +64,8 @@ static inline uint32_t djb_hash(const char *key) #define NFT_CACHE_HSIZE 8192 -struct netlink_ctx; struct table; struct chain; -struct handle; - -int cache_init(struct netlink_ctx *ctx, unsigned int flags); -int cache_update(struct nft_ctx *nft, unsigned int flags, struct list_head *msgs); -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 char *name); diff --git a/include/nftables.h b/include/nftables.h index 9095ff3d..f239fcf0 100644 --- a/include/nftables.h +++ b/include/nftables.h @@ -5,6 +5,7 @@ #include #include #include +#include #include struct cookie { @@ -95,13 +96,6 @@ static inline bool nft_output_terse(const struct output_ctx *octx) return octx->flags & NFT_CTX_OUTPUT_TERSE; } -struct nft_cache { - uint32_t genid; - struct list_head list; - uint32_t seqnum; - uint32_t flags; -}; - struct mnl_socket; struct parser_state; struct scope; diff --git a/include/rule.h b/include/rule.h index 90c01e90..7896eafe 100644 --- a/include/rule.h +++ b/include/rule.h @@ -771,12 +771,6 @@ extern struct error_record *rule_postprocess(struct rule *rule); struct netlink_ctx; extern int do_command(struct netlink_ctx *ctx, struct cmd *cmd); -extern unsigned int cache_evaluate(struct nft_ctx *nft, struct list_head *cmds); -extern int cache_update(struct nft_ctx *ctx, enum cmd_ops cmd, - struct list_head *msgs); -extern bool cache_needs_update(struct nft_cache *cache); -extern void cache_release(struct nft_cache *cache); - struct timeout_protocol { uint32_t array_size; const char *const *state_to_name; -- cgit v1.2.3