libnftables: remove set element uncollapse for error reporting
Pablo Neira Ayuso
maintainerPATCH v2 1/1 libnftables: remove set element uncollapse for error reporting
Error reporting works fine with recent -stable kernels:
# cat ruleset.nft
add table ip x
add chain ip x y
add set ip x y { type ipv4_addr; }
create element ip x y { 1.1.1.1 }
create element ip x y { 1.1.1.1 } # nft -f ruleset.nft
ruleset.nft:5:25-31: Error: Could not process rule: File exists
create element ip x y { 1.1.1.1 }
^^^^^^^which is provided by this small "fix":
commit b53c116642502b0c85ecef78bff4f826a7dd4145
Author: Pablo Neira Ayuso <[email protected]>
Date: Fri May 20 00:02:06 2022 +0200
netfilter: nf_tables: set element extended ACK reporting support
no need to relate commands via sequence number, ditch this expensive workaround in userspace.
Release collapsed commands from list since they contain no elements anymore.
Fixes 498a5f0c219d ("rule: collapse set element commands")
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v2: release empty command object after collapsing elements.
include/cmd.h | 2 +- include/expression.h | 1 - include/rule.h | 1 - src/cmd.c | 42 +++++------------------------------------- src/libnftables.c | 7 +------ src/rule.c | 1 - 6 files changed, 7 insertions(+), 47 deletions(-)
include/cmd.h +1 -1
@@ -7,7 +7,7 @@ void nft_cmd_error(struct netlink_ctx *ctx, struct cmd *cmd,void nft_cmd_expand (struct cmd *cmd);void nft_cmd_post_expand (struct cmd *cmd); -bool nft_cmd_collapse (struct list_head *cmds); +void nft_cmd_collapse (struct list_head *cmds);void nft_cmd_uncollapse (struct list_head *cmds);#endif
include/expression.h +0 -1
@@ -255,7 +255,6 @@ struct expr { enum expr_types etype:8; enum ops op:8;unsigned int len; -struct cmd *cmd; union { struct {
include/rule.h +0 -1
@@ -718,7 +718,6 @@ struct cmd {enum cmd_obj obj;struct handle handle;uint32_t seqnum; -struct list_head collapse_list;union {void *data;struct expr *expr;
src/cmd.c +5 -37
59 lines not on this page · raw message
src/libnftables.c +1 -6
@@ -513,7 +513,6 @@ static int nft_evaluate(struct nft_ctx *nft, struct list_head *msgs, {struct nft_cache_filter *filter;struct cmd *cmd, *next; -bool collapsed = false;unsigned int flags;int err =0 ;
@@ -529,8 +528,7 @@ static int nft_evaluate(struct nft_ctx *nft, struct list_head *msgs,nft_cache_filter_fini (filter); -if (nft_cmd_collapse (cmds)) - collapsed = true; +nft_cmd_collapse (cmds);list_for_each_entry (cmd, cmds, list) { if (cmd->op != CMD_ADD &&
@@ -553,9 +551,6 @@ static int nft_evaluate(struct nft_ctx *nft, struct list_head *msgs, } } -if (collapsed) -nft_cmd_uncollapse (cmds); -if (err <0 || nft->state->nerrs)return -1 ;
src/rule.c +0 -1
@@ -1332,7 +1332,6 @@ struct cmd *cmd_alloc(enum cmd_ops op, enum cmd_obj obj, cmd->attr =xzalloc_array (NFT_NLATTR_LOC_MAX ,sizeof (struct nlerr_loc )); cmd->attr_array_len =NFT_NLATTR_LOC_MAX ; -init_list_head (&cmd->collapse_list);return cmd; }
Signature · 1 line
2.30.2