path: root/src/netlink_linearize.c
diff options
authorEric Leblond <>2013-06-09 01:08:47 +0200
committerPablo Neira Ayuso <>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 <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'src/netlink_linearize.c')
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);