Skip to contentSkip to conversation

Correct initial value of bytes counter in nftables rule

PATCH Applied Yanchuan Nian 2 participants 2 messages Jun 19, 2014 – Jun 25, 2014 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Correct initial value of bytes counter in nftables rule

Packages can be accounted by nftables through such command. % nft add rule filter output ip daddr 8.8.8.8 counter

You can also give the initial values of packets and bytes.
% nft add rule filter output ip daddr 8.8.8.8 counter packets 10 bytes 20

But packets and bytes are both initialized to 10 in above command for there is a mistake in the program.

---
 src/netlink_linearize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/netlink_linearize.c +1 -1
index b0ca241..222d102 100644
@@ -545,7 +545,7 @@ static void netlink_gen_counter_stmt(struct netlink_linearize_ctx *ctx,
 	}
 	if (stmt->counter.bytes) {
 		nft_rule_expr_set_u64(nle, NFT_EXPR_CTR_BYTES,
-				      stmt->counter.packets);
+				      stmt->counter.bytes);
 	}
 	nft_rule_add_expr(ctx->nlr, nle);
 }
Signature · 1 line
1.9.3
maintainer Applied
#1 lore raw
Quoted 8 lines · Yanchuan Nian

Packages can be accounted by nftables through such command. % nft add rule filter output ip daddr 8.8.8.8 counter

You can also give the initial values of packets and bytes.
% nft add rule filter output ip daddr 8.8.8.8 counter packets 10 bytes 20

But packets and bytes are both initialized to 10 in above command for there is a mistake in the program.

Applied, thanks.