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

Review code using go-iptables module #924

Merged
merged 2 commits into from Jul 21, 2023

Conversation

SirPhuttel
Copy link
Contributor

Patch 1 makes callers use the module-provided ChainExists() method, it is faster than the custom implementation. This does not bump dependencies, the required version of go-iptables in go.mod is already sufficient.
Patch 2 tries to speed up meta/portmap plugin's teardown() by avoiding an expensive ipt.List() call (in big rulesets). Make it fall back to the old code for unexpected cases.

Starting with v0.5.0, go-iptables exports a fast ChainExists() which
does not rely upon listing all chains and searching the results but
probes chain existence by listing its first rule. This should make a
significant difference in rulesets with thousands of chains.

Signed-off-by: Phil Sutter <psutter@redhat.com>
Just attempt to delete the known rules referring to the custom chain,
then flush and delete it. If the latter succeeds, no referencing rules
are left and the job is done.

If the final flush'n'delete fails, fall back to the referencing rule
search which is slow with large rulesets.

Signed-off-by: Phil Sutter <psutter@redhat.com>
@squeed squeed merged commit 1561794 into containernetworking:main Jul 21, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants