conntrack: T7482: Fix custom timeouts #4628
Open
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.
Fix custom conntrack timeout rules and add smoketests
Change summary
Custom timeout rules were previously not working at all.
The problem is that the firewall rules were originally configured to jump directly to the VYOS_CT_TIMEOUT chain from the PREROUTING and OUTPUT base chains. But those two base chains have a priority of raw (-300), and conntrack hooks at priority -200, therefore any rules that modify conntrack entries must have a priority above -200.
So I removed the VYOS_CT_TIMEOUT jumps from PREROUTING and OUTPUT, and created my own prerouting and output base chains with priority -199 to perform the jump to VYOS_CT_TIMEOUT. The two timeout jumping base chains are only created if custom timeout rules have been configured by an administrator.
To tidy up the nftables config, it also removes the empty VYOS_CT_TIMEOUT chain if there are no custom timeout rules created, since nothing else uses it.
I also added much more extensive smoke testing for this to ensure it doesn't accidentally break in the future. Custom timeout rules are very important to have for VoIP, and I'm sure there are plenty of other use cases for it as well.
Types of changes
Related Task(s)
https://vyos.dev/T7482
Related PR(s)
How to test / Smoketest result
Experiment with creating custom conntrack timeout rules and verifying the records are being updated in conntrack.
Here is an IPv4 example using DNS traffic from a server with IP address 172.16.99.2:
Using this DNS example rule, you'll need to generate some DNS queries from your 172.16.99.2 server. You can just use
dig google.com
or ping a domain name.After querying DNS records, run
conntrack -E
orshow conntrack table ipv4 | grep "172.16.99.2"
, and you should see your new timeouts of 700 seconds instead of the default of 30 for unreplied and 180 for stream.Checklist: