firewall: flush stale UDP conntrack entries on port_forward setup/teardown#1362
firewall: flush stale UDP conntrack entries on port_forward setup/teardown#1362shivkr6 wants to merge 1 commit intocontainers:mainfrom
Conversation
|
The unit tests seem to be failing because conntrack-tools is not installed in CI/CD |
f61d2f3 to
0731a48
Compare
0731a48 to
82cb21c
Compare
|
Ephemeral COPR build failed. @containers/packit-build please check. |
2 similar comments
|
Ephemeral COPR build failed. @containers/packit-build please check. |
|
Ephemeral COPR build failed. @containers/packit-build please check. |
|
I moved the conntrack entries flushing code to the end of all setup_port_forward and teardown_port_forward functions, instead of keeping it at the start, to avoid a potential race condition where a new conntrack entry is created after the flush but before the port forwarding rules are completely set up. |
82cb21c to
86d1881
Compare
Yes we can do that. I make that happen. |
Needed for containers/netavark#1362 Signed-off-by: Paul Holzinger <[email protected]>
425517c to
107bf6b
Compare
|
#1363 this should include conntrack now (once that merges you can rebase) |
|
#1363 was merged so CI should have access to conntrack I hope. |
107bf6b to
e6104d8
Compare
|
|
b07535a to
bf8e6dc
Compare
|
I have an error message nit, but on the whole LGTM |
| rand = "0.9.2" | ||
| sha2 = "0.10.9" | ||
| netlink-packet-route = "0.25.1" | ||
| netlink-packet-netfilter = { git = "https://github.com/shivkr6/netlink-packet-netfilter.git", branch = "conntrack-new" } |
There was a problem hiding this comment.
just so it is not overlooked, we cannot merge this while the upstream lib isn't merged so I mark as changes requested
|
Forgot to say overall great work! |
bf8e6dc to
bcb10cb
Compare
Thanks! The appreciation from you and Matt really keeps my motivation and confidence high |
|
It's extremely weird that the |
bcb10cb to
343b730
Compare
…rdown Add a new netlink_netfilter module to interact with the kernel's conntrack table using the netlink_packet_netfilter crate. This module allows dumping and deleting conntrack entries. All firewall drivers now call the new flush_udp_conntrack() function during port forwarding setup and teardown. When a container with a UDP port mapping is started, stale conntrack entries can prevent traffic from reaching the new container instance. This change proactively deletes these stale entries for the mapped UDP ports, ensuring that new connections are not dropped by the kernel. Added an integration test for the same and unit tests for dump_conntrack and del_conntrack. Fixes: containers#1045 Signed-off-by: Shivang K Raghuvanshi <[email protected]>
343b730 to
49b6f1d
Compare
|
I skipped the |
|
Tests green, just waiting on that upstream library now. Nice work @shivkr6 |
|
Thanks @mheon. The bigger PR, rust-netlink/netlink-packet-netfilter#12, got merged. The remaining smaller PRs yet to be merged are rust-netlink/netlink-packet-netfilter#14 and rust-netlink/netlink-packet-netfilter#15 CC @Luap99 |
Those two appear to be merged now. Any other blockers? EDIT: Crate needs to publish a new release, since there doesn't seem to be any activity there pushing that along I've opened an issue requesting that. |
|
@polarathene , the maintainer of the rust-netlink crates, said: He wants the subsystem layout of netlink-packet-netfilter to be similar to netlink-packet-route. I’m open to doing the subsystem layout rewrite around February or March 2026; I have some exams right now. |
I don't see how that's a release blocker 🤔
No worries though, thanks for chiming in with an update! 😁 |
|
@polarathene That is not up for us to decide but the maintainer of that crate though. |

Add a new netlink_netfilter module to interact with the kernel's conntrack table using the netlink_packet_netfilter crate. This module allows dumping and deleting conntrack entries. All firewall drivers now call the new flush_udp_conntrack() function during port forwarding setup and teardown.
When a container with a UDP port mapping is started, stale conntrack entries can prevent traffic from reaching the new container instance. This change proactively deletes these stale entries for the mapped UDP ports, ensuring that new connections are not dropped by the kernel.
Fixes: #1045
NOTE: This PR cannot be merged right now because:
1) I'm waiting for my PRs to be merged in the netlink-packet-netfilter crate.[DONE]2) I have to write integration tests to test this functionality.[DONE]3) netlink-packet-netfilter new release
CC: @Luap99 @mheon