summaryrefslogtreecommitdiffstats
path: root/iptables/nft-ipv4.c
diff options
context:
space:
mode:
authorShivani Bhardwaj <shivanib134@gmail.com>2016-02-24 01:19:34 +0530
committerPablo Neira Ayuso <pablo@netfilter.org>2016-02-29 13:32:48 +0100
commita9a599ab675b8feb942355a24934901a9adcef1b (patch)
tree872d0db62e83241488d4742e5a3760ae11e05869 /iptables/nft-ipv4.c
parent3bc0951c107c5da741a330ba5df49a2c823f5e5d (diff)
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 <shivanib134@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/nft-ipv4.c')
-rw-r--r--iptables/nft-ipv4.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index 5e2857d3..cf985b73 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -432,6 +432,7 @@ static void nft_ipv4_save_counters(const void *data)
static int nft_ipv4_xlate(const void *data, struct xt_xlate *xl)
{
const struct iptables_command_state *cs = data;
+ const char *comment;
int ret;
if (cs->fw.ip.iniface[0] != '\0') {
@@ -484,6 +485,10 @@ static int nft_ipv4_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->fw.ip.flags & IPT_F_GOTO), xl);
return ret;