From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 1/2] cache: prepare nft_cache_evaluate() to return error
Date: Mon, 18 Jul 2022 17:02:26 +0200 [thread overview]
Message-ID: <20220718150227.506532-1-pablo@netfilter.org> (raw)
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>
---
include/cache.h | 5 +++--
src/cache.c | 8 +++++---
src/libnftables.c | 5 ++++-
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/include/cache.h b/include/cache.h
index b6c7d48bfba6..575381ef971b 100644
--- a/include/cache.h
+++ b/include/cache.h
@@ -65,8 +65,9 @@ struct nft_cache_filter {
struct nft_cache;
enum cmd_ops;
-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 *flags);
int nft_cache_update(struct nft_ctx *ctx, enum cmd_ops cmd,
struct list_head *msgs,
const struct nft_cache_filter *filter);
diff --git a/src/cache.c b/src/cache.c
index b6ae2310b175..9e2fe950a884 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 f2a1ef04e80b..a376825d7309 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;
--
2.30.2
next reply other threads:[~2022-07-18 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 15:02 Pablo Neira Ayuso [this message]
2022-07-18 15:02 ` [PATCH nft 2/2] cache: validate handle string length Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220718150227.506532-1-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).