summaryrefslogtreecommitdiffstats
path: root/src/parser.y
diff options
context:
space:
mode:
authorEric Leblond <eric@regit.org>2013-07-06 17:33:57 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-07-19 17:48:11 +0200
commitdf84fdeb32c7a76388dd456a835b5f29e0c9caa1 (patch)
treed8d913a8b4c2fe36d91bedaf49f4891be5b1d2fb /src/parser.y
parent4f6c75e40ac8898feaa5ca39f7934268a7f7796a (diff)
src: Add support for insertion inside rule list
This patch adds support to insert and to add rule using a rule handle as reference. The rule handle syntax has an new optional position field which take a handle as argument. Two examples: nft add rule filter output position 5 ip daddr 1.2.3.1 drop nft insert rule filter output position 5 ip daddr 1.2.3.1 drop Signed-off-by: Eric Leblond <eric@regit.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser.y')
-rw-r--r--src/parser.y17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/parser.y b/src/parser.y
index 2923b598..91981e9a 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -326,6 +326,8 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%token SNAT "snat"
%token DNAT "dnat"
+%token POSITION "position"
+
%type <string> identifier string
%destructor { xfree($$); } identifier string
@@ -339,7 +341,7 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%destructor { handle_free(&$$); } table_spec tables_spec chain_spec chain_identifier ruleid_spec
%type <handle> set_spec set_identifier
%destructor { handle_free(&$$); } set_spec set_identifier
-%type <val> handle_spec family_spec
+%type <val> handle_spec family_spec position_spec
%type <table> table_block_alloc table_block
%destructor { table_free($$); } table_block_alloc
@@ -842,10 +844,21 @@ handle_spec : /* empty */
}
;
-ruleid_spec : chain_spec handle_spec
+position_spec : /* empty */
+ {
+ $$ = 0;
+ }
+ | POSITION NUM
+ {
+ $$ = $2;
+ }
+ ;
+
+ruleid_spec : chain_spec handle_spec position_spec
{
$$ = $1;
$$.handle = $2;
+ $$.position = $3;
}
;