In order to translate comment matches into the single nftables rule
comment, libxtables does not immediately (maybe mid-rule) print a
comment match's string but instead stores it into struct
xt_xlate::comment array for later.
Since xt_stmt_xlate() is called by a statement's .print callback which
can't communicate data back to caller, nftables has to print it right
away.
Since parser_bison accepts rule comments only at end of line though, the
output from above can't be restored anymore. Which is a bad idea to
begin with so accept this quirk and avoid refactoring the statement
printing API.
Signed-off-by: Phil Sutter <phil@nwl.cc>
break;
}
- if (rc == 1)
+ if (rc == 1) {
nft_print(octx, "%s", xt_xlate_get(xl));
+ if (xt_xlate_get_comment(xl))
+ nft_print(octx, "comment %s",
+ xt_xlate_get_comment(xl));
+ }
xt_xlate_free(xl);
free(entry);
#endif