Revert "Move TCP Connect into its own handshaker. (#29111)" (#29558)

This reverts commit 0675af8511.
pull/29559/head
AJ Heller 3 years ago committed by GitHub
parent b92f885756
commit 815029fe2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 88
      BUILD
  2. 14
      CMakeLists.txt
  3. 14
      Makefile
  4. 32
      build_autogenerated.yaml
  5. 7
      config.m4
  6. 7
      config.w32
  7. 18
      gRPC-C++.podspec
  8. 25
      gRPC-Core.podspec
  9. 16
      grpc.gemspec
  10. 14
      grpc.gyp
  11. 16
      package.xml
  12. 1
      src/core/ext/filters/client_channel/client_channel.cc
  13. 2
      src/core/ext/filters/client_channel/client_channel_plugin.cc
  14. 8
      src/core/ext/filters/client_channel/http_connect_handshaker.cc
  15. 6
      src/core/ext/filters/client_channel/http_connect_handshaker.h
  16. 2
      src/core/ext/filters/client_channel/http_proxy.cc
  17. 106
      src/core/ext/transport/chttp2/client/chttp2_connector.cc
  18. 9
      src/core/ext/transport/chttp2/client/chttp2_connector.h
  19. 2
      src/core/ext/transport/chttp2/server/chttp2_server.cc
  20. 3
      src/core/lib/channel/handshaker.cc
  21. 10
      src/core/lib/channel/handshaker.h
  22. 6
      src/core/lib/channel/handshaker_factory.h
  23. 2
      src/core/lib/channel/handshaker_registry.cc
  24. 8
      src/core/lib/channel/handshaker_registry.h
  25. 2
      src/core/lib/config/core_configuration.h
  26. 103
      src/core/lib/http/httpcli.cc
  27. 7
      src/core/lib/http/httpcli.h
  28. 2
      src/core/lib/security/security_connector/fake/fake_security_connector.cc
  29. 2
      src/core/lib/security/security_connector/fake/fake_security_connector.h
  30. 2
      src/core/lib/security/security_connector/security_connector.cc
  31. 2
      src/core/lib/security/security_connector/security_connector.h
  32. 2
      src/core/lib/security/security_connector/ssl/ssl_security_connector.cc
  33. 2
      src/core/lib/security/transport/security_handshaker.cc
  34. 2
      src/core/lib/security/transport/security_handshaker.h
  35. 229
      src/core/lib/transport/tcp_connect_handshaker.cc
  36. 39
      src/core/lib/transport/tcp_connect_handshaker.h
  37. 7
      src/core/plugin_registry/grpc_plugin_registry.cc
  38. 7
      src/python/grpcio/grpc_core_dependencies.py
  39. 2
      test/core/client_channel/http_proxy_mapper_test.cc
  40. 4
      test/core/handshake/readahead_handshaker_server_ssl.cc
  41. 6
      test/core/util/port_server_client.cc
  42. 16
      tools/doxygen/Doxyfile.c++.internal
  43. 16
      tools/doxygen/Doxyfile.core.internal

88
BUILD

@ -398,9 +398,7 @@ grpc_cc_library(
"grpc_common",
"grpc_security_base",
"grpc_trace",
"http_connect_handshaker",
"slice",
"tcp_connect_handshaker",
],
)
@ -449,9 +447,7 @@ grpc_cc_library(
"grpc_secure",
"grpc_security_base",
"grpc_trace",
"http_connect_handshaker",
"slice",
"tcp_connect_handshaker",
],
)
@ -1462,35 +1458,11 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "handshaker",
srcs = [
"src/core/lib/transport/handshaker.cc",
],
external_deps = [
"absl/strings",
"absl/strings:str_format",
],
language = "c++",
public_hdrs = [
"src/core/lib/transport/handshaker.h",
],
deps = [
"channel_args",
"closure",
"gpr_base",
"grpc_base",
"grpc_codegen",
"grpc_trace",
"slice",
],
)
grpc_cc_library(
name = "handshaker_factory",
language = "c++",
public_hdrs = [
"src/core/lib/transport/handshaker_factory.h",
"src/core/lib/channel/handshaker_factory.h",
],
deps = [
"gpr_base",
@ -1500,11 +1472,11 @@ grpc_cc_library(
grpc_cc_library(
name = "handshaker_registry",
srcs = [
"src/core/lib/transport/handshaker_registry.cc",
"src/core/lib/channel/handshaker_registry.cc",
],
language = "c++",
public_hdrs = [
"src/core/lib/transport/handshaker_registry.h",
"src/core/lib/channel/handshaker_registry.h",
],
deps = [
"gpr_base",
@ -1512,47 +1484,6 @@ grpc_cc_library(
],
)
grpc_cc_library(
name = "http_connect_handshaker",
srcs = [
"src/core/lib/transport/http_connect_handshaker.cc",
],
external_deps = [
"absl/strings",
],
language = "c++",
public_hdrs = [
"src/core/lib/transport/http_connect_handshaker.h",
],
deps = [
"config",
"gpr_base",
"grpc_base",
"handshaker",
"handshaker_registry",
"httpcli",
"uri_parser",
],
)
grpc_cc_library(
name = "tcp_connect_handshaker",
srcs = [
"src/core/lib/transport/tcp_connect_handshaker.cc",
],
language = "c++",
public_hdrs = [
"src/core/lib/transport/tcp_connect_handshaker.h",
],
deps = [
"config",
"gpr_platform",
"grpc_base",
"handshaker",
"handshaker_registry",
],
)
grpc_cc_library(
name = "channel_creds_registry",
hdrs = [
@ -1961,6 +1892,7 @@ grpc_cc_library(
"src/core/lib/channel/channelz.cc",
"src/core/lib/channel/channelz_registry.cc",
"src/core/lib/channel/connected_channel.cc",
"src/core/lib/channel/handshaker.cc",
"src/core/lib/channel/promise_based_filter.cc",
"src/core/lib/channel/status_util.cc",
"src/core/lib/compression/compression.cc",
@ -2100,6 +2032,7 @@ grpc_cc_library(
"src/core/lib/channel/channelz_registry.h",
"src/core/lib/channel/connected_channel.h",
"src/core/lib/channel/context.h",
"src/core/lib/channel/handshaker.h",
"src/core/lib/channel/status_util.h",
"src/core/lib/compression/compression_internal.h",
"src/core/lib/resource_quota/api.h",
@ -2254,7 +2187,6 @@ grpc_cc_library(
"grpc_codegen",
"grpc_sockaddr",
"grpc_trace",
"handshaker_registry",
"iomgr_port",
"json",
"latch",
@ -2541,6 +2473,7 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/dynamic_filters.cc",
"src/core/ext/filters/client_channel/global_subchannel_pool.cc",
"src/core/ext/filters/client_channel/health/health_check_client.cc",
"src/core/ext/filters/client_channel/http_connect_handshaker.cc",
"src/core/ext/filters/client_channel/http_proxy.cc",
"src/core/ext/filters/client_channel/lb_policy.cc",
"src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc",
@ -2568,6 +2501,7 @@ grpc_cc_library(
"src/core/ext/filters/client_channel/dynamic_filters.h",
"src/core/ext/filters/client_channel/global_subchannel_pool.h",
"src/core/ext/filters/client_channel/health/health_check_client.h",
"src/core/ext/filters/client_channel/http_connect_handshaker.h",
"src/core/ext/filters/client_channel/http_proxy.h",
"src/core/ext/filters/client_channel/lb_policy.h",
"src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h",
@ -2611,7 +2545,6 @@ grpc_cc_library(
"grpc_service_config_impl",
"grpc_trace",
"handshaker_registry",
"http_connect_handshaker",
"httpcli",
"json",
"json_util",
@ -3791,7 +3724,6 @@ grpc_cc_library(
"grpc_security_base",
"ref_counted_ptr",
"sockaddr_utils",
"tcp_connect_handshaker",
"useful",
],
)
@ -3867,7 +3799,6 @@ grpc_cc_library(
"gpr_base",
"grpc_base",
"grpc_security_base",
"handshaker",
"promise",
"ref_counted_ptr",
"tsi_fake_credentials",
@ -3989,7 +3920,6 @@ grpc_cc_library(
"grpc_credentials_util",
"grpc_security_base",
"grpc_transport_chttp2_alpn",
"handshaker",
"promise",
"ref_counted_ptr",
"tsi_base",
@ -4308,7 +4238,6 @@ grpc_cc_library(
"gpr_base",
"grpc_base",
"grpc_trace",
"handshaker",
"json",
"memory_quota",
"promise",
@ -4719,10 +4648,8 @@ grpc_cc_library(
"grpc_resolver",
"grpc_security_base",
"grpc_transport_chttp2",
"handshaker",
"slice",
"sockaddr_utils",
"tcp_connect_handshaker",
"uri_parser",
],
)
@ -4749,7 +4676,6 @@ grpc_cc_library(
"grpc_insecure_credentials",
"grpc_security_base",
"grpc_transport_chttp2",
"handshaker",
"memory_quota",
"ref_counted",
"ref_counted_ptr",

14
CMakeLists.txt generated

@ -1613,6 +1613,7 @@ add_library(grpc
src/core/ext/filters/client_channel/dynamic_filters.cc
src/core/ext/filters/client_channel/global_subchannel_pool.cc
src/core/ext/filters/client_channel/health/health_check_client.cc
src/core/ext/filters/client_channel/http_connect_handshaker.cc
src/core/ext/filters/client_channel/http_proxy.cc
src/core/ext/filters/client_channel/lb_policy.cc
src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
@ -2010,6 +2011,8 @@ add_library(grpc
src/core/lib/channel/channelz.cc
src/core/lib/channel/channelz_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_registry.cc
src/core/lib/channel/promise_based_filter.cc
src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
@ -2224,13 +2227,9 @@ add_library(grpc
src/core/lib/transport/byte_stream.cc
src/core/lib/transport/connectivity_state.cc
src/core/lib/transport/error_utils.cc
src/core/lib/transport/handshaker.cc
src/core/lib/transport/handshaker_registry.cc
src/core/lib/transport/http_connect_handshaker.cc
src/core/lib/transport/parsed_metadata.cc
src/core/lib/transport/pid_controller.cc
src/core/lib/transport/status_conversion.cc
src/core/lib/transport/tcp_connect_handshaker.cc
src/core/lib/transport/timeout_encoding.cc
src/core/lib/transport/transport.cc
src/core/lib/transport/transport_op_string.cc
@ -2511,6 +2510,7 @@ add_library(grpc_unsecure
src/core/ext/filters/client_channel/dynamic_filters.cc
src/core/ext/filters/client_channel/global_subchannel_pool.cc
src/core/ext/filters/client_channel/health/health_check_client.cc
src/core/ext/filters/client_channel/http_connect_handshaker.cc
src/core/ext/filters/client_channel/http_proxy.cc
src/core/ext/filters/client_channel/lb_policy.cc
src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
@ -2617,6 +2617,8 @@ add_library(grpc_unsecure
src/core/lib/channel/channelz.cc
src/core/lib/channel/channelz_registry.cc
src/core/lib/channel/connected_channel.cc
src/core/lib/channel/handshaker.cc
src/core/lib/channel/handshaker_registry.cc
src/core/lib/channel/promise_based_filter.cc
src/core/lib/channel/status_util.cc
src/core/lib/compression/compression.cc
@ -2791,13 +2793,9 @@ add_library(grpc_unsecure
src/core/lib/transport/byte_stream.cc
src/core/lib/transport/connectivity_state.cc
src/core/lib/transport/error_utils.cc
src/core/lib/transport/handshaker.cc
src/core/lib/transport/handshaker_registry.cc
src/core/lib/transport/http_connect_handshaker.cc
src/core/lib/transport/parsed_metadata.cc
src/core/lib/transport/pid_controller.cc
src/core/lib/transport/status_conversion.cc
src/core/lib/transport/tcp_connect_handshaker.cc
src/core/lib/transport/timeout_encoding.cc
src/core/lib/transport/transport.cc
src/core/lib/transport/transport_op_string.cc

14
Makefile generated

@ -1032,6 +1032,7 @@ LIBGRPC_SRC = \
src/core/ext/filters/client_channel/dynamic_filters.cc \
src/core/ext/filters/client_channel/global_subchannel_pool.cc \
src/core/ext/filters/client_channel/health/health_check_client.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/lb_policy.cc \
src/core/ext/filters/client_channel/lb_policy/address_filtering.cc \
@ -1429,6 +1430,8 @@ LIBGRPC_SRC = \
src/core/lib/channel/channelz.cc \
src/core/lib/channel/channelz_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
@ -1643,13 +1646,9 @@ LIBGRPC_SRC = \
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/handshaker.cc \
src/core/lib/transport/handshaker_registry.cc \
src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/tcp_connect_handshaker.cc \
src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/transport.cc \
src/core/lib/transport/transport_op_string.cc \
@ -1775,6 +1774,7 @@ LIBGRPC_UNSECURE_SRC = \
src/core/ext/filters/client_channel/dynamic_filters.cc \
src/core/ext/filters/client_channel/global_subchannel_pool.cc \
src/core/ext/filters/client_channel/health/health_check_client.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/lb_policy.cc \
src/core/ext/filters/client_channel/lb_policy/address_filtering.cc \
@ -1881,6 +1881,8 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/channel/channelz.cc \
src/core/lib/channel/channelz_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
@ -2055,13 +2057,9 @@ LIBGRPC_UNSECURE_SRC = \
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/handshaker.cc \
src/core/lib/transport/handshaker_registry.cc \
src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/tcp_connect_handshaker.cc \
src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/transport.cc \
src/core/lib/transport/transport_op_string.cc \

@ -325,6 +325,7 @@ libs:
- src/core/ext/filters/client_channel/dynamic_filters.h
- src/core/ext/filters/client_channel/global_subchannel_pool.h
- src/core/ext/filters/client_channel/health/health_check_client.h
- src/core/ext/filters/client_channel/http_connect_handshaker.h
- src/core/ext/filters/client_channel/http_proxy.h
- src/core/ext/filters/client_channel/lb_policy.h
- src/core/ext/filters/client_channel/lb_policy/address_filtering.h
@ -714,6 +715,9 @@ libs:
- src/core/lib/channel/channelz_registry.h
- src/core/lib/channel/connected_channel.h
- src/core/lib/channel/context.h
- src/core/lib/channel/handshaker.h
- src/core/lib/channel/handshaker_factory.h
- src/core/lib/channel/handshaker_registry.h
- src/core/lib/channel/promise_based_filter.h
- src/core/lib/channel/status_util.h
- src/core/lib/compression/compression_internal.h
@ -931,16 +935,11 @@ libs:
- src/core/lib/transport/byte_stream.h
- src/core/lib/transport/connectivity_state.h
- src/core/lib/transport/error_utils.h
- src/core/lib/transport/handshaker.h
- src/core/lib/transport/handshaker_factory.h
- src/core/lib/transport/handshaker_registry.h
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/http_connect_handshaker.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/pid_controller.h
- src/core/lib/transport/status_conversion.h
- src/core/lib/transport/tcp_connect_handshaker.h
- src/core/lib/transport/timeout_encoding.h
- src/core/lib/transport/transport.h
- src/core/lib/transport/transport_impl.h
@ -989,6 +988,7 @@ libs:
- src/core/ext/filters/client_channel/dynamic_filters.cc
- src/core/ext/filters/client_channel/global_subchannel_pool.cc
- src/core/ext/filters/client_channel/health/health_check_client.cc
- src/core/ext/filters/client_channel/http_connect_handshaker.cc
- src/core/ext/filters/client_channel/http_proxy.cc
- src/core/ext/filters/client_channel/lb_policy.cc
- src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
@ -1386,6 +1386,8 @@ libs:
- src/core/lib/channel/channelz.cc
- src/core/lib/channel/channelz_registry.cc
- src/core/lib/channel/connected_channel.cc
- src/core/lib/channel/handshaker.cc
- src/core/lib/channel/handshaker_registry.cc
- src/core/lib/channel/promise_based_filter.cc
- src/core/lib/channel/status_util.cc
- src/core/lib/compression/compression.cc
@ -1600,13 +1602,9 @@ libs:
- src/core/lib/transport/byte_stream.cc
- src/core/lib/transport/connectivity_state.cc
- src/core/lib/transport/error_utils.cc
- src/core/lib/transport/handshaker.cc
- src/core/lib/transport/handshaker_registry.cc
- src/core/lib/transport/http_connect_handshaker.cc
- src/core/lib/transport/parsed_metadata.cc
- src/core/lib/transport/pid_controller.cc
- src/core/lib/transport/status_conversion.cc
- src/core/lib/transport/tcp_connect_handshaker.cc
- src/core/lib/transport/timeout_encoding.cc
- src/core/lib/transport/transport.cc
- src/core/lib/transport/transport_op_string.cc
@ -1799,6 +1797,7 @@ libs:
- src/core/ext/filters/client_channel/dynamic_filters.h
- src/core/ext/filters/client_channel/global_subchannel_pool.h
- src/core/ext/filters/client_channel/health/health_check_client.h
- src/core/ext/filters/client_channel/http_connect_handshaker.h
- src/core/ext/filters/client_channel/http_proxy.h
- src/core/ext/filters/client_channel/lb_policy.h
- src/core/ext/filters/client_channel/lb_policy/address_filtering.h
@ -1897,6 +1896,9 @@ libs:
- src/core/lib/channel/channelz_registry.h
- src/core/lib/channel/connected_channel.h
- src/core/lib/channel/context.h
- src/core/lib/channel/handshaker.h
- src/core/lib/channel/handshaker_factory.h
- src/core/lib/channel/handshaker_registry.h
- src/core/lib/channel/promise_based_filter.h
- src/core/lib/channel/status_util.h
- src/core/lib/compression/compression_internal.h
@ -2081,16 +2083,11 @@ libs:
- src/core/lib/transport/byte_stream.h
- src/core/lib/transport/connectivity_state.h
- src/core/lib/transport/error_utils.h
- src/core/lib/transport/handshaker.h
- src/core/lib/transport/handshaker_factory.h
- src/core/lib/transport/handshaker_registry.h
- src/core/lib/transport/http2_errors.h
- src/core/lib/transport/http_connect_handshaker.h
- src/core/lib/transport/metadata_batch.h
- src/core/lib/transport/parsed_metadata.h
- src/core/lib/transport/pid_controller.h
- src/core/lib/transport/status_conversion.h
- src/core/lib/transport/tcp_connect_handshaker.h
- src/core/lib/transport/timeout_encoding.h
- src/core/lib/transport/transport.h
- src/core/lib/transport/transport_impl.h
@ -2116,6 +2113,7 @@ libs:
- src/core/ext/filters/client_channel/dynamic_filters.cc
- src/core/ext/filters/client_channel/global_subchannel_pool.cc
- src/core/ext/filters/client_channel/health/health_check_client.cc
- src/core/ext/filters/client_channel/http_connect_handshaker.cc
- src/core/ext/filters/client_channel/http_proxy.cc
- src/core/ext/filters/client_channel/lb_policy.cc
- src/core/ext/filters/client_channel/lb_policy/address_filtering.cc
@ -2222,6 +2220,8 @@ libs:
- src/core/lib/channel/channelz.cc
- src/core/lib/channel/channelz_registry.cc
- src/core/lib/channel/connected_channel.cc
- src/core/lib/channel/handshaker.cc
- src/core/lib/channel/handshaker_registry.cc
- src/core/lib/channel/promise_based_filter.cc
- src/core/lib/channel/status_util.cc
- src/core/lib/compression/compression.cc
@ -2396,13 +2396,9 @@ libs:
- src/core/lib/transport/byte_stream.cc
- src/core/lib/transport/connectivity_state.cc
- src/core/lib/transport/error_utils.cc
- src/core/lib/transport/handshaker.cc
- src/core/lib/transport/handshaker_registry.cc
- src/core/lib/transport/http_connect_handshaker.cc
- src/core/lib/transport/parsed_metadata.cc
- src/core/lib/transport/pid_controller.cc
- src/core/lib/transport/status_conversion.cc
- src/core/lib/transport/tcp_connect_handshaker.cc
- src/core/lib/transport/timeout_encoding.cc
- src/core/lib/transport/transport.cc
- src/core/lib/transport/transport_op_string.cc

7
config.m4 generated

@ -54,6 +54,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/ext/filters/client_channel/dynamic_filters.cc \
src/core/ext/filters/client_channel/global_subchannel_pool.cc \
src/core/ext/filters/client_channel/health/health_check_client.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/lb_policy.cc \
src/core/ext/filters/client_channel/lb_policy/address_filtering.cc \
@ -451,6 +452,8 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/channel/channelz.cc \
src/core/lib/channel/channelz_registry.cc \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/status_util.cc \
src/core/lib/compression/compression.cc \
@ -709,13 +712,9 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/transport/byte_stream.cc \
src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/handshaker.cc \
src/core/lib/transport/handshaker_registry.cc \
src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/tcp_connect_handshaker.cc \
src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/transport.cc \
src/core/lib/transport/transport_op_string.cc \

7
config.w32 generated

@ -20,6 +20,7 @@ if (PHP_GRPC != "no") {
"src\\core\\ext\\filters\\client_channel\\dynamic_filters.cc " +
"src\\core\\ext\\filters\\client_channel\\global_subchannel_pool.cc " +
"src\\core\\ext\\filters\\client_channel\\health\\health_check_client.cc " +
"src\\core\\ext\\filters\\client_channel\\http_connect_handshaker.cc " +
"src\\core\\ext\\filters\\client_channel\\http_proxy.cc " +
"src\\core\\ext\\filters\\client_channel\\lb_policy.cc " +
"src\\core\\ext\\filters\\client_channel\\lb_policy\\address_filtering.cc " +
@ -417,6 +418,8 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\channel\\channelz.cc " +
"src\\core\\lib\\channel\\channelz_registry.cc " +
"src\\core\\lib\\channel\\connected_channel.cc " +
"src\\core\\lib\\channel\\handshaker.cc " +
"src\\core\\lib\\channel\\handshaker_registry.cc " +
"src\\core\\lib\\channel\\promise_based_filter.cc " +
"src\\core\\lib\\channel\\status_util.cc " +
"src\\core\\lib\\compression\\compression.cc " +
@ -675,13 +678,9 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\transport\\byte_stream.cc " +
"src\\core\\lib\\transport\\connectivity_state.cc " +
"src\\core\\lib\\transport\\error_utils.cc " +
"src\\core\\lib\\transport\\handshaker.cc " +
"src\\core\\lib\\transport\\handshaker_registry.cc " +
"src\\core\\lib\\transport\\http_connect_handshaker.cc " +
"src\\core\\lib\\transport\\parsed_metadata.cc " +
"src\\core\\lib\\transport\\pid_controller.cc " +
"src\\core\\lib\\transport\\status_conversion.cc " +
"src\\core\\lib\\transport\\tcp_connect_handshaker.cc " +
"src\\core\\lib\\transport\\timeout_encoding.cc " +
"src\\core\\lib\\transport\\transport.cc " +
"src\\core\\lib\\transport\\transport_op_string.cc " +

18
gRPC-C++.podspec generated

@ -226,6 +226,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/dynamic_filters.h',
'src/core/ext/filters/client_channel/global_subchannel_pool.h',
'src/core/ext/filters/client_channel/health/health_check_client.h',
'src/core/ext/filters/client_channel/http_connect_handshaker.h',
'src/core/ext/filters/client_channel/http_proxy.h',
'src/core/ext/filters/client_channel/lb_policy.h',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.h',
@ -653,6 +654,9 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channelz_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
'src/core/lib/compression/compression_internal.h',
@ -898,16 +902,11 @@ Pod::Spec.new do |s|
'src/core/lib/transport/byte_stream.h',
'src/core/lib/transport/connectivity_state.h',
'src/core/lib/transport/error_utils.h',
'src/core/lib/transport/handshaker.h',
'src/core/lib/transport/handshaker_factory.h',
'src/core/lib/transport/handshaker_registry.h',
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/status_conversion.h',
'src/core/lib/transport/tcp_connect_handshaker.h',
'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.h',
'src/core/lib/transport/transport_impl.h',
@ -1059,6 +1058,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/dynamic_filters.h',
'src/core/ext/filters/client_channel/global_subchannel_pool.h',
'src/core/ext/filters/client_channel/health/health_check_client.h',
'src/core/ext/filters/client_channel/http_connect_handshaker.h',
'src/core/ext/filters/client_channel/http_proxy.h',
'src/core/ext/filters/client_channel/lb_policy.h',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.h',
@ -1468,6 +1468,9 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channelz_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
'src/core/lib/compression/compression_internal.h',
@ -1713,16 +1716,11 @@ Pod::Spec.new do |s|
'src/core/lib/transport/byte_stream.h',
'src/core/lib/transport/connectivity_state.h',
'src/core/lib/transport/error_utils.h',
'src/core/lib/transport/handshaker.h',
'src/core/lib/transport/handshaker_factory.h',
'src/core/lib/transport/handshaker_registry.h',
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/status_conversion.h',
'src/core/lib/transport/tcp_connect_handshaker.h',
'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.h',
'src/core/lib/transport/transport_impl.h',

25
gRPC-Core.podspec generated

@ -217,6 +217,8 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/global_subchannel_pool.h',
'src/core/ext/filters/client_channel/health/health_check_client.cc',
'src/core/ext/filters/client_channel/health/health_check_client.h',
'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
'src/core/ext/filters/client_channel/http_connect_handshaker.h',
'src/core/ext/filters/client_channel/http_proxy.cc',
'src/core/ext/filters/client_channel/http_proxy.h',
'src/core/ext/filters/client_channel/lb_policy.cc',
@ -1003,6 +1005,11 @@ Pod::Spec.new do |s|
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.cc',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/channel/promise_based_filter.cc',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.cc',
@ -1506,14 +1513,7 @@ Pod::Spec.new do |s|
'src/core/lib/transport/connectivity_state.h',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/error_utils.h',
'src/core/lib/transport/handshaker.cc',
'src/core/lib/transport/handshaker.h',
'src/core/lib/transport/handshaker_factory.h',
'src/core/lib/transport/handshaker_registry.cc',
'src/core/lib/transport/handshaker_registry.h',
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.cc',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/parsed_metadata.h',
@ -1521,8 +1521,6 @@ Pod::Spec.new do |s|
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/status_conversion.cc',
'src/core/lib/transport/status_conversion.h',
'src/core/lib/transport/tcp_connect_handshaker.cc',
'src/core/lib/transport/tcp_connect_handshaker.h',
'src/core/lib/transport/timeout_encoding.cc',
'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.cc',
@ -1683,6 +1681,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/client_channel/dynamic_filters.h',
'src/core/ext/filters/client_channel/global_subchannel_pool.h',
'src/core/ext/filters/client_channel/health/health_check_client.h',
'src/core/ext/filters/client_channel/http_connect_handshaker.h',
'src/core/ext/filters/client_channel/http_proxy.h',
'src/core/ext/filters/client_channel/lb_policy.h',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.h',
@ -2072,6 +2071,9 @@ Pod::Spec.new do |s|
'src/core/lib/channel/channelz_registry.h',
'src/core/lib/channel/connected_channel.h',
'src/core/lib/channel/context.h',
'src/core/lib/channel/handshaker.h',
'src/core/lib/channel/handshaker_factory.h',
'src/core/lib/channel/handshaker_registry.h',
'src/core/lib/channel/promise_based_filter.h',
'src/core/lib/channel/status_util.h',
'src/core/lib/compression/compression_internal.h',
@ -2317,16 +2319,11 @@ Pod::Spec.new do |s|
'src/core/lib/transport/byte_stream.h',
'src/core/lib/transport/connectivity_state.h',
'src/core/lib/transport/error_utils.h',
'src/core/lib/transport/handshaker.h',
'src/core/lib/transport/handshaker_factory.h',
'src/core/lib/transport/handshaker_registry.h',
'src/core/lib/transport/http2_errors.h',
'src/core/lib/transport/http_connect_handshaker.h',
'src/core/lib/transport/metadata_batch.h',
'src/core/lib/transport/parsed_metadata.h',
'src/core/lib/transport/pid_controller.h',
'src/core/lib/transport/status_conversion.h',
'src/core/lib/transport/tcp_connect_handshaker.h',
'src/core/lib/transport/timeout_encoding.h',
'src/core/lib/transport/transport.h',
'src/core/lib/transport/transport_impl.h',

16
grpc.gemspec generated

@ -136,6 +136,8 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/client_channel/global_subchannel_pool.h )
s.files += %w( src/core/ext/filters/client_channel/health/health_check_client.cc )
s.files += %w( src/core/ext/filters/client_channel/health/health_check_client.h )
s.files += %w( src/core/ext/filters/client_channel/http_connect_handshaker.cc )
s.files += %w( src/core/ext/filters/client_channel/http_connect_handshaker.h )
s.files += %w( src/core/ext/filters/client_channel/http_proxy.cc )
s.files += %w( src/core/ext/filters/client_channel/http_proxy.h )
s.files += %w( src/core/ext/filters/client_channel/lb_policy.cc )
@ -922,6 +924,11 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/channel/connected_channel.cc )
s.files += %w( src/core/lib/channel/connected_channel.h )
s.files += %w( src/core/lib/channel/context.h )
s.files += %w( src/core/lib/channel/handshaker.cc )
s.files += %w( src/core/lib/channel/handshaker.h )
s.files += %w( src/core/lib/channel/handshaker_factory.h )
s.files += %w( src/core/lib/channel/handshaker_registry.cc )
s.files += %w( src/core/lib/channel/handshaker_registry.h )
s.files += %w( src/core/lib/channel/promise_based_filter.cc )
s.files += %w( src/core/lib/channel/promise_based_filter.h )
s.files += %w( src/core/lib/channel/status_util.cc )
@ -1425,14 +1432,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/connectivity_state.h )
s.files += %w( src/core/lib/transport/error_utils.cc )
s.files += %w( src/core/lib/transport/error_utils.h )
s.files += %w( src/core/lib/transport/handshaker.cc )
s.files += %w( src/core/lib/transport/handshaker.h )
s.files += %w( src/core/lib/transport/handshaker_factory.h )
s.files += %w( src/core/lib/transport/handshaker_registry.cc )
s.files += %w( src/core/lib/transport/handshaker_registry.h )
s.files += %w( src/core/lib/transport/http2_errors.h )
s.files += %w( src/core/lib/transport/http_connect_handshaker.cc )
s.files += %w( src/core/lib/transport/http_connect_handshaker.h )
s.files += %w( src/core/lib/transport/metadata_batch.h )
s.files += %w( src/core/lib/transport/parsed_metadata.cc )
s.files += %w( src/core/lib/transport/parsed_metadata.h )
@ -1440,8 +1440,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/transport/pid_controller.h )
s.files += %w( src/core/lib/transport/status_conversion.cc )
s.files += %w( src/core/lib/transport/status_conversion.h )
s.files += %w( src/core/lib/transport/tcp_connect_handshaker.cc )
s.files += %w( src/core/lib/transport/tcp_connect_handshaker.h )
s.files += %w( src/core/lib/transport/timeout_encoding.cc )
s.files += %w( src/core/lib/transport/timeout_encoding.h )
s.files += %w( src/core/lib/transport/transport.cc )

14
grpc.gyp generated

@ -385,6 +385,7 @@
'src/core/ext/filters/client_channel/dynamic_filters.cc',
'src/core/ext/filters/client_channel/global_subchannel_pool.cc',
'src/core/ext/filters/client_channel/health/health_check_client.cc',
'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
'src/core/ext/filters/client_channel/http_proxy.cc',
'src/core/ext/filters/client_channel/lb_policy.cc',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.cc',
@ -782,6 +783,8 @@
'src/core/lib/channel/channelz.cc',
'src/core/lib/channel/channelz_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_registry.cc',
'src/core/lib/channel/promise_based_filter.cc',
'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
@ -996,13 +999,9 @@
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/handshaker.cc',
'src/core/lib/transport/handshaker_registry.cc',
'src/core/lib/transport/http_connect_handshaker.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',
'src/core/lib/transport/tcp_connect_handshaker.cc',
'src/core/lib/transport/timeout_encoding.cc',
'src/core/lib/transport/transport.cc',
'src/core/lib/transport/transport_op_string.cc',
@ -1135,6 +1134,7 @@
'src/core/ext/filters/client_channel/dynamic_filters.cc',
'src/core/ext/filters/client_channel/global_subchannel_pool.cc',
'src/core/ext/filters/client_channel/health/health_check_client.cc',
'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
'src/core/ext/filters/client_channel/http_proxy.cc',
'src/core/ext/filters/client_channel/lb_policy.cc',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.cc',
@ -1241,6 +1241,8 @@
'src/core/lib/channel/channelz.cc',
'src/core/lib/channel/channelz_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_registry.cc',
'src/core/lib/channel/promise_based_filter.cc',
'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
@ -1415,13 +1417,9 @@
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/handshaker.cc',
'src/core/lib/transport/handshaker_registry.cc',
'src/core/lib/transport/http_connect_handshaker.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',
'src/core/lib/transport/tcp_connect_handshaker.cc',
'src/core/lib/transport/timeout_encoding.cc',
'src/core/lib/transport/transport.cc',
'src/core/lib/transport/transport_op_string.cc',

16
package.xml generated

@ -116,6 +116,8 @@
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/global_subchannel_pool.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health_check_client.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/health/health_check_client.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_connect_handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_connect_handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_proxy.cc" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/http_proxy.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/client_channel/lb_policy.cc" role="src" />
@ -902,6 +904,11 @@
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/connected_channel.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/context.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/handshaker_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/promise_based_filter.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/promise_based_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/status_util.cc" role="src" />
@ -1405,14 +1412,7 @@
<file baseinstalldir="/" name="src/core/lib/transport/connectivity_state.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/error_utils.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/error_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/handshaker_factory.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/handshaker_registry.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/handshaker_registry.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/http2_errors.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/http_connect_handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/http_connect_handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/metadata_batch.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/parsed_metadata.h" role="src" />
@ -1420,8 +1420,6 @@
<file baseinstalldir="/" name="src/core/lib/transport/pid_controller.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/status_conversion.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/status_conversion.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/tcp_connect_handshaker.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/tcp_connect_handshaker.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/timeout_encoding.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/transport/transport.cc" role="src" />

@ -43,6 +43,7 @@
#include "src/core/ext/filters/client_channel/config_selector.h"
#include "src/core/ext/filters/client_channel/dynamic_filters.h"
#include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/local_subchannel_pool.h"

@ -28,6 +28,7 @@
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/ext/filters/client_channel/client_channel_channelz.h"
#include "src/core/ext/filters/client_channel/global_subchannel_pool.h"
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/http_proxy.h"
#include "src/core/ext/filters/client_channel/lb_policy_registry.h"
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
@ -52,6 +53,7 @@ void grpc_client_channel_shutdown(void) {
namespace grpc_core {
void BuildClientChannelConfiguration(CoreConfiguration::Builder* builder) {
RegisterHttpConnectHandshaker(builder);
internal::ClientChannelServiceConfigParser::Register(builder);
internal::RetryServiceConfigParser::Register(builder);
builder->channel_init()->RegisterStage(

@ -18,7 +18,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include <limits.h>
#include <string.h>
@ -30,15 +30,17 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/ext/filters/client_channel/client_channel.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/sync.h"
#include "src/core/lib/http/format_request.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/resolver/resolver_registry.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/transport/handshaker_registry.h"
#include "src/core/lib/uri/uri_parser.h"
namespace grpc_core {

@ -16,8 +16,8 @@
*
*/
#ifndef GRPC_CORE_LIB_TRANSPORT_HTTP_CONNECT_HANDSHAKER_H
#define GRPC_CORE_LIB_TRANSPORT_HTTP_CONNECT_HANDSHAKER_H
#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H
#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H
#include <grpc/support/port_platform.h>
@ -39,4 +39,4 @@ void RegisterHttpConnectHandshaker(CoreConfiguration::Builder* builder);
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_TRANSPORT_HTTP_CONNECT_HANDSHAKER_H */
#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_HTTP_CONNECT_HANDSHAKER_H */

@ -32,6 +32,7 @@
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/proxy_mapper_registry.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/env.h"
@ -39,7 +40,6 @@
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/slice/b64.h"
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "src/core/lib/uri/uri_parser.h"
namespace grpc_core {

@ -33,6 +33,7 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/memory.h"
#include "src/core/lib/iomgr/endpoint.h"
@ -46,8 +47,6 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/transport/tcp_connect_handshaker.h"
#include "src/core/lib/transport/transport.h"
#include "src/core/lib/uri/uri_parser.h"
@ -62,14 +61,9 @@
namespace grpc_core {
namespace {
void NullThenSchedClosure(const DebugLocation& location, grpc_closure** closure,
grpc_error_handle error) {
grpc_closure* c = *closure;
*closure = nullptr;
ExecCtx::Run(location, c, error);
Chttp2Connector::Chttp2Connector() {
GRPC_CLOSURE_INIT(&connected_, Connected, this, grpc_schedule_on_exec_ctx);
}
} // namespace
Chttp2Connector::~Chttp2Connector() {
if (endpoint_ != nullptr) {
@ -79,52 +73,92 @@ Chttp2Connector::~Chttp2Connector() {
void Chttp2Connector::Connect(const Args& args, Result* result,
grpc_closure* notify) {
grpc_endpoint** ep;
{
MutexLock lock(&mu_);
GPR_ASSERT(notify_ == nullptr);
args_ = args;
result_ = result;
notify_ = notify;
GPR_ASSERT(!connecting_);
connecting_ = true;
GPR_ASSERT(endpoint_ == nullptr);
ep = &endpoint_;
}
absl::StatusOr<std::string> address = grpc_sockaddr_to_uri(args.address);
if (!address.ok()) {
grpc_error_handle error =
GRPC_ERROR_CREATE_FROM_CPP_STRING(address.status().ToString());
NullThenSchedClosure(DEBUG_LOCATION, &notify_, error);
return;
}
absl::InlinedVector<grpc_arg, 2> args_to_add = {
grpc_channel_arg_string_create(
const_cast<char*>(GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS),
const_cast<char*>(address.value().c_str())),
grpc_channel_arg_integer_create(
const_cast<char*>(GRPC_ARG_TCP_HANDSHAKER_BIND_ENDPOINT_TO_POLLSET),
1),
};
grpc_channel_args* channel_args = grpc_channel_args_copy_and_add(
args_.channel_args, args_to_add.data(), args_to_add.size());
handshake_mgr_ = MakeRefCounted<HandshakeManager>();
CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_CLIENT, channel_args, args_.interested_parties,
handshake_mgr_.get());
Ref().release(); // Ref held by OnHandshakeDone().
handshake_mgr_->DoHandshake(nullptr /* endpoint */, channel_args,
args.deadline, nullptr /* acceptor */,
OnHandshakeDone, this);
grpc_channel_args_destroy(channel_args);
// In some implementations, the closure can be flushed before
// grpc_tcp_client_connect() returns, and since the closure requires access
// to mu_, this can result in a deadlock (see
// https://github.com/grpc/grpc/issues/16427 for details).
// grpc_tcp_client_connect() will fill endpoint_ with proper contents, and we
// make sure that we still exist at that point by taking a ref.
Ref().release(); // Ref held by callback.
grpc_tcp_client_connect(&connected_, ep, args.interested_parties,
args.channel_args, args.address, args.deadline);
}
void Chttp2Connector::Shutdown(grpc_error_handle error) {
MutexLock lock(&mu_);
shutdown_ = true;
if (handshake_mgr_ != nullptr) {
// Handshaker will also shutdown the endpoint if it exists
handshake_mgr_->Shutdown(GRPC_ERROR_REF(error));
}
// If handshaking is not yet in progress, shutdown the endpoint.
// Otherwise, the handshaker will do this for us.
if (!connecting_ && endpoint_ != nullptr) {
grpc_endpoint_shutdown(endpoint_, GRPC_ERROR_REF(error));
}
GRPC_ERROR_UNREF(error);
}
void Chttp2Connector::Connected(void* arg, grpc_error_handle error) {
Chttp2Connector* self = static_cast<Chttp2Connector*>(arg);
bool unref = false;
{
MutexLock lock(&self->mu_);
GPR_ASSERT(self->connecting_);
self->connecting_ = false;
if (error != GRPC_ERROR_NONE || self->shutdown_) {
if (error == GRPC_ERROR_NONE) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("connector shutdown");
} else {
error = GRPC_ERROR_REF(error);
}
if (self->endpoint_ != nullptr) {
grpc_endpoint_shutdown(self->endpoint_, GRPC_ERROR_REF(error));
}
self->result_->Reset();
grpc_closure* notify = self->notify_;
self->notify_ = nullptr;
ExecCtx::Run(DEBUG_LOCATION, notify, error);
unref = true;
} else {
GPR_ASSERT(self->endpoint_ != nullptr);
self->StartHandshakeLocked();
}
}
if (unref) self->Unref();
}
void Chttp2Connector::StartHandshakeLocked() {
handshake_mgr_ = MakeRefCounted<HandshakeManager>();
CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_CLIENT, args_.channel_args, args_.interested_parties,
handshake_mgr_.get());
grpc_endpoint_add_to_pollset_set(endpoint_, args_.interested_parties);
handshake_mgr_->DoHandshake(endpoint_, args_.channel_args, args_.deadline,
nullptr /* acceptor */, OnHandshakeDone, this);
endpoint_ = nullptr; // Endpoint handed off to handshake manager.
}
namespace {
void NullThenSchedClosure(const DebugLocation& location, grpc_closure** closure,
grpc_error_handle error) {
grpc_closure* c = *closure;
*closure = nullptr;
ExecCtx::Run(location, c, error);
}
} // namespace
void Chttp2Connector::OnHandshakeDone(void* arg, grpc_error_handle error) {
auto* args = static_cast<HandshakerArgs*>(arg);
Chttp2Connector* self = static_cast<Chttp2Connector*>(args->user_data);

@ -22,19 +22,22 @@
#include <grpc/support/port_platform.h>
#include "src/core/ext/filters/client_channel/connector.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/transport/handshaker_registry.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/channel/handshaker_registry.h"
namespace grpc_core {
class Chttp2Connector : public SubchannelConnector {
public:
Chttp2Connector();
~Chttp2Connector() override;
void Connect(const Args& args, Result* result, grpc_closure* notify) override;
void Shutdown(grpc_error_handle error) override;
private:
static void Connected(void* arg, grpc_error_handle error);
void StartHandshakeLocked();
static void OnHandshakeDone(void* arg, grpc_error_handle error);
static void OnReceiveSettings(void* arg, grpc_error_handle error);
static void OnTimeout(void* arg, grpc_error_handle error);
@ -55,9 +58,11 @@ class Chttp2Connector : public SubchannelConnector {
Result* result_ = nullptr;
grpc_closure* notify_ = nullptr;
bool shutdown_ = false;
bool connecting_ = false;
// Holds the endpoint when first created before being handed off to
// the handshake manager, and then again after handshake is done.
grpc_endpoint* endpoint_ = nullptr;
grpc_closure connected_;
grpc_closure on_receive_settings_;
grpc_timer timer_;
grpc_closure on_timeout_;

@ -43,6 +43,7 @@
#include "src/core/ext/transport/chttp2/transport/internal.h"
#include "src/core/lib/address_utils/sockaddr_utils.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -59,7 +60,6 @@
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/uri/uri_parser.h"
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD

@ -18,7 +18,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/channel/handshaker.h"
#include <string.h>
@ -180,7 +180,6 @@ void HandshakeManager::DoHandshake(grpc_endpoint* endpoint,
// Construct handshaker args. These will be passed through all
// handshakers and eventually be freed by the on_handshake_done callback.
args_.endpoint = endpoint;
args_.deadline = deadline;
args_.args = grpc_channel_args_copy(channel_args);
args_.user_data = user_data;
args_.read_buffer =

@ -16,8 +16,8 @@
*
*/
#ifndef GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_H
#define GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_H
#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H
#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H
#include <grpc/support/port_platform.h>
@ -68,10 +68,6 @@ struct HandshakerArgs {
// User data passed through the handshake manager. Not used by
// individual handshakers.
void* user_data = nullptr;
// Deadline associated with the handshake.
// TODO(anramach): Move this out of handshake args after event engine
// is the default.
Timestamp deadline;
};
///
@ -162,4 +158,4 @@ typedef grpc_core::Handshaker grpc_handshaker;
void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
grpc_handshaker* handshaker);
#endif /* GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_H */
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */

@ -16,8 +16,8 @@
*
*/
#ifndef GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_FACTORY_H
#define GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_FACTORY_H
#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H
#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H
#include <grpc/support/port_platform.h>
@ -47,4 +47,4 @@ class HandshakerFactory {
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_FACTORY_H */
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */

@ -18,7 +18,7 @@
#include <grpc/support/port_platform.h>
#include "src/core/lib/transport/handshaker_registry.h"
#include "src/core/lib/channel/handshaker_registry.h"
namespace grpc_core {

@ -16,8 +16,8 @@
*
*/
#ifndef GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H
#define GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H
#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H
#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H
#include <grpc/support/port_platform.h>
@ -26,7 +26,7 @@
#include <grpc/impl/codegen/grpc_types.h>
#include "src/core/lib/transport/handshaker_factory.h"
#include "src/core/lib/channel/handshaker_factory.h"
namespace grpc_core {
@ -68,4 +68,4 @@ class HandshakerRegistry {
} // namespace grpc_core
#endif /* GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H */
#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */

@ -21,11 +21,11 @@
#include <functional>
#include "src/core/lib/channel/channel_args_preconditioning.h"
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/resolver/resolver_registry.h"
#include "src/core/lib/security/credentials/channel_creds_registry.h"
#include "src/core/lib/service_config/service_config_parser.h"
#include "src/core/lib/surface/channel_init.h"
#include "src/core/lib/transport/handshaker_registry.h"
namespace grpc_core {

@ -47,7 +47,6 @@
#include "src/core/lib/resource_quota/api.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/error_utils.h"
#include "src/core/lib/transport/tcp_connect_handshaker.h"
namespace grpc_core {
@ -216,10 +215,20 @@ void HttpRequest::Orphan() {
GPR_ASSERT(!cancelled_);
cancelled_ = true;
dns_request_.reset(); // cancel potentially pending DNS resolution
if (connecting_) {
// gRPC's TCP connection establishment API doesn't currently have
// a mechanism for cancellation. So invoke the user callback now. The TCP
// connection will eventually complete (at least within its deadline), and
// we'll simply unref ourselves at that point.
// TODO(apolcyn): fix this to cancel the TCP connection attempt when
// an API to do so exists.
Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"HTTP request cancelled during TCP connection establishment",
&overall_error_, 1));
}
if (handshake_mgr_ != nullptr) {
// Shutdown will cancel any ongoing tcp connect.
handshake_mgr_->Shutdown(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"HTTP request cancelled during handshake"));
"HTTP request cancelled during security handshake"));
}
if (own_endpoint_ && ep_ != nullptr) {
grpc_endpoint_shutdown(
@ -297,7 +306,8 @@ void HttpRequest::OnHandshakeDone(void* arg, grpc_error_handle error) {
MutexLock lock(&req->mu_);
req->own_endpoint_ = true;
if (error != GRPC_ERROR_NONE) {
req->handshake_mgr_.reset();
gpr_log(GPR_ERROR, "Secure transport setup failed: %s",
grpc_error_std_string(error).c_str());
req->NextAddress(GRPC_ERROR_REF(error));
return;
}
@ -306,55 +316,69 @@ void HttpRequest::OnHandshakeDone(void* arg, grpc_error_handle error) {
grpc_slice_buffer_destroy_internal(args->read_buffer);
gpr_free(args->read_buffer);
req->ep_ = args->endpoint;
req->handshake_mgr_.reset();
if (req->cancelled_) {
req->NextAddress(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"HTTP request cancelled during handshake"));
"HTTP request cancelled during security handshake"));
return;
}
req->StartWrite();
}
void HttpRequest::DoHandshake(const grpc_resolved_address* addr) {
void HttpRequest::OnConnected(void* arg, grpc_error_handle error) {
RefCountedPtr<HttpRequest> req(static_cast<HttpRequest*>(arg));
MutexLock lock(&req->mu_);
req->connecting_ = false;
req->own_endpoint_ = true;
if (req->cancelled_) {
// since we were cancelled while connecting, Finish has already
// been called.
return;
}
if (!req->ep_) {
req->NextAddress(GRPC_ERROR_REF(error));
return;
}
// TODO(yihuaz): treating nullptr channel_creds_ as insecure is
// a hack used to support the port server client (a test utility) in
// unsecure builds (when no definition of grpc_insecure_credentials_create
// exists). We can remove this hack and unconditionally assume a valid
// channel_creds_ object after unsecure builds are deleted, in
// https://github.com/grpc/grpc/pull/25586.
if (req->channel_creds_ == nullptr) {
gpr_log(GPR_DEBUG,
"HTTP request skipping handshake because creds are null");
req->StartWrite();
return;
}
// Create the security connector using the credentials and target name.
grpc_channel_args* new_args_from_connector = nullptr;
RefCountedPtr<grpc_channel_security_connector> sc =
channel_creds_->create_security_connector(
nullptr /*call_creds*/, uri_.authority().c_str(), channel_args_,
&new_args_from_connector);
req->channel_creds_->create_security_connector(
nullptr /*call_creds*/, req->uri_.authority().c_str(),
req->channel_args_, &new_args_from_connector);
if (sc == nullptr) {
Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"failed to create security connector", &overall_error_, 1));
req->Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"failed to create security connector", &req->overall_error_, 1));
return;
}
absl::StatusOr<std::string> address = grpc_sockaddr_to_uri(addr);
if (!address.ok()) {
Finish(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Failed to extract URI from address", &overall_error_, 1));
return;
}
absl::InlinedVector<grpc_arg, 2> args_to_add = {
grpc_security_connector_to_arg(sc.get()),
grpc_channel_arg_string_create(
const_cast<char*>(GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS),
const_cast<char*>(address.value().c_str())),
};
const grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
grpc_arg security_connector_arg = grpc_security_connector_to_arg(sc.get());
grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
new_args_from_connector != nullptr ? new_args_from_connector
: channel_args_,
args_to_add.data(), args_to_add.size());
: req->channel_args_,
&security_connector_arg, 1);
grpc_channel_args_destroy(new_args_from_connector);
// Start the handshake
handshake_mgr_ = MakeRefCounted<HandshakeManager>();
req->handshake_mgr_ = MakeRefCounted<HandshakeManager>();
CoreConfiguration::Get().handshaker_registry().AddHandshakers(
HANDSHAKER_CLIENT, new_args, pollset_set_, handshake_mgr_.get());
Ref().release(); // ref held by pending handshake
grpc_endpoint* ep = ep_;
ep_ = nullptr;
own_endpoint_ = false;
handshake_mgr_->DoHandshake(ep, new_args, deadline_,
/*acceptor=*/nullptr, OnHandshakeDone,
/*user_data=*/this);
HANDSHAKER_CLIENT, new_args, req->pollset_set_,
req->handshake_mgr_.get());
req->Ref().release(); // ref held by pending handshake
grpc_endpoint* ep = req->ep_;
req->ep_ = nullptr;
req->own_endpoint_ = false;
req->handshake_mgr_->DoHandshake(ep, new_args, req->deadline_,
/*acceptor=*/nullptr, OnHandshakeDone,
/*user_data=*/req.get());
sc.reset(DEBUG_LOCATION, "httpcli");
grpc_channel_args_destroy(new_args);
}
@ -374,7 +398,12 @@ void HttpRequest::NextAddress(grpc_error_handle error) {
return;
}
const grpc_resolved_address* addr = &addresses_[next_address_++];
DoHandshake(addr);
GRPC_CLOSURE_INIT(&connected_, OnConnected, this, grpc_schedule_on_exec_ctx);
connecting_ = true;
own_endpoint_ = false;
Ref().release(); // ref held by pending connect
grpc_tcp_client_connect(&connected_, &ep_, pollset_set_, channel_args_, addr,
deadline_);
}
void HttpRequest::OnResolved(

@ -25,6 +25,7 @@
#include <grpc/support/time.h>
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gprpp/orphanable.h"
#include "src/core/lib/http/parser.h"
#include "src/core/lib/iomgr/endpoint.h"
@ -34,7 +35,6 @@
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/resource_quota/resource_quota.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/uri/uri_parser.h"
/* User agent this library reports */
@ -211,8 +211,7 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
static void OnHandshakeDone(void* arg, grpc_error_handle error);
void DoHandshake(const grpc_resolved_address* addr)
ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
static void OnConnected(void* arg, grpc_error_handle error);
void NextAddress(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
@ -228,6 +227,7 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
grpc_closure continue_on_read_after_schedule_on_exec_ctx_;
grpc_closure done_write_;
grpc_closure continue_done_write_after_schedule_on_exec_ctx_;
grpc_closure connected_;
grpc_endpoint* ep_ = nullptr;
grpc_closure* on_done_;
ResourceQuotaRefPtr resource_quota_;
@ -238,6 +238,7 @@ class HttpRequest : public InternallyRefCounted<HttpRequest> {
RefCountedPtr<HandshakeManager> handshake_mgr_ ABSL_GUARDED_BY(mu_);
bool own_endpoint_ ABSL_GUARDED_BY(mu_) = true;
bool cancelled_ ABSL_GUARDED_BY(mu_) = false;
bool connecting_ ABSL_GUARDED_BY(mu_) = false;
grpc_http_parser parser_ ABSL_GUARDED_BY(mu_);
std::vector<grpc_resolved_address> addresses_ ABSL_GUARDED_BY(mu_);
size_t next_address_ ABSL_GUARDED_BY(mu_) = 0;

@ -30,6 +30,7 @@
#include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -38,7 +39,6 @@
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/credentials/fake/fake_credentials.h"
#include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/tsi/fake_transport_security.h"
namespace {

@ -23,9 +23,9 @@
#include <grpc/grpc_security.h>
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/lib/transport/handshaker.h"
/* Creates a fake connector that emulates real channel security. */
grpc_core::RefCountedPtr<grpc_channel_security_connector>

@ -26,12 +26,12 @@
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/credentials/credentials.h"
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/transport/handshaker.h"
grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount(
false, "security_connector_refcount");

@ -25,12 +25,12 @@
#include <grpc/grpc_security.h>
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gprpp/ref_counted.h"
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/pollset.h"
#include "src/core/lib/iomgr/tcp_server.h"
#include "src/core/lib/promise/arena_promise.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/tsi/transport_security_interface.h"
extern grpc_core::DebugOnlyTraceFlag grpc_trace_security_connector_refcount;

@ -30,6 +30,7 @@
#include <grpc/support/log.h>
#include "src/core/ext/transport/chttp2/alpn/alpn.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/gpr/string.h"
#include "src/core/lib/gprpp/host_port.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
@ -41,7 +42,6 @@
#include "src/core/lib/security/security_connector/load_system_roots.h"
#include "src/core/lib/security/security_connector/ssl_utils.h"
#include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/tsi/ssl_transport_security.h"
#include "src/core/tsi/transport_security.h"

@ -31,13 +31,13 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/security/context/security_context.h"
#include "src/core/lib/security/transport/secure_endpoint.h"
#include "src/core/lib/security/transport/tsi_error.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/tsi/transport_security_grpc.h"
#define GRPC_INITIAL_HANDSHAKE_BUFFER_SIZE 256

@ -21,9 +21,9 @@
#include <grpc/support/port_platform.h>
#include "src/core/lib/channel/handshaker.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/security/security_connector/security_connector.h"
#include "src/core/lib/transport/handshaker.h"
namespace grpc_core {

@ -1,229 +0,0 @@
//
//
// Copyright 2022 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
#include <grpc/support/port_platform.h>
#include "src/core/lib/transport/tcp_connect_handshaker.h"
#include <string.h>
#include "src/core/lib/address_utils/parse_address.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/iomgr/polling_entity.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/transport/handshaker.h"
#include "src/core/lib/transport/handshaker_registry.h"
namespace grpc_core {
namespace {
class TCPConnectHandshaker : public Handshaker {
public:
explicit TCPConnectHandshaker(grpc_pollset_set* pollset_set);
void Shutdown(grpc_error_handle why) override;
void DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
grpc_closure* on_handshake_done,
HandshakerArgs* args) override;
const char* name() const override { return "tcp_connect"; }
private:
~TCPConnectHandshaker() override;
void CleanupArgsForFailureLocked() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
void FinishLocked(grpc_error_handle error) ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_);
static void Connected(void* arg, grpc_error_handle error);
Mutex mu_;
bool shutdown_ ABSL_GUARDED_BY(mu_) = false;
// Endpoint and read buffer to destroy after a shutdown.
grpc_endpoint* endpoint_to_destroy_ ABSL_GUARDED_BY(mu_) = nullptr;
grpc_slice_buffer* read_buffer_to_destroy_ ABSL_GUARDED_BY(mu_) = nullptr;
grpc_closure* on_handshake_done_ ABSL_GUARDED_BY(mu_) = nullptr;
grpc_pollset_set* interested_parties_ = nullptr;
grpc_polling_entity pollent_;
HandshakerArgs* args_ = nullptr;
bool bind_endpoint_to_pollset_ = false;
grpc_resolved_address addr_;
grpc_closure connected_;
};
TCPConnectHandshaker::TCPConnectHandshaker(grpc_pollset_set* pollset_set)
: interested_parties_(grpc_pollset_set_create()),
pollent_(grpc_polling_entity_create_from_pollset_set(pollset_set)) {
// Intersted parties might be null for platforms like Apple.
// Explicitly check before adding/deleting from pollset_set to handle this
// use case.
if (interested_parties_ != nullptr) {
grpc_polling_entity_add_to_pollset_set(&pollent_, interested_parties_);
}
GRPC_CLOSURE_INIT(&connected_, Connected, this, grpc_schedule_on_exec_ctx);
}
void TCPConnectHandshaker::Shutdown(grpc_error_handle why) {
// TODO(anramach): After migration to EventEngine, cancel the in-progress
// TCP connection attempt.
{
MutexLock lock(&mu_);
if (!shutdown_) {
shutdown_ = true;
// If we are shutting down while connecting, respond back with
// handshake done.
// The callback from grpc_tcp_client_connect will perform
// the necessary clean up.
if (on_handshake_done_ != nullptr) {
CleanupArgsForFailureLocked();
FinishLocked(
GRPC_ERROR_CREATE_FROM_STATIC_STRING("tcp handshaker shutdown"));
}
}
}
GRPC_ERROR_UNREF(why);
}
void TCPConnectHandshaker::DoHandshake(grpc_tcp_server_acceptor* /*acceptor*/,
grpc_closure* on_handshake_done,
HandshakerArgs* args) {
{
MutexLock lock(&mu_);
on_handshake_done_ = on_handshake_done;
}
GPR_ASSERT(args->endpoint == nullptr);
args_ = args;
char* address = grpc_channel_args_find_string(
args->args, GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS);
absl::StatusOr<URI> uri = URI::Parse(address);
if (!uri.ok() || !grpc_parse_uri(*uri, &addr_)) {
MutexLock lock(&mu_);
FinishLocked(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Resolved address in invalid format"));
return;
}
bind_endpoint_to_pollset_ = grpc_channel_args_find_bool(
args->args, GRPC_ARG_TCP_HANDSHAKER_BIND_ENDPOINT_TO_POLLSET, false);
const char* args_to_remove[] = {
GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS,
GRPC_ARG_TCP_HANDSHAKER_BIND_ENDPOINT_TO_POLLSET};
// Update args to not contain the args relevant to TCP connect handshaker.
grpc_channel_args* channel_args = grpc_channel_args_copy_and_remove(
args->args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove));
grpc_channel_args_destroy(args->args);
args->args = channel_args;
// In some implementations, the closure can be flushed before
// grpc_tcp_client_connect() returns, and since the closure requires access
// to mu_, this can result in a deadlock (see
// https://github.com/grpc/grpc/issues/16427 for details).
// grpc_tcp_client_connect() will fill endpoint_ with proper contents, and we
// make sure that we still exist at that point by taking a ref.
Ref().release(); // Ref held by callback.
// As we fake the TCP client connection failure when shutdown is called
// we don't want to pass args->endpoint directly.
// Instead pass endpoint_ and swap this endpoint to
// args endpoint on success.
grpc_tcp_client_connect(&connected_, &endpoint_to_destroy_,
interested_parties_, args->args, &addr_,
args->deadline);
}
void TCPConnectHandshaker::Connected(void* arg, grpc_error_handle error) {
RefCountedPtr<TCPConnectHandshaker> self(
static_cast<TCPConnectHandshaker*>(arg));
{
MutexLock lock(&self->mu_);
if (error != GRPC_ERROR_NONE || self->shutdown_) {
if (error == GRPC_ERROR_NONE) {
error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("tcp handshaker shutdown");
} else {
error = GRPC_ERROR_REF(error);
}
if (self->endpoint_to_destroy_ != nullptr) {
grpc_endpoint_shutdown(self->endpoint_to_destroy_,
GRPC_ERROR_REF(error));
}
if (!self->shutdown_) {
self->CleanupArgsForFailureLocked();
self->shutdown_ = true;
self->FinishLocked(error);
} else {
// The on_handshake_done_ is already as part of shutdown when connecting
// So nothing to be done here other than unrefing the error.
GRPC_ERROR_UNREF(error);
}
return;
}
GPR_ASSERT(self->endpoint_to_destroy_ != nullptr);
self->args_->endpoint = self->endpoint_to_destroy_;
self->endpoint_to_destroy_ = nullptr;
if (self->bind_endpoint_to_pollset_) {
grpc_endpoint_add_to_pollset_set(self->args_->endpoint,
self->interested_parties_);
}
self->FinishLocked(GRPC_ERROR_NONE);
}
}
TCPConnectHandshaker::~TCPConnectHandshaker() {
if (endpoint_to_destroy_ != nullptr) {
grpc_endpoint_destroy(endpoint_to_destroy_);
}
if (read_buffer_to_destroy_ != nullptr) {
grpc_slice_buffer_destroy_internal(read_buffer_to_destroy_);
gpr_free(read_buffer_to_destroy_);
}
grpc_pollset_set_destroy(interested_parties_);
}
void TCPConnectHandshaker::CleanupArgsForFailureLocked() {
read_buffer_to_destroy_ = args_->read_buffer;
args_->read_buffer = nullptr;
grpc_channel_args_destroy(args_->args);
args_->args = nullptr;
}
void TCPConnectHandshaker::FinishLocked(grpc_error_handle error) {
if (interested_parties_ != nullptr) {
grpc_polling_entity_del_from_pollset_set(&pollent_, interested_parties_);
}
ExecCtx::Run(DEBUG_LOCATION, on_handshake_done_, error);
on_handshake_done_ = nullptr;
}
//
// TCPConnectHandshakerFactory
//
class TCPConnectHandshakerFactory : public HandshakerFactory {
public:
void AddHandshakers(const grpc_channel_args* /*args*/,
grpc_pollset_set* interested_parties,
HandshakeManager* handshake_mgr) override {
handshake_mgr->Add(
MakeRefCounted<TCPConnectHandshaker>(interested_parties));
}
~TCPConnectHandshakerFactory() override = default;
};
} // namespace
void RegisterTCPConnectHandshaker(CoreConfiguration::Builder* builder) {
builder->handshaker_registry()->RegisterHandshakerFactory(
true /* at_start */, HANDSHAKER_CLIENT,
absl::make_unique<TCPConnectHandshakerFactory>());
}
} // namespace grpc_core

@ -1,39 +0,0 @@
//
// Copyright 2022 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef GRPC_CORE_LIB_TRANSPORT_TCP_CONNECT_HANDSHAKER_H
#define GRPC_CORE_LIB_TRANSPORT_TCP_CONNECT_HANDSHAKER_H
#include <grpc/support/port_platform.h>
#include "src/core/lib/config/core_configuration.h"
// Indicates the address that the tcp connect handshaker should connect to.
#define GRPC_ARG_TCP_HANDSHAKER_RESOLVED_ADDRESS \
"grpc.internal.tcp_handshaker_resolved_address"
// Whether the TCP connect handshaker should bind the endpoint to the pollset.
#define GRPC_ARG_TCP_HANDSHAKER_BIND_ENDPOINT_TO_POLLSET \
"grpc.internal.tcp_handshaker_bind_endpoint_to_pollset"
namespace grpc_core {
// Register the TCP Connect handshaker into the configuration builder.
void RegisterTCPConnectHandshaker(CoreConfiguration::Builder* builder);
} // namespace grpc_core
#endif // GRPC_CORE_LIB_TRANSPORT_TCP_CONNECT_HANDSHAKER_H

@ -22,8 +22,6 @@
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/surface/builtins.h"
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "src/core/lib/transport/tcp_connect_handshaker.h"
extern void grpc_register_extra_plugins(void);
@ -103,11 +101,6 @@ extern void RegisterBinderResolver(CoreConfiguration::Builder* builder);
#endif
void BuildCoreConfiguration(CoreConfiguration::Builder* builder) {
// The order of the handshaker registration is crucial here.
// We want TCP connect handshaker to be registered last so that it is added to
// the start of the handshaker list.
RegisterHttpConnectHandshaker(builder);
RegisterTCPConnectHandshaker(builder);
BuildClientChannelConfiguration(builder);
SecurityRegisterHandshakerFactories(builder);
RegisterClientAuthorityFilter(builder);

@ -29,6 +29,7 @@ CORE_SOURCE_FILES = [
'src/core/ext/filters/client_channel/dynamic_filters.cc',
'src/core/ext/filters/client_channel/global_subchannel_pool.cc',
'src/core/ext/filters/client_channel/health/health_check_client.cc',
'src/core/ext/filters/client_channel/http_connect_handshaker.cc',
'src/core/ext/filters/client_channel/http_proxy.cc',
'src/core/ext/filters/client_channel/lb_policy.cc',
'src/core/ext/filters/client_channel/lb_policy/address_filtering.cc',
@ -426,6 +427,8 @@ CORE_SOURCE_FILES = [
'src/core/lib/channel/channelz.cc',
'src/core/lib/channel/channelz_registry.cc',
'src/core/lib/channel/connected_channel.cc',
'src/core/lib/channel/handshaker.cc',
'src/core/lib/channel/handshaker_registry.cc',
'src/core/lib/channel/promise_based_filter.cc',
'src/core/lib/channel/status_util.cc',
'src/core/lib/compression/compression.cc',
@ -684,13 +687,9 @@ CORE_SOURCE_FILES = [
'src/core/lib/transport/byte_stream.cc',
'src/core/lib/transport/connectivity_state.cc',
'src/core/lib/transport/error_utils.cc',
'src/core/lib/transport/handshaker.cc',
'src/core/lib/transport/handshaker_registry.cc',
'src/core/lib/transport/http_connect_handshaker.cc',
'src/core/lib/transport/parsed_metadata.cc',
'src/core/lib/transport/pid_controller.cc',
'src/core/lib/transport/status_conversion.cc',
'src/core/lib/transport/tcp_connect_handshaker.cc',
'src/core/lib/transport/timeout_encoding.cc',
'src/core/lib/transport/transport.cc',
'src/core/lib/transport/transport_op_string.cc',

@ -18,10 +18,10 @@
#include <gmock/gmock.h>
#include "src/core/ext/filters/client_channel/http_connect_handshaker.h"
#include "src/core/ext/filters/client_channel/http_proxy.h"
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/env.h"
#include "src/core/lib/transport/http_connect_handshaker.h"
#include "test/core/util/test_config.h"
namespace grpc_core {

@ -31,11 +31,11 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include "src/core/lib/channel/handshaker_factory.h"
#include "src/core/lib/channel/handshaker_registry.h"
#include "src/core/lib/config/core_configuration.h"
#include "src/core/lib/iomgr/load_file.h"
#include "src/core/lib/security/transport/security_handshaker.h"
#include "src/core/lib/transport/handshaker_factory.h"
#include "src/core/lib/transport/handshaker_registry.h"
#include "test/core/handshake/server_ssl_common.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"

@ -91,7 +91,7 @@ void grpc_free_port_using_server(int port) {
grpc_schedule_on_exec_ctx),
&rsp,
grpc_core::RefCountedPtr<grpc_channel_credentials>(
grpc_insecure_credentials_create()));
nullptr /* insecure credentials */));
http_request->Start();
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);
@ -175,7 +175,7 @@ static void got_port_from_server(void* arg, grpc_error_handle error) {
grpc_schedule_on_exec_ctx),
&pr->response,
grpc_core::RefCountedPtr<grpc_channel_credentials>(
grpc_insecure_credentials_create()));
nullptr /* insecure credentials */));
pr->http_request->Start();
return;
}
@ -222,7 +222,7 @@ int grpc_pick_port_using_server(void) {
grpc_schedule_on_exec_ctx),
&pr.response,
grpc_core::RefCountedPtr<grpc_channel_credentials>(
grpc_insecure_credentials_create()));
nullptr /*insecure credentials*/));
http_request->Start();
grpc_core::ExecCtx::Get()->Flush();
gpr_mu_lock(pr.mu);

@ -1078,6 +1078,8 @@ src/core/ext/filters/client_channel/global_subchannel_pool.cc \
src/core/ext/filters/client_channel/global_subchannel_pool.h \
src/core/ext/filters/client_channel/health/health_check_client.cc \
src/core/ext/filters/client_channel/health/health_check_client.h \
src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.h \
src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/http_proxy.h \
src/core/ext/filters/client_channel/lb_policy.cc \
@ -1902,6 +1904,11 @@ src/core/lib/channel/channelz_registry.h \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/connected_channel.h \
src/core/lib/channel/context.h \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker.h \
src/core/lib/channel/handshaker_factory.h \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/handshaker_registry.h \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/promise_based_filter.h \
src/core/lib/channel/status_util.cc \
@ -2405,14 +2412,7 @@ src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/connectivity_state.h \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/error_utils.h \
src/core/lib/transport/handshaker.cc \
src/core/lib/transport/handshaker.h \
src/core/lib/transport/handshaker_factory.h \
src/core/lib/transport/handshaker_registry.cc \
src/core/lib/transport/handshaker_registry.h \
src/core/lib/transport/http2_errors.h \
src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/http_connect_handshaker.h \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \
@ -2420,8 +2420,6 @@ src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/pid_controller.h \
src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/status_conversion.h \
src/core/lib/transport/tcp_connect_handshaker.cc \
src/core/lib/transport/tcp_connect_handshaker.h \
src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/timeout_encoding.h \
src/core/lib/transport/transport.cc \

@ -898,6 +898,8 @@ src/core/ext/filters/client_channel/global_subchannel_pool.cc \
src/core/ext/filters/client_channel/global_subchannel_pool.h \
src/core/ext/filters/client_channel/health/health_check_client.cc \
src/core/ext/filters/client_channel/health/health_check_client.h \
src/core/ext/filters/client_channel/http_connect_handshaker.cc \
src/core/ext/filters/client_channel/http_connect_handshaker.h \
src/core/ext/filters/client_channel/http_proxy.cc \
src/core/ext/filters/client_channel/http_proxy.h \
src/core/ext/filters/client_channel/lb_policy.cc \
@ -1694,6 +1696,11 @@ src/core/lib/channel/channelz_registry.h \
src/core/lib/channel/connected_channel.cc \
src/core/lib/channel/connected_channel.h \
src/core/lib/channel/context.h \
src/core/lib/channel/handshaker.cc \
src/core/lib/channel/handshaker.h \
src/core/lib/channel/handshaker_factory.h \
src/core/lib/channel/handshaker_registry.cc \
src/core/lib/channel/handshaker_registry.h \
src/core/lib/channel/promise_based_filter.cc \
src/core/lib/channel/promise_based_filter.h \
src/core/lib/channel/status_util.cc \
@ -2202,14 +2209,7 @@ src/core/lib/transport/connectivity_state.cc \
src/core/lib/transport/connectivity_state.h \
src/core/lib/transport/error_utils.cc \
src/core/lib/transport/error_utils.h \
src/core/lib/transport/handshaker.cc \
src/core/lib/transport/handshaker.h \
src/core/lib/transport/handshaker_factory.h \
src/core/lib/transport/handshaker_registry.cc \
src/core/lib/transport/handshaker_registry.h \
src/core/lib/transport/http2_errors.h \
src/core/lib/transport/http_connect_handshaker.cc \
src/core/lib/transport/http_connect_handshaker.h \
src/core/lib/transport/metadata_batch.h \
src/core/lib/transport/parsed_metadata.cc \
src/core/lib/transport/parsed_metadata.h \
@ -2217,8 +2217,6 @@ src/core/lib/transport/pid_controller.cc \
src/core/lib/transport/pid_controller.h \
src/core/lib/transport/status_conversion.cc \
src/core/lib/transport/status_conversion.h \
src/core/lib/transport/tcp_connect_handshaker.cc \
src/core/lib/transport/tcp_connect_handshaker.h \
src/core/lib/transport/timeout_encoding.cc \
src/core/lib/transport/timeout_encoding.h \
src/core/lib/transport/transport.cc \

Loading…
Cancel
Save