summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2016-01-07 13:23:33 +0100
committerFlorian Westphal <fw@strlen.de>2016-01-07 13:23:33 +0100
commit757b3ab08b8b22f230fb8e481bec78ecbfbb335a (patch)
tree6da3963f04e13807ed3f660639a177306b014155 /src
parentc2494dd6daac9a91f090504de6d38b7f404f0c1f (diff)
nft: swap key and direction in ct_dir syntax
old: ct saddr original 1.2.3.4 new: ct original saddr 1.2.3.4 The advantage is that this allows to add ct keys where direction is optional without creating ambiguities in the parser. So we can have ct packets gt 42 ct original packets gt 42 Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r--src/ct.c13
-rw-r--r--src/parser_bison.y6
2 files changed, 9 insertions, 10 deletions
diff --git a/src/ct.c b/src/ct.c
index 515e3ebf..ff6cd61b 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -209,19 +209,18 @@ static void ct_expr_print(const struct expr *expr)
{
const struct symbolic_constant *s;
- printf("ct %s", ct_templates[expr->ct.key].token);
-
+ printf("ct ");
if (expr->ct.direction < 0)
- return;
+ goto done;
for (s = ct_dir_tbl.symbols; s->identifier != NULL; s++) {
if (expr->ct.direction == (int) s->value) {
- printf(" %s", s->identifier);
- return;
+ printf("%s ", s->identifier);
+ break;
}
}
-
- printf(" %d", expr->ct.direction);
+ done:
+ printf("%s", ct_templates[expr->ct.key].token);
}
static bool ct_expr_cmp(const struct expr *e1, const struct expr *e2)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index fcf84b9a..ca9b757a 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -2252,18 +2252,18 @@ ct_expr : CT ct_key
{
$$ = ct_expr_alloc(&@$, $2, -1);
}
- | CT ct_key_dir STRING
+ | CT STRING ct_key_dir
{
struct error_record *erec;
int8_t direction;
- erec = ct_dir_parse(&@$, $3, &direction);
+ erec = ct_dir_parse(&@$, $2, &direction);
if (erec != NULL) {
erec_queue(erec, state->msgs);
YYERROR;
}
- $$ = ct_expr_alloc(&@$, $2, direction);
+ $$ = ct_expr_alloc(&@$, $3, direction);
}
;