grpc 1.38.0 → 1.39.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 (199) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +50 -19
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +13 -15
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +17 -7
  7. data/include/grpc/grpc.h +9 -2
  8. data/include/grpc/grpc_security.h +32 -0
  9. data/include/grpc/grpc_security_constants.h +1 -0
  10. data/include/grpc/impl/codegen/grpc_types.h +17 -13
  11. data/include/grpc/impl/codegen/port_platform.h +17 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +2 -2
  13. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  14. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  15. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +755 -0
  17. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +10 -24
  19. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +63 -95
  20. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  21. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  22. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  23. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  24. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  25. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +15 -3
  26. data/src/core/ext/filters/client_channel/retry_filter.cc +665 -404
  27. data/src/core/ext/filters/client_channel/retry_service_config.cc +43 -24
  28. data/src/core/ext/filters/client_channel/retry_service_config.h +8 -2
  29. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  30. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +6 -0
  31. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  32. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  33. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +10 -4
  34. data/src/core/ext/transport/chttp2/transport/internal.h +1 -0
  35. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -2
  36. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  37. data/src/core/ext/xds/xds_api.cc +247 -106
  38. data/src/core/ext/xds/xds_api.h +15 -6
  39. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  40. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  41. data/src/core/lib/channel/channelz.h +3 -0
  42. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  43. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  44. data/src/core/lib/event_engine/event_engine.cc +50 -0
  45. data/src/core/lib/event_engine/slice_allocator.cc +33 -3
  46. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  47. data/src/core/lib/event_engine/sockaddr.h +44 -0
  48. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  49. data/src/core/lib/gprpp/status_helper.h +3 -0
  50. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  51. data/src/core/lib/iomgr/error.cc +5 -4
  52. data/src/core/lib/iomgr/error.h +1 -1
  53. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  54. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  55. data/src/core/lib/iomgr/event_engine/endpoint.cc +194 -0
  56. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  57. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  58. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  59. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  60. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  61. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  62. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  63. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  64. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  65. data/src/core/lib/iomgr/event_engine/tcp.cc +243 -0
  66. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  67. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  68. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  69. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  70. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  71. data/src/core/lib/iomgr/iomgr.cc +1 -1
  72. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  73. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  74. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  75. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  76. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  77. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  78. data/src/core/lib/iomgr/port.h +7 -5
  79. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  80. data/src/core/lib/iomgr/resolve_address.h +6 -0
  81. data/src/core/lib/iomgr/sockaddr.h +1 -0
  82. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  83. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  84. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  85. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  86. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  87. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  88. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  89. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  90. data/src/core/lib/iomgr/tcp_server_posix.cc +6 -0
  91. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  92. data/src/core/lib/iomgr/timer.h +6 -1
  93. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  94. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  95. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  96. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  97. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  98. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  99. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  100. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  101. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  102. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  103. data/src/core/lib/surface/call.cc +21 -1
  104. data/src/core/lib/surface/call.h +11 -0
  105. data/src/core/lib/surface/completion_queue.cc +22 -22
  106. data/src/core/lib/surface/completion_queue.h +1 -1
  107. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  108. data/src/core/lib/surface/init.cc +1 -3
  109. data/src/core/lib/surface/init.h +10 -1
  110. data/src/core/lib/surface/version.cc +1 -1
  111. data/src/core/lib/transport/error_utils.cc +2 -2
  112. data/src/core/lib/transport/transport.h +2 -0
  113. data/src/core/lib/transport/transport_op_string.cc +1 -1
  114. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  115. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  116. data/src/ruby/ext/grpc/extconf.rb +2 -0
  117. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  118. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  119. data/src/ruby/lib/grpc/version.rb +1 -1
  120. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  121. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  122. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  123. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  124. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  125. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  126. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  127. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  128. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  129. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  130. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  131. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  132. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  133. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  134. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  135. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  136. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  137. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  138. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  139. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  140. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  141. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  142. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  143. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  144. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  145. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  146. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  147. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  148. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  149. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  150. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  151. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  152. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  153. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  154. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  155. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  156. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  157. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  158. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  159. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  160. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  161. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  162. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  163. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  164. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  165. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  166. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  167. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  168. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  169. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  170. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  171. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  172. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  173. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  174. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  175. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  176. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  177. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  178. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  179. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  180. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  181. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  182. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  183. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  184. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  185. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  186. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  187. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  188. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  189. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  190. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  191. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  192. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  193. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  194. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  195. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  196. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  197. metadata +65 -40
  198. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  199. data/third_party/boringssl-with-bazel/src/crypto/x509/vpm_int.h +0 -71
@@ -19,9 +19,19 @@
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
22
+ #include <stdlib.h>
23
+
24
+ #include "src/core/lib/iomgr/error.h"
25
+ #include "src/core/lib/json/json.h"
26
+
22
27
  namespace grpc_core {
23
28
  extern const char* kRequestRingHashAttribute;
24
29
 
30
+ // Helper Parsing method to parse ring hash policy configs; for example, ring
31
+ // hash size validity.
32
+ void ParseRingHashLbConfig(const Json& json, size_t* min_ring_size,
33
+ size_t* max_ring_size,
34
+ std::vector<grpc_error_handle>* error_list);
25
35
  } // namespace grpc_core
26
36
 
27
37
  #endif // GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_RING_HASH_RING_HASH_H
@@ -392,26 +392,25 @@ bool CdsLb::GenerateDiscoveryMechanismForCluster(
392
392
  }
393
393
  return !missing_cluster;
394
394
  }
395
- std::string type;
395
+ Json::Object mechanism = {
396
+ {"clusterName", name},
397
+ {"max_concurrent_requests", state.update->max_concurrent_requests},
398
+ };
396
399
  switch (state.update->cluster_type) {
397
400
  case XdsApi::CdsUpdate::ClusterType::EDS:
398
- type = "EDS";
401
+ mechanism["type"] = "EDS";
402
+ if (!state.update->eds_service_name.empty()) {
403
+ mechanism["edsServiceName"] = state.update->eds_service_name;
404
+ }
399
405
  break;
400
406
  case XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS:
401
- type = "LOGICAL_DNS";
407
+ mechanism["type"] = "LOGICAL_DNS";
408
+ mechanism["dnsHostname"] = state.update->dns_hostname;
402
409
  break;
403
410
  default:
404
411
  GPR_ASSERT(0);
405
412
  break;
406
413
  }
407
- Json::Object mechanism = {
408
- {"clusterName", name},
409
- {"max_concurrent_requests", state.update->max_concurrent_requests},
410
- {"type", std::move(type)},
411
- };
412
- if (!state.update->eds_service_name.empty()) {
413
- mechanism["edsServiceName"] = state.update->eds_service_name;
414
- }
415
414
  if (state.update->lrs_load_reporting_server_name.has_value()) {
416
415
  mechanism["lrsLoadReportingServerName"] =
417
416
  state.update->lrs_load_reporting_server_name.value();
@@ -452,22 +451,9 @@ void CdsLb::OnClusterChanged(const std::string& name,
452
451
  // Construct config for child policy.
453
452
  Json::Object xds_lb_policy;
454
453
  if (cluster_data.lb_policy == "RING_HASH") {
455
- std::string hash_function;
456
- switch (cluster_data.hash_function) {
457
- case XdsApi::CdsUpdate::HashFunction::XX_HASH:
458
- hash_function = "XX_HASH";
459
- break;
460
- case XdsApi::CdsUpdate::HashFunction::MURMUR_HASH_2:
461
- hash_function = "MURMUR_HASH_2";
462
- break;
463
- default:
464
- GPR_ASSERT(0);
465
- break;
466
- }
467
454
  xds_lb_policy["RING_HASH"] = Json::Object{
468
455
  {"min_ring_size", cluster_data.min_ring_size},
469
456
  {"max_ring_size", cluster_data.max_ring_size},
470
- {"hash_function", hash_function},
471
457
  };
472
458
  } else {
473
459
  xds_lb_policy["ROUND_ROBIN"] = Json::Object();
@@ -28,6 +28,7 @@
28
28
  #include "src/core/ext/filters/client_channel/lb_policy.h"
29
29
  #include "src/core/ext/filters/client_channel/lb_policy/address_filtering.h"
30
30
  #include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
31
+ #include "src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h"
31
32
  #include "src/core/ext/filters/client_channel/lb_policy/xds/xds.h"
32
33
  #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h"
33
34
  #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
@@ -71,13 +72,16 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
71
72
  };
72
73
  DiscoveryMechanismType type;
73
74
  std::string eds_service_name;
75
+ std::string dns_hostname;
74
76
 
75
77
  bool operator==(const DiscoveryMechanism& other) const {
76
78
  return (cluster_name == other.cluster_name &&
77
79
  lrs_load_reporting_server_name ==
78
80
  other.lrs_load_reporting_server_name &&
79
81
  max_concurrent_requests == other.max_concurrent_requests &&
80
- type == other.type && eds_service_name == other.eds_service_name);
82
+ type == other.type &&
83
+ eds_service_name == other.eds_service_name &&
84
+ dns_hostname == other.dns_hostname);
81
85
  }
82
86
  };
83
87
 
@@ -131,17 +135,6 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
131
135
  virtual Json::Array override_child_policy() = 0;
132
136
  virtual bool disable_reresolution() = 0;
133
137
 
134
- // Caller must ensure that config_ is set before calling.
135
- absl::string_view GetXdsClusterResolverResourceName() const {
136
- if (!parent_->is_xds_uri_) return parent_->server_name_;
137
- if (!parent_->config_->discovery_mechanisms()[index_]
138
- .eds_service_name.empty()) {
139
- return parent_->config_->discovery_mechanisms()[index_]
140
- .eds_service_name;
141
- }
142
- return parent_->config_->discovery_mechanisms()[index_].cluster_name;
143
- }
144
-
145
138
  // Returns a pair containing the cluster and eds_service_name
146
139
  // to use for LRS load reporting. Caller must ensure that config_ is set
147
140
  // before calling.
@@ -218,6 +211,18 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
218
211
  RefCountedPtr<EdsDiscoveryMechanism> discovery_mechanism_;
219
212
  };
220
213
 
214
+ absl::string_view GetEdsResourceName() const {
215
+ if (!parent()->is_xds_uri_) return parent()->server_name_;
216
+ if (!parent()
217
+ ->config_->discovery_mechanisms()[index()]
218
+ .eds_service_name.empty()) {
219
+ return parent()
220
+ ->config_->discovery_mechanisms()[index()]
221
+ .eds_service_name;
222
+ }
223
+ return parent()->config_->discovery_mechanisms()[index()].cluster_name;
224
+ }
225
+
221
226
  // Note that this is not owned, so this pointer must never be dereferenced.
222
227
  EndpointWatcher* watcher_ = nullptr;
223
228
  };
@@ -255,9 +260,11 @@ class XdsClusterResolverLb : public LoadBalancingPolicy {
255
260
  private:
256
261
  RefCountedPtr<LogicalDNSDiscoveryMechanism> discovery_mechanism_;
257
262
  };
258
- // This is only necessary because of a bug in msvc where nested class cannot
263
+
264
+ // This is necessary only because of a bug in msvc where nested class cannot
259
265
  // access protected member in base class.
260
266
  friend class ResolverResultHandler;
267
+
261
268
  OrphanablePtr<Resolver> resolver_;
262
269
  };
263
270
 
@@ -389,13 +396,12 @@ void XdsClusterResolverLb::EdsDiscoveryMechanism::Start() {
389
396
  gpr_log(GPR_INFO,
390
397
  "[xds_cluster_resolver_lb %p] eds discovery mechanism %" PRIuPTR
391
398
  ":%p starting xds watch for %s",
392
- parent(), index(), this,
393
- std::string(GetXdsClusterResolverResourceName()).c_str());
399
+ parent(), index(), this, std::string(GetEdsResourceName()).c_str());
394
400
  }
395
401
  auto watcher = absl::make_unique<EndpointWatcher>(
396
402
  Ref(DEBUG_LOCATION, "EdsDiscoveryMechanism"));
397
403
  watcher_ = watcher.get();
398
- parent()->xds_client_->WatchEndpointData(GetXdsClusterResolverResourceName(),
404
+ parent()->xds_client_->WatchEndpointData(GetEdsResourceName(),
399
405
  std::move(watcher));
400
406
  }
401
407
 
@@ -404,11 +410,10 @@ void XdsClusterResolverLb::EdsDiscoveryMechanism::Orphan() {
404
410
  gpr_log(GPR_INFO,
405
411
  "[xds_cluster_resolver_lb %p] eds discovery mechanism %" PRIuPTR
406
412
  ":%p cancelling xds watch for %s",
407
- parent(), index(), this,
408
- std::string(GetXdsClusterResolverResourceName()).c_str());
413
+ parent(), index(), this, std::string(GetEdsResourceName()).c_str());
409
414
  }
410
- parent()->xds_client_->CancelEndpointDataWatch(
411
- GetXdsClusterResolverResourceName(), watcher_);
415
+ parent()->xds_client_->CancelEndpointDataWatch(GetEdsResourceName(),
416
+ watcher_);
412
417
  Unref();
413
418
  }
414
419
 
@@ -477,7 +482,8 @@ void XdsClusterResolverLb::EdsDiscoveryMechanism::EndpointWatcher::Notifier::
477
482
  //
478
483
 
479
484
  void XdsClusterResolverLb::LogicalDNSDiscoveryMechanism::Start() {
480
- std::string target = parent()->server_name_;
485
+ std::string target =
486
+ parent()->config_->discovery_mechanisms()[index()].dns_hostname;
481
487
  grpc_channel_args* args = nullptr;
482
488
  FakeResolverResponseGenerator* fake_resolver_response_generator =
483
489
  grpc_channel_args_find_pointer<FakeResolverResponseGenerator>(
@@ -489,6 +495,7 @@ void XdsClusterResolverLb::LogicalDNSDiscoveryMechanism::Start() {
489
495
  fake_resolver_response_generator);
490
496
  args = grpc_channel_args_copy_and_add(parent()->args_, &new_arg, 1);
491
497
  } else {
498
+ target = absl::StrCat("dns:", target);
492
499
  args = grpc_channel_args_copy(parent()->args_);
493
500
  }
494
501
  resolver_ = ResolverRegistry::CreateResolver(
@@ -834,6 +841,13 @@ ServerAddressList XdsClusterResolverLb::CreateChildPolicyAddressesLocked() {
834
841
  std::vector<std::string> hierarchical_path = {
835
842
  priority_child_name, locality_name->AsHumanReadableString()};
836
843
  for (const auto& endpoint : locality.endpoints) {
844
+ const ServerAddressWeightAttribute* weight_attribute = static_cast<
845
+ const ServerAddressWeightAttribute*>(endpoint.GetAttribute(
846
+ ServerAddressWeightAttribute::kServerAddressWeightAttributeKey));
847
+ uint32_t weight = locality.lb_weight;
848
+ if (weight_attribute != nullptr) {
849
+ weight = locality.lb_weight * weight_attribute->weight();
850
+ }
837
851
  addresses.emplace_back(
838
852
  endpoint
839
853
  .WithAttribute(kHierarchicalPathAttributeKey,
@@ -841,10 +855,10 @@ ServerAddressList XdsClusterResolverLb::CreateChildPolicyAddressesLocked() {
841
855
  .WithAttribute(kXdsLocalityNameAttributeKey,
842
856
  absl::make_unique<XdsLocalityAttribute>(
843
857
  locality_name->Ref()))
844
- .WithAttribute(ServerAddressWeightAttribute::
845
- kServerAddressWeightAttributeKey,
846
- absl::make_unique<ServerAddressWeightAttribute>(
847
- locality.lb_weight)));
858
+ .WithAttribute(
859
+ ServerAddressWeightAttribute::
860
+ kServerAddressWeightAttributeKey,
861
+ absl::make_unique<ServerAddressWeightAttribute>(weight)));
848
862
  }
849
863
  }
850
864
  }
@@ -1100,7 +1114,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1100
1114
  GPR_ASSERT(uri.ok() && !uri->path().empty());
1101
1115
  absl::string_view server_name = absl::StripPrefix(uri->path(), "/");
1102
1116
  // Determine if it's an xds URI.
1103
- bool is_xds_uri = uri->scheme() == "xds";
1117
+ bool is_xds_uri = uri->scheme() == "xds" || uri->scheme() == "google-c2p";
1104
1118
  // Get XdsClient.
1105
1119
  RefCountedPtr<XdsClient> xds_client =
1106
1120
  XdsClient::GetFromChannelArgs(*args.args);
@@ -1201,65 +1215,11 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1201
1215
  }
1202
1216
  policy_it = policy.find("RING_HASH");
1203
1217
  if (policy_it != policy.end()) {
1204
- if (policy_it->second.type() != Json::Type::OBJECT) {
1205
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1206
- "field:RING_HASH error:type should be object"));
1207
- continue;
1208
- }
1209
- // TODO(donnadionne): Move this to a method in
1210
- // ring_hash_experimental and call it here.
1211
- const Json::Object& ring_hash = policy_it->second.object_value();
1212
1218
  xds_lb_policy = array[i];
1213
- size_t min_ring_size = 1024;
1214
- size_t max_ring_size = 8388608;
1215
- auto ring_hash_it = ring_hash.find("min_ring_size");
1216
- if (ring_hash_it == ring_hash.end()) {
1217
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1218
- "field:min_ring_size missing"));
1219
- } else if (ring_hash_it->second.type() != Json::Type::NUMBER) {
1220
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1221
- "field:min_ring_size error: should be of "
1222
- "number"));
1223
- } else {
1224
- min_ring_size = gpr_parse_nonnegative_int(
1225
- ring_hash_it->second.string_value().c_str());
1226
- }
1227
- ring_hash_it = ring_hash.find("max_ring_size");
1228
- if (ring_hash_it == ring_hash.end()) {
1229
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1230
- "field:max_ring_size missing"));
1231
- } else if (ring_hash_it->second.type() != Json::Type::NUMBER) {
1232
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1233
- "field:max_ring_size error: should be of "
1234
- "number"));
1235
- } else {
1236
- max_ring_size = gpr_parse_nonnegative_int(
1237
- ring_hash_it->second.string_value().c_str());
1238
- }
1239
- if (min_ring_size <= 0 || min_ring_size > 8388608 ||
1240
- max_ring_size <= 0 || max_ring_size > 8388608 ||
1241
- min_ring_size > max_ring_size) {
1242
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1243
- "field:max_ring_size and or min_ring_size error: "
1244
- "values need to be in the range of 1 to 8388608 "
1245
- "and max_ring_size cannot be smaller than "
1246
- "min_ring_size"));
1247
- }
1248
- ring_hash_it = ring_hash.find("hash_function");
1249
- if (ring_hash_it == ring_hash.end()) {
1250
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1251
- "field:hash_function missing"));
1252
- } else if (ring_hash_it->second.type() != Json::Type::STRING) {
1253
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1254
- "field:hash_function error: should be a "
1255
- "string"));
1256
- } else if (ring_hash_it->second.string_value() != "XX_HASH" &&
1257
- ring_hash_it->second.string_value() != "MURMUR_HASH_2") {
1258
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1259
- "field:hash_function error: unsupported "
1260
- "hash_function"));
1261
- }
1262
- break;
1219
+ size_t min_ring_size;
1220
+ size_t max_ring_size;
1221
+ ParseRingHashLbConfig(policy_it->second, &min_ring_size,
1222
+ &max_ring_size, &error_list);
1263
1223
  }
1264
1224
  }
1265
1225
  }
@@ -1331,25 +1291,33 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1331
1291
  if (it->second.string_value() == "EDS") {
1332
1292
  discovery_mechanism->type = XdsClusterResolverLbConfig::
1333
1293
  DiscoveryMechanism::DiscoveryMechanismType::EDS;
1294
+ it = json.object_value().find("edsServiceName");
1295
+ if (it != json.object_value().end()) {
1296
+ if (it->second.type() != Json::Type::STRING) {
1297
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1298
+ "field:edsServiceName error:type should be string"));
1299
+ } else {
1300
+ discovery_mechanism->eds_service_name = it->second.string_value();
1301
+ }
1302
+ }
1334
1303
  } else if (it->second.string_value() == "LOGICAL_DNS") {
1335
1304
  discovery_mechanism->type = XdsClusterResolverLbConfig::
1336
1305
  DiscoveryMechanism::DiscoveryMechanismType::LOGICAL_DNS;
1306
+ it = json.object_value().find("dnsHostname");
1307
+ if (it == json.object_value().end()) {
1308
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1309
+ "field:dnsHostname error:required field missing"));
1310
+ } else if (it->second.type() != Json::Type::STRING) {
1311
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1312
+ "field:dnsHostname error:type should be string"));
1313
+ } else {
1314
+ discovery_mechanism->dns_hostname = it->second.string_value();
1315
+ }
1337
1316
  } else {
1338
1317
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1339
1318
  "field:type error:invalid type"));
1340
1319
  }
1341
1320
  }
1342
- // EDS service name.
1343
- it = json.object_value().find("edsServiceName");
1344
- if (it != json.object_value().end()) {
1345
- if (it->second.type() != Json::Type::STRING) {
1346
- error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1347
- "field:xds_cluster_resolverServiceName error:type should be "
1348
- "string"));
1349
- } else {
1350
- discovery_mechanism->eds_service_name = it->second.string_value();
1351
- }
1352
- }
1353
1321
  return error_list;
1354
1322
  }
1355
1323
 
@@ -60,8 +60,6 @@ namespace grpc_core {
60
60
 
61
61
  namespace {
62
62
 
63
- const char kDefaultPort[] = "https";
64
-
65
63
  class AresDnsResolver : public Resolver {
66
64
  public:
67
65
  explicit AresDnsResolver(ResolverArgs args);
@@ -431,7 +429,7 @@ void AresDnsResolver::StartResolvingLocked() {
431
429
  resolving_ = true;
432
430
  service_config_json_ = nullptr;
433
431
  pending_request_ = grpc_dns_lookup_ares_locked(
434
- dns_server_.c_str(), name_to_resolve_.c_str(), kDefaultPort,
432
+ dns_server_.c_str(), name_to_resolve_.c_str(), kDefaultSecurePort,
435
433
  interested_parties_, &on_resolved_, &addresses_,
436
434
  enable_srv_queries_ ? &balancer_addresses_ : nullptr,
437
435
  request_service_config_ ? &service_config_json_ : nullptr,
@@ -0,0 +1,31 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #include <grpc/support/port_platform.h>
15
+
16
+ #include "src/core/lib/iomgr/port.h"
17
+ #if GRPC_ARES == 1 && defined(GRPC_USE_EVENT_ENGINE)
18
+
19
+ #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h"
20
+ #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
21
+
22
+ namespace grpc_core {
23
+
24
+ std::unique_ptr<GrpcPolledFdFactory> NewGrpcPolledFdFactory(
25
+ std::shared_ptr<WorkSerializer> /* work_serializer */) {
26
+ return nullptr;
27
+ }
28
+
29
+ } // namespace grpc_core
30
+
31
+ #endif /* GRPC_ARES == 1 && defined(GRPC_USE_EVENT_ENGINE) */
@@ -0,0 +1,28 @@
1
+ // Copyright 2021 The gRPC Authors
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ #include <grpc/support/port_platform.h>
15
+
16
+ #include "src/core/lib/iomgr/port.h"
17
+ #if GRPC_ARES == 1 && defined(GRPC_USE_EVENT_ENGINE)
18
+
19
+ #include "src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h"
20
+
21
+ bool grpc_ares_query_ipv6() {
22
+ /* The libuv grpc code currently does not have the code to probe for this,
23
+ * so we assume for now that IPv6 is always available in contexts where this
24
+ * code will be used. */
25
+ return true;
26
+ }
27
+
28
+ #endif /* GRPC_ARES == 1 && defined(GRPC_USE_EVENT_ENGINE) */
@@ -48,8 +48,6 @@ namespace grpc_core {
48
48
 
49
49
  namespace {
50
50
 
51
- const char kDefaultPort[] = "https";
52
-
53
51
  class NativeDnsResolver : public Resolver {
54
52
  public:
55
53
  explicit NativeDnsResolver(ResolverArgs args);
@@ -276,7 +274,7 @@ void NativeDnsResolver::StartResolvingLocked() {
276
274
  addresses_ = nullptr;
277
275
  GRPC_CLOSURE_INIT(&on_resolved_, NativeDnsResolver::OnResolved, this,
278
276
  grpc_schedule_on_exec_ctx);
279
- grpc_resolve_address(name_to_resolve_.c_str(), kDefaultPort,
277
+ grpc_resolve_address(name_to_resolve_.c_str(), kDefaultSecurePort,
280
278
  interested_parties_, &on_resolved_, &addresses_);
281
279
  last_resolution_timestamp_ = grpc_core::ExecCtx::Get()->Now();
282
280
  }