diff options
-rw-r--r-- | include/rule.h | 1 | ||||
-rw-r--r-- | src/rule.c | 16 | ||||
-rw-r--r-- | src/xt.c | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/include/rule.h b/include/rule.h index ad9f9127..00a1bac5 100644 --- a/include/rule.h +++ b/include/rule.h @@ -169,6 +169,7 @@ struct table { unsigned int refcnt; uint32_t owner; const char *comment; + bool has_xt_stmts; }; extern struct table *table_alloc(void); @@ -1233,6 +1233,11 @@ static void table_print(const struct table *table, struct output_ctx *octx) const char *delim = ""; const char *family = family2str(table->handle.family); + if (table->has_xt_stmts) + fprintf(octx->error_fp, + "# Warning: table %s %s is managed by iptables-nft, do not touch!\n", + family, table->handle.table.name); + nft_print(octx, "table %s %s {", family, table->handle.table.name); if (nft_output_handle(octx) || table->flags & TABLE_F_OWNER) nft_print(octx, " #"); @@ -2387,9 +2392,14 @@ static int do_list_tables(struct netlink_ctx *ctx, struct cmd *cmd) static void table_print_declaration(struct table *table, struct output_ctx *octx) { - nft_print(octx, "table %s %s {\n", - family2str(table->handle.family), - table->handle.table.name); + const char *family = family2str(table->handle.family); + + if (table->has_xt_stmts) + fprintf(octx->error_fp, + "# Warning: table %s %s is managed by iptables-nft, do not touch!\n", + family, table->handle.table.name); + + nft_print(octx, "table %s %s {\n", family, table->handle.table.name); } static int do_list_chain(struct netlink_ctx *ctx, struct cmd *cmd, @@ -238,6 +238,7 @@ void netlink_parse_match(struct netlink_parse_ctx *ctx, stmt->xt.name = strdup(name); stmt->xt.type = NFT_XT_MATCH; #endif + ctx->table->has_xt_stmts = true; rule_stmt_append(ctx->rule, stmt); } @@ -283,6 +284,7 @@ void netlink_parse_target(struct netlink_parse_ctx *ctx, stmt->xt.name = strdup(name); stmt->xt.type = NFT_XT_TARGET; #endif + ctx->table->has_xt_stmts = true; rule_stmt_append(ctx->rule, stmt); } |