From df84fdeb32c7a76388dd456a835b5f29e0c9caa1 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Sat, 6 Jul 2013 17:33:57 +0200 Subject: 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 Signed-off-by: Pablo Neira Ayuso --- src/parser.y | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/parser.y') 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 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 set_spec set_identifier %destructor { handle_free(&$$); } set_spec set_identifier -%type handle_spec family_spec +%type handle_spec family_spec position_spec %type 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; } ; -- cgit v1.2.3