From 3fdc7541fba079f9626bcb1605368a7da3a8d81a Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sat, 26 Oct 2019 13:15:10 +0200 Subject: src: add multidevice support for netdev chain This patch allows you to specify multiple netdevices to be bound to the netdev basechain, eg. # nft add chain netdev x y { \ type filter hook ingress devices = { eth0, eth1 } priority 0\; } json codebase has been updated to support for one single device with the existing representation, no support for multidevice is included in this patch. Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 11f0dc8b..7f9b1752 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -564,11 +564,11 @@ int nft_lex(void *, void *, void *); %type family_spec family_spec_explicit %type int_num chain_policy %type extended_prio_spec prio_spec -%type extended_prio_name -%destructor { xfree($$); } extended_prio_name +%type extended_prio_name quota_unit +%destructor { xfree($$); } extended_prio_name quota_unit -%type dev_spec quota_unit -%destructor { xfree($$); } dev_spec quota_unit +%type dev_spec +%destructor { xfree($$); } dev_spec %type table_block_alloc table_block %destructor { close_scope(state); table_free($$); } table_block_alloc @@ -1992,7 +1992,7 @@ hook_spec : TYPE STRING HOOK STRING dev_spec prio_spec } xfree($4); - $0->dev = $5; + $0->dev_expr = $5; $0->priority = $6; $0->flags |= CHAIN_F_BASECHAIN; } @@ -2072,7 +2072,21 @@ int_num : NUM { $$ = $1; } | DASH NUM { $$ = -$2; } ; -dev_spec : DEVICE string { $$ = $2; } +dev_spec : DEVICE string + { + struct expr *expr; + + expr = constant_expr_alloc(&@$, &string_type, + BYTEORDER_HOST_ENDIAN, + strlen($2) * BITS_PER_BYTE, $2); + $$ = compound_expr_alloc(&@$, EXPR_LIST); + compound_expr_add($$, expr); + + } + | DEVICES '=' flowtable_expr + { + $$ = $3; + } | /* empty */ { $$ = NULL; } ; -- cgit v1.2.3