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 into
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 <pholzing@redhat.com>
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 |
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. |
|
@shivkr6 just merged upstream \o/ 🎆 |
Hi, I'll rebase the PR tomorrow and it should be ready to merge |
49b6f1d to
c5e896f
Compare
|
Ohh, looks, like it still has serious troubles to compile... I haven't looked at any rust code in my life before, but it seems, that the netavark rust interface does not fit the netlink-netfilter git code. |
…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 <shivangraghuvanshi2005@gmail.com>
c5e896f to
199f1e6
Compare
|
Looks like some of the testing-farm machines are missing the conntrack binary |
|
I remain LGTM, though we should sort out the testing farm issues before we merge. TYVM @shivkr6 |

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 releaseCC: @Luap99 @mheon