Add translation for comment module to nftables. Examples: $ sudo iptables-translate -A INPUT -m comment --comment "random comment" nft add rule ip filter INPUT counter comment \"random comment\" $ sudo iptables-translate -A INPUT -i eth1 -m comment --comment "Local LAN" nft add rule ip filter INPUT iifname eth1 counter comment \"Local LAN\" Signed-off-by: Shivani Bhardwaj <shivanib134@xxxxxxxxx> --- extensions/libxt_comment.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/extensions/libxt_comment.c b/extensions/libxt_comment.c index 6ed2ff9..bbbd6cb 100644 --- a/extensions/libxt_comment.c +++ b/extensions/libxt_comment.c @@ -48,6 +48,18 @@ comment_save(const void *ip, const struct xt_entry_match *match) xtables_save_string(commentinfo->comment); } +static int +comment_xlate(const struct xt_entry_match *match, + struct xt_buf *buf, int numeric) +{ + struct xt_comment_info *commentinfo = (void *)match->data; + + commentinfo->comment[XT_MAX_COMMENT_LEN-1] = '\0'; + xt_buf_add(buf, "counter comment \\\"%s\\\" ", commentinfo->comment); + + return 1; +} + static struct xtables_match comment_match = { .family = NFPROTO_UNSPEC, .name = "comment", @@ -55,10 +67,11 @@ static struct xtables_match comment_match = { .size = XT_ALIGN(sizeof(struct xt_comment_info)), .userspacesize = XT_ALIGN(sizeof(struct xt_comment_info)), .help = comment_help, - .print = comment_print, - .save = comment_save, + .print = comment_print, + .save = comment_save, .x6_parse = xtables_option_parse, .x6_options = comment_opts, + .xlate = comment_xlate, }; void _init(void) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html