diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-07-18 15:56:00 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-07-18 16:20:33 +0200 |
commit | 64c74ba5795bbdd8c8080380bc1e66dec55cde65 (patch) | |
tree | 51887432873e1f93f2fec2bca91f7d4d0e5b17e1 /src | |
parent | 46980cddddfd77f2700fcb8234641711b985cd04 (diff) |
cache: prepare nft_cache_evaluate() to return error
Move flags as parameter reference and add list of error messages to prepare
for sanity checks.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cache.c | 8 | ||||
-rw-r--r-- | src/libnftables.c | 5 |
2 files changed, 9 insertions, 4 deletions
diff --git a/src/cache.c b/src/cache.c index b6ae2310..9e2fe950 100644 --- a/src/cache.c +++ b/src/cache.c @@ -262,8 +262,9 @@ static unsigned int evaluate_cache_list(struct nft_ctx *nft, struct cmd *cmd, return flags; } -unsigned int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds, - struct nft_cache_filter *filter) +int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds, + struct list_head *msgs, struct nft_cache_filter *filter, + unsigned int *pflags) { unsigned int flags = NFT_CACHE_EMPTY; struct cmd *cmd; @@ -318,8 +319,9 @@ unsigned int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds, break; } } + *pflags = flags; - return flags; + return 0; } void table_cache_add(struct table *table, struct nft_cache *cache) diff --git a/src/libnftables.c b/src/libnftables.c index f2a1ef04..a376825d 100644 --- a/src/libnftables.c +++ b/src/libnftables.c @@ -506,7 +506,10 @@ static int nft_evaluate(struct nft_ctx *nft, struct list_head *msgs, int err = 0; filter = nft_cache_filter_init(); - flags = nft_cache_evaluate(nft, cmds, filter); + if (nft_cache_evaluate(nft, cmds, msgs, filter, &flags) < 0) { + nft_cache_filter_fini(filter); + return -1; + } if (nft_cache_update(nft, flags, msgs, filter) < 0) { nft_cache_filter_fini(filter); return -1; |