connection: Add TCP_FASTOPEN listener option#2793
Conversation
|
@dnoe This is related to the other socket-option work you're looking at. |
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
|
Per new release note policy please add a release note with any applicable feature docs to https://github.com/envoyproxy/data-plane-api/blob/master/docs/root/intro/version_history.rst. Thank you! |
|
@mattklein123 I've added a note in envoyproxy/data-plane-api#539 |
|
@bmetzdorf #2734 is in - are you up for pulling and merging? |
|
@alyssawilk yep! Will do in the next couple of days! |
|
@alyssawilk I think I need to wait for #2719 to be merged. |
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
There was a problem hiding this comment.
Please wrap the IP_TRANSPARENT option setting above into if (state != Socket::SocketState::Listening) { ... }.
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
|
|
||
| // Add the options to the socket_ so that SocketState::Listening options can be | ||
| // set in the worker after listen()/evconnlistener_new() is called. | ||
| socket_->addOption(option); |
There was a problem hiding this comment.
Does adding these options here break anything else?
|
I wrote a lot of this code, so removing myself as reviewer |
|
I've tested this latest commit macOS: Linux: |
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
|
|
||
| enum class SocketState { PreBind, PostBind }; | ||
| enum class SocketState { | ||
| PreBind, // after socket creation but before binding the socket to a port |
There was a problem hiding this comment.
I'd suggest moving these to the line previous, e.g.
// Socket options are applied after socket creation but before...
Prebind,
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
htuch
left a comment
There was a problem hiding this comment.
This looks great, just a few more comments.
| #ifdef TCP_FASTOPEN | ||
| #define ENVOY_SOCKET_TCP_FASTOPEN Network::SocketOptionName(TCP_FASTOPEN) | ||
| #else | ||
| #define ENVOY_SOCKET_TCP_FASTOPEN Network::SocketOptionName() |
There was a problem hiding this comment.
Have you tried manually forcing this option and seeing what happens to the tests? In my experience, this is a useful step.
There was a problem hiding this comment.
@htuch Do you mean just enforce TCP_FASTOPEN on all listeners by default and then run the tests?
There was a problem hiding this comment.
I mean as an experiment in your local client, change that #ifdef line to #if 0 and see if bazel test //test/... passes.
|
|
||
| #include "server/configuration_impl.h" | ||
|
|
||
| #ifdef TCP_FASTOPEN |
There was a problem hiding this comment.
I think this can live in socket_option_impl.h alongside the others.
| std::shared_ptr<MockSocketOption> option = std::make_shared<MockSocketOption>(); | ||
| socket.addOption(option); | ||
| EXPECT_CALL(*option, setOption(_, Socket::SocketState::Listening)).WillOnce(Return(false)); | ||
| EXPECT_THROW(TestListenerImpl(dispatcher, socket, listener_callbacks, true, false), |
There was a problem hiding this comment.
Could make this EXPECT_THROW_WITH_MESSAGE to get better precision on why we see the exception.
There was a problem hiding this comment.
Yes, I'm working on this one.
| TEST_F(SocketOptionImplTest, SetOptionFreebindPostBind) { | ||
| SocketOptionImpl socket_option{{}, true}; | ||
| EXPECT_TRUE(socket_option.setOption(socket_, Socket::SocketState::PostBind)); | ||
| testSetSocketOptionSuccess(socket_option, IPPROTO_IP, ENVOY_SOCKET_IP_FREEBIND, 0, |
| Api::MockOsSysCalls os_sys_calls_; | ||
| TestThreadsafeSingletonInjector<Api::OsSysCallsImpl> os_calls{&os_sys_calls_}; | ||
|
|
||
| void testSetSocketOptionSuccess(ListenerSocketOptionImpl& socket_option, int socket_level, |
There was a problem hiding this comment.
Could this subclass SocketOptionImplTest and inherit this method?
There was a problem hiding this comment.
@bmetzdorf can you give me a quick yes/no on the various feedback? Thanks!
There was a problem hiding this comment.
Yes, I'm working on this one.
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
| #ifdef TCP_FASTOPEN | ||
| #define ENVOY_SOCKET_TCP_FASTOPEN Network::SocketOptionName(TCP_FASTOPEN) | ||
| #else | ||
| #define ENVOY_SOCKET_TCP_FASTOPEN Network::SocketOptionName() |
There was a problem hiding this comment.
@htuch Do you mean just enforce TCP_FASTOPEN on all listeners by default and then run the tests?
| ENVOY_LOG(debug, "Successfully set socket option TCP_FASTOPEN to {}", tfo_value); | ||
| } | ||
| } else { | ||
| ENVOY_LOG(warn, "Unsupported socket option TCP_FASTOPEN"); |
Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
|
@htuch Please let me know if |
| namespace Network { | ||
| namespace { | ||
|
|
||
| class SocketOptionTestHarness : public testing::Test { |
There was a problem hiding this comment.
Yep, this looks good. As a nit, I would probably call it SocketOptionTestBase or SocketOptionTest.
htuch
left a comment
There was a problem hiding this comment.
Thanks @bmetzdorf. Merging to unblock #3042, @bmetzdorf has signed up to address remaining minor feedback in a followup PR.
Add TCP_FASTOPEN listener option API changes for: envoyproxy/envoy#2793 Signed-off-by: Bjoern Metzdorf <bmetzdorf@apple.com>
connection: Add TCP_FASTOPEN listener option
This allows accepting TCP_FASTOPEN based connections. Works on both Linux and OSX.
Feedback on this is very welcome. It was tested manually on Linux and OSX.
API Changes: envoyproxy/data-plane-api#539
Signed-off-by: Bjoern Metzdorf bmetzdorf@apple.com
Risk Level: Low