Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: add timeout for transport connect #13610

Merged
merged 12 commits into from
Oct 27, 2020

Conversation

akonradi
Copy link
Contributor

Commit Message: Add a timeout for how long an incoming connection has to establish a transport-level connection
Additional Description:
Adds a configurable timeout for the amount of time a downstream client is allowed to finish the transport-level connect before the connection is forcefully terminated. This can be used to require that a client finishes the TLS handshake in a bounded amount of time.

Risk Level: low
Testing: added unit tests
Docs Changes: document new field
Release Notes: document new feature
Platform Specific Features: none

Addresses #11426

Add a new interface and impl class for incoming connections to the
server. This class currently adds no methods on top of the existing
Connection class, but will be used to add new functionality in the
future.

Signed-off-by: Alex Konradi <akonradi@google.com>
Add code to the new ServerConnection class to support a timeout for the
transport socket connect event. This will be used to require TLS
connections to complete their handshake within a specified period of
time.

Signed-off-by: Alex Konradi <akonradi@google.com>
Add a config field to the filter chain proto to specify the transport
socket timeout and use that to set the value on the server socket.

Signed-off-by: Alex Konradi <akonradi@google.com>
Signed-off-by: Alex Konradi <akonradi@google.com>
@repokitteh-read-only
Copy link

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to api/envoy/.
CC @envoyproxy/api-watchers: FYI only for changes made to api/envoy/.

🐱

Caused by: #13610 was opened by akonradi.

see: more, trace.

@akonradi
Copy link
Contributor Author

/assign @antoniovicente

Signed-off-by: Alex Konradi <akonradi@google.com>
@htuch
Copy link
Member

htuch commented Oct 16, 2020

/lgtm api

Copy link
Contributor

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very elegant implementation on top of raiseEvent. Thanks for getting this done.

docs/root/version_history/current.rst Outdated Show resolved Hide resolved
source/common/network/connection_impl.cc Show resolved Hide resolved
source/common/network/connection_impl.cc Outdated Show resolved Hide resolved
source/common/network/connection_impl.h Outdated Show resolved Hide resolved
include/envoy/network/connection.h Outdated Show resolved Hide resolved
test/mocks/network/connection.h Show resolved Hide resolved
test/common/network/connection_impl_test.cc Show resolved Hide resolved
test/common/network/connection_impl_test.cc Outdated Show resolved Hide resolved
Signed-off-by: Alex Konradi <akonradi@google.com>
source/common/network/connection_impl.cc Show resolved Hide resolved
test/common/network/connection_impl_test.cc Outdated Show resolved Hide resolved
test/common/network/connection_impl_test.cc Show resolved Hide resolved
docs/root/faq/configuration/timeouts.rst Outdated Show resolved Hide resolved

* The :ref:`transport_socket_connect_timeout <envoy_v3_api_field_config.listener.v3.FilterChain.transport_socket_connect_timeout>`
specifies the amount of time Envoy will wait for a downstream client to complete transport-level
negotiations. This can be used to limit the amount of time allowed to finish a TLS handshake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth generalizing this description further? The timeout covers transport socket establishment, which includes the handshake step when establishing TLS or ALPN sockets.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, PTAL. I'm open to suggestions for optimizing for searchability for "tls timeout" and such.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I hadn't looked at the rest of this doc until now.

It makes some sense to me to move this timeout closer to the top. Alternatively, you could add references to the HTTP connection level timeouts and TCP timeouts sections: "See :ref:`Transport Socket` for other connection timeouts."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved above the TCP section.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that now it is even more hidden than before.

Signed-off-by: Alex Konradi <akonradi@google.com>
Signed-off-by: Alex Konradi <akonradi@google.com>
docs/root/faq/configuration/timeouts.rst Outdated Show resolved Hide resolved

* The :ref:`transport_socket_connect_timeout <envoy_v3_api_field_config.listener.v3.FilterChain.transport_socket_connect_timeout>`
specifies the amount of time Envoy will wait for a downstream client to complete transport-level
negotiations. This can be used to limit the amount of time allowed to finish a TLS handshake
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I hadn't looked at the rest of this doc until now.

It makes some sense to me to move this timeout closer to the top. Alternatively, you could add references to the HTTP connection level timeouts and TCP timeouts sections: "See :ref:`Transport Socket` for other connection timeouts."

docs/root/version_history/current.rst Outdated Show resolved Hide resolved
source/server/listener_manager_impl.cc Show resolved Hide resolved
Signed-off-by: Alex Konradi <akonradi@google.com>
antoniovicente
antoniovicente previously approved these changes Oct 21, 2020
Copy link
Contributor

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this important timeout.

Signed-off-by: Alex Konradi <akonradi@google.com>
antoniovicente
antoniovicente previously approved these changes Oct 22, 2020
@antoniovicente
Copy link
Contributor

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines.

🐱

Caused by: a #13610 (comment) was created by @antoniovicente.

see: more, trace.

…eout

Signed-off-by: Alex Konradi <akonradi@google.com>
@akonradi
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines.
Cannot retry non-completed check: envoy-presubmit (check linux_x64 compile_time_options), please wait.

🐱

Caused by: a #13610 (comment) was created by @akonradi.

see: more, trace.

@mattklein123 mattklein123 self-assigned this Oct 24, 2020
@akonradi
Copy link
Contributor Author

The clang_tidy check looks to be the same GOAWAY issue seen elsewhere. Would merging master help, or should I just kick off a retest?

@akonradi
Copy link
Contributor Author

/retest

@repokitteh-read-only
Copy link

Retrying Azure Pipelines:
Retried failed jobs in: envoy-presubmit

🐱

Caused by: a #13610 (comment) was created by @akonradi.

see: more, trace.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks LGTM with some small comments. Very nice to have this timout.

Is it possible to add a simple integration test of this behavior? I think it should be pretty straightforward.

/wait


void ServerConnectionImpl::onTransportSocketConnectTimeout() {
closeConnectionImmediately();
stream_info_.setConnectionTerminationDetails("transport socket timeout was reached");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you make this a const string_view somewhere to avoid a probable string_view temporary? Also, I would set the stream info details before closing just for safety in case something looks up the info in the immediate close path.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +729 to +731
case ConnectionEvent::Connected:
case ConnectionEvent::RemoteClose:
case ConnectionEvent::LocalClose:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you envision other events in the future in which we wouldn't do this? Seems like you can just remove the switch and do this always?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, but this seemed like a good way of 1) demonstrating that this is supposed to handle all cases identically (i.e. I didn't consider one and forget about the others) and 2) ensuring that if someone ever adds an event type, they have to consider how to modify this since it'll cause a compile error otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fair enough. Fine by me.

Signed-off-by: Alex Konradi <akonradi@google.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mattklein123 mattklein123 merged commit 2d0a2f6 into envoyproxy:master Oct 27, 2020
mpuncel added a commit to mpuncel/envoy that referenced this pull request Oct 30, 2020
* master: (83 commits)
  tls: Typesafe tls slots (envoyproxy#13789)
  docs(example): Correct URL for caching example page (envoyproxy#13810)
  [fuzz] Made health check fuzz more efficient (envoyproxy#13747)
  rtds: properly scope rtds stats (envoyproxy#13764)
  http: fixing a bug with IPv6 hosts (envoyproxy#13798)
  connection: Remember transport socket read resumption requests and replay them when re-enabling read. (envoyproxy#13772)
  network: adding some accessors for ALPN work. (envoyproxy#13785)
  docs: added a step about how to handle platform specific extensions (envoyproxy#13759)
  Fix identation in ip transparency code snippet (envoyproxy#13743)
  wasm: enable WAVM's stack unwinding feature (envoyproxy#13792)
  log: set route name for direct response (envoyproxy#13683)
  Use nghttp2 as external dependsncy in protocol_constraints_lib (envoyproxy#13763)
  [Windows] Update windows dev docs (envoyproxy#13741)
  cel: patch thread safety issue (envoyproxy#13739)
  Windows: Fix ssl_socket_test (envoyproxy#13264)
  apple dns: add fake api test suite (envoyproxy#13780)
  overload: scale selected timers in response to load (envoyproxy#13475)
  examples: Add dynamic configuration (control plane) sandbox (envoyproxy#13746)
  Removed exception in getResponseStatus() (envoyproxy#13314)
  network: add timeout for transport connect (envoyproxy#13610)
  ...

Signed-off-by: Michael Puncel <mpuncel@squareup.com>
gunnar-solo added a commit to gunnar-solo/gloo that referenced this pull request Oct 15, 2021
passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes solo-io#5438
gunnar-solo added a commit to gunnar-solo/gloo that referenced this pull request Oct 15, 2021
passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes solo-io#5438
gunnar-solo added a commit to gunnar-solo/gloo that referenced this pull request Oct 15, 2021
passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes solo-io#5438
gunnar-solo added a commit to gunnar-solo/gloo that referenced this pull request Oct 18, 2021
passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes solo-io#5438
gunnar-solo added a commit to gunnar-solo/gloo that referenced this pull request Oct 19, 2021
passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes solo-io#5438
soloio-bulldozer bot pushed a commit to solo-io/gloo that referenced this pull request Oct 19, 2021
* feat(ssl): added timeout option

passthrough functionality for "TLS handshake timeout".  Envoy has supported this [for a bit](envoyproxy/envoy#13610), and this
PR will allow gloo-edge to support the functionality as well.

[Referenced Documentation Here](https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/listener/v3/listener_components.proto#config-listener-v3-filterchain)

closes #5438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants