From a9a599ab675b8feb942355a24934901a9adcef1b Mon Sep 17 00:00:00 2001 From: Shivani Bhardwaj Date: Wed, 24 Feb 2016 01:19:34 +0530 Subject: comment: Add translation to nft Add translation for match comment to nftables. This patch also adds the relevant infrastructure for carrying out the translation. Example: $ sudo iptables-translate -A INPUT -s 192.168.0.0 -m comment --comment "A privatized IP block" nft add rule ip filter INPUT ip saddr 192.168.0.0 counter comment \"A privatized IP block\" Signed-off-by: Shivani Bhardwaj Signed-off-by: Pablo Neira Ayuso --- iptables/nft-ipv6.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'iptables/nft-ipv6.c') diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c index 0ee79575..92d37a02 100644 --- a/iptables/nft-ipv6.c +++ b/iptables/nft-ipv6.c @@ -392,6 +392,7 @@ static void xlate_ipv6_addr(const char *selector, const struct in6_addr *addr, static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl) { const struct iptables_command_state *cs = data; + const char *comment; int ret; if (cs->fw6.ipv6.iniface[0] != '\0') { @@ -435,6 +436,10 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl) /* Always add counters per rule, as in iptables */ xt_xlate_add(xl, "counter "); + comment = xt_xlate_get_comment(xl); + if (comment) + xt_xlate_add(xl, "comment \\\"%s\\\" ", comment); + ret = xlate_action(cs, !!(cs->fw6.ipv6.flags & IP6T_F_GOTO), xl); return ret; -- cgit v1.2.3