From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net, arturo.borrero.glez@gmail.com, fw@strlen.de
Subject: [PATCH 2/2 nft] evaluate: use table_lookup_global() from expr_evaluate_symbol()
Date: Mon, 14 Mar 2016 20:38:28 +0100 [thread overview]
Message-ID: <1457984308-23864-2-git-send-email-pablo@netfilter.org> (raw)
In-Reply-To: <1457984308-23864-1-git-send-email-pablo@netfilter.org>
If there's already a table 'test' defined in the kernel and you load
another table 'test' via `nft -f', table_lookup() returns the table
that already exists in the kernel, so if you look up for objects that
are defined in the file, nft bails out with 'Set does not exist'.
Use table_lookup_global() function returns the existing table that is
defined in the file and that it is set as context via
ctx->handle->table.
This is not a complete fix, we should splice the existing kernel objects
into the userspace declaration. We just need some way to identify what
objects are already in the kernel so we don't send them again (otherwise
we will hit EEXIST errors). I'll follow up with this full fix asap.
Anyway, this patch fixes this shell test:
I: [OK] ./testcases/sets/cache_handling_0
So at least by now we have all shell test returning OK. I'll add more
tests to catch the case I describe above once it is fixed too.
Cc: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/evaluate.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 45d585d..1cd77cb 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -155,6 +155,20 @@ static int byteorder_conversion(struct eval_ctx *ctx, struct expr **expr,
return 0;
}
+static struct table *table_lookup_global(struct eval_ctx *ctx)
+{
+ struct table *table;
+
+ if (ctx->table != NULL)
+ return ctx->cmd->table;
+
+ table = table_lookup(&ctx->cmd->handle);
+ if (table == NULL)
+ return NULL;
+
+ return table;
+}
+
/*
* Symbol expression: parse symbol and evaluate resulting expression.
*/
@@ -189,7 +203,7 @@ static int expr_evaluate_symbol(struct eval_ctx *ctx, struct expr **expr)
if (ret < 0)
return cmd_error(ctx, "Could not process rule: Cannot list sets");
- table = table_lookup(&ctx->cmd->handle);
+ table = table_lookup_global(ctx);
if (table == NULL)
return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
ctx->cmd->handle.table);
@@ -2073,20 +2087,6 @@ int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt)
}
}
-static struct table *table_lookup_global(struct eval_ctx *ctx)
-{
- struct table *table;
-
- if (ctx->table != NULL)
- return ctx->cmd->table;
-
- table = table_lookup(&ctx->cmd->handle);
- if (table == NULL)
- return NULL;
-
- return table;
-}
-
static int setelem_evaluate(struct eval_ctx *ctx, struct expr **expr)
{
struct table *table;
--
2.1.4
next prev parent reply other threads:[~2016-03-14 19:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-14 19:38 [PATCH 1/2 nft] src: revisit cache population logic Pablo Neira Ayuso
2016-03-14 19:38 ` Pablo Neira Ayuso [this message]
2016-03-15 11:14 ` 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=1457984308-23864-2-git-send-email-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=arturo.borrero.glez@gmail.com \
--cc=fw@strlen.de \
--cc=kaber@trash.net \
--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).