From c156232a530b30b6668712eda22bc491b0900283 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado Gomez" Date: Fri, 21 Aug 2020 18:40:30 +0200 Subject: src: add comment support when adding tables Adds userdata building logic if a comment is specified when creating a new table. Adds netlink userdata parsing callback function. Relies on kernel supporting userdata for nft_table. Example: > nft add table ip x { comment "test"\; } > nft list ruleset table ip x { comment "test" } Signed-off-by: Jose M. Guisado Gomez Signed-off-by: Pablo Neira Ayuso --- src/rule.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/rule.c') diff --git a/src/rule.c b/src/rule.c index a925d844..2c4b5dbe 100644 --- a/src/rule.c +++ b/src/rule.c @@ -1324,6 +1324,8 @@ void table_free(struct table *table) if (--table->refcnt > 0) return; + if (table->comment) + xfree(table->comment); list_for_each_entry_safe(chain, next, &table->chains, list) chain_free(chain); list_for_each_entry_safe(chain, next, &table->chain_bindings, list) @@ -1422,6 +1424,9 @@ static void table_print(const struct table *table, struct output_ctx *octx) nft_print(octx, "\n"); table_print_options(table, &delim, octx); + if (table->comment) + nft_print(octx, "\tcomment \"%s\"\n", table->comment); + list_for_each_entry(obj, &table->objs, list) { nft_print(octx, "%s", delim); obj_print(obj, octx); -- cgit v1.2.3