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
@@ -125,21 +125,7 @@ LoadBalancingPolicy::PickResult LoadBalancingPolicy::QueuePicker::Pick(
125
125
  parent, nullptr),
126
126
  GRPC_ERROR_NONE);
127
127
  }
128
- PickResult result;
129
- result.type = PickResult::PICK_QUEUE;
130
- return result;
131
- }
132
-
133
- //
134
- // LoadBalancingPolicy::TransientFailurePicker
135
- //
136
-
137
- LoadBalancingPolicy::PickResult
138
- LoadBalancingPolicy::TransientFailurePicker::Pick(PickArgs /*args*/) {
139
- PickResult result;
140
- result.type = PickResult::PICK_FAILED;
141
- result.error = GRPC_ERROR_REF(error_);
142
- return result;
128
+ return PickResult::Queue();
143
129
  }
144
130
 
145
131
  } // namespace grpc_core
@@ -26,6 +26,7 @@
26
26
 
27
27
  #include "absl/status/status.h"
28
28
  #include "absl/strings/string_view.h"
29
+ #include "absl/types/variant.h"
29
30
 
30
31
  #include "src/core/ext/filters/client_channel/server_address.h"
31
32
  #include "src/core/ext/filters/client_channel/service_config.h"
@@ -204,47 +205,69 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
204
205
 
205
206
  /// The result of picking a subchannel for a call.
206
207
  struct PickResult {
207
- enum ResultType {
208
- /// Pick complete. If \a subchannel is non-null, the client channel
209
- /// will immediately proceed with the call on that subchannel;
210
- /// otherwise, it will drop the call.
211
- PICK_COMPLETE,
212
- /// Pick cannot be completed until something changes on the control
213
- /// plane. The client channel will queue the pick and try again the
214
- /// next time the picker is updated.
215
- PICK_QUEUE,
216
- /// Pick failed. If the call is wait_for_ready, the client channel
217
- /// will wait for the next picker and try again; otherwise, it
218
- /// will immediately fail the call with the status indicated via
219
- /// \a error (although the call may be retried if the client channel
220
- /// is configured to do so).
221
- PICK_FAILED,
208
+ /// A successful pick.
209
+ struct Complete {
210
+ /// The subchannel to be used for the call. Must be non-null.
211
+ RefCountedPtr<SubchannelInterface> subchannel;
212
+
213
+ /// Callback set by LB policy to be notified of trailing metadata.
214
+ /// If non-null, the client channel will invoke the callback
215
+ /// when trailing metadata is returned.
216
+ /// The metadata may be modified by the callback. However, the callback
217
+ /// does not take ownership, so any data that needs to be used after
218
+ /// returning must be copied.
219
+ /// The call state can be used to obtain backend metric data.
220
+ // TODO(roth): The arguments to this callback should be moved into a
221
+ // struct, so that we can later add new fields without breaking
222
+ // existing implementations.
223
+ std::function<void(absl::Status, MetadataInterface*, CallState*)>
224
+ recv_trailing_metadata_ready;
225
+
226
+ explicit Complete(
227
+ RefCountedPtr<SubchannelInterface> sc,
228
+ std::function<void(absl::Status, MetadataInterface*, CallState*)> cb =
229
+ nullptr)
230
+ : subchannel(std::move(sc)),
231
+ recv_trailing_metadata_ready(std::move(cb)) {}
222
232
  };
223
- ResultType type;
224
-
225
- /// Used only if type is PICK_COMPLETE. Will be set to the selected
226
- /// subchannel, or nullptr if the LB policy decides to drop the call.
227
- RefCountedPtr<SubchannelInterface> subchannel;
228
-
229
- /// Used only if type is PICK_FAILED.
230
- /// Error to be set when returning a failure.
231
- // TODO(roth): Replace this with something similar to grpc::Status,
232
- // so that we don't expose grpc_error to this API.
233
- grpc_error_handle error = GRPC_ERROR_NONE;
234
-
235
- /// Used only if type is PICK_COMPLETE.
236
- /// Callback set by LB policy to be notified of trailing metadata.
237
- /// If set by LB policy, the client channel will invoke the callback
238
- /// when trailing metadata is returned.
239
- /// The metadata may be modified by the callback. However, the callback
240
- /// does not take ownership, so any data that needs to be used after
241
- /// returning must be copied.
242
- /// The call state can be used to obtain backend metric data.
243
- // TODO(roth): The arguments to this callback should be moved into a
244
- // struct, so that we can later add new fields without breaking
245
- // existing implementations.
246
- std::function<void(grpc_error_handle, MetadataInterface*, CallState*)>
247
- recv_trailing_metadata_ready;
233
+
234
+ /// Pick cannot be completed until something changes on the control
235
+ /// plane. The client channel will queue the pick and try again the
236
+ /// next time the picker is updated.
237
+ struct Queue {};
238
+
239
+ /// Pick failed. If the call is wait_for_ready, the client channel
240
+ /// will wait for the next picker and try again; otherwise, it
241
+ /// will immediately fail the call with the status indicated (although
242
+ /// the call may be retried if the client channel is configured to do so).
243
+ struct Fail {
244
+ absl::Status status;
245
+
246
+ explicit Fail(absl::Status s) : status(s) {}
247
+ };
248
+
249
+ /// Pick will be dropped with the status specified.
250
+ /// Unlike FailPick, the call will be dropped even if it is
251
+ /// wait_for_ready, and retries (if configured) will be inhibited.
252
+ struct Drop {
253
+ absl::Status status;
254
+
255
+ explicit Drop(absl::Status s) : status(s) {}
256
+ };
257
+
258
+ // A pick result must be one of these types.
259
+ // Default to Queue, just to allow default construction.
260
+ absl::variant<Complete, Queue, Fail, Drop> result = Queue();
261
+
262
+ PickResult() = default;
263
+ // NOLINTNEXTLINE(google-explicit-constructor)
264
+ PickResult(Complete complete) : result(std::move(complete)) {}
265
+ // NOLINTNEXTLINE(google-explicit-constructor)
266
+ PickResult(Queue queue) : result(queue) {}
267
+ // NOLINTNEXTLINE(google-explicit-constructor)
268
+ PickResult(Fail fail) : result(std::move(fail)) {}
269
+ // NOLINTNEXTLINE(google-explicit-constructor)
270
+ PickResult(Drop drop) : result(std::move(drop)) {}
248
271
  };
249
272
 
250
273
  /// A subchannel picker is the object used to pick the subchannel to
@@ -367,7 +390,7 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
367
390
  // Note: This must be invoked while holding the work_serializer.
368
391
  void Orphan() override;
369
392
 
370
- // A picker that returns PICK_QUEUE for all picks.
393
+ // A picker that returns PickResult::Queue for all picks.
371
394
  // Also calls the parent LB policy's ExitIdleLocked() method when the
372
395
  // first pick is seen.
373
396
  class QueuePicker : public SubchannelPicker {
@@ -384,16 +407,17 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
384
407
  bool exit_idle_called_ = false;
385
408
  };
386
409
 
387
- // A picker that returns PICK_TRANSIENT_FAILURE for all picks.
410
+ // A picker that returns PickResult::Fail for all picks.
388
411
  class TransientFailurePicker : public SubchannelPicker {
389
412
  public:
390
- explicit TransientFailurePicker(grpc_error_handle error) : error_(error) {}
391
- ~TransientFailurePicker() override { GRPC_ERROR_UNREF(error_); }
413
+ explicit TransientFailurePicker(absl::Status status) : status_(status) {}
392
414
 
393
- PickResult Pick(PickArgs args) override;
415
+ PickResult Pick(PickArgs /*args*/) override {
416
+ return PickResult::Fail(status_);
417
+ }
394
418
 
395
419
  private:
396
- grpc_error_handle error_;
420
+ absl::Status status_;
397
421
  };
398
422
 
399
423
  protected:
@@ -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
  }
@@ -16,6 +16,8 @@
16
16
 
17
17
  #include <grpc/support/port_platform.h>
18
18
 
19
+ #include <random>
20
+
19
21
  #include "src/core/ext/filters/client_channel/resolver_registry.h"
20
22
  #include "src/core/ext/xds/xds_client.h"
21
23
  #include "src/core/lib/gpr/env.h"
@@ -195,7 +197,7 @@ void GoogleCloud2ProdResolver::ZoneQuery::OnDone(
195
197
  gpr_log(GPR_ERROR, "could not parse zone from metadata server: %s",
196
198
  std::string(body).c_str());
197
199
  } else {
198
- zone = std::string(body.substr(i));
200
+ zone = std::string(body.substr(i + 1));
199
201
  }
200
202
  }
201
203
  resolver->ZoneQueryDone(std::move(zone));
@@ -297,8 +299,11 @@ void GoogleCloud2ProdResolver::IPv6QueryDone(bool ipv6_supported) {
297
299
 
298
300
  void GoogleCloud2ProdResolver::StartXdsResolver() {
299
301
  // Construct bootstrap JSON.
302
+ std::random_device rd;
303
+ std::mt19937 mt(rd());
304
+ std::uniform_int_distribution<uint64_t> dist(1, UINT64_MAX);
300
305
  Json::Object node = {
301
- {"id", "C2P"},
306
+ {"id", absl::StrCat("C2P-", dist(mt))},
302
307
  };
303
308
  if (!zone_->empty()) {
304
309
  node["locality"] = Json::Object{
@@ -34,7 +34,6 @@
34
34
  #include "src/core/lib/channel/channel_args.h"
35
35
  #include "src/core/lib/iomgr/closure.h"
36
36
  #include "src/core/lib/iomgr/exec_ctx.h"
37
- #include "src/core/lib/surface/lame_client.h"
38
37
  #include "src/core/lib/transport/timeout_encoding.h"
39
38
 
40
39
  namespace grpc_core {
@@ -130,23 +129,68 @@ class XdsResolver : public Resolver {
130
129
  RefCountedPtr<XdsResolver> resolver_;
131
130
  };
132
131
 
133
- class ClusterState
134
- : public RefCounted<ClusterState, PolymorphicRefCount, kUnrefNoDelete> {
132
+ // An entry in the map of clusters that need to be present in the LB
133
+ // policy config. The map holds a weak ref. One strong ref is held by
134
+ // the ConfigSelector, and another is held by each call assigned to
135
+ // the cluster by the ConfigSelector. The ref for each call is held
136
+ // until the call is committed. When the strong refs go away, we hop
137
+ // back into the WorkSerializer to remove the entry from the map.
138
+ class ClusterState : public DualRefCounted<ClusterState> {
135
139
  public:
136
140
  using ClusterStateMap =
137
- std::map<std::string, std::unique_ptr<ClusterState>>;
141
+ std::map<std::string, WeakRefCountedPtr<ClusterState>>;
138
142
 
139
- ClusterState(const std::string& cluster_name,
140
- ClusterStateMap* cluster_state_map)
141
- : it_(cluster_state_map
142
- ->emplace(cluster_name, std::unique_ptr<ClusterState>(this))
143
+ ClusterState(RefCountedPtr<XdsResolver> resolver,
144
+ const std::string& cluster_name)
145
+ : resolver_(std::move(resolver)),
146
+ it_(resolver_->cluster_state_map_.emplace(cluster_name, WeakRef())
143
147
  .first) {}
148
+
149
+ void Orphan() override {
150
+ auto* resolver = resolver_.release();
151
+ resolver->work_serializer_->Run(
152
+ [resolver]() {
153
+ resolver->MaybeRemoveUnusedClusters();
154
+ resolver->Unref();
155
+ },
156
+ DEBUG_LOCATION);
157
+ }
158
+
144
159
  const std::string& cluster() const { return it_->first; }
145
160
 
146
161
  private:
162
+ RefCountedPtr<XdsResolver> resolver_;
147
163
  ClusterStateMap::iterator it_;
148
164
  };
149
165
 
166
+ // Call dispatch controller, created for each call handled by the
167
+ // ConfigSelector. Holds a ref to the ClusterState object until the
168
+ // call is committed.
169
+ class XdsCallDispatchController
170
+ : public ConfigSelector::CallDispatchController {
171
+ public:
172
+ explicit XdsCallDispatchController(
173
+ RefCountedPtr<ClusterState> cluster_state)
174
+ : cluster_state_(std::move(cluster_state)) {}
175
+
176
+ bool ShouldRetry() override {
177
+ // TODO(donnadionne): Implement the retry circuit breaker here.
178
+ return true;
179
+ }
180
+
181
+ void Commit() override {
182
+ // TODO(donnadionne): If ShouldRetry() was called previously,
183
+ // decrement the retry circuit breaker counter.
184
+ cluster_state_.reset();
185
+ }
186
+
187
+ private:
188
+ // Note: The XdsCallDispatchController object is never actually destroyed,
189
+ // so do not add any data members that require destruction unless you have
190
+ // some other way to clean them up.
191
+ RefCountedPtr<ClusterState> cluster_state_;
192
+ };
193
+
150
194
  class XdsConfigSelector : public ConfigSelector {
151
195
  public:
152
196
  XdsConfigSelector(RefCountedPtr<XdsResolver> resolver,
@@ -198,7 +242,6 @@ class XdsResolver : public Resolver {
198
242
  RouteTable route_table_;
199
243
  std::map<absl::string_view, RefCountedPtr<ClusterState>> clusters_;
200
244
  std::vector<const grpc_channel_filter*> filters_;
201
- grpc_error_handle filter_error_ = GRPC_ERROR_NONE;
202
245
  };
203
246
 
204
247
  void OnListenerUpdate(XdsApi::LdsUpdate listener);
@@ -377,16 +420,8 @@ XdsResolver::XdsConfigSelector::XdsConfigSelector(
377
420
  }
378
421
  }
379
422
  // Populate filter list.
380
- bool found_router = false;
381
423
  for (const auto& http_filter :
382
424
  resolver_->current_listener_.http_connection_manager.http_filters) {
383
- // Stop at the router filter. It's a no-op for us, and we ignore
384
- // anything that may come after it, for compatibility with Envoy.
385
- if (http_filter.config.config_proto_type_name ==
386
- kXdsHttpRouterFilterConfigName) {
387
- found_router = true;
388
- break;
389
- }
390
425
  // Find filter. This is guaranteed to succeed, because it's checked
391
426
  // at config validation time in the XdsApi code.
392
427
  const XdsHttpFilterImpl* filter_impl =
@@ -394,16 +429,9 @@ XdsResolver::XdsConfigSelector::XdsConfigSelector(
394
429
  http_filter.config.config_proto_type_name);
395
430
  GPR_ASSERT(filter_impl != nullptr);
396
431
  // Add C-core filter to list.
397
- filters_.push_back(filter_impl->channel_filter());
398
- }
399
- // For compatibility with Envoy, if the router filter is not
400
- // configured, we fail all RPCs.
401
- if (!found_router) {
402
- filter_error_ =
403
- grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
404
- "no xDS HTTP router filter configured"),
405
- GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE);
406
- filters_.push_back(&grpc_lame_filter);
432
+ if (filter_impl->channel_filter() != nullptr) {
433
+ filters_.push_back(filter_impl->channel_filter());
434
+ }
407
435
  }
408
436
  }
409
437
 
@@ -414,7 +442,6 @@ XdsResolver::XdsConfigSelector::~XdsConfigSelector() {
414
442
  }
415
443
  clusters_.clear();
416
444
  resolver_->MaybeRemoveUnusedClusters();
417
- GRPC_ERROR_UNREF(filter_error_);
418
445
  }
419
446
 
420
447
  const XdsHttpFilterImpl::FilterConfig* FindFilterConfigOverride(
@@ -441,6 +468,42 @@ grpc_error_handle XdsResolver::XdsConfigSelector::CreateMethodConfig(
441
468
  const XdsApi::Route::ClusterWeight* cluster_weight,
442
469
  RefCountedPtr<ServiceConfig>* method_config) {
443
470
  std::vector<std::string> fields;
471
+ // Set retry policy if any.
472
+ if (route.retry_policy.has_value()) {
473
+ std::vector<std::string> retry_parts;
474
+ retry_parts.push_back(absl::StrFormat(
475
+ "\"retryPolicy\": {\n"
476
+ " \"maxAttempts\": %d,\n"
477
+ " \"initialBackoff\": \"%d.%09ds\",\n"
478
+ " \"maxBackoff\": \"%d.%09ds\",\n"
479
+ " \"backoffMultiplier\": 2,\n",
480
+ route.retry_policy->num_retries + 1,
481
+ route.retry_policy->retry_back_off.base_interval.seconds,
482
+ route.retry_policy->retry_back_off.base_interval.nanos,
483
+ route.retry_policy->retry_back_off.max_interval.seconds,
484
+ route.retry_policy->retry_back_off.max_interval.nanos));
485
+ std::vector<std::string> code_parts;
486
+ if (route.retry_policy->retry_on.Contains(GRPC_STATUS_CANCELLED)) {
487
+ code_parts.push_back(" \"CANCELLED\"");
488
+ }
489
+ if (route.retry_policy->retry_on.Contains(GRPC_STATUS_DEADLINE_EXCEEDED)) {
490
+ code_parts.push_back(" \"DEADLINE_EXCEEDED\"");
491
+ }
492
+ if (route.retry_policy->retry_on.Contains(GRPC_STATUS_INTERNAL)) {
493
+ code_parts.push_back(" \"INTERNAL\"");
494
+ }
495
+ if (route.retry_policy->retry_on.Contains(GRPC_STATUS_RESOURCE_EXHAUSTED)) {
496
+ code_parts.push_back(" \"RESOURCE_EXHAUSTED\"");
497
+ }
498
+ if (route.retry_policy->retry_on.Contains(GRPC_STATUS_UNAVAILABLE)) {
499
+ code_parts.push_back(" \"UNAVAILABLE\"");
500
+ }
501
+ retry_parts.push_back(
502
+ absl::StrFormat(" \"retryableStatusCodes\": [\n %s ]\n",
503
+ absl::StrJoin(code_parts, ",\n")));
504
+ retry_parts.push_back(absl::StrFormat(" }"));
505
+ fields.emplace_back(absl::StrJoin(retry_parts, ""));
506
+ }
444
507
  // Set timeout.
445
508
  if (route.max_stream_duration.has_value() &&
446
509
  (route.max_stream_duration->seconds != 0 ||
@@ -454,18 +517,15 @@ grpc_error_handle XdsResolver::XdsConfigSelector::CreateMethodConfig(
454
517
  grpc_channel_args* args = grpc_channel_args_copy(resolver_->args_);
455
518
  for (const auto& http_filter :
456
519
  resolver_->current_listener_.http_connection_manager.http_filters) {
457
- // Stop at the router filter. It's a no-op for us, and we ignore
458
- // anything that may come after it, for compatibility with Envoy.
459
- if (http_filter.config.config_proto_type_name ==
460
- kXdsHttpRouterFilterConfigName) {
461
- break;
462
- }
463
520
  // Find filter. This is guaranteed to succeed, because it's checked
464
521
  // at config validation time in the XdsApi code.
465
522
  const XdsHttpFilterImpl* filter_impl =
466
523
  XdsHttpFilterRegistry::GetFilterForType(
467
524
  http_filter.config.config_proto_type_name);
468
525
  GPR_ASSERT(filter_impl != nullptr);
526
+ // If there is not actually any C-core filter associated with this
527
+ // xDS filter, then it won't need any config, so skip it.
528
+ if (filter_impl->channel_filter() == nullptr) continue;
469
529
  // Allow filter to add channel args that may affect service config
470
530
  // parsing.
471
531
  args = filter_impl->ModifyChannelArgs(args);
@@ -513,20 +573,14 @@ grpc_error_handle XdsResolver::XdsConfigSelector::CreateMethodConfig(
513
573
 
514
574
  grpc_channel_args* XdsResolver::XdsConfigSelector::ModifyChannelArgs(
515
575
  grpc_channel_args* args) {
516
- if (filter_error_ == GRPC_ERROR_NONE) return args;
517
- grpc_arg error_arg = MakeLameClientErrorArg(filter_error_);
518
- grpc_channel_args* new_args =
519
- grpc_channel_args_copy_and_add(args, &error_arg, 1);
520
- grpc_channel_args_destroy(args);
521
- return new_args;
576
+ return args;
522
577
  }
523
578
 
524
579
  void XdsResolver::XdsConfigSelector::MaybeAddCluster(const std::string& name) {
525
580
  if (clusters_.find(name) == clusters_.end()) {
526
581
  auto it = resolver_->cluster_state_map_.find(name);
527
582
  if (it == resolver_->cluster_state_map_.end()) {
528
- auto new_cluster_state =
529
- MakeRefCounted<ClusterState>(name, &resolver_->cluster_state_map_);
583
+ auto new_cluster_state = MakeRefCounted<ClusterState>(resolver_, name);
530
584
  clusters_[new_cluster_state->cluster()] = std::move(new_cluster_state);
531
585
  } else {
532
586
  clusters_[it->second->cluster()] = it->second->Ref();
@@ -568,6 +622,9 @@ absl::optional<uint64_t> HeaderHashHelper(
568
622
  std::string value_buffer;
569
623
  absl::optional<absl::string_view> header_value =
570
624
  GetHeaderValue(initial_metadata, policy.header_name, &value_buffer);
625
+ if (!header_value.has_value()) {
626
+ return absl::nullopt;
627
+ }
571
628
  if (policy.regex != nullptr) {
572
629
  // If GetHeaderValue() did not already store the value in
573
630
  // value_buffer, copy it there now, so we can modify it.
@@ -638,10 +695,7 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
638
695
  }
639
696
  auto it = clusters_.find(cluster_name);
640
697
  GPR_ASSERT(it != clusters_.end());
641
- XdsResolver* resolver =
642
- static_cast<XdsResolver*>(resolver_->Ref().release());
643
- ClusterState* cluster_state = it->second->Ref().release();
644
- // Generate a hash
698
+ // Generate a hash.
645
699
  absl::optional<uint64_t> hash;
646
700
  for (const auto& hash_policy : entry.route.hash_policies) {
647
701
  absl::optional<uint64_t> new_hash;
@@ -650,8 +704,8 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
650
704
  new_hash = HeaderHashHelper(hash_policy, args.initial_metadata);
651
705
  break;
652
706
  case XdsApi::Route::HashPolicy::CHANNEL_ID:
653
- new_hash =
654
- static_cast<uint64_t>(reinterpret_cast<uintptr_t>(resolver));
707
+ new_hash = static_cast<uint64_t>(
708
+ reinterpret_cast<uintptr_t>(resolver_.get()));
655
709
  break;
656
710
  default:
657
711
  GPR_ASSERT(0);
@@ -671,7 +725,12 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
671
725
  }
672
726
  if (!hash.has_value()) {
673
727
  // If there is no hash, we just choose a random value as a default.
674
- hash = rand();
728
+ // We cannot directly use the result of rand() as the hash value,
729
+ // since it is a 32-bit number and not a 64-bit number and will
730
+ // therefore not be evenly distributed.
731
+ uint32_t upper = rand();
732
+ uint32_t lower = rand();
733
+ hash = (static_cast<uint64_t>(upper) << 32) | lower;
675
734
  }
676
735
  CallConfig call_config;
677
736
  if (method_config != nullptr) {
@@ -680,33 +739,14 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
680
739
  call_config.service_config = std::move(method_config);
681
740
  }
682
741
  call_config.call_attributes[kXdsClusterAttribute] = it->first;
683
- call_config.call_attributes[kRequestRingHashAttribute] =
684
- absl::StrFormat("%" PRIu64, hash.value());
685
- call_config.on_call_committed = [resolver, cluster_state]() {
686
- cluster_state->Unref();
687
- ExecCtx::Run(
688
- // TODO(roth): This hop into the ExecCtx is being done to avoid
689
- // entering the WorkSerializer while holding the client channel data
690
- // plane mutex, since that can lead to deadlocks. However, we should
691
- // not have to solve this problem in each individual ConfigSelector
692
- // implementation. When we have time, we should fix the client channel
693
- // code to avoid this by not invoking the
694
- // CallConfig::on_call_committed callback until after it has released
695
- // the data plane mutex.
696
- DEBUG_LOCATION,
697
- GRPC_CLOSURE_CREATE(
698
- [](void* arg, grpc_error_handle /*error*/) {
699
- auto* resolver = static_cast<XdsResolver*>(arg);
700
- resolver->work_serializer_->Run(
701
- [resolver]() {
702
- resolver->MaybeRemoveUnusedClusters();
703
- resolver->Unref();
704
- },
705
- DEBUG_LOCATION);
706
- },
707
- resolver, nullptr),
708
- GRPC_ERROR_NONE);
709
- };
742
+ std::string hash_string = absl::StrCat(hash.value());
743
+ char* hash_value =
744
+ static_cast<char*>(args.arena->Alloc(hash_string.size() + 1));
745
+ memcpy(hash_value, hash_string.c_str(), hash_string.size());
746
+ hash_value[hash_string.size()] = '\0';
747
+ call_config.call_attributes[kRequestRingHashAttribute] = hash_value;
748
+ call_config.call_dispatch_controller =
749
+ args.arena->New<XdsCallDispatchController>(it->second->Ref());
710
750
  return call_config;
711
751
  }
712
752
  return CallConfig();