feat(firewall): add connection tracking state matching support #3144
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces support for matching connection tracking states (
ctstate) in firewall rules. The changes span API, CRD, and implementation layers, allowing users to specify connection tracking states as match criteria in firewall configurations.This feature extends the firewalling functionalities proposed in the PR #2966, but these two PRs are independent so there is no need to merge #2966 before.
With this update, it is possible to add "ctstate" to the "match" field of a filter rule, for example:
The operations supported are:
How Has This Been Tested?
This feature was tested with a firewall configuration that blocks incoming connections from a specific subnet. Without the rule to accept established or related connections, outgoing connections to that subnet were also blocked because responses were not able to pass through. By adding the match rule with ctstate to allow established and related connections, it was possible to block connections in only one direction.
In addition, the result was checked in nftables, ensuring that the rule was actually added to the chain.