Skip to content

portmap: flush UDP conntrack on DEL to avoid hostPort blackhole - #1277

Open
locker95 wants to merge 1 commit into
containernetworking:mainfrom
locker95:fix/portmap-del-flush-conntrack
Open

portmap: flush UDP conntrack on DEL to avoid hostPort blackhole#1277
locker95 wants to merge 1 commit into
containernetworking:mainfrom
locker95:fix/portmap-del-flush-conntrack

Conversation

@locker95

Copy link
Copy Markdown

Summary

cmdAdd already flushes stale UDP conntrack entries after installing DNAT rules (so a replacement pod with a new IP is not blackholed). cmdDel only tore down the iptables/nftables rules and left conntrack alone.

That breaks flipping a pod to hostNetwork: true on the same hostPort: DEL removes the NAT mapping, but leftover UDP conntrack still steers packets at the gone container IP. Traffic to the hostPort blackholes until the entries expire.

This makes DEL flush UDP conntrack the same way ADD does (best-effort; failures are logged only).

Test plan

  • Unit test: deletePortmapStaleConnections is a no-op for TCP-only / empty mappings
  • Linux CI for full portmap package (needs netns/root for integration tests)

Fixes #1190

cmdAdd already deletes stale UDP conntrack entries after installing
DNAT rules so a replacement pod with a new IP is not blackholed. cmdDel
only tore down the iptables/nftables rules and left conntrack alone.

That breaks the common case of flipping a pod to hostNetwork:true on
the same hostPort: DEL removes the NAT mapping, but leftover UDP
conntrack still steers packets at the gone container IP. Flush on DEL
the same way ADD does (best-effort; failures are logged only).

Fixes containernetworking#1190

Signed-off-by: Dean Chen <862469039@qq.com>
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.

[portmap] Setting hostNetwork: true an existing pod with a UDP hostPort to black holes traffic.

1 participant