nftables jump <chain> target invalid argument
Hi,
When attempting to use the jump target to forward traffic to a newly created chain I get the following error:
[root@home nftables]# nft add rule filter forward ip daddr 9.9.9.9 jump new <cmdline>:1:1-49: Error: Could not process rule in batch: Invalid argument add rule filter forward ip daddr 9.9.9.9 jump new ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[root@home nftables]# nft list table filter table ip filter {
chain input {
type filter hook input priority 0; }
chain forward {
type filter hook forward priority 0; }
chain output {
type filter hook output priority 0; }
chain new {
}
}
Is this the correct use of the command?
Thanks!
Hello,
Quoted 8 lines · Alex Chapman
Hi,
When attempting to use the jump target to forward traffic to a newly created chain I get the following error:
[root@home nftables]# nft add rule filter forward ip daddr 9.9.9.9 jump new <cmdline>:1:1-49: Error: Could not process rule in batch: Invalid argument add rule filter forward ip daddr 9.9.9.9 jump new ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Looks like an issue. I'm investigating into it.
BR,
Signature · 2 lines
Eric Leblond <[email protected]> Blog: https://home.regit.org/
cover Fix jump operation
In reply to Alex ChapmanHello,
The jump operation was not correctly working in nftables. This small patchset fixes the issue.
BR,
--
Eric
PATCH 1/3 expression: fix indent
--- src/expression.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/expression.c +1 -1
@@ -156,7 +156,7 @@ static void verdict_expr_clone(struct expr *new, const struct expr *expr)static void verdict_expr_destroy (struct expr *expr) { -xfree (expr->chain); +xfree (expr->chain); }static const struct expr_ops verdict_expr_ops = {
Signature · 1 line
1.8.4.3
PATCH 2/3 jump: fix logic in netlink linearize.
In reply to Eric LeblondLogic in the test was inverted. The result was the jump string not to be set.
--- src/netlink_linearize.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
src/netlink_linearize.c +2 -1
@@ -440,7 +440,8 @@ static void netlink_gen_immediate(struct netlink_linearize_ctx *ctx,nft_rule_expr_set (nle,NFT_EXPR_IMM_DATA , nld.value, nld.len);break ;case EXPR_VERDICT : -if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_CHAIN )) { +if ((expr->chain !=NULL ) && + !nft_rule_expr_is_set (nle,NFT_EXPR_IMM_CHAIN )) {nft_rule_expr_set_str (nle,NFT_EXPR_IMM_CHAIN , nld.chain); }
Signature · 1 line
1.8.4.3
PATCH 3/3 verdict: fix delinearize in case of jump
In reply to Eric LeblondThe name of the chain was not handled in case of a jump or a goto. This patch adds parsing of the chain.
--- src/netlink_delinearize.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
src/netlink_delinearize.c +6 -2
@@ -81,9 +81,13 @@ static void netlink_parse_immediate(struct netlink_parse_ctx *ctx,struct stmt *stmt;struct expr *expr; -if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_VERDICT )) +if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_VERDICT )) { nld.verdict =nft_rule_expr_get_u32 (nle,NFT_EXPR_IMM_VERDICT ); -else if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_DATA )) { +if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_CHAIN )) { + nld.chain =nft_rule_expr_get (nle,NFT_EXPR_IMM_CHAIN , + &nld.len); + } + }else if (nft_rule_expr_is_set (nle,NFT_EXPR_IMM_DATA )) { nld.value =nft_rule_expr_get (nle,NFT_EXPR_IMM_DATA , &nld.len); }
Signature · 1 line
1.8.4.3
Pablo Neira Ayuso
maintainerRe: [nftables PATCh 0/3] Fix jump operation
In reply to Eric LeblondQuoted 5 lines · Eric Leblond
Hello,
The jump operation was not correctly working in nftables. This small patchset fixes the issue.
Seried applied, thanks a lot Eric!