Repository navigation
listener: add SO_REUSEPORT support for TcpListenSocket by option and UdpListenSocket forcibly - #8884
Conversation
Make TCP listeners supporting SO_REUSEPORT, then each worker thread will create and listen on socket using same address and port. Signed-off-by: lhuang8 <[email protected]>
|
@l8huang I think @danzh2010 is already working on this so this might conflict with her work. I will let her chime in. |
danzh2010
left a comment
There was a problem hiding this comment.
@l8huang, ListenerConfig change is conflicting with what I am doing now. And the SO_REUSEPORT part is not. I still need to address the use case of hot restart in my PR before sending it out for review. But I think you can continue work on protobuf and SO_REUSEPORT change in this PR.
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
|
This PR needs to sync with #8976. After that, do you mind to change this PR to add SO_REUSEPORT support for TcpListenSocket by option and UdpListenSocket all the time? |
Signed-off-by: lhuang8 <[email protected]>
|
@danzh2010 sure, I will merge your change and do so ;) |
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
|
Can you merge master and then we can take a look? Excited to see this land to get SO_REUSEPORT for UDP listeners! /wait |
Signed-off-by: lhuang8 <[email protected]>
|
@danzh2010 @mattklein123 merged master, could you please take a look? |
danzh2010
left a comment
There was a problem hiding this comment.
Thanks for working on this!
l8huang
left a comment
There was a problem hiding this comment.
Thanks for review :)
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, awesome work. Looks great modulo some small comments and sorting out @danzh2010 comment on the additional factories.
/wait
Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
l8huang
left a comment
There was a problem hiding this comment.
thanks for comments
Signed-off-by: lhuang8 <[email protected]>
| // If a listener's port is set to 0, socket_ should be created for reserving a port | ||
| // number, it is handed over to the first worker thread came here. | ||
| // There are several reasons for doing this: | ||
| // - for UDP, once a socket being bound, it begins to receive packets, it can't be |
There was a problem hiding this comment.
As an aside, I'm not sure how much this really matters. There is going to be a delay between creating the socket on the main thread and when the first worker actually steals it (the delay may be very large due to xDS init, etc.). In general this should be covered by downstream health check, etc. This is related to an offline conversation I had with @danzh2010 about UDP and hot restart. I think it probably will never work correctly with stateless protocols like QUIC. I will open an issue to figure out how to deal with that.
mattklein123
left a comment
There was a problem hiding this comment.
Thanks, this works for me. I don't have a strong opinion on the final back and forth between you and @danzh2010. @danzh2010 LMK when you are satisfied. Great work!
> The only need of reuse_port here is to add SO_REUSEPORT option. You can > just embed > (socket_type_ == Network::Address::SocketType::Datagram) ? true : config.reuse_port() > in the if condition. > You can also change ListenerManagerImpl::createListenSocketFactory() to take reuse_port > as parameter, and its caller ListenerManagerImpl::addOrUpdateListener() should also have > access to config. So ListenerImpl doesn't need reusePort() interface. Signed-off-by: lhuang8 <[email protected]>
Signed-off-by: lhuang8 <[email protected]>
|
/azp run envoy-linux |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This change makes TCP and UDP listeners supporting SO_REUSEPORT. For TCP, it can be switched on/off by option 'reuse_port' added to envoy.api.v2.Listener; For UDP, it's always on, the value of 'reuse_port' is ignored.
Signed-off-by: lhuang8 [email protected]
Risk Level: Medium
Testing: Update UTs and integration tests, new UT cases added
Docs Changes:
Release Notes:
Fixes #8794