grpc 1.38.0 → 1.40.0

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 (340) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +68 -21
  3. data/include/grpc/event_engine/endpoint_config.h +48 -0
  4. data/include/grpc/event_engine/event_engine.h +23 -29
  5. data/include/grpc/event_engine/port.h +2 -0
  6. data/include/grpc/event_engine/slice_allocator.h +21 -36
  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 +33 -19
  11. data/include/grpc/impl/codegen/port_platform.h +41 -0
  12. data/src/core/ext/filters/client_channel/client_channel.cc +415 -249
  13. data/src/core/ext/filters/client_channel/client_channel.h +42 -18
  14. data/src/core/ext/filters/client_channel/config_selector.h +19 -6
  15. data/src/core/ext/filters/client_channel/health/health_check_client.cc +2 -0
  16. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  17. data/src/core/ext/filters/client_channel/http_proxy.cc +16 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +7 -8
  19. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +12 -21
  20. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +3 -5
  21. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +734 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +8 -15
  24. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -6
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -36
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -22
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +2 -9
  28. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +68 -103
  29. data/src/core/ext/filters/client_channel/lb_policy.cc +1 -15
  30. data/src/core/ext/filters/client_channel/lb_policy.h +70 -46
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -3
  32. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_event_engine.cc +31 -0
  33. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_event_engine.cc +28 -0
  34. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -3
  35. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +7 -2
  36. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +116 -76
  37. data/src/core/ext/filters/client_channel/retry_filter.cc +967 -544
  38. data/src/core/ext/filters/client_channel/retry_service_config.cc +57 -28
  39. data/src/core/ext/filters/client_channel/retry_service_config.h +9 -3
  40. data/src/core/ext/filters/client_channel/service_config_call_data.h +45 -5
  41. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  42. data/src/core/ext/filters/http/client/http_client_filter.cc +5 -2
  43. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +2 -1
  44. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +5 -1
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +3 -2
  46. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +1 -1
  47. data/src/core/{lib/event_engine/slice_allocator.cc → ext/transport/chttp2/transport/chttp2_slice_allocator.cc} +23 -16
  48. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +74 -0
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +12 -10
  50. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -1
  51. data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
  52. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +8 -8
  53. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +5 -5
  54. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +639 -752
  55. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +190 -69
  56. data/src/core/ext/transport/chttp2/transport/internal.h +2 -1
  57. data/src/core/ext/transport/chttp2/transport/parsing.cc +72 -56
  58. data/src/core/ext/transport/chttp2/transport/varint.cc +6 -4
  59. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -31
  60. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +56 -35
  61. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +180 -76
  62. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +35 -27
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +97 -48
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -9
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +67 -7
  66. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +66 -9
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +227 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +46 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +121 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +1 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +35 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +90 -0
  73. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +32 -24
  74. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +120 -73
  75. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +4 -2
  76. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +15 -0
  77. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +48 -0
  78. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +171 -0
  79. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +8 -6
  80. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +27 -19
  81. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +1 -0
  82. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +24 -7
  83. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +57 -0
  84. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +29 -17
  85. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +72 -0
  86. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +3 -2
  87. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +4 -0
  88. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +6 -5
  89. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +15 -11
  90. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +85 -43
  91. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +274 -91
  92. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +11 -8
  93. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +30 -13
  94. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +33 -5
  95. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +115 -0
  96. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +60 -0
  97. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +181 -0
  98. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +1 -0
  99. data/src/core/ext/upb-generated/validate/validate.upb.c +82 -66
  100. data/src/core/ext/upb-generated/validate/validate.upb.h +220 -124
  101. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +15 -7
  102. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +53 -52
  103. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +318 -277
  104. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +5 -0
  105. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +437 -410
  106. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +198 -170
  107. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +10 -0
  108. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +9 -8
  109. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +219 -163
  110. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +15 -0
  111. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.c +59 -0
  112. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/resolver.upbdefs.h +40 -0
  113. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +29 -25
  114. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.c +52 -0
  115. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/udp_socket_config.upbdefs.h +35 -0
  116. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +135 -125
  117. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +5 -0
  118. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +131 -123
  119. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.c +90 -0
  120. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/quic_config.upbdefs.h +35 -0
  121. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +32 -24
  122. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +69 -55
  123. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +5 -0
  124. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +684 -664
  125. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +5 -0
  126. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +13 -10
  127. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +13 -10
  128. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +441 -375
  129. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +10 -0
  130. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +122 -114
  131. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +1 -1
  132. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +112 -79
  133. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +5 -0
  134. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.c +64 -0
  135. data/src/core/ext/upbdefs-generated/envoy/type/http/v3/path_transformation.upbdefs.h +50 -0
  136. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +35 -32
  137. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +4 -4
  138. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +182 -160
  139. data/src/core/ext/xds/certificate_provider_store.h +1 -1
  140. data/src/core/ext/xds/xds_api.cc +582 -257
  141. data/src/core/ext/xds/xds_api.h +46 -8
  142. data/src/core/ext/xds/xds_bootstrap.cc +4 -1
  143. data/src/core/ext/xds/xds_client.cc +66 -43
  144. data/src/core/ext/xds/xds_client.h +0 -4
  145. data/src/core/ext/xds/xds_http_filters.cc +3 -2
  146. data/src/core/ext/xds/xds_http_filters.h +3 -0
  147. data/src/core/lib/address_utils/sockaddr_utils.cc +13 -0
  148. data/src/core/lib/address_utils/sockaddr_utils.h +10 -0
  149. data/src/core/lib/channel/call_tracer.h +85 -0
  150. data/src/core/lib/channel/channel_stack.h +1 -1
  151. data/src/core/lib/channel/channelz.h +3 -0
  152. data/src/core/lib/channel/context.h +3 -0
  153. data/src/core/lib/channel/status_util.h +4 -0
  154. data/src/core/lib/compression/stream_compression.h +1 -1
  155. data/src/core/lib/compression/stream_compression_gzip.h +1 -1
  156. data/src/core/lib/compression/stream_compression_identity.h +1 -1
  157. data/src/core/lib/debug/stats.h +1 -1
  158. data/src/core/lib/event_engine/endpoint_config.cc +46 -0
  159. data/src/core/lib/event_engine/endpoint_config_internal.h +42 -0
  160. data/src/core/lib/event_engine/event_engine.cc +50 -0
  161. data/src/core/lib/event_engine/sockaddr.cc +14 -12
  162. data/src/core/lib/event_engine/sockaddr.h +44 -0
  163. data/src/core/lib/gpr/murmur_hash.cc +4 -2
  164. data/src/core/lib/gpr/wrap_memcpy.cc +2 -1
  165. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  166. data/src/core/lib/gprpp/orphanable.h +3 -3
  167. data/src/core/lib/gprpp/status_helper.h +3 -0
  168. data/src/core/lib/gprpp/sync.h +2 -30
  169. data/src/core/lib/iomgr/buffer_list.cc +1 -1
  170. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +33 -0
  171. data/src/core/lib/iomgr/error.cc +5 -4
  172. data/src/core/lib/iomgr/error.h +1 -1
  173. data/src/core/lib/iomgr/ev_apple.h +1 -1
  174. data/src/core/lib/iomgr/event_engine/closure.cc +54 -0
  175. data/src/core/lib/iomgr/event_engine/closure.h +33 -0
  176. data/src/core/lib/iomgr/event_engine/endpoint.cc +192 -0
  177. data/src/core/lib/iomgr/event_engine/endpoint.h +53 -0
  178. data/src/core/lib/iomgr/event_engine/iomgr.cc +105 -0
  179. data/src/core/lib/iomgr/event_engine/iomgr.h +24 -0
  180. data/src/core/lib/iomgr/event_engine/pollset.cc +87 -0
  181. data/{include/grpc/event_engine/channel_args.h → src/core/lib/iomgr/event_engine/pollset.h} +7 -10
  182. data/src/core/lib/iomgr/event_engine/promise.h +51 -0
  183. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +41 -0
  184. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +35 -0
  185. data/src/core/lib/iomgr/event_engine/resolver.cc +110 -0
  186. data/src/core/lib/iomgr/event_engine/tcp.cc +263 -0
  187. data/src/core/lib/iomgr/event_engine/timer.cc +57 -0
  188. data/src/core/lib/iomgr/exec_ctx.cc +8 -0
  189. data/src/core/lib/iomgr/exec_ctx.h +3 -4
  190. data/src/core/lib/iomgr/executor/threadpool.cc +2 -3
  191. data/src/core/lib/iomgr/executor/threadpool.h +2 -2
  192. data/src/core/lib/iomgr/iomgr.cc +1 -1
  193. data/src/core/lib/iomgr/iomgr_posix.cc +2 -0
  194. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +40 -10
  195. data/src/core/lib/iomgr/pollset_custom.cc +2 -2
  196. data/src/core/lib/iomgr/pollset_custom.h +3 -1
  197. data/src/core/lib/iomgr/pollset_uv.cc +3 -1
  198. data/src/core/lib/iomgr/pollset_uv.h +5 -1
  199. data/src/core/lib/iomgr/port.h +7 -5
  200. data/src/core/lib/iomgr/python_util.h +1 -1
  201. data/src/core/lib/iomgr/resolve_address.cc +5 -1
  202. data/src/core/lib/iomgr/resolve_address.h +6 -0
  203. data/src/core/lib/iomgr/resource_quota.cc +2 -0
  204. data/src/core/lib/iomgr/sockaddr.h +1 -0
  205. data/src/core/lib/iomgr/socket_mutator.cc +15 -2
  206. data/src/core/lib/iomgr/socket_mutator.h +26 -2
  207. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -4
  208. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  209. data/src/core/lib/iomgr/tcp_client_posix.cc +7 -2
  210. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -0
  211. data/src/core/lib/iomgr/tcp_posix.cc +42 -39
  212. data/src/core/lib/iomgr/tcp_posix.h +8 -0
  213. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -4
  214. data/src/core/lib/iomgr/tcp_server_posix.cc +7 -0
  215. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +2 -1
  216. data/src/core/lib/iomgr/timer.h +6 -1
  217. data/src/core/lib/iomgr/timer_manager.cc +1 -1
  218. data/src/core/lib/json/json_reader.cc +1 -2
  219. data/src/core/lib/matchers/matchers.cc +8 -20
  220. data/src/core/lib/matchers/matchers.h +2 -1
  221. data/src/core/lib/security/authorization/authorization_engine.h +44 -0
  222. data/src/core/lib/security/authorization/authorization_policy_provider.h +32 -0
  223. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +46 -0
  224. data/src/core/lib/security/authorization/evaluate_args.cc +209 -0
  225. data/src/core/lib/security/authorization/evaluate_args.h +91 -0
  226. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -1
  227. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +49 -0
  228. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -0
  229. data/src/core/lib/security/credentials/tls/tls_utils.cc +32 -0
  230. data/src/core/lib/security/credentials/tls/tls_utils.h +13 -0
  231. data/src/core/lib/security/security_connector/local/local_security_connector.cc +9 -6
  232. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -0
  233. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +6 -18
  234. data/src/core/lib/security/transport/security_handshaker.cc +12 -4
  235. data/src/core/lib/security/transport/server_auth_filter.cc +0 -7
  236. data/src/core/lib/slice/slice.cc +12 -2
  237. data/src/core/lib/slice/slice_internal.h +1 -0
  238. data/src/core/lib/surface/call.cc +26 -7
  239. data/src/core/lib/surface/call.h +11 -0
  240. data/src/core/lib/surface/completion_queue.cc +22 -22
  241. data/src/core/lib/surface/completion_queue.h +1 -1
  242. data/src/core/lib/surface/completion_queue_factory.cc +1 -2
  243. data/src/core/lib/surface/init.cc +1 -3
  244. data/src/core/lib/surface/init.h +10 -1
  245. data/src/core/lib/surface/server.cc +3 -1
  246. data/src/core/lib/surface/server.h +3 -3
  247. data/src/core/lib/surface/version.cc +2 -4
  248. data/src/core/lib/transport/error_utils.cc +2 -2
  249. data/src/core/lib/transport/metadata_batch.cc +13 -2
  250. data/src/core/lib/transport/metadata_batch.h +7 -0
  251. data/src/core/lib/transport/transport.h +2 -0
  252. data/src/core/lib/transport/transport_op_string.cc +1 -1
  253. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  254. data/src/core/tsi/alts/crypt/gsec.h +2 -0
  255. data/src/ruby/ext/grpc/extconf.rb +2 -0
  256. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +6 -0
  257. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +10 -1
  258. data/src/ruby/lib/grpc/version.rb +1 -1
  259. data/third_party/boringssl-with-bazel/err_data.c +269 -263
  260. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +8 -6
  261. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +4 -0
  262. data/third_party/boringssl-with-bazel/src/crypto/curve25519/curve25519.c +1 -1
  263. data/third_party/boringssl-with-bazel/src/crypto/curve25519/internal.h +1 -1
  264. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +9 -0
  265. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/prime.c +0 -4
  266. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +7 -0
  267. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/md32_common.h +87 -121
  268. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +20 -30
  269. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +19 -30
  270. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +1 -4
  271. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +0 -13
  272. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +26 -24
  273. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +10 -7
  274. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +28 -39
  275. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +48 -66
  276. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +4 -5
  277. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +362 -371
  278. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +4 -2
  279. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +2 -2
  280. data/third_party/boringssl-with-bazel/src/crypto/rsa_extra/rsa_asn1.c +1 -2
  281. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +101 -11
  282. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +3 -0
  283. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +2 -2
  284. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +3 -0
  285. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +1 -1
  286. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +2 -0
  287. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +14 -15
  288. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +53 -73
  289. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +31 -0
  290. data/third_party/boringssl-with-bazel/src/crypto/x509/x509rset.c +3 -0
  291. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +3 -0
  292. data/third_party/boringssl-with-bazel/src/crypto/x509/x_req.c +5 -8
  293. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +5 -0
  294. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +3 -0
  295. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +7 -0
  296. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  297. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +5 -8
  298. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +1 -1
  299. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +66 -1
  300. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +40 -9
  301. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +1 -0
  302. data/third_party/boringssl-with-bazel/src/include/openssl/chacha.h +1 -1
  303. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +6 -2
  304. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +14 -0
  305. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +19 -11
  306. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +325 -0
  307. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +23 -7
  308. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +99 -63
  309. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +139 -109
  310. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +12 -19
  311. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +48 -50
  312. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +451 -435
  313. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +0 -1
  314. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +2 -2
  315. data/third_party/boringssl-with-bazel/src/ssl/d1_srtp.cc +1 -1
  316. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +773 -84
  317. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +80 -47
  318. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -19
  319. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +189 -86
  320. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +45 -56
  321. data/third_party/boringssl-with-bazel/src/ssl/internal.h +272 -167
  322. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +2 -2
  323. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  324. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +14 -19
  325. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +34 -102
  326. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +2 -0
  327. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +8 -31
  328. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +3 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +4 -3
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +7 -3
  331. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +576 -648
  332. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +31 -3
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -39
  334. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +141 -94
  335. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +58 -68
  336. data/third_party/xxhash/xxhash.h +77 -195
  337. metadata +81 -39
  338. data/src/core/lib/gpr/arena.h +0 -47
  339. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +0 -267
  340. 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
@@ -213,10 +213,7 @@ RoundRobin::PickResult RoundRobin::Picker::Pick(PickArgs /*args*/) {
213
213
  parent_, this, last_picked_index_,
214
214
  subchannels_[last_picked_index_].get());
215
215
  }
216
- PickResult result;
217
- result.type = PickResult::PICK_COMPLETE;
218
- result.subchannel = subchannels_[last_picked_index_];
219
- return result;
216
+ return PickResult::Complete(subchannels_[last_picked_index_]);
220
217
  }
221
218
 
222
219
  //
@@ -331,13 +328,11 @@ void RoundRobin::RoundRobinSubchannelList::
331
328
  absl::make_unique<QueuePicker>(p->Ref(DEBUG_LOCATION, "QueuePicker")));
332
329
  } else if (num_transient_failure_ == num_subchannels()) {
333
330
  /* 3) TRANSIENT_FAILURE */
334
- grpc_error_handle error =
335
- grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
336
- "connections to all backends failing"),
337
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
331
+ absl::Status status =
332
+ absl::UnavailableError("connections to all backends failing");
338
333
  p->channel_control_helper()->UpdateState(
339
- GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
340
- absl::make_unique<TransientFailurePicker>(error));
334
+ GRPC_CHANNEL_TRANSIENT_FAILURE, status,
335
+ absl::make_unique<TransientFailurePicker>(status));
341
336
  }
342
337
  }
343
338
 
@@ -449,12 +444,10 @@ void RoundRobin::UpdateLocked(UpdateArgs args) {
449
444
  if (latest_pending_subchannel_list_->num_subchannels() == 0) {
450
445
  // If the new list is empty, immediately promote the new list to the
451
446
  // current list and transition to TRANSIENT_FAILURE.
452
- grpc_error_handle error =
453
- grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty update"),
454
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
447
+ absl::Status status = absl::UnavailableError("Empty update");
455
448
  channel_control_helper()->UpdateState(
456
- GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
457
- absl::make_unique<TransientFailurePicker>(error));
449
+ GRPC_CHANNEL_TRANSIENT_FAILURE, status,
450
+ absl::make_unique<TransientFailurePicker>(status));
458
451
  subchannel_list_ = std::move(latest_pending_subchannel_list_);
459
452
  } else if (subchannel_list_ == nullptr) {
460
453
  // If there is no current list, immediately promote the new list to
@@ -387,12 +387,9 @@ void WeightedTargetLb::UpdateStateLocked() {
387
387
  absl::make_unique<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker"));
388
388
  break;
389
389
  default:
390
- grpc_error_handle error = grpc_error_set_int(
391
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
392
- "weighted_target: all children report state TRANSIENT_FAILURE"),
393
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
394
- status = grpc_error_to_absl_status(error);
395
- picker = absl::make_unique<TransientFailurePicker>(error);
390
+ status = absl::UnavailableError(
391
+ "weighted_target: all children report state TRANSIENT_FAILURE");
392
+ picker = absl::make_unique<TransientFailurePicker>(status);
396
393
  }
397
394
  channel_control_helper()->UpdateState(connectivity_state, status,
398
395
  std::move(picker));
@@ -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();
@@ -550,12 +536,12 @@ void CdsLb::OnError(const std::string& name, grpc_error_handle error) {
550
536
  // policy (i.e., we have not yet received data from xds). Otherwise,
551
537
  // we keep running with the data we had previously.
552
538
  if (child_policy_ == nullptr) {
539
+ absl::Status status = grpc_error_to_absl_status(error);
553
540
  channel_control_helper()->UpdateState(
554
- GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
555
- absl::make_unique<TransientFailurePicker>(error));
556
- } else {
557
- GRPC_ERROR_UNREF(error);
541
+ GRPC_CHANNEL_TRANSIENT_FAILURE, status,
542
+ absl::make_unique<TransientFailurePicker>(status));
558
543
  }
544
+ GRPC_ERROR_UNREF(error);
559
545
  }
560
546
 
561
547
  void CdsLb::OnResourceDoesNotExist(const std::string& name) {
@@ -563,15 +549,11 @@ void CdsLb::OnResourceDoesNotExist(const std::string& name) {
563
549
  "[cdslb %p] CDS resource for %s does not exist -- reporting "
564
550
  "TRANSIENT_FAILURE",
565
551
  this, name.c_str());
566
- grpc_error_handle error =
567
- grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
568
- absl::StrCat("CDS resource \"", config_->cluster(),
569
- "\" does not exist")
570
- .c_str()),
571
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
552
+ absl::Status status = absl::UnavailableError(
553
+ absl::StrCat("CDS resource \"", config_->cluster(), "\" does not exist"));
572
554
  channel_control_helper()->UpdateState(
573
- GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
574
- absl::make_unique<TransientFailurePicker>(error));
555
+ GRPC_CHANNEL_TRANSIENT_FAILURE, status,
556
+ absl::make_unique<TransientFailurePicker>(status));
575
557
  MaybeDestroyChildPolicyLocked();
576
558
  }
577
559
 
@@ -284,59 +284,51 @@ LoadBalancingPolicy::PickResult XdsClusterImplLb::Picker::Pick(
284
284
  const std::string* drop_category;
285
285
  if (drop_config_->ShouldDrop(&drop_category)) {
286
286
  if (drop_stats_ != nullptr) drop_stats_->AddCallDropped(*drop_category);
287
- PickResult result;
288
- result.type = PickResult::PICK_COMPLETE;
289
- return result;
287
+ return PickResult::Drop(absl::UnavailableError(
288
+ absl::StrCat("EDS-configured drop: ", *drop_category)));
290
289
  }
291
290
  // Handle circuit breaking.
292
291
  uint32_t current = call_counter_->Load();
293
292
  // Check and see if we exceeded the max concurrent requests count.
294
293
  if (current >= max_concurrent_requests_) {
295
294
  if (drop_stats_ != nullptr) drop_stats_->AddUncategorizedDrops();
296
- PickResult result;
297
- result.type = PickResult::PICK_COMPLETE;
298
- return result;
295
+ return PickResult::Drop(absl::UnavailableError("circuit breaker drop"));
299
296
  }
300
297
  call_counter_->Increment();
301
298
  // If we're not dropping the call, we should always have a child picker.
302
299
  if (picker_ == nullptr) { // Should never happen.
303
- PickResult result;
304
- result.type = PickResult::PICK_FAILED;
305
- result.error = grpc_error_set_int(
306
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
307
- "xds_cluster_impl picker not given any child picker"),
308
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL);
309
300
  call_counter_->Decrement();
310
- return result;
301
+ return PickResult::Fail(absl::InternalError(
302
+ "xds_cluster_impl picker not given any child picker"));
311
303
  }
312
304
  // Not dropping, so delegate to child picker.
313
305
  PickResult result = picker_->Pick(args);
314
- if (result.type == result.PICK_COMPLETE && result.subchannel != nullptr) {
306
+ auto* complete_pick = absl::get_if<PickResult::Complete>(&result.result);
307
+ if (complete_pick != nullptr) {
315
308
  XdsClusterLocalityStats* locality_stats = nullptr;
316
309
  if (drop_stats_ != nullptr) { // If load reporting is enabled.
317
310
  auto* subchannel_wrapper =
318
- static_cast<StatsSubchannelWrapper*>(result.subchannel.get());
311
+ static_cast<StatsSubchannelWrapper*>(complete_pick->subchannel.get());
319
312
  // Handle load reporting.
320
313
  locality_stats = subchannel_wrapper->locality_stats()->Ref().release();
321
314
  // Record a call started.
322
315
  locality_stats->AddCallStarted();
323
316
  // Unwrap subchannel to pass back up the stack.
324
- result.subchannel = subchannel_wrapper->wrapped_subchannel();
317
+ complete_pick->subchannel = subchannel_wrapper->wrapped_subchannel();
325
318
  }
326
319
  // Intercept the recv_trailing_metadata op to record call completion.
327
320
  auto* call_counter = call_counter_->Ref(DEBUG_LOCATION, "call").release();
328
321
  auto original_recv_trailing_metadata_ready =
329
- result.recv_trailing_metadata_ready;
330
- result.recv_trailing_metadata_ready =
322
+ complete_pick->recv_trailing_metadata_ready;
323
+ complete_pick->recv_trailing_metadata_ready =
331
324
  // Note: This callback does not run in either the control plane
332
325
  // work serializer or in the data plane mutex.
333
326
  [locality_stats, original_recv_trailing_metadata_ready, call_counter](
334
- grpc_error_handle error, MetadataInterface* metadata,
327
+ absl::Status status, MetadataInterface* metadata,
335
328
  CallState* call_state) {
336
329
  // Record call completion for load reporting.
337
330
  if (locality_stats != nullptr) {
338
- const bool call_failed = error != GRPC_ERROR_NONE;
339
- locality_stats->AddCallFinished(call_failed);
331
+ locality_stats->AddCallFinished(!status.ok());
340
332
  locality_stats->Unref(DEBUG_LOCATION, "LocalityStats+call");
341
333
  }
342
334
  // Decrement number of calls in flight.
@@ -344,7 +336,7 @@ LoadBalancingPolicy::PickResult XdsClusterImplLb::Picker::Pick(
344
336
  call_counter->Unref(DEBUG_LOCATION, "call");
345
337
  // Invoke the original recv_trailing_metadata_ready callback, if any.
346
338
  if (original_recv_trailing_metadata_ready != nullptr) {
347
- original_recv_trailing_metadata_ready(error, metadata, call_state);
339
+ original_recv_trailing_metadata_ready(status, metadata, call_state);
348
340
  }
349
341
  };
350
342
  } else {
@@ -212,15 +212,8 @@ XdsClusterManagerLb::PickResult XdsClusterManagerLb::ClusterPicker::Pick(
212
212
  if (it != cluster_map_.end()) {
213
213
  return it->second->Pick(args);
214
214
  }
215
- PickResult result;
216
- result.type = PickResult::PICK_FAILED;
217
- result.error = grpc_error_set_int(
218
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
219
- absl::StrCat("xds cluster manager picker: unknown cluster \"",
220
- cluster_name, "\"")
221
- .c_str()),
222
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL);
223
- return result;
215
+ return PickResult::Fail(absl::InternalError(absl::StrCat(
216
+ "xds cluster manager picker: unknown cluster \"", cluster_name, "\"")));
224
217
  }
225
218
 
226
219
  //
@@ -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
  }
@@ -1013,15 +1027,12 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() {
1013
1027
  "config -- "
1014
1028
  "will put channel in TRANSIENT_FAILURE: %s",
1015
1029
  this, grpc_error_std_string(error).c_str());
1016
- error = grpc_error_set_int(
1017
- grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1018
- "xds_cluster_resolver LB policy: error "
1019
- "parsing generated child policy config"),
1020
- error),
1021
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL);
1030
+ absl::Status status = absl::InternalError(
1031
+ "xds_cluster_resolver LB policy: error parsing generated child policy "
1032
+ "config");
1022
1033
  channel_control_helper()->UpdateState(
1023
- GRPC_CHANNEL_TRANSIENT_FAILURE, grpc_error_to_absl_status(error),
1024
- absl::make_unique<TransientFailurePicker>(error));
1034
+ GRPC_CHANNEL_TRANSIENT_FAILURE, status,
1035
+ absl::make_unique<TransientFailurePicker>(status));
1025
1036
  return nullptr;
1026
1037
  }
1027
1038
  return config;
@@ -1100,7 +1111,7 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1100
1111
  GPR_ASSERT(uri.ok() && !uri->path().empty());
1101
1112
  absl::string_view server_name = absl::StripPrefix(uri->path(), "/");
1102
1113
  // Determine if it's an xds URI.
1103
- bool is_xds_uri = uri->scheme() == "xds";
1114
+ bool is_xds_uri = uri->scheme() == "xds" || uri->scheme() == "google-c2p";
1104
1115
  // Get XdsClient.
1105
1116
  RefCountedPtr<XdsClient> xds_client =
1106
1117
  XdsClient::GetFromChannelArgs(*args.args);
@@ -1201,65 +1212,11 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1201
1212
  }
1202
1213
  policy_it = policy.find("RING_HASH");
1203
1214
  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
1215
  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;
1216
+ size_t min_ring_size;
1217
+ size_t max_ring_size;
1218
+ ParseRingHashLbConfig(policy_it->second, &min_ring_size,
1219
+ &max_ring_size, &error_list);
1263
1220
  }
1264
1221
  }
1265
1222
  }
@@ -1331,25 +1288,33 @@ class XdsClusterResolverLbFactory : public LoadBalancingPolicyFactory {
1331
1288
  if (it->second.string_value() == "EDS") {
1332
1289
  discovery_mechanism->type = XdsClusterResolverLbConfig::
1333
1290
  DiscoveryMechanism::DiscoveryMechanismType::EDS;
1291
+ it = json.object_value().find("edsServiceName");
1292
+ if (it != json.object_value().end()) {
1293
+ if (it->second.type() != Json::Type::STRING) {
1294
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1295
+ "field:edsServiceName error:type should be string"));
1296
+ } else {
1297
+ discovery_mechanism->eds_service_name = it->second.string_value();
1298
+ }
1299
+ }
1334
1300
  } else if (it->second.string_value() == "LOGICAL_DNS") {
1335
1301
  discovery_mechanism->type = XdsClusterResolverLbConfig::
1336
1302
  DiscoveryMechanism::DiscoveryMechanismType::LOGICAL_DNS;
1303
+ it = json.object_value().find("dnsHostname");
1304
+ if (it == json.object_value().end()) {
1305
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1306
+ "field:dnsHostname error:required field missing"));
1307
+ } else if (it->second.type() != Json::Type::STRING) {
1308
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1309
+ "field:dnsHostname error:type should be string"));
1310
+ } else {
1311
+ discovery_mechanism->dns_hostname = it->second.string_value();
1312
+ }
1337
1313
  } else {
1338
1314
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1339
1315
  "field:type error:invalid type"));
1340
1316
  }
1341
1317
  }
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
1318
  return error_list;
1354
1319
  }
1355
1320