From 30d45266bf38b209df33e4df1a116c60531ae3e5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 9 Nov 2017 03:42:55 +0100 Subject: expr: extend fwd statement to support address and family Allow to forward packets through to explicit destination and interface. nft add rule netdev x y fwd ip to 192.168.2.200 device eth0 Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 5797ee76..c6491a3b 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -698,6 +698,8 @@ int nft_lex(void *, void *, void *); %destructor { expr_free($$); } rt_expr %type rt_key +%type fwd_key_proto + %type ct_expr %destructor { expr_free($$); } ct_expr %type ct_key ct_dir ct_key_dir_optional ct_key_dir ct_key_proto_field @@ -2675,10 +2677,21 @@ dup_stmt : DUP TO stmt_expr } ; -fwd_stmt : FWD TO expr +fwd_key_proto : IP { $$ = NFPROTO_IPV4; } + | IP6 { $$ = NFPROTO_IPV6; } + ; + +fwd_stmt : FWD TO stmt_expr + { + $$ = fwd_stmt_alloc(&@$); + $$->fwd.dev = $3; + } + | FWD fwd_key_proto TO stmt_expr DEVICE stmt_expr { $$ = fwd_stmt_alloc(&@$); - $$->fwd.to = $3; + $$->fwd.family = $2; + $$->fwd.addr = $4; + $$->fwd.dev = $6; } ; -- cgit v1.2.3