cilium, socklb: Add states filter for the termination iteration#1
Open
MitchLewis930 wants to merge 1 commit intopr_041_beforefrom
Open
cilium, socklb: Add states filter for the termination iteration#1MitchLewis930 wants to merge 1 commit intopr_041_beforefrom
MitchLewis930 wants to merge 1 commit intopr_041_beforefrom
Conversation
Add a state filter to the iterator and skip TCP sockets which are in closing or time wait state. There is no need to spend time to iterate these. Technically, there is no harm since when the client app closes the socket and it goes into time wait state, then upon close the socket LB removes the socket from the revnat map in cil_sock_release.. but then again, no need to iterate through these. Suggested-by: Yusuke Suzuki <yusuke.suzuki@isovalent.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Author
Greptile OverviewGreptile SummaryAdded protocol-specific state filtering for socket termination operations to improve efficiency when iterating and destroying sockets connected to deleted/unhealthy backends. Key Changes:
Critical Issue: Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Reconciler as Socket Termination Loop
participant Filter as SocketFilter
participant Sockets as sockets.Destroy()
participant Netlink as Netlink Socket API
participant Kernel as Linux Kernel
Note over Reconciler: Backend marked unhealthy/deleted
Reconciler->>Filter: Create filter with protocol-specific states
alt TCP Protocol
Filter->>Filter: Set States = StateFilterTCP
else UDP Protocol
Filter->>Filter: Set States = StateFilterUDP (0xffff)
end
Reconciler->>Sockets: Destroy(filter)
Sockets->>Netlink: filterAndDestroySockets(family, protocol, states)
Netlink->>Kernel: Query sockets with state filter
Kernel-->>Netlink: Return matching sockets
loop For each matching socket
Sockets->>Filter: MatchSocket(socketID)
Filter->>Filter: Check destination IP/Port
Filter->>Filter: Check RevNAT map (via DestroyCB)
alt Socket matches filter
Sockets->>Netlink: destroySocket(socketID, states)
Netlink->>Kernel: SOCK_DESTROY with state filter
Kernel-->>Netlink: ACK or ENOENT
end
end
|
| netlink.TCP_NEW_SYN_REC, | ||
| // Sockets in TCP_LISTEN are moved to closing state | ||
| // (net/ipv4/tcp.c#L4908) | ||
| netlink.TCP_CLOSE, |
There was a problem hiding this comment.
Contradicts comment on lines 46-48 which says TCP_CLOSE should be omitted to avoid ENOENT errors
Suggested change
| netlink.TCP_CLOSE, | |
| // Following are handled without any special consideration/just closed |
Prompt To Fix With AI
This is a comment left during a code review.
Path: pkg/datapath/sockets/sockets.go
Line: 69:69
Comment:
Contradicts comment on lines 46-48 which says `TCP_CLOSE` should be omitted to avoid `ENOENT` errors
```suggestion
// Following are handled without any special consideration/just closed
```
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR_041