summaryrefslogtreecommitdiffstats
path: root/src/netlink_linearize.c
diff options
context:
space:
mode:
authorEric Leblond <eric@regit.org>2013-06-09 01:08:47 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2013-06-12 11:41:39 +0200
commitbf371bca68e266ea41805fc3efbb39f82b76e2fe (patch)
tree3775819809be262762ba21c8e679622dcaf81ac9 /src/netlink_linearize.c
parent856789c1546c6356e9b61289db6c5c5f92213145 (diff)
src: fix counter restoration
It was not possible to restore a ruleset countaining counter. The packets and bytes fields were not known from the parser but they were in the output of the list command. This patch fixes the issue by restoring correctly the counters if they are present in the command. Signed-off-by: Eric Leblond <eric@regit.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/netlink_linearize.c')
-rw-r--r--src/netlink_linearize.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index cfd66915..accab9c2 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -440,6 +440,10 @@ static void netlink_gen_counter_stmt(struct netlink_linearize_ctx *ctx,
struct nfnl_nft_expr *nle;
nle = alloc_nft_expr(nfnl_nft_counter_init);
+ if (stmt->counter.packets)
+ nfnl_nft_counter_set_packets(nle, stmt->counter.packets);
+ if (stmt->counter.bytes)
+ nfnl_nft_counter_set_bytes(nle, stmt->counter.bytes);
nfnl_nft_rule_add_expr(ctx->nlr, nle);
}