* [PATCH 0/2] parser_bison: delete chains via chain handle
@ 2018-01-09 18:58 Harsha Sharma
2018-01-09 18:59 ` [PATCH 1/2] src: Print handle attribute in chains Harsha Sharma
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Harsha Sharma @ 2018-01-09 18:58 UTC (permalink / raw)
To: pablo, harshasharmaiitr; +Cc: netfilter-devel
Print chain handles with option '-a' and delete chains via chain handle
Harsha Sharma (2):
src: Print handle attribute in chains
parser_bison: extend nft to delete chain via chain handle
src/parser_bison.y | 16 ++++++++++++++--
src/rule.c | 5 ++++-
2 files changed, 18 insertions(+), 3 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] src: Print handle attribute in chains
2018-01-09 18:58 [PATCH 0/2] parser_bison: delete chains via chain handle Harsha Sharma
@ 2018-01-09 18:59 ` Harsha Sharma
2018-01-09 18:59 ` [PATCH 2/2] parser_bison: extend nft to delete chain via chain handle Harsha Sharma
2018-01-10 15:34 ` [PATCH 0/2] parser_bison: delete chains " Pablo Neira Ayuso
2 siblings, 0 replies; 5+ messages in thread
From: Harsha Sharma @ 2018-01-09 18:59 UTC (permalink / raw)
To: pablo, harshasharmaiitr; +Cc: netfilter-devel
Print handle attribute in chains when listing via '-a' option.
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
src/rule.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/rule.c b/src/rule.c
index e875816..7d66c22 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -694,7 +694,10 @@ static void chain_print(const struct chain *chain, struct output_ctx *octx)
rule_print(rule, octx);
nft_print(octx, "\n");
}
- nft_print(octx, "\t}\n");
+ nft_print(octx, "\t}");
+ if (octx->handle > 0)
+ nft_print(octx, " # handle %" PRIu64, chain->handle.handle.id);
+ nft_print(octx, "\n");
}
void chain_print_plain(const struct chain *chain, struct output_ctx *octx)
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] parser_bison: extend nft to delete chain via chain handle
2018-01-09 18:58 [PATCH 0/2] parser_bison: delete chains via chain handle Harsha Sharma
2018-01-09 18:59 ` [PATCH 1/2] src: Print handle attribute in chains Harsha Sharma
@ 2018-01-09 18:59 ` Harsha Sharma
2018-01-10 15:34 ` [PATCH 0/2] parser_bison: delete chains " Pablo Neira Ayuso
2 siblings, 0 replies; 5+ messages in thread
From: Harsha Sharma @ 2018-01-09 18:59 UTC (permalink / raw)
To: pablo, harshasharmaiitr; +Cc: netfilter-devel
This patch allows deletion of chains via unique chain handles which
can be listed with '-a' option and table name and family.
For eg.
nft delete chain [<family>] <table-name> [handle <handle>]
Signed-off-by: Harsha Sharma <harshasharmaiitr@gmail.com>
---
src/parser_bison.y | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index a5c47c2..dbe80a5 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -495,8 +495,8 @@ int nft_lex(void *, void *, void *);
%type <cmd> base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd list_cmd reset_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd
%destructor { cmd_free($$); } base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd list_cmd reset_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd
-%type <handle> table_spec tableid_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec
-%destructor { handle_free(&$$); } table_spec tableid_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec
+%type <handle> table_spec tableid_spec chain_spec chainid_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec
+%destructor { handle_free(&$$); } table_spec tableid_spec chain_spec chainid_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec
%type <handle> set_spec set_identifier obj_spec obj_identifier
%destructor { handle_free(&$$); } set_spec set_identifier obj_spec obj_identifier
%type <val> family_spec family_spec_explicit chain_policy prio_spec
@@ -986,6 +986,10 @@ delete_cmd : TABLE table_spec
{
$$ = cmd_alloc(CMD_DELETE, CMD_OBJ_CHAIN, &$2, &@$, NULL);
}
+ | CHAIN chainid_spec
+ {
+ $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_CHAIN, &$2, &@$, NULL);
+ }
| RULE ruleid_spec
{
$$ = cmd_alloc(CMD_DELETE, CMD_OBJ_RULE, &$2, &@$, NULL);
@@ -1680,6 +1684,14 @@ chain_spec : table_spec identifier
}
;
+chainid_spec : table_spec HANDLE NUM
+ {
+ $$ = $1;
+ $$.handle.location = @$;
+ $$.handle.id = $3;
+ }
+ ;
+
chain_identifier : identifier
{
memset(&$$, 0, sizeof($$));
--
2.11.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] parser_bison: delete chains via chain handle
2018-01-09 18:58 [PATCH 0/2] parser_bison: delete chains via chain handle Harsha Sharma
2018-01-09 18:59 ` [PATCH 1/2] src: Print handle attribute in chains Harsha Sharma
2018-01-09 18:59 ` [PATCH 2/2] parser_bison: extend nft to delete chain via chain handle Harsha Sharma
@ 2018-01-10 15:34 ` Pablo Neira Ayuso
2018-01-10 15:35 ` Pablo Neira Ayuso
2 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-10 15:34 UTC (permalink / raw)
To: Harsha Sharma; +Cc: netfilter-devel
On Wed, Jan 10, 2018 at 12:28:24AM +0530, Harsha Sharma wrote:
> Print chain handles with option '-a' and delete chains via chain handle
Harsha, could you send a follow up patch to add tests to tests/shell/
so we can automate that this works fine.
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] parser_bison: delete chains via chain handle
2018-01-10 15:34 ` [PATCH 0/2] parser_bison: delete chains " Pablo Neira Ayuso
@ 2018-01-10 15:35 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2018-01-10 15:35 UTC (permalink / raw)
To: Harsha Sharma; +Cc: netfilter-devel
On Wed, Jan 10, 2018 at 04:34:41PM +0100, Pablo Neira Ayuso wrote:
> On Wed, Jan 10, 2018 at 12:28:24AM +0530, Harsha Sharma wrote:
> > Print chain handles with option '-a' and delete chains via chain handle
>
> Harsha, could you send a follow up patch to add tests to tests/shell/
> so we can automate that this works fine.
Same thing applies to every new handle deletion that you add in your
patches.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-10 15:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-09 18:58 [PATCH 0/2] parser_bison: delete chains via chain handle Harsha Sharma
2018-01-09 18:59 ` [PATCH 1/2] src: Print handle attribute in chains Harsha Sharma
2018-01-09 18:59 ` [PATCH 2/2] parser_bison: extend nft to delete chain via chain handle Harsha Sharma
2018-01-10 15:34 ` [PATCH 0/2] parser_bison: delete chains " Pablo Neira Ayuso
2018-01-10 15:35 ` Pablo Neira Ayuso
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).