bgp: return BgpConnectionTcp sockets returned by Listener to nonblocking=false#658
Merged
Conversation
It was observed in a customer deployment that several (16) recv loop threads were pinning the CPU due to a busy loop that was constantly handling EAGAIN. Code analysis showed that non_blocking was set to true only for inbound connections, as the Listener<BgpConnectionTcp> was configured to be nonblocking and TCP sockets returned by accept() inherit this setting. The recv loop thread for each BgpConnectionTcp is structured in a way that depends on SO_RCVTIMEO being respected in order to rate limit the busy loop. However, when nonblocking is true SO_RCVTIMEO is ignored and EAGAIN/EWOULDBLOCK is returned immediately -- short-circuiting the timeout that rate limits the busy loop. This explicitly sets nonblocking to false for the new sockets returned by accept(), which ensures that the timeout works to rate limit the busy loop as expected. Fixes: #657
Contributor
Author
|
Output from manual testing below. This was confirmed to only show up for inbound connections. During testing on the interop topology, all connections came up as active/outbound (which I believe is due to #659) and the recv calls didn't sky-rocket until I reconfigured the peers to make them passive on the mgd side (also removing md5 per #659). pre-fix: post-fix: |
rcgoodfellow
approved these changes
Mar 10, 2026
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.
It was observed in a customer deployment that several (16) recv loop threads were pinning the CPU due to a busy loop that was constantly handling EAGAIN.
Code analysis showed that non_blocking was set to true only for inbound connections, as the Listener was configured to be nonblocking and TCP sockets returned by accept() inherit this setting. The recv loop thread for each BgpConnectionTcp is structured in a way that depends on SO_RCVTIMEO being respected in order to rate limit the busy loop. However, when nonblocking is true SO_RCVTIMEO is ignored and EAGAIN/EWOULDBLOCK is returned immediately -- short-circuiting the timeout that rate limits the busy loop.
This explicitly sets nonblocking to false for the new sockets returned by accept(), which ensures that the timeout works to rate limit the busy loop as expected.
Fixes: #657