Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Named Counters #20

Open
aojea opened this issue Dec 9, 2024 · 7 comments · May be fixed by #21
Open

Support Named Counters #20

aojea opened this issue Dec 9, 2024 · 7 comments · May be fixed by #21
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@aojea
Copy link
Contributor

aojea commented Dec 9, 2024

This will be very useful to implement metrics in kube-proxy

https://wiki.nftables.org/wiki-nftables/index.php/Counters

@aojea aojea added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 9, 2024
@aojea
Copy link
Contributor Author

aojea commented Dec 9, 2024

/cc @aroradaman

@aroradaman
Copy link
Member

I don't think these counters will be persisted, these will reset to 0 at every sync. Or we will have to parse the current value and use that when rewriting the rules.

That is why we used nfacct for the iptables metrics, may be we can integrate nfacct counters for this.

@aojea
Copy link
Contributor Author

aojea commented Dec 9, 2024

I don't think these counters will be persisted, these will reset to 0 at every sync

that is not how I read it from the documentation, why they will be resetted?

@aroradaman
Copy link
Member

We flush the rules and write them again every sync, so in our use case, they will reset to 0 at every sync.
I'll confirm the behavior.

@aojea
Copy link
Contributor Author

aojea commented Dec 28, 2024

I do think the counters do not reset , they are presented as the alternative to nfacct https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#nfacct

@aroradaman aroradaman linked a pull request Jan 7, 2025 that will close this issue
@aroradaman
Copy link
Member

I do think the counters do not reset , they are presented as the alternative to nfacct https://wiki.nftables.org/wiki-nftables/index.php/Supported_features_compared_to_xtables#nfacct

I tried implementing this, and counters are persisted indeed.

We flush the rules and write them again every sync, so in our use case, they will reset to 0 at every sync.
I'll confirm the behavior.

This thought stemmed from iptables-coutners which were being reset at every sync.

@danwinship
Copy link
Collaborator

If you have "anonymous" counters in your rules (ip daddr @firewalled-ips counter drop) then I think they'd get reset each time you rewrite the rule, but named counters are intentionally persistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants