grpc 1.32.0 → 1.33.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +175 -376
  3. data/include/grpc/grpc.h +0 -5
  4. data/include/grpc/grpc_security.h +16 -0
  5. data/include/grpc/impl/codegen/grpc_types.h +0 -5
  6. data/src/core/ext/filters/client_channel/client_channel.cc +204 -170
  7. data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
  8. data/src/core/ext/filters/client_channel/config_selector.h +34 -5
  9. data/src/core/ext/filters/client_channel/lb_policy.h +1 -1
  10. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
  11. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  12. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +3 -2
  13. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +106 -106
  14. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +2 -2
  15. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
  17. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -32
  18. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -3
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +198 -126
  20. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +439 -249
  21. data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +571 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +727 -0
  23. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
  24. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  25. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +553 -358
  26. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  27. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +8 -39
  28. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +4 -2
  29. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +44 -43
  30. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +5 -9
  31. data/src/core/ext/filters/client_channel/server_address.cc +80 -0
  32. data/src/core/ext/filters/client_channel/server_address.h +25 -36
  33. data/src/core/ext/filters/client_channel/service_config.cc +16 -13
  34. data/src/core/ext/filters/client_channel/service_config.h +7 -4
  35. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
  36. data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
  37. data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
  38. data/src/core/ext/filters/client_channel/subchannel_interface.h +44 -0
  39. data/src/core/ext/filters/message_size/message_size_filter.cc +2 -1
  40. data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
  41. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +17 -10
  42. data/src/core/ext/transport/chttp2/transport/flow_control.cc +10 -2
  43. data/src/core/ext/transport/chttp2/transport/flow_control.h +10 -0
  44. data/src/core/ext/transport/chttp2/transport/internal.h +5 -0
  45. data/src/core/ext/transport/chttp2/transport/parsing.cc +16 -2
  46. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +29 -9
  47. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +66 -0
  48. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +123 -45
  49. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +310 -53
  50. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +17 -5
  51. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +45 -0
  52. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +1 -0
  53. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +16 -9
  54. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +38 -15
  55. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  56. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +133 -0
  57. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +54 -8
  58. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +123 -5
  59. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +40 -16
  60. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +114 -5
  61. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
  62. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +85 -0
  63. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +36 -16
  64. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +86 -20
  65. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +23 -6
  66. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +54 -5
  67. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +10 -6
  68. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +28 -11
  69. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +184 -57
  70. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +504 -69
  71. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +6 -5
  72. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +11 -7
  73. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +78 -26
  74. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +236 -25
  75. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +8 -9
  76. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +19 -33
  77. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +7 -3
  78. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +16 -0
  79. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +65 -23
  80. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +229 -47
  81. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +20 -10
  82. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +67 -4
  83. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +3 -2
  84. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +6 -0
  85. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  86. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +753 -0
  87. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  88. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +57 -0
  89. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
  90. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +53 -0
  91. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
  92. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +129 -0
  93. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
  94. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +77 -0
  95. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
  96. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +85 -0
  97. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
  98. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +160 -0
  99. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
  100. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +84 -0
  101. data/src/core/ext/xds/certificate_provider_factory.h +59 -0
  102. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  103. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  104. data/src/core/ext/xds/certificate_provider_store.h +50 -0
  105. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +377 -0
  106. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +102 -0
  107. data/src/core/ext/xds/xds_api.cc +301 -93
  108. data/src/core/ext/xds/xds_api.h +129 -92
  109. data/src/core/ext/xds/xds_channel_args.h +6 -3
  110. data/src/core/ext/xds/xds_client.cc +498 -410
  111. data/src/core/ext/xds/xds_client.h +105 -51
  112. data/src/core/ext/xds/xds_client_stats.cc +18 -12
  113. data/src/core/ext/xds/xds_client_stats.h +33 -5
  114. data/src/core/lib/channel/channel_args.h +0 -1
  115. data/src/core/lib/channel/channelz.cc +10 -45
  116. data/src/core/lib/channel/channelz.h +11 -19
  117. data/src/core/lib/channel/channelz_registry.cc +12 -11
  118. data/src/core/lib/channel/channelz_registry.h +3 -0
  119. data/src/core/lib/gpr/time_precise.cc +2 -0
  120. data/src/core/lib/gpr/time_precise.h +6 -2
  121. data/src/core/lib/gprpp/dual_ref_counted.h +336 -0
  122. data/src/core/lib/gprpp/ref_counted.h +51 -22
  123. data/src/core/lib/gprpp/ref_counted_ptr.h +153 -0
  124. data/src/core/lib/iomgr/endpoint_cfstream.cc +9 -5
  125. data/src/core/lib/iomgr/exec_ctx.h +10 -8
  126. data/src/core/lib/json/json_util.cc +58 -0
  127. data/src/core/lib/json/json_util.h +37 -0
  128. data/src/core/lib/security/certificate_provider.h +60 -0
  129. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +321 -0
  130. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +214 -0
  131. data/src/core/lib/security/credentials/xds/xds_credentials.cc +45 -0
  132. data/src/core/lib/security/credentials/xds/xds_credentials.h +51 -0
  133. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -10
  134. data/src/core/lib/security/security_connector/ssl_utils.h +5 -0
  135. data/src/core/lib/surface/channel.cc +9 -31
  136. data/src/core/lib/surface/channel.h +6 -1
  137. data/src/core/lib/surface/init.cc +26 -9
  138. data/src/core/lib/surface/version.cc +2 -2
  139. data/src/core/lib/transport/bdp_estimator.h +2 -1
  140. data/src/core/lib/transport/connectivity_state.h +2 -2
  141. data/src/core/lib/transport/metadata.cc +11 -1
  142. data/src/core/plugin_registry/grpc_plugin_registry.cc +35 -20
  143. data/src/core/tsi/ssl_transport_security.cc +2 -2
  144. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -2
  145. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -3
  146. data/src/ruby/lib/grpc/version.rb +1 -1
  147. data/third_party/boringssl-with-bazel/err_data.c +465 -463
  148. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
  149. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
  150. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  151. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  152. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  153. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  154. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  155. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
  156. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
  157. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -15
  158. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +98 -11
  159. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +51 -6
  160. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +44 -2
  161. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +221 -49
  162. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +64 -20
  163. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
  164. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +0 -8
  165. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  166. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  167. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
  168. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
  169. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  170. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
  171. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
  172. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  173. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
  174. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
  175. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
  176. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
  177. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  178. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
  179. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  180. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  181. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  182. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
  183. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
  184. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  185. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
  186. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
  187. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
  188. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +1 -1
  189. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
  190. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
  191. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
  192. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
  193. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
  194. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +9 -2
  195. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +26 -6
  196. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +188 -78
  197. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +52 -43
  198. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
  199. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
  200. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
  201. data/third_party/boringssl-with-bazel/src/ssl/internal.h +9 -9
  202. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  203. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
  204. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +4 -8
  205. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +2 -2
  206. metadata +72 -42
  207. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -537
  208. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1141
  209. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  210. data/src/core/ext/upb-generated/gogoproto/gogo.upb.h +0 -29
  211. data/src/core/ext/xds/xds_channel.h +0 -46
  212. data/src/core/ext/xds/xds_channel_secure.cc +0 -103
  213. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  214. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
@@ -31,16 +31,17 @@
31
31
  namespace grpc_core {
32
32
 
33
33
  RefCountedPtr<ServiceConfig> ServiceConfig::Create(
34
- absl::string_view json_string, grpc_error** error) {
34
+ const grpc_channel_args* args, absl::string_view json_string,
35
+ grpc_error** error) {
35
36
  GPR_DEBUG_ASSERT(error != nullptr);
36
37
  Json json = Json::Parse(json_string, error);
37
38
  if (*error != GRPC_ERROR_NONE) return nullptr;
38
- return MakeRefCounted<ServiceConfig>(
39
- std::string(json_string.data(), json_string.size()), std::move(json),
40
- error);
39
+ return MakeRefCounted<ServiceConfig>(args, std::string(json_string),
40
+ std::move(json), error);
41
41
  }
42
42
 
43
- ServiceConfig::ServiceConfig(std::string json_string, Json json,
43
+ ServiceConfig::ServiceConfig(const grpc_channel_args* args,
44
+ std::string json_string, Json json,
44
45
  grpc_error** error)
45
46
  : json_string_(std::move(json_string)), json_(std::move(json)) {
46
47
  GPR_DEBUG_ASSERT(error != nullptr);
@@ -52,9 +53,9 @@ ServiceConfig::ServiceConfig(std::string json_string, Json json,
52
53
  std::vector<grpc_error*> error_list;
53
54
  grpc_error* global_error = GRPC_ERROR_NONE;
54
55
  parsed_global_configs_ =
55
- ServiceConfigParser::ParseGlobalParameters(json_, &global_error);
56
+ ServiceConfigParser::ParseGlobalParameters(args, json_, &global_error);
56
57
  if (global_error != GRPC_ERROR_NONE) error_list.push_back(global_error);
57
- grpc_error* local_error = ParsePerMethodParams();
58
+ grpc_error* local_error = ParsePerMethodParams(args);
58
59
  if (local_error != GRPC_ERROR_NONE) error_list.push_back(local_error);
59
60
  if (!error_list.empty()) {
60
61
  *error = GRPC_ERROR_CREATE_FROM_VECTOR("Service config parsing error",
@@ -68,14 +69,15 @@ ServiceConfig::~ServiceConfig() {
68
69
  }
69
70
  }
70
71
 
71
- grpc_error* ServiceConfig::ParseJsonMethodConfig(const Json& json) {
72
+ grpc_error* ServiceConfig::ParseJsonMethodConfig(const grpc_channel_args* args,
73
+ const Json& json) {
72
74
  std::vector<grpc_error*> error_list;
73
75
  // Parse method config with each registered parser.
74
76
  auto parsed_configs =
75
77
  absl::make_unique<ServiceConfigParser::ParsedConfigVector>();
76
78
  grpc_error* parser_error = GRPC_ERROR_NONE;
77
79
  *parsed_configs =
78
- ServiceConfigParser::ParsePerMethodParameters(json, &parser_error);
80
+ ServiceConfigParser::ParsePerMethodParameters(args, json, &parser_error);
79
81
  if (parser_error != GRPC_ERROR_NONE) {
80
82
  error_list.push_back(parser_error);
81
83
  }
@@ -128,7 +130,7 @@ grpc_error* ServiceConfig::ParseJsonMethodConfig(const Json& json) {
128
130
  return GRPC_ERROR_CREATE_FROM_VECTOR("methodConfig", &error_list);
129
131
  }
130
132
 
131
- grpc_error* ServiceConfig::ParsePerMethodParams() {
133
+ grpc_error* ServiceConfig::ParsePerMethodParams(const grpc_channel_args* args) {
132
134
  std::vector<grpc_error*> error_list;
133
135
  auto it = json_.object_value().find("methodConfig");
134
136
  if (it != json_.object_value().end()) {
@@ -142,7 +144,7 @@ grpc_error* ServiceConfig::ParsePerMethodParams() {
142
144
  "field:methodConfig error:not of type Object"));
143
145
  continue;
144
146
  }
145
- grpc_error* error = ParseJsonMethodConfig(method_config);
147
+ grpc_error* error = ParseJsonMethodConfig(args, method_config);
146
148
  if (error != GRPC_ERROR_NONE) {
147
149
  error_list.push_back(error);
148
150
  }
@@ -202,15 +204,16 @@ std::string ServiceConfig::ParseJsonMethodName(const Json& json,
202
204
 
203
205
  const ServiceConfigParser::ParsedConfigVector*
204
206
  ServiceConfig::GetMethodParsedConfigVector(const grpc_slice& path) const {
207
+ if (parsed_method_configs_map_.empty()) return nullptr;
205
208
  // Try looking up the full path in the map.
206
209
  auto it = parsed_method_configs_map_.find(path);
207
210
  if (it != parsed_method_configs_map_.end()) return it->second;
208
211
  // If we didn't find a match for the path, try looking for a wildcard
209
212
  // entry (i.e., change "/service/method" to "/service/").
210
213
  UniquePtr<char> path_str(grpc_slice_to_c_string(path));
211
- char* sep = strrchr(path_str.get(), '/') + 1;
214
+ char* sep = strrchr(path_str.get(), '/');
212
215
  if (sep == nullptr) return nullptr; // Shouldn't ever happen.
213
- *sep = '\0';
216
+ sep[1] = '\0';
214
217
  grpc_slice wildcard_path = grpc_slice_from_static_string(path_str.get());
215
218
  it = parsed_method_configs_map_.find(wildcard_path);
216
219
  if (it != parsed_method_configs_map_.end()) return it->second;
@@ -65,10 +65,12 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
65
65
  public:
66
66
  /// Creates a new service config from parsing \a json_string.
67
67
  /// Returns null on parse error.
68
- static RefCountedPtr<ServiceConfig> Create(absl::string_view json_string,
68
+ static RefCountedPtr<ServiceConfig> Create(const grpc_channel_args* args,
69
+ absl::string_view json_string,
69
70
  grpc_error** error);
70
71
 
71
- ServiceConfig(std::string json_string, Json json, grpc_error** error);
72
+ ServiceConfig(const grpc_channel_args* args, std::string json_string,
73
+ Json json, grpc_error** error);
72
74
  ~ServiceConfig();
73
75
 
74
76
  const std::string& json_string() const { return json_string_; }
@@ -89,8 +91,9 @@ class ServiceConfig : public RefCounted<ServiceConfig> {
89
91
 
90
92
  private:
91
93
  // Helper functions for parsing the method configs.
92
- grpc_error* ParsePerMethodParams();
93
- grpc_error* ParseJsonMethodConfig(const Json& json);
94
+ grpc_error* ParsePerMethodParams(const grpc_channel_args* args);
95
+ grpc_error* ParseJsonMethodConfig(const grpc_channel_args* args,
96
+ const Json& json);
94
97
 
95
98
  // Returns a path string for the JSON name object specified by json.
96
99
  // Sets *error on error.
@@ -37,8 +37,8 @@ class ServiceConfigChannelArgChannelData {
37
37
  args->channel_args, GRPC_ARG_SERVICE_CONFIG);
38
38
  if (service_config_str != nullptr) {
39
39
  grpc_error* service_config_error = GRPC_ERROR_NONE;
40
- auto service_config =
41
- ServiceConfig::Create(service_config_str, &service_config_error);
40
+ auto service_config = ServiceConfig::Create(
41
+ args->channel_args, service_config_str, &service_config_error);
42
42
  if (service_config_error == GRPC_ERROR_NONE) {
43
43
  service_config_ = std::move(service_config);
44
44
  } else {
@@ -45,14 +45,15 @@ size_t ServiceConfigParser::RegisterParser(std::unique_ptr<Parser> parser) {
45
45
  }
46
46
 
47
47
  ServiceConfigParser::ParsedConfigVector
48
- ServiceConfigParser::ParseGlobalParameters(const Json& json,
48
+ ServiceConfigParser::ParseGlobalParameters(const grpc_channel_args* args,
49
+ const Json& json,
49
50
  grpc_error** error) {
50
51
  ParsedConfigVector parsed_global_configs;
51
52
  std::vector<grpc_error*> error_list;
52
53
  for (size_t i = 0; i < g_registered_parsers->size(); i++) {
53
54
  grpc_error* parser_error = GRPC_ERROR_NONE;
54
- auto parsed_config =
55
- (*g_registered_parsers)[i]->ParseGlobalParams(json, &parser_error);
55
+ auto parsed_config = (*g_registered_parsers)[i]->ParseGlobalParams(
56
+ args, json, &parser_error);
56
57
  if (parser_error != GRPC_ERROR_NONE) {
57
58
  error_list.push_back(parser_error);
58
59
  }
@@ -65,14 +66,15 @@ ServiceConfigParser::ParseGlobalParameters(const Json& json,
65
66
  }
66
67
 
67
68
  ServiceConfigParser::ParsedConfigVector
68
- ServiceConfigParser::ParsePerMethodParameters(const Json& json,
69
+ ServiceConfigParser::ParsePerMethodParameters(const grpc_channel_args* args,
70
+ const Json& json,
69
71
  grpc_error** error) {
70
72
  ParsedConfigVector parsed_method_configs;
71
73
  std::vector<grpc_error*> error_list;
72
74
  for (size_t i = 0; i < g_registered_parsers->size(); i++) {
73
75
  grpc_error* parser_error = GRPC_ERROR_NONE;
74
- auto parsed_config =
75
- (*g_registered_parsers)[i]->ParsePerMethodParams(json, &parser_error);
76
+ auto parsed_config = (*g_registered_parsers)[i]->ParsePerMethodParams(
77
+ args, json, &parser_error);
76
78
  if (parser_error != GRPC_ERROR_NONE) {
77
79
  error_list.push_back(parser_error);
78
80
  }
@@ -23,6 +23,8 @@
23
23
 
24
24
  #include "absl/container/inlined_vector.h"
25
25
 
26
+ #include <grpc/impl/codegen/grpc_types.h>
27
+
26
28
  #include "src/core/lib/iomgr/error.h"
27
29
  #include "src/core/lib/json/json.h"
28
30
 
@@ -45,7 +47,7 @@ class ServiceConfigParser {
45
47
  virtual ~Parser() = default;
46
48
 
47
49
  virtual std::unique_ptr<ParsedConfig> ParseGlobalParams(
48
- const Json& /* json */, grpc_error** error) {
50
+ const grpc_channel_args*, const Json& /* json */, grpc_error** error) {
49
51
  // Avoid unused parameter warning on debug-only parameter
50
52
  (void)error;
51
53
  GPR_DEBUG_ASSERT(error != nullptr);
@@ -53,7 +55,7 @@ class ServiceConfigParser {
53
55
  }
54
56
 
55
57
  virtual std::unique_ptr<ParsedConfig> ParsePerMethodParams(
56
- const Json& /* json */, grpc_error** error) {
58
+ const grpc_channel_args*, const Json& /* json */, grpc_error** error) {
57
59
  // Avoid unused parameter warning on debug-only parameter
58
60
  (void)error;
59
61
  GPR_DEBUG_ASSERT(error != nullptr);
@@ -77,11 +79,12 @@ class ServiceConfigParser {
77
79
  /// retrieved using the same index that was returned at registration time.
78
80
  static size_t RegisterParser(std::unique_ptr<Parser> parser);
79
81
 
80
- static ParsedConfigVector ParseGlobalParameters(const Json& json,
82
+ static ParsedConfigVector ParseGlobalParameters(const grpc_channel_args* args,
83
+ const Json& json,
81
84
  grpc_error** error);
82
85
 
83
- static ParsedConfigVector ParsePerMethodParameters(const Json& json,
84
- grpc_error** error);
86
+ static ParsedConfigVector ParsePerMethodParameters(
87
+ const grpc_channel_args* args, const Json& json, grpc_error** error);
85
88
  };
86
89
 
87
90
  } // namespace grpc_core
@@ -21,6 +21,7 @@
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
24
+ #include "src/core/ext/filters/client_channel/server_address.h"
24
25
  #include "src/core/lib/gprpp/ref_counted.h"
25
26
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
26
27
 
@@ -87,6 +88,49 @@ class SubchannelInterface : public RefCounted<SubchannelInterface> {
87
88
 
88
89
  // TODO(roth): Need a better non-grpc-specific abstraction here.
89
90
  virtual const grpc_channel_args* channel_args() = 0;
91
+
92
+ // Allows accessing the attributes associated with the address for
93
+ // this subchannel.
94
+ virtual const ServerAddress::AttributeInterface* GetAttribute(
95
+ const char* key) const = 0;
96
+ };
97
+
98
+ // A class that delegates to another subchannel, to be used in cases
99
+ // where an LB policy needs to wrap a subchannel.
100
+ class DelegatingSubchannel : public SubchannelInterface {
101
+ public:
102
+ explicit DelegatingSubchannel(RefCountedPtr<SubchannelInterface> subchannel)
103
+ : wrapped_subchannel_(std::move(subchannel)) {}
104
+
105
+ RefCountedPtr<SubchannelInterface> wrapped_subchannel() const {
106
+ return wrapped_subchannel_;
107
+ }
108
+
109
+ grpc_connectivity_state CheckConnectivityState() override {
110
+ return wrapped_subchannel_->CheckConnectivityState();
111
+ }
112
+ void WatchConnectivityState(
113
+ grpc_connectivity_state initial_state,
114
+ std::unique_ptr<ConnectivityStateWatcherInterface> watcher) override {
115
+ return wrapped_subchannel_->WatchConnectivityState(initial_state,
116
+ std::move(watcher));
117
+ }
118
+ void CancelConnectivityStateWatch(
119
+ ConnectivityStateWatcherInterface* watcher) override {
120
+ return wrapped_subchannel_->CancelConnectivityStateWatch(watcher);
121
+ }
122
+ void AttemptToConnect() override { wrapped_subchannel_->AttemptToConnect(); }
123
+ void ResetBackoff() override { wrapped_subchannel_->ResetBackoff(); }
124
+ const grpc_channel_args* channel_args() override {
125
+ return wrapped_subchannel_->channel_args();
126
+ }
127
+ const ServerAddress::AttributeInterface* GetAttribute(
128
+ const char* key) const override {
129
+ return wrapped_subchannel_->GetAttribute(key);
130
+ }
131
+
132
+ private:
133
+ RefCountedPtr<SubchannelInterface> wrapped_subchannel_;
90
134
  };
91
135
 
92
136
  } // namespace grpc_core
@@ -66,7 +66,8 @@ const MessageSizeParsedConfig* MessageSizeParsedConfig::GetFromCallContext(
66
66
  //
67
67
 
68
68
  std::unique_ptr<ServiceConfigParser::ParsedConfig>
69
- MessageSizeParser::ParsePerMethodParams(const Json& json, grpc_error** error) {
69
+ MessageSizeParser::ParsePerMethodParams(const grpc_channel_args* /*args*/,
70
+ const Json& json, grpc_error** error) {
70
71
  GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
71
72
  std::vector<grpc_error*> error_list;
72
73
  // Max request size.
@@ -50,7 +50,8 @@ class MessageSizeParsedConfig : public ServiceConfigParser::ParsedConfig {
50
50
  class MessageSizeParser : public ServiceConfigParser::Parser {
51
51
  public:
52
52
  std::unique_ptr<ServiceConfigParser::ParsedConfig> ParsePerMethodParams(
53
- const Json& json, grpc_error** error) override;
53
+ const grpc_channel_args* /*args*/, const Json& json,
54
+ grpc_error** error) override;
54
55
 
55
56
  static void Register();
56
57
 
@@ -140,7 +140,6 @@ static void post_destructive_reclaimer(grpc_chttp2_transport* t);
140
140
  static void close_transport_locked(grpc_chttp2_transport* t, grpc_error* error);
141
141
  static void end_all_the_calls(grpc_chttp2_transport* t, grpc_error* error);
142
142
 
143
- static void schedule_bdp_ping_locked(grpc_chttp2_transport* t);
144
143
  static void start_bdp_ping(void* tp, grpc_error* error);
145
144
  static void finish_bdp_ping(void* tp, grpc_error* error);
146
145
  static void start_bdp_ping_locked(void* tp, grpc_error* error);
@@ -511,8 +510,7 @@ grpc_chttp2_transport::grpc_chttp2_transport(
511
510
  init_keepalive_pings_if_enabled(this);
512
511
 
513
512
  if (enable_bdp) {
514
- GRPC_CHTTP2_REF_TRANSPORT(this, "bdp_ping");
515
- schedule_bdp_ping_locked(this);
513
+ bdp_ping_blocked = true;
516
514
  grpc_chttp2_act_on_flowctl_action(flow_control->PeriodicUpdate(), this,
517
515
  nullptr);
518
516
  }
@@ -859,6 +857,9 @@ static void inc_initiate_write_reason(
859
857
  case GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING:
860
858
  GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_APPLICATION_PING();
861
859
  break;
860
+ case GRPC_CHTTP2_INITIATE_WRITE_BDP_PING:
861
+ GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_BDP_ESTIMATOR_PING();
862
+ break;
862
863
  case GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING:
863
864
  GRPC_STATS_INC_HTTP2_INITIATE_WRITE_DUE_TO_KEEPALIVE_PING();
864
865
  break;
@@ -2495,11 +2496,6 @@ static void read_action_locked(void* tp, grpc_error* error) {
2495
2496
  grpc_error* errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE,
2496
2497
  GRPC_ERROR_NONE};
2497
2498
  for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) {
2498
- grpc_core::BdpEstimator* bdp_est = t->flow_control->bdp_estimator();
2499
- if (bdp_est) {
2500
- bdp_est->AddIncomingBytes(
2501
- static_cast<int64_t> GRPC_SLICE_LENGTH(t->read_buffer.slices[i]));
2502
- }
2503
2499
  errors[1] = grpc_chttp2_perform_read(t, t->read_buffer.slices[i]);
2504
2500
  }
2505
2501
  if (errors[1] != GRPC_ERROR_NONE) {
@@ -2578,7 +2574,7 @@ static void continue_read_action_locked(grpc_chttp2_transport* t) {
2578
2574
 
2579
2575
  // t is reffed prior to calling the first time, and once the callback chain
2580
2576
  // that kicks off finishes, it's unreffed
2581
- static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
2577
+ void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
2582
2578
  t->flow_control->bdp_estimator()->SchedulePing();
2583
2579
  send_ping_locked(
2584
2580
  t,
@@ -2586,6 +2582,9 @@ static void schedule_bdp_ping_locked(grpc_chttp2_transport* t) {
2586
2582
  grpc_schedule_on_exec_ctx),
2587
2583
  GRPC_CLOSURE_INIT(&t->finish_bdp_ping_locked, finish_bdp_ping, t,
2588
2584
  grpc_schedule_on_exec_ctx));
2585
+ // TODO(yashykt): Enabling this causes internal b/168345569. Re-enable once
2586
+ // fixed.
2587
+ // grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_BDP_PING);
2589
2588
  }
2590
2589
 
2591
2590
  static void start_bdp_ping(void* tp, grpc_error* error) {
@@ -2665,7 +2664,13 @@ static void next_bdp_ping_timer_expired_locked(void* tp, grpc_error* error) {
2665
2664
  GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
2666
2665
  return;
2667
2666
  }
2668
- schedule_bdp_ping_locked(t);
2667
+ if (t->flow_control->bdp_estimator()->accumulator() == 0) {
2668
+ // Block the bdp ping till we receive more data.
2669
+ t->bdp_ping_blocked = true;
2670
+ GRPC_CHTTP2_UNREF_TRANSPORT(t, "bdp_ping");
2671
+ } else {
2672
+ schedule_bdp_ping_locked(t);
2673
+ }
2669
2674
  }
2670
2675
 
2671
2676
  void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
@@ -3261,6 +3266,8 @@ const char* grpc_chttp2_initiate_write_reason_string(
3261
3266
  return "FLOW_CONTROL_UNSTALLED_BY_UPDATE";
3262
3267
  case GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING:
3263
3268
  return "APPLICATION_PING";
3269
+ case GRPC_CHTTP2_INITIATE_WRITE_BDP_PING:
3270
+ return "BDP_PING";
3264
3271
  case GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING:
3265
3272
  return "KEEPALIVE_PING";
3266
3273
  case GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED:
@@ -40,6 +40,9 @@ grpc_core::TraceFlag grpc_flowctl_trace(false, "flowctl");
40
40
  namespace grpc_core {
41
41
  namespace chttp2 {
42
42
 
43
+ TestOnlyTransportTargetWindowEstimatesMocker*
44
+ g_test_only_transport_target_window_estimates_mocker;
45
+
43
46
  namespace {
44
47
 
45
48
  static constexpr const int kTracePadding = 30;
@@ -355,8 +358,13 @@ FlowControlAction TransportFlowControl::PeriodicUpdate() {
355
358
  // target might change based on how much memory pressure we are under
356
359
  // TODO(ncteisen): experiment with setting target to be huge under low
357
360
  // memory pressure.
358
- const double target = pow(2, SmoothLogBdp(TargetLogBdp()));
359
-
361
+ double target = pow(2, SmoothLogBdp(TargetLogBdp()));
362
+ if (g_test_only_transport_target_window_estimates_mocker != nullptr) {
363
+ // Hook for simulating unusual flow control situations in tests.
364
+ target = g_test_only_transport_target_window_estimates_mocker
365
+ ->ComputeNextTargetInitialWindowSizeFromPeriodicUpdate(
366
+ target_initial_window_size_ /* current target */);
367
+ }
360
368
  // Though initial window 'could' drop to 0, we keep the floor at 128
361
369
  target_initial_window_size_ =
362
370
  static_cast<int32_t> GPR_CLAMP(target, 128, INT32_MAX);
@@ -466,6 +466,16 @@ class StreamFlowControl final : public StreamFlowControlBase {
466
466
  }
467
467
  };
468
468
 
469
+ class TestOnlyTransportTargetWindowEstimatesMocker {
470
+ public:
471
+ virtual ~TestOnlyTransportTargetWindowEstimatesMocker() {}
472
+ virtual double ComputeNextTargetInitialWindowSizeFromPeriodicUpdate(
473
+ double current_target) = 0;
474
+ };
475
+
476
+ extern TestOnlyTransportTargetWindowEstimatesMocker*
477
+ g_test_only_transport_target_window_estimates_mocker;
478
+
469
479
  } // namespace chttp2
470
480
  } // namespace grpc_core
471
481
 
@@ -101,6 +101,7 @@ typedef enum {
101
101
  GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_SETTING,
102
102
  GRPC_CHTTP2_INITIATE_WRITE_FLOW_CONTROL_UNSTALLED_BY_UPDATE,
103
103
  GRPC_CHTTP2_INITIATE_WRITE_APPLICATION_PING,
104
+ GRPC_CHTTP2_INITIATE_WRITE_BDP_PING,
104
105
  GRPC_CHTTP2_INITIATE_WRITE_KEEPALIVE_PING,
105
106
  GRPC_CHTTP2_INITIATE_WRITE_TRANSPORT_FLOW_CONTROL_UNSTALLED,
106
107
  GRPC_CHTTP2_INITIATE_WRITE_PING_RESPONSE,
@@ -434,6 +435,8 @@ struct grpc_chttp2_transport {
434
435
  grpc_chttp2_write_cb* write_cb_pool = nullptr;
435
436
 
436
437
  /* bdp estimator */
438
+ bool bdp_ping_blocked =
439
+ false; /* Is the BDP blocked due to not receiving any data? */
437
440
  grpc_closure next_bdp_ping_timer_expired_locked;
438
441
  grpc_closure start_bdp_ping_locked;
439
442
  grpc_closure finish_bdp_ping_locked;
@@ -878,4 +881,6 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args,
878
881
 
879
882
  void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error* error);
880
883
 
884
+ void schedule_bdp_ping_locked(grpc_chttp2_transport* t);
885
+
881
886
  #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */
@@ -334,6 +334,16 @@ void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t) {
334
334
  }
335
335
 
336
336
  static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t) {
337
+ // Update BDP accounting since we have received a data frame.
338
+ grpc_core::BdpEstimator* bdp_est = t->flow_control->bdp_estimator();
339
+ if (bdp_est) {
340
+ if (t->bdp_ping_blocked) {
341
+ t->bdp_ping_blocked = false;
342
+ GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping");
343
+ schedule_bdp_ping_locked(t);
344
+ }
345
+ bdp_est->AddIncomingBytes(t->incoming_frame_size);
346
+ }
337
347
  grpc_chttp2_stream* s =
338
348
  grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id);
339
349
  grpc_error* err = GRPC_ERROR_NONE;
@@ -437,7 +447,8 @@ static grpc_error* GPR_ATTRIBUTE_NOINLINE handle_metadata_size_limit_exceeded(
437
447
  size_t new_size, size_t metadata_size_limit) {
438
448
  gpr_log(GPR_DEBUG,
439
449
  "received initial metadata size exceeds limit (%" PRIuPTR
440
- " vs. %" PRIuPTR ")",
450
+ " vs. %" PRIuPTR
451
+ "). GRPC_ARG_MAX_METADATA_SIZE can be set to increase this limit.",
441
452
  new_size, metadata_size_limit);
442
453
  grpc_chttp2_cancel_stream(
443
454
  t, s,
@@ -518,7 +529,10 @@ static grpc_error* on_trailing_header(void* tp, grpc_mdelem md) {
518
529
  if (new_size > metadata_size_limit) {
519
530
  gpr_log(GPR_DEBUG,
520
531
  "received trailing metadata size exceeds limit (%" PRIuPTR
521
- " vs. %" PRIuPTR ")",
532
+ " vs. %" PRIuPTR
533
+ "). Please note that the status is also included in the trailing "
534
+ "metadata and a large status message can also trigger this. "
535
+ "GRPC_ARG_MAX_METADATA_SIZE can be set to increase this limit.",
522
536
  new_size, metadata_size_limit);
523
537
  grpc_chttp2_cancel_stream(
524
538
  t, s,