summaryrefslogtreecommitdiffstats
path: root/iptables/nft-shared.c
diff options
context:
space:
mode:
authorPablo M. Bermudo Garay <pablombg@gmail.com>2016-08-02 16:29:47 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-09 10:41:14 +0200
commita44bee8c3582cb72868a3b7f703494dd2b24bf7d (patch)
tree2cdfbc1527e110fdb704d75acd9ea46b299fe4bd /iptables/nft-shared.c
parent175a0148eb53289691b757358b84f5c3b31b72ea (diff)
xtables-compat: fix comments listing
ip[6]tables-compat -L was not printing the comments since commit d64ef34a9961 ("iptables-compat: use nft built-in comments support"). This patch solves the issue. Signed-off-by: Pablo M. Bermudo Garay <pablombg@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'iptables/nft-shared.c')
-rw-r--r--iptables/nft-shared.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index 4007cbcc..68e5c55d 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -525,6 +525,32 @@ void nft_rule_to_iptables_command_state(struct nftnl_rule *r,
nftnl_expr_iter_destroy(iter);
+ if (nftnl_rule_is_set(r, NFTNL_RULE_USERDATA)) {
+ const void *data;
+ uint32_t len;
+ struct xtables_match *match;
+ struct xt_entry_match *m;
+
+ data = nftnl_rule_get_data(r, NFTNL_RULE_USERDATA, &len);
+ match = xtables_find_match("comment", XTF_TRY_LOAD,
+ &cs->matches);
+ if (match == NULL)
+ return;
+
+ m = calloc(1, sizeof(struct xt_entry_match) + len);
+ if (m == NULL) {
+ fprintf(stderr, "OOM");
+ exit(EXIT_FAILURE);
+ }
+
+ memcpy(&m->data, get_comment(data, len), len);
+ m->u.match_size = len + XT_ALIGN(sizeof(struct xt_entry_match));
+ m->u.user.revision = 0;
+ strcpy(m->u.user.name, match->name);
+
+ match->m = m;
+ }
+
if (cs->target != NULL)
cs->jumpto = cs->target->name;
else if (cs->jumpto != NULL)