]> git.ipfire.org Git - thirdparty/nftables.git/commit
json: collapse set element commands from parser
authorPablo Neira Ayuso <pablo@netfilter.org>
Thu, 31 Oct 2024 20:38:02 +0000 (21:38 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 5 Nov 2024 20:57:18 +0000 (21:57 +0100)
commit193faa5475a5df7d9ac0b1a8fe647196de3e5688
tree9477a08597765474ea50f884faed2c54a1481917
parent0373ca62be3c11a58bd462ee0689718ad25142b6
json: collapse set element commands from parser

Update json parser to collapse {add,create} element commands to reduce
memory consumption in the case of large sets defined by one element per
command:

{"nftables": [{"add": {"element": {"family": "ip", "table": "x", "name":
"y", "elem": [{"set": ["1.1.0.0"]}]}}},...]}

Add CTX_F_COLLAPSED flag to report that command has been collapsed.

This patch reduces memory consumption by ~32% this case.

Fixes: 20f1c60ac8c8 ("src: collapse set element commands from parser")
Reported-by: Eric Garver <eric@garver.life>
Tested-by: Eric Garver <eric@garver.life>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_json.c