Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Clear stale conntrack UDP entries for nodePorts
When an EndpointSlice for a UDP NodePort or loadbalancer type of service
is updated, stale conntrack entries for removed endpoints must be
flushed. The existing logic failed to do this correctly if the backend
pod was on a different node. This patch fixes the issue by flushing
conntrack entries by filtering the nodePort when the node is not
hosting the backend pod.

In case that the backend pod was on the same node as the service, this
issue won't happen. Since all old pod entries are removed from the node
by the function deletePodConntrack when the pod is deleted.

Signed-off-by: Peng Liu <pliu@redhat.com>
(cherry picked from commit b426934)
Signed-off-by: Venkata Charan Sunku <vsunku@redhat.com>
  • Loading branch information
pliurh authored and sunku5494 committed Feb 27, 2026
commit 46ce09a9e9ad75d388fa9ff678afb814e6c46e89
13 changes: 12 additions & 1 deletion go-controller/pkg/node/default_node_network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1474,13 +1474,24 @@ func (nc *DefaultNodeNetworkController) reconcileConntrackUponEndpointSliceEvent
klog.Errorf("Failed to get service port for endpoint %s: %v", oldIPStr, err)
continue
}
// upon update and delete events, flush conntrack only for UDP
// upon update and delete events, flush UDP conntrack for Service port
klog.V(5).Infof("Deleting conntrack entry for endpoint %s, port %d, protocol %s", oldIPStr, servicePort.Port, *oldPort.Protocol)
if err := util.DeleteConntrackServicePort(oldIPStr, servicePort.Port, *oldPort.Protocol,
netlink.ConntrackReplyAnyIP, nil); err != nil {
klog.Errorf("Failed to delete conntrack entry for %s port %d: %v", oldIPStr, servicePort.Port, err)
errors = append(errors, err)
}

// Flush UDP conntrack entries for NodePort (and LoadBalancer services that allocate NodePorts)
// TODO: Once vishvananda/netlink support ConntrackFilterType '--reply-port-src', we can use one DeleteConntrackServicePort() call
// conntrack entries for both ClusterIP and NodePort.
if util.ServiceTypeHasNodePort(svc) && servicePort.NodePort > 0 {
if err := util.DeleteConntrackServicePort(oldIPStr, servicePort.NodePort, *oldPort.Protocol,
netlink.ConntrackReplyAnyIP, nil); err != nil {
klog.Errorf("Failed to delete conntrack entry for %s NodePort %d: %v", oldIPStr, servicePort.NodePort, err)
errors = append(errors, err)
}
}
}
}
}
Expand Down
Loading