cilium, socklb: Add states filter for the termination iteration#1
cilium, socklb: Add states filter for the termination iteration#1MitchLewis930 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>
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
User description
PR_041
PR Type
Enhancement
Description
Add TCP and UDP state filters for socket termination operations
Introduce
StateFilterTCPandStateFilterUDPconstants with documented state masksExtend
SocketFilterstruct withStatesfield for granular state filteringUpdate socket destruction logic to use state filters instead of hardcoded values
Apply state filters in load balancer connection termination
Diagram Walkthrough
File Walkthrough
sockets.go
Add state filter constants and update socket filteringpkg/datapath/sockets/sockets.go
stateMask()helper function to create bitmasks from state valuesStateFilterTCPconstant with documented TCP states to filter(excluding TCP_CLOSE and TCP_TIME_WAIT)
StateFilterUDPconstant with all UDP states (0xffff)Statesfield toSocketFilterstructfilterAndDestroySockets()to accept and passstatesparameter0xffffstate filter withfilter.StatesinDestroy()function
termination.go
Apply state filters in connection terminationpkg/loadbalancer/reconciler/termination.go
statesvariable initialization interminateConnectionsToBackend()states = sockets.StateFilterUDPfor UDP protocolstates = sockets.StateFilterTCPfor TCP protocolStates: statestoSocketFilterinDestroy()callsockets_test.go
Update test with state filter fieldpkg/datapath/sockets/sockets_test.go
TestDestroy()test to includeStates: StateFilterUDPinSocketFilterinitialization