grpc 1.28.0 → 1.36.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 (1466) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1692 -22343
  3. data/etc/roots.pem +257 -573
  4. data/include/grpc/compression.h +1 -1
  5. data/include/grpc/grpc.h +17 -9
  6. data/include/grpc/grpc_security.h +274 -180
  7. data/include/grpc/grpc_security_constants.h +4 -0
  8. data/include/grpc/impl/codegen/README.md +22 -0
  9. data/include/grpc/impl/codegen/atm_windows.h +4 -0
  10. data/include/grpc/impl/codegen/byte_buffer.h +1 -1
  11. data/include/grpc/impl/codegen/grpc_types.h +32 -30
  12. data/include/grpc/impl/codegen/log.h +0 -2
  13. data/include/grpc/impl/codegen/port_platform.h +34 -90
  14. data/include/grpc/impl/codegen/sync_windows.h +4 -0
  15. data/include/grpc/module.modulemap +24 -39
  16. data/include/grpc/slice_buffer.h +3 -3
  17. data/include/grpc/support/sync.h +3 -3
  18. data/include/grpc/support/time.h +7 -7
  19. data/src/core/ext/filters/client_channel/backend_metric.cc +16 -12
  20. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  21. data/src/core/ext/filters/client_channel/client_channel.cc +3750 -2341
  22. data/src/core/ext/filters/client_channel/client_channel.h +1 -7
  23. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  24. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +4 -3
  25. data/src/core/ext/filters/client_channel/config_selector.cc +58 -0
  26. data/src/core/ext/filters/client_channel/config_selector.h +125 -0
  27. data/src/core/ext/filters/client_channel/dynamic_filters.cc +186 -0
  28. data/src/core/ext/filters/client_channel/dynamic_filters.h +99 -0
  29. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -2
  30. data/src/core/ext/filters/client_channel/health/health_check_client.cc +25 -30
  31. data/src/core/ext/filters/client_channel/health/health_check_client.h +7 -7
  32. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +15 -16
  33. data/src/core/ext/filters/client_channel/http_proxy.cc +44 -34
  34. data/src/core/ext/filters/client_channel/lb_policy.cc +25 -20
  35. data/src/core/ext/filters/client_channel/lb_policy.h +50 -38
  36. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +96 -0
  37. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +101 -0
  38. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +20 -11
  39. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +1 -1
  40. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +481 -510
  41. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +76 -0
  42. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +37 -0
  43. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -2
  44. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +6 -41
  45. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +3 -1
  46. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +3 -2
  47. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  48. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  49. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +24 -18
  50. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +922 -0
  51. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +11 -10
  52. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +18 -46
  53. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +744 -0
  54. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +520 -134
  55. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +53 -26
  56. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +29 -0
  57. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +810 -0
  58. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +722 -0
  59. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +1384 -0
  60. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +18 -8
  61. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +2 -1
  62. data/src/core/ext/filters/client_channel/resolver.cc +6 -10
  63. data/src/core/ext/filters/client_channel/resolver.h +10 -20
  64. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +111 -110
  65. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +4 -34
  66. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +22 -24
  67. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +13 -11
  68. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +79 -122
  69. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +642 -180
  70. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +10 -3
  71. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  72. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  73. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +61 -61
  74. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +102 -108
  75. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -5
  76. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +362 -0
  77. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +38 -31
  78. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +625 -46
  79. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  80. data/src/core/ext/filters/client_channel/resolver_factory.h +8 -8
  81. data/src/core/ext/filters/client_channel/resolver_registry.cc +55 -52
  82. data/src/core/ext/filters/client_channel/resolver_registry.h +10 -10
  83. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +47 -93
  84. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +30 -26
  85. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -3
  86. data/src/core/ext/filters/client_channel/retry_throttle.h +4 -2
  87. data/src/core/ext/filters/client_channel/server_address.cc +129 -13
  88. data/src/core/ext/filters/client_channel/server_address.h +80 -32
  89. data/src/core/ext/filters/client_channel/service_config.cc +114 -149
  90. data/src/core/ext/filters/client_channel/service_config.h +33 -100
  91. data/src/core/ext/filters/client_channel/service_config_call_data.h +86 -0
  92. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +142 -0
  93. data/src/core/ext/filters/client_channel/service_config_parser.cc +89 -0
  94. data/src/core/ext/filters/client_channel/service_config_parser.h +92 -0
  95. data/src/core/ext/filters/client_channel/subchannel.cc +156 -98
  96. data/src/core/ext/filters/client_channel/subchannel.h +65 -35
  97. data/src/core/ext/filters/client_channel/subchannel_interface.h +41 -5
  98. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +6 -2
  99. data/src/core/ext/filters/deadline/deadline_filter.cc +87 -79
  100. data/src/core/ext/filters/deadline/deadline_filter.h +7 -11
  101. data/src/core/ext/filters/http/client/http_client_filter.cc +29 -34
  102. data/src/core/ext/filters/http/client_authority_filter.cc +10 -10
  103. data/src/core/ext/filters/http/http_filters_plugin.cc +34 -15
  104. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +258 -221
  105. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +399 -0
  106. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +31 -0
  107. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -3
  108. data/src/core/ext/filters/max_age/max_age_filter.cc +38 -34
  109. data/src/core/ext/filters/message_size/message_size_filter.cc +64 -90
  110. data/src/core/ext/filters/message_size/message_size_filter.h +12 -5
  111. data/src/core/ext/filters/workarounds/workaround_utils.cc +1 -1
  112. data/src/core/ext/transport/chttp2/client/authority.cc +3 -3
  113. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  114. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +19 -2
  115. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +20 -8
  116. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +21 -10
  117. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +34 -47
  118. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +505 -344
  119. data/src/core/ext/transport/chttp2/server/chttp2_server.h +16 -2
  120. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +13 -3
  121. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +19 -18
  122. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +65 -21
  123. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -7
  124. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +4 -6
  125. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +307 -343
  126. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  127. data/src/core/ext/transport/chttp2/transport/flow_control.cc +36 -33
  128. data/src/core/ext/transport/chttp2/transport/flow_control.h +27 -19
  129. data/src/core/ext/transport/chttp2/transport/frame_data.cc +9 -12
  130. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -7
  131. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -3
  132. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  133. data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -3
  134. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +12 -13
  135. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -3
  136. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -9
  137. data/src/core/ext/transport/chttp2/transport/frame_settings.h +4 -4
  138. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +15 -18
  139. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -3
  140. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +29 -16
  141. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -3
  142. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +37 -37
  143. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -3
  144. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +13 -17
  145. data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -2
  146. data/src/core/ext/transport/chttp2/transport/http2_settings.h +4 -5
  147. data/src/core/ext/transport/chttp2/transport/huffsyms.h +2 -3
  148. data/src/core/ext/transport/chttp2/transport/internal.h +37 -23
  149. data/src/core/ext/transport/chttp2/transport/parsing.cc +52 -74
  150. data/src/core/ext/transport/chttp2/transport/stream_map.h +2 -3
  151. data/src/core/ext/transport/chttp2/transport/writing.cc +30 -28
  152. data/src/core/ext/transport/inproc/inproc_transport.cc +106 -33
  153. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -1
  154. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
  155. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +10 -4
  156. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +243 -0
  157. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +865 -0
  158. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  159. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +253 -0
  160. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +453 -0
  161. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1801 -0
  162. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +35 -0
  163. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +77 -0
  164. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +56 -0
  165. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +364 -0
  166. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +124 -0
  167. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +428 -0
  168. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +35 -0
  169. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +88 -0
  170. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +334 -0
  171. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +1066 -0
  172. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +103 -0
  173. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +388 -0
  174. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  175. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +78 -0
  176. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  177. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +149 -0
  178. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +241 -0
  179. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +839 -0
  180. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  181. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +767 -0
  182. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +36 -0
  183. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +88 -0
  184. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +176 -0
  185. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +730 -0
  186. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +27 -0
  187. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +65 -0
  188. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +34 -0
  189. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +95 -0
  190. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +42 -0
  191. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +126 -0
  192. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +90 -0
  193. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +243 -0
  194. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  195. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +305 -0
  196. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  197. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +367 -0
  198. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +33 -0
  199. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +73 -0
  200. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +130 -0
  201. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +557 -0
  202. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +159 -0
  203. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +623 -0
  204. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +40 -0
  205. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +107 -0
  206. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +178 -0
  207. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +662 -0
  208. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +65 -0
  209. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +237 -0
  210. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +926 -0
  211. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +3746 -0
  212. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +60 -0
  213. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +159 -0
  214. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +49 -0
  215. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +122 -0
  216. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +29 -0
  217. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +67 -0
  218. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +361 -0
  219. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1484 -0
  220. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +19 -0
  221. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +35 -0
  222. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +113 -0
  223. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +458 -0
  224. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +73 -0
  225. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +219 -0
  226. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +146 -0
  227. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +621 -0
  228. data/src/core/ext/upb-generated/envoy/{api/v2/rds.upb.c → service/cluster/v3/cds.upb.c} +7 -9
  229. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +56 -0
  230. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +25 -0
  231. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +56 -0
  232. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +146 -0
  233. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +499 -0
  234. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +27 -0
  235. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +56 -0
  236. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +27 -0
  237. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +56 -0
  238. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +54 -0
  239. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +151 -0
  240. data/src/core/ext/upb-generated/envoy/{api/v2/srds.upb.c → service/route/v3/rds.upb.c} +7 -7
  241. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +56 -0
  242. data/src/core/ext/upb-generated/envoy/{api/v2/cds.upb.c → service/route/v3/srds.upb.c} +7 -7
  243. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +56 -0
  244. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  245. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +128 -0
  246. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  247. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +84 -0
  248. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  249. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +78 -0
  250. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  251. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +166 -0
  252. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +53 -0
  253. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +146 -0
  254. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  255. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +207 -0
  256. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  257. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +301 -0
  258. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  259. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +283 -0
  260. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +3 -2
  261. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +9 -9
  262. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +40 -0
  263. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +99 -0
  264. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +51 -0
  265. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +130 -0
  266. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +30 -0
  267. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +68 -0
  268. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
  269. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  270. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +830 -0
  271. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +251 -0
  272. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +871 -0
  273. data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
  274. data/src/core/ext/upb-generated/google/api/http.upb.h +52 -32
  275. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
  276. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +12 -6
  277. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +107 -106
  278. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +691 -496
  279. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
  280. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +12 -6
  281. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  282. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +8 -2
  283. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +5 -5
  284. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +55 -57
  285. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
  286. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +12 -6
  287. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +9 -9
  288. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +82 -28
  289. data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
  290. data/src/core/ext/upb-generated/google/rpc/status.upb.h +17 -10
  291. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +5 -5
  292. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +40 -45
  293. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +43 -43
  294. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +236 -184
  295. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +5 -5
  296. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +29 -13
  297. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
  298. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +19 -7
  299. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +17 -17
  300. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +122 -62
  301. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
  302. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +30 -12
  303. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  304. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +64 -0
  305. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -1
  306. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
  307. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +71 -0
  308. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  309. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +60 -0
  310. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +9 -9
  311. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +48 -68
  312. data/src/core/ext/upb-generated/validate/validate.upb.c +71 -70
  313. data/src/core/ext/upb-generated/validate/validate.upb.h +732 -586
  314. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +28 -0
  315. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +60 -0
  316. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +52 -0
  317. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +143 -0
  318. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +42 -0
  319. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +84 -0
  320. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +36 -0
  321. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +94 -0
  322. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +54 -0
  323. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +166 -0
  324. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +36 -0
  325. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +85 -0
  326. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +38 -0
  327. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.h +30 -0
  328. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +41 -0
  329. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.h +35 -0
  330. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +251 -0
  331. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +105 -0
  332. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +100 -0
  333. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.h +45 -0
  334. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +543 -0
  335. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +145 -0
  336. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +53 -0
  337. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.h +35 -0
  338. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +136 -0
  339. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.h +35 -0
  340. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +127 -0
  341. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +65 -0
  342. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +56 -0
  343. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.h +35 -0
  344. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +272 -0
  345. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +135 -0
  346. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +143 -0
  347. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +55 -0
  348. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +56 -0
  349. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.h +35 -0
  350. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +66 -0
  351. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +40 -0
  352. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +263 -0
  353. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.h +100 -0
  354. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +233 -0
  355. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +70 -0
  356. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +56 -0
  357. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.h +35 -0
  358. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +228 -0
  359. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +80 -0
  360. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +43 -0
  361. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +35 -0
  362. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +59 -0
  363. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +35 -0
  364. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +68 -0
  365. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.h +35 -0
  366. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +107 -0
  367. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.h +50 -0
  368. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +113 -0
  369. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +50 -0
  370. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +146 -0
  371. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.h +55 -0
  372. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +50 -0
  373. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.h +35 -0
  374. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +195 -0
  375. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +55 -0
  376. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +193 -0
  377. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.h +65 -0
  378. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +59 -0
  379. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.h +40 -0
  380. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +101 -0
  381. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +40 -0
  382. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +938 -0
  383. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +285 -0
  384. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +71 -0
  385. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.h +45 -0
  386. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +61 -0
  387. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.h +40 -0
  388. data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c +51 -0
  389. data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h +35 -0
  390. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +504 -0
  391. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +115 -0
  392. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +44 -0
  393. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.h +30 -0
  394. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +170 -0
  395. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +55 -0
  396. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +97 -0
  397. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.h +45 -0
  398. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +246 -0
  399. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +60 -0
  400. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +72 -0
  401. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.h +35 -0
  402. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +60 -0
  403. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.h +35 -0
  404. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +142 -0
  405. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +65 -0
  406. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +73 -0
  407. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.h +35 -0
  408. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +72 -0
  409. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.h +35 -0
  410. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +80 -0
  411. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.h +40 -0
  412. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +80 -0
  413. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.h +35 -0
  414. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +74 -0
  415. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.h +35 -0
  416. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +64 -0
  417. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.h +40 -0
  418. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +54 -0
  419. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.h +35 -0
  420. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +53 -0
  421. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.h +35 -0
  422. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +73 -0
  423. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.h +45 -0
  424. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +69 -0
  425. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.h +40 -0
  426. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +81 -0
  427. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.h +45 -0
  428. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +92 -0
  429. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.h +65 -0
  430. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +95 -0
  431. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.h +55 -0
  432. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +34 -0
  433. data/src/core/ext/{upb-generated/gogoproto/gogo.upb.h → upbdefs-generated/envoy/type/v3/http.upbdefs.h} +10 -10
  434. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +59 -0
  435. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.h +40 -0
  436. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +54 -0
  437. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.h +45 -0
  438. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +47 -0
  439. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.h +35 -0
  440. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +40 -0
  441. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.h +30 -0
  442. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +61 -0
  443. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.h +45 -0
  444. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +39 -0
  445. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.h +35 -0
  446. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +386 -0
  447. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.h +165 -0
  448. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +40 -0
  449. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.h +35 -0
  450. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +37 -0
  451. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.h +35 -0
  452. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +65 -0
  453. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.h +50 -0
  454. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +40 -0
  455. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.h +35 -0
  456. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +66 -0
  457. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.h +75 -0
  458. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +42 -0
  459. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.h +35 -0
  460. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +70 -0
  461. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.h +45 -0
  462. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +56 -0
  463. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.h +35 -0
  464. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +33 -0
  465. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.h +30 -0
  466. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +49 -0
  467. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.h +35 -0
  468. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +43 -0
  469. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.h +35 -0
  470. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +310 -0
  471. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.h +145 -0
  472. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +42 -0
  473. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.h +35 -0
  474. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +62 -0
  475. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.h +40 -0
  476. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +45 -0
  477. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.h +40 -0
  478. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +49 -0
  479. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.h +35 -0
  480. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +67 -0
  481. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.h +40 -0
  482. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +50 -0
  483. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.h +35 -0
  484. data/src/core/ext/xds/certificate_provider_factory.h +61 -0
  485. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  486. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  487. data/src/core/ext/xds/certificate_provider_store.cc +87 -0
  488. data/src/core/ext/xds/certificate_provider_store.h +112 -0
  489. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +144 -0
  490. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +69 -0
  491. data/src/core/ext/xds/xds_api.cc +2479 -0
  492. data/src/core/ext/xds/xds_api.h +431 -0
  493. data/src/core/ext/xds/xds_bootstrap.cc +539 -0
  494. data/src/core/ext/xds/xds_bootstrap.h +116 -0
  495. data/src/core/ext/xds/xds_certificate_provider.cc +405 -0
  496. data/src/core/ext/xds/xds_certificate_provider.h +151 -0
  497. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +9 -6
  498. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +839 -774
  499. data/src/core/ext/xds/xds_client.h +339 -0
  500. data/src/core/ext/xds/xds_client_stats.cc +159 -0
  501. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +78 -38
  502. data/src/core/ext/xds/xds_server_config_fetcher.cc +267 -0
  503. data/src/core/lib/channel/channel_args.cc +24 -22
  504. data/src/core/lib/channel/channel_args.h +3 -2
  505. data/src/core/lib/channel/channel_stack.h +20 -13
  506. data/src/core/lib/channel/channel_trace.cc +6 -8
  507. data/src/core/lib/channel/channel_trace.h +1 -1
  508. data/src/core/lib/channel/channelz.cc +46 -94
  509. data/src/core/lib/channel/channelz.h +17 -25
  510. data/src/core/lib/channel/channelz_registry.cc +20 -15
  511. data/src/core/lib/channel/channelz_registry.h +3 -1
  512. data/src/core/lib/channel/connected_channel.cc +7 -5
  513. data/src/core/lib/channel/context.h +1 -1
  514. data/src/core/lib/channel/handshaker.cc +15 -20
  515. data/src/core/lib/channel/handshaker.h +7 -5
  516. data/src/core/lib/channel/handshaker_registry.cc +5 -17
  517. data/src/core/lib/channel/status_util.cc +2 -3
  518. data/src/core/lib/compression/compression.cc +8 -4
  519. data/src/core/lib/compression/compression_args.cc +3 -2
  520. data/src/core/lib/compression/compression_internal.cc +10 -5
  521. data/src/core/lib/compression/compression_internal.h +2 -1
  522. data/src/core/lib/compression/message_compress.cc +5 -1
  523. data/src/core/lib/compression/stream_compression_identity.cc +1 -3
  524. data/src/core/lib/debug/stats.cc +21 -27
  525. data/src/core/lib/debug/stats.h +5 -3
  526. data/src/core/lib/debug/stats_data.cc +1 -0
  527. data/src/core/lib/debug/stats_data.h +13 -13
  528. data/src/core/lib/gpr/alloc.cc +3 -2
  529. data/src/core/lib/gpr/cpu_iphone.cc +10 -2
  530. data/src/core/lib/gpr/log.cc +59 -17
  531. data/src/core/lib/gpr/log_linux.cc +23 -9
  532. data/src/core/lib/gpr/log_posix.cc +19 -7
  533. data/src/core/lib/gpr/log_windows.cc +18 -4
  534. data/src/core/lib/gpr/murmur_hash.cc +1 -1
  535. data/src/core/lib/gpr/spinlock.h +12 -5
  536. data/src/core/lib/gpr/string.cc +33 -55
  537. data/src/core/lib/gpr/string.h +9 -24
  538. data/src/core/lib/gpr/sync.cc +4 -4
  539. data/src/core/lib/gpr/sync_abseil.cc +2 -0
  540. data/src/core/lib/gpr/sync_posix.cc +2 -8
  541. data/src/core/lib/gpr/time.cc +16 -12
  542. data/src/core/lib/gpr/time_posix.cc +1 -1
  543. data/src/core/lib/gpr/time_precise.cc +5 -2
  544. data/src/core/lib/gpr/time_precise.h +6 -2
  545. data/src/core/lib/gpr/tls.h +4 -0
  546. data/src/core/lib/gpr/tls_msvc.h +2 -0
  547. data/src/core/lib/gpr/tls_stdcpp.h +48 -0
  548. data/src/core/lib/gpr/useful.h +5 -4
  549. data/src/core/lib/gprpp/arena.h +3 -2
  550. data/src/core/lib/gprpp/atomic.h +6 -6
  551. data/src/core/lib/gprpp/dual_ref_counted.h +331 -0
  552. data/src/core/lib/gprpp/examine_stack.cc +43 -0
  553. data/src/core/lib/gprpp/examine_stack.h +46 -0
  554. data/src/core/lib/gprpp/fork.cc +3 -3
  555. data/src/core/lib/gprpp/global_config_env.cc +8 -6
  556. data/src/core/lib/gprpp/host_port.cc +29 -35
  557. data/src/core/lib/gprpp/host_port.h +14 -17
  558. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  559. data/src/core/lib/gprpp/mpscq.cc +2 -2
  560. data/src/core/lib/gprpp/orphanable.h +4 -8
  561. data/src/core/lib/gprpp/ref_counted.h +91 -68
  562. data/src/core/lib/gprpp/ref_counted_ptr.h +171 -7
  563. data/src/core/lib/gprpp/stat.h +38 -0
  564. data/src/core/lib/gprpp/stat_posix.cc +49 -0
  565. data/src/core/lib/gprpp/stat_windows.cc +48 -0
  566. data/src/core/lib/gprpp/sync.h +129 -40
  567. data/src/core/lib/gprpp/thd.h +2 -2
  568. data/src/core/lib/gprpp/thd_posix.cc +42 -37
  569. data/src/core/lib/gprpp/thd_windows.cc +3 -1
  570. data/src/core/lib/gprpp/time_util.cc +77 -0
  571. data/src/core/lib/gprpp/time_util.h +42 -0
  572. data/src/core/lib/http/format_request.cc +46 -65
  573. data/src/core/lib/http/httpcli.cc +16 -14
  574. data/src/core/lib/http/httpcli.h +4 -6
  575. data/src/core/lib/http/httpcli_security_connector.cc +13 -13
  576. data/src/core/lib/http/parser.cc +47 -27
  577. data/src/core/lib/http/parser.h +2 -3
  578. data/src/core/lib/iomgr/buffer_list.h +22 -21
  579. data/src/core/lib/iomgr/call_combiner.cc +8 -5
  580. data/src/core/lib/iomgr/call_combiner.h +3 -2
  581. data/src/core/lib/iomgr/cfstream_handle.cc +4 -2
  582. data/src/core/lib/iomgr/closure.h +2 -3
  583. data/src/core/lib/iomgr/combiner.cc +2 -1
  584. data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
  585. data/src/core/lib/iomgr/endpoint.cc +5 -1
  586. data/src/core/lib/iomgr/endpoint.h +8 -4
  587. data/src/core/lib/iomgr/endpoint_cfstream.cc +38 -14
  588. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  589. data/src/core/lib/iomgr/endpoint_pair_posix.cc +10 -10
  590. data/src/core/lib/iomgr/error.cc +23 -21
  591. data/src/core/lib/iomgr/error.h +0 -1
  592. data/src/core/lib/iomgr/error_cfstream.cc +9 -8
  593. data/src/core/lib/iomgr/error_internal.h +1 -1
  594. data/src/core/lib/iomgr/ev_apple.cc +359 -0
  595. data/src/core/lib/iomgr/ev_apple.h +43 -0
  596. data/src/core/lib/iomgr/ev_epoll1_linux.cc +43 -40
  597. data/src/core/lib/iomgr/ev_epollex_linux.cc +46 -45
  598. data/src/core/lib/iomgr/ev_poll_posix.cc +18 -15
  599. data/src/core/lib/iomgr/ev_posix.cc +2 -3
  600. data/src/core/lib/iomgr/exec_ctx.cc +1 -1
  601. data/src/core/lib/iomgr/exec_ctx.h +26 -10
  602. data/src/core/lib/iomgr/executor.cc +2 -1
  603. data/src/core/lib/iomgr/executor.h +1 -1
  604. data/src/core/lib/iomgr/executor/mpmcqueue.h +5 -5
  605. data/src/core/lib/iomgr/executor/threadpool.h +4 -4
  606. data/src/core/lib/iomgr/iomgr.cc +1 -1
  607. data/src/core/lib/iomgr/iomgr_posix.cc +0 -1
  608. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +84 -21
  609. data/src/core/lib/iomgr/is_epollexclusive_available.cc +14 -0
  610. data/src/core/lib/iomgr/load_file.h +1 -1
  611. data/src/core/lib/iomgr/lockfree_event.cc +19 -14
  612. data/src/core/lib/iomgr/lockfree_event.h +2 -2
  613. data/src/core/lib/iomgr/parse_address.cc +322 -0
  614. data/src/core/lib/iomgr/parse_address.h +77 -0
  615. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +2 -1
  616. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +1 -1
  617. data/src/core/lib/iomgr/pollset_set_custom.cc +11 -11
  618. data/src/core/lib/{gprpp/optional.h → iomgr/pollset_uv.h} +11 -12
  619. data/src/core/lib/iomgr/port.h +2 -21
  620. data/src/core/lib/iomgr/python_util.h +46 -0
  621. data/src/core/lib/iomgr/resolve_address.cc +4 -4
  622. data/src/core/lib/iomgr/resolve_address.h +4 -6
  623. data/src/core/lib/iomgr/resolve_address_custom.cc +42 -57
  624. data/src/core/lib/iomgr/resolve_address_custom.h +4 -2
  625. data/src/core/lib/iomgr/resolve_address_posix.cc +11 -16
  626. data/src/core/lib/iomgr/resolve_address_windows.cc +16 -25
  627. data/src/core/lib/iomgr/resource_quota.cc +38 -37
  628. data/src/core/lib/iomgr/sockaddr_utils.cc +41 -44
  629. data/src/core/lib/iomgr/sockaddr_utils.h +13 -17
  630. data/src/core/lib/iomgr/socket_factory_posix.cc +3 -2
  631. data/src/core/lib/iomgr/socket_factory_posix.h +2 -3
  632. data/src/core/lib/iomgr/socket_mutator.cc +3 -2
  633. data/src/core/lib/iomgr/socket_mutator.h +2 -3
  634. data/src/core/lib/iomgr/socket_utils_common_posix.cc +103 -81
  635. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  636. data/src/core/lib/iomgr/socket_windows.cc +4 -5
  637. data/src/core/lib/iomgr/tcp_client.cc +3 -3
  638. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -18
  639. data/src/core/lib/iomgr/tcp_client_custom.cc +13 -15
  640. data/src/core/lib/iomgr/tcp_client_posix.cc +31 -37
  641. data/src/core/lib/iomgr/tcp_client_windows.cc +10 -11
  642. data/src/core/lib/iomgr/tcp_custom.cc +56 -36
  643. data/src/core/lib/iomgr/tcp_custom.h +1 -1
  644. data/src/core/lib/iomgr/tcp_posix.cc +47 -25
  645. data/src/core/lib/iomgr/tcp_server.cc +3 -4
  646. data/src/core/lib/iomgr/tcp_server.h +7 -5
  647. data/src/core/lib/iomgr/tcp_server_custom.cc +39 -45
  648. data/src/core/lib/iomgr/tcp_server_posix.cc +38 -44
  649. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -4
  650. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +7 -8
  651. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +10 -18
  652. data/src/core/lib/iomgr/tcp_server_windows.cc +16 -16
  653. data/src/core/lib/iomgr/tcp_uv.cc +3 -2
  654. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  655. data/src/core/lib/iomgr/time_averaged_stats.h +2 -3
  656. data/src/core/lib/iomgr/timer_custom.cc +5 -5
  657. data/src/core/lib/iomgr/timer_generic.cc +18 -18
  658. data/src/core/lib/{gprpp/inlined_vector.h → iomgr/timer_generic.h} +19 -17
  659. data/src/core/lib/iomgr/timer_heap.h +2 -3
  660. data/src/core/lib/iomgr/timer_manager.cc +2 -2
  661. data/src/core/lib/iomgr/udp_server.cc +33 -38
  662. data/src/core/lib/iomgr/udp_server.h +6 -4
  663. data/src/core/lib/iomgr/unix_sockets_posix.cc +36 -30
  664. data/src/core/lib/iomgr/unix_sockets_posix.h +8 -1
  665. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +12 -2
  666. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -2
  667. data/src/core/lib/json/json.h +15 -4
  668. data/src/core/lib/json/json_reader.cc +33 -30
  669. data/src/core/lib/json/json_util.cc +58 -0
  670. data/src/core/lib/json/json_util.h +204 -0
  671. data/src/core/lib/json/json_writer.cc +15 -13
  672. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  673. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  674. data/src/core/lib/security/authorization/evaluate_args.cc +148 -0
  675. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  676. data/src/core/lib/security/authorization/matchers.cc +339 -0
  677. data/src/core/lib/security/authorization/matchers.h +158 -0
  678. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  679. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +44 -0
  680. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +69 -0
  681. data/src/core/lib/security/authorization/mock_cel/cel_value.h +99 -0
  682. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  683. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +57 -0
  684. data/src/core/lib/security/context/security_context.cc +4 -3
  685. data/src/core/lib/security/context/security_context.h +3 -1
  686. data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -1
  687. data/src/core/lib/security/credentials/alts/alts_credentials.h +1 -1
  688. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
  689. data/src/core/lib/security/credentials/composite/composite_credentials.cc +12 -0
  690. data/src/core/lib/security/credentials/composite/composite_credentials.h +6 -3
  691. data/src/core/lib/security/credentials/credentials.cc +7 -91
  692. data/src/core/lib/security/credentials/credentials.h +18 -66
  693. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +413 -0
  694. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +80 -0
  695. data/src/core/lib/security/credentials/external/aws_request_signer.cc +213 -0
  696. data/src/core/lib/security/credentials/external/aws_request_signer.h +72 -0
  697. data/src/core/lib/security/credentials/external/external_account_credentials.cc +497 -0
  698. data/src/core/lib/security/credentials/external/external_account_credentials.h +120 -0
  699. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +135 -0
  700. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +48 -0
  701. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +213 -0
  702. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +58 -0
  703. data/src/core/lib/security/credentials/fake/fake_credentials.cc +3 -2
  704. data/src/core/lib/security/credentials/fake/fake_credentials.h +4 -0
  705. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +8 -6
  706. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +90 -67
  707. data/src/core/lib/security/credentials/iam/iam_credentials.cc +8 -6
  708. data/src/core/lib/security/credentials/iam/iam_credentials.h +4 -0
  709. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +64 -0
  710. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -4
  711. data/src/core/lib/security/credentials/jwt/json_token.h +2 -5
  712. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +7 -4
  713. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +13 -0
  714. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +13 -19
  715. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -3
  716. data/src/core/lib/security/credentials/local/local_credentials.cc +2 -1
  717. data/src/core/lib/security/credentials/local/local_credentials.h +1 -1
  718. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +109 -97
  719. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +14 -7
  720. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +20 -7
  721. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  722. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +27 -6
  723. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +12 -2
  724. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +346 -0
  725. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +213 -0
  726. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +399 -0
  727. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +138 -0
  728. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +78 -140
  729. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +74 -167
  730. data/src/core/lib/security/credentials/tls/tls_credentials.cc +18 -13
  731. data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -3
  732. data/src/core/lib/security/credentials/tls/tls_utils.cc +91 -0
  733. data/src/core/lib/security/credentials/tls/tls_utils.h +38 -0
  734. data/src/core/lib/security/credentials/xds/xds_credentials.cc +244 -0
  735. data/src/core/lib/security/credentials/xds/xds_credentials.h +69 -0
  736. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +22 -7
  737. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +27 -32
  738. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +121 -0
  739. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +87 -0
  740. data/src/core/lib/security/security_connector/load_system_roots.h +4 -0
  741. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -2
  742. data/src/core/lib/security/security_connector/load_system_roots_linux.h +2 -0
  743. data/src/core/lib/security/security_connector/local/local_security_connector.cc +4 -4
  744. data/src/core/lib/security/security_connector/security_connector.cc +6 -3
  745. data/src/core/lib/security/security_connector/security_connector.h +6 -4
  746. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +42 -40
  747. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +8 -5
  748. data/src/core/lib/security/security_connector/ssl_utils.cc +94 -23
  749. data/src/core/lib/security/security_connector/ssl_utils.h +37 -31
  750. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +388 -284
  751. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +108 -42
  752. data/src/core/lib/security/transport/auth_filters.h +0 -5
  753. data/src/core/lib/security/transport/client_auth_filter.cc +11 -11
  754. data/src/core/lib/security/transport/secure_endpoint.cc +9 -3
  755. data/src/core/lib/security/transport/security_handshaker.cc +4 -6
  756. data/src/core/lib/security/transport/server_auth_filter.cc +2 -1
  757. data/src/core/lib/security/util/json_util.cc +12 -13
  758. data/src/core/lib/security/util/json_util.h +1 -0
  759. data/src/core/lib/slice/slice.cc +45 -5
  760. data/src/core/lib/slice/slice_buffer.cc +2 -1
  761. data/src/core/lib/slice/slice_intern.cc +9 -11
  762. data/src/core/lib/slice/slice_internal.h +17 -2
  763. data/src/core/lib/slice/slice_utils.h +9 -0
  764. data/src/core/lib/surface/byte_buffer_reader.cc +2 -47
  765. data/src/core/lib/surface/call.cc +95 -88
  766. data/src/core/lib/surface/call.h +2 -1
  767. data/src/core/lib/surface/call_details.cc +8 -8
  768. data/src/core/lib/surface/call_log_batch.cc +50 -58
  769. data/src/core/lib/surface/channel.cc +86 -72
  770. data/src/core/lib/surface/channel.h +54 -7
  771. data/src/core/lib/surface/channel_init.cc +1 -1
  772. data/src/core/lib/surface/channel_ping.cc +2 -3
  773. data/src/core/lib/surface/completion_queue.cc +63 -62
  774. data/src/core/lib/surface/completion_queue.h +16 -16
  775. data/src/core/lib/surface/event_string.cc +18 -25
  776. data/src/core/lib/surface/event_string.h +3 -1
  777. data/src/core/lib/surface/init.cc +45 -29
  778. data/src/core/lib/surface/init_secure.cc +1 -4
  779. data/src/core/lib/surface/lame_client.cc +20 -46
  780. data/src/core/lib/surface/lame_client.h +4 -0
  781. data/src/core/lib/surface/server.cc +1311 -1309
  782. data/src/core/lib/surface/server.h +410 -45
  783. data/src/core/lib/surface/validate_metadata.h +3 -0
  784. data/src/core/lib/surface/version.cc +2 -2
  785. data/src/core/lib/transport/authority_override.cc +40 -0
  786. data/src/core/lib/transport/authority_override.h +37 -0
  787. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  788. data/src/core/lib/transport/bdp_estimator.h +2 -1
  789. data/src/core/lib/transport/byte_stream.h +10 -5
  790. data/src/core/lib/transport/connectivity_state.cc +23 -17
  791. data/src/core/lib/transport/connectivity_state.h +31 -15
  792. data/src/core/lib/transport/error_utils.cc +13 -0
  793. data/src/core/lib/transport/error_utils.h +7 -1
  794. data/src/core/lib/transport/metadata.cc +19 -5
  795. data/src/core/lib/transport/metadata.h +2 -2
  796. data/src/core/lib/transport/metadata_batch.h +6 -7
  797. data/src/core/lib/transport/static_metadata.cc +296 -277
  798. data/src/core/lib/transport/static_metadata.h +81 -74
  799. data/src/core/lib/transport/status_conversion.cc +6 -14
  800. data/src/core/lib/transport/status_metadata.cc +4 -3
  801. data/src/core/lib/transport/timeout_encoding.cc +4 -4
  802. data/src/core/lib/transport/transport.cc +7 -6
  803. data/src/core/lib/transport/transport.h +24 -10
  804. data/src/core/lib/transport/transport_op_string.cc +61 -102
  805. data/src/core/lib/uri/uri_parser.cc +135 -258
  806. data/src/core/lib/uri/uri_parser.h +60 -23
  807. data/src/core/plugin_registry/grpc_plugin_registry.cc +59 -12
  808. data/src/core/tsi/alts/crypt/aes_gcm.cc +0 -2
  809. data/src/core/tsi/alts/crypt/gsec.cc +5 -4
  810. data/src/core/tsi/alts/frame_protector/frame_handler.cc +8 -6
  811. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +48 -34
  812. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +8 -4
  813. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +98 -48
  814. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +9 -1
  815. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +2 -0
  816. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +2 -3
  817. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +8 -6
  818. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +4 -4
  819. data/src/core/tsi/fake_transport_security.cc +17 -19
  820. data/src/core/tsi/local_transport_security.cc +5 -1
  821. data/src/core/tsi/local_transport_security.h +6 -7
  822. data/src/core/tsi/ssl/session_cache/ssl_session.h +0 -2
  823. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  824. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +0 -2
  825. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -4
  826. data/src/core/tsi/ssl_transport_security.cc +226 -105
  827. data/src/core/tsi/ssl_transport_security.h +28 -16
  828. data/src/core/tsi/ssl_types.h +0 -2
  829. data/src/core/tsi/transport_security.cc +10 -8
  830. data/src/core/tsi/transport_security.h +6 -9
  831. data/src/core/tsi/transport_security_grpc.h +2 -3
  832. data/src/core/tsi/transport_security_interface.h +9 -4
  833. data/src/ruby/bin/math_services_pb.rb +4 -4
  834. data/src/ruby/ext/grpc/extconf.rb +6 -3
  835. data/src/ruby/ext/grpc/rb_call.c +12 -3
  836. data/src/ruby/ext/grpc/rb_call.h +4 -0
  837. data/src/ruby/ext/grpc/rb_call_credentials.c +57 -12
  838. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  839. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  840. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +42 -18
  841. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +80 -44
  842. data/src/ruby/lib/grpc/errors.rb +103 -42
  843. data/src/ruby/lib/grpc/generic/active_call.rb +2 -3
  844. data/src/ruby/lib/grpc/generic/client_stub.rb +1 -1
  845. data/src/ruby/lib/grpc/generic/interceptors.rb +5 -5
  846. data/src/ruby/lib/grpc/generic/rpc_server.rb +9 -10
  847. data/src/ruby/lib/grpc/generic/service.rb +5 -4
  848. data/src/ruby/lib/grpc/structs.rb +1 -1
  849. data/src/ruby/lib/grpc/version.rb +1 -1
  850. data/src/ruby/pb/generate_proto_ruby.sh +5 -3
  851. data/src/ruby/pb/grpc/health/v1/health_services_pb.rb +2 -2
  852. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +51 -0
  853. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +61 -11
  854. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  855. data/src/ruby/spec/debug_message_spec.rb +134 -0
  856. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  857. data/src/ruby/spec/generic/service_spec.rb +2 -0
  858. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
  859. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +7 -0
  860. data/src/ruby/spec/pb/codegen/grpc/testing/same_package_service_name.proto +27 -0
  861. data/src/ruby/spec/pb/codegen/grpc/testing/same_ruby_package_service_name.proto +29 -0
  862. data/src/ruby/spec/pb/codegen/package_option_spec.rb +29 -7
  863. data/src/ruby/spec/support/services.rb +10 -4
  864. data/src/ruby/spec/testdata/ca.pem +18 -13
  865. data/src/ruby/spec/testdata/client.key +26 -14
  866. data/src/ruby/spec/testdata/client.pem +18 -12
  867. data/src/ruby/spec/testdata/server1.key +26 -14
  868. data/src/ruby/spec/testdata/server1.pem +20 -14
  869. data/src/ruby/spec/user_agent_spec.rb +74 -0
  870. data/third_party/abseil-cpp/absl/algorithm/container.h +1764 -0
  871. data/third_party/abseil-cpp/absl/base/attributes.h +99 -38
  872. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  873. data/third_party/abseil-cpp/absl/base/casts.h +9 -6
  874. data/third_party/abseil-cpp/absl/base/config.h +60 -17
  875. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +428 -335
  876. data/third_party/abseil-cpp/absl/base/internal/bits.h +17 -16
  877. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +166 -0
  878. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +398 -0
  879. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  880. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  881. data/third_party/abseil-cpp/absl/base/internal/invoke.h +4 -4
  882. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  883. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  884. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +29 -1
  885. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +2 -2
  886. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +7 -5
  887. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +25 -38
  888. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +19 -25
  889. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +8 -0
  890. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +28 -5
  891. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +8 -0
  892. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +3 -1
  893. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +2 -2
  894. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -3
  895. data/third_party/abseil-cpp/absl/base/macros.h +36 -109
  896. data/third_party/abseil-cpp/absl/base/optimization.h +61 -1
  897. data/third_party/abseil-cpp/absl/base/options.h +31 -4
  898. data/third_party/abseil-cpp/absl/base/policy_checks.h +1 -1
  899. data/third_party/abseil-cpp/absl/base/thread_annotations.h +94 -39
  900. data/third_party/abseil-cpp/absl/container/fixed_array.h +532 -0
  901. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +606 -0
  902. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +504 -0
  903. data/third_party/abseil-cpp/absl/container/inlined_vector.h +33 -36
  904. data/third_party/abseil-cpp/absl/container/internal/common.h +206 -0
  905. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +33 -8
  906. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +460 -0
  907. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +161 -0
  908. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +208 -0
  909. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  910. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +270 -0
  911. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +321 -0
  912. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  913. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +50 -0
  914. data/third_party/abseil-cpp/absl/container/internal/layout.h +743 -0
  915. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +197 -0
  916. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  917. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1903 -0
  918. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +139 -0
  919. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  920. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1945 -0
  921. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  922. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  923. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  924. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +196 -0
  925. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +134 -0
  926. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +89 -0
  927. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +108 -0
  928. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  929. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  930. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +93 -0
  931. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  932. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +149 -0
  933. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +173 -0
  934. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  935. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  936. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  937. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +36 -0
  938. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  939. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +101 -0
  940. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1560 -0
  941. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  942. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  943. data/third_party/abseil-cpp/absl/functional/bind_front.h +184 -0
  944. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  945. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +95 -0
  946. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  947. data/third_party/abseil-cpp/absl/hash/hash.h +325 -0
  948. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  949. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  950. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  951. data/third_party/abseil-cpp/absl/hash/internal/hash.h +996 -0
  952. data/third_party/abseil-cpp/absl/memory/memory.h +4 -0
  953. data/third_party/abseil-cpp/absl/meta/type_traits.h +2 -8
  954. data/third_party/abseil-cpp/absl/numeric/int128.cc +13 -27
  955. data/third_party/abseil-cpp/absl/numeric/int128.h +16 -15
  956. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +51 -0
  957. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +399 -0
  958. data/third_party/abseil-cpp/absl/status/status.cc +445 -0
  959. data/third_party/abseil-cpp/absl/status/status.h +817 -0
  960. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +38 -0
  961. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  962. data/third_party/abseil-cpp/absl/status/statusor.cc +71 -0
  963. data/third_party/abseil-cpp/absl/status/statusor.h +760 -0
  964. data/third_party/abseil-cpp/absl/strings/charconv.cc +2 -2
  965. data/third_party/abseil-cpp/absl/strings/cord.cc +1998 -0
  966. data/third_party/abseil-cpp/absl/strings/cord.h +1276 -0
  967. data/third_party/abseil-cpp/absl/strings/escaping.cc +9 -9
  968. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +1 -1
  969. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
  970. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +2 -2
  971. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  972. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +173 -0
  973. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +222 -136
  974. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +136 -64
  975. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +1 -1
  976. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +14 -21
  977. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +7 -14
  978. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +31 -7
  979. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +147 -135
  980. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +999 -87
  981. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +3 -3
  982. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +4 -12
  983. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +8 -6
  984. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +13 -11
  985. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -2
  986. data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
  987. data/third_party/abseil-cpp/absl/strings/str_cat.h +1 -1
  988. data/third_party/abseil-cpp/absl/strings/str_format.h +289 -13
  989. data/third_party/abseil-cpp/absl/strings/str_split.cc +2 -2
  990. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -0
  991. data/third_party/abseil-cpp/absl/strings/string_view.h +26 -19
  992. data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -5
  993. data/third_party/abseil-cpp/absl/strings/substitute.h +32 -29
  994. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  995. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  996. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  997. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  998. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  999. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  1000. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +698 -0
  1001. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  1002. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  1003. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +249 -0
  1004. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  1005. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  1006. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +492 -0
  1007. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  1008. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2739 -0
  1009. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1065 -0
  1010. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  1011. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  1012. data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
  1013. data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
  1014. data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
  1015. data/third_party/abseil-cpp/absl/time/clock.h +74 -0
  1016. data/third_party/abseil-cpp/absl/time/duration.cc +953 -0
  1017. data/third_party/abseil-cpp/absl/time/format.cc +160 -0
  1018. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
  1019. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +632 -0
  1020. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +386 -0
  1021. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
  1022. data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
  1023. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
  1024. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
  1025. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +1029 -0
  1026. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
  1027. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
  1028. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +113 -0
  1029. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
  1030. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +965 -0
  1031. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +137 -0
  1032. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +309 -0
  1033. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
  1034. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
  1035. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
  1036. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
  1037. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
  1038. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +116 -0
  1039. data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
  1040. data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
  1041. data/third_party/abseil-cpp/absl/time/time.cc +499 -0
  1042. data/third_party/abseil-cpp/absl/time/time.h +1583 -0
  1043. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  1044. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  1045. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  1046. data/third_party/abseil-cpp/absl/types/optional.h +9 -9
  1047. data/third_party/abseil-cpp/absl/types/span.h +49 -36
  1048. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  1049. data/third_party/abseil-cpp/absl/utility/utility.h +2 -2
  1050. data/third_party/address_sorting/include/address_sorting/address_sorting.h +2 -0
  1051. data/third_party/boringssl-with-bazel/err_data.c +759 -707
  1052. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +6 -6
  1053. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +5 -5
  1054. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +6 -6
  1055. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +6 -13
  1056. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +3 -3
  1057. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +2 -2
  1058. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +5 -3
  1059. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +2 -2
  1060. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +15 -20
  1061. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +30 -0
  1062. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn_pack.c +1 -1
  1063. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_enum.c +1 -1
  1064. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_int.c +1 -1
  1065. data/third_party/boringssl-with-bazel/src/crypto/asn1/f_string.c +1 -1
  1066. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +28 -79
  1067. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +39 -85
  1068. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +5 -16
  1069. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +10 -61
  1070. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +0 -2
  1071. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +2 -2
  1072. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +2 -0
  1073. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +4 -0
  1074. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +158 -0
  1075. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c +3 -10
  1076. data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +8 -9
  1077. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +60 -45
  1078. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +1 -1
  1079. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +6 -81
  1080. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +87 -0
  1081. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/tls_cbc.c +1 -0
  1082. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-win.c +41 -0
  1083. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +7 -5
  1084. data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +13 -4
  1085. data/third_party/boringssl-with-bazel/src/crypto/crypto.c +11 -0
  1086. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519.c +18 -26
  1087. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519_tables.h +13 -21
  1088. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/internal.h +14 -22
  1089. data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +1 -1
  1090. data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/dh_asn1.c +0 -0
  1091. data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/params.c +179 -0
  1092. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +25 -0
  1093. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +19 -43
  1094. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  1095. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  1096. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +2 -17
  1097. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +385 -0
  1098. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +56 -0
  1099. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +2 -2
  1100. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +33 -32
  1101. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  1102. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +159 -0
  1103. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  1104. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1 -1
  1105. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/mode_wrappers.c +17 -1
  1106. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +5 -2
  1107. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +13 -20
  1108. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +2 -3
  1109. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +3 -3
  1110. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +34 -13
  1111. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +8 -8
  1112. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +30 -154
  1113. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +173 -35
  1114. data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/check.c +0 -0
  1115. data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/dh.c +149 -211
  1116. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  1117. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +16 -0
  1118. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +301 -117
  1119. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +22 -28
  1120. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +96 -55
  1121. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +25 -7
  1122. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +434 -161
  1123. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +63 -71
  1124. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +18 -25
  1125. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9481 -9485
  1126. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +104 -122
  1127. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +740 -0
  1128. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
  1129. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +90 -11
  1130. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +125 -148
  1131. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +189 -3
  1132. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/util.c +3 -3
  1133. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +61 -18
  1134. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +2 -2
  1135. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +20 -5
  1136. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
  1137. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
  1138. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
  1139. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +69 -5
  1140. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +155 -50
  1141. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +24 -121
  1142. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +4 -0
  1143. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +5 -0
  1144. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +73 -40
  1145. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +122 -55
  1146. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +217 -2
  1147. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +44 -35
  1148. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +532 -0
  1149. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +246 -0
  1150. data/third_party/boringssl-with-bazel/src/crypto/mem.c +47 -16
  1151. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +15 -1
  1152. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +7 -0
  1153. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +36 -5
  1154. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +10 -7
  1155. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +13 -11
  1156. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +4 -0
  1157. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +6 -10
  1158. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +34 -0
  1159. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +4 -0
  1160. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +16 -0
  1161. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +7 -13
  1162. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +4 -0
  1163. data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +4 -0
  1164. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +318 -0
  1165. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1399 -0
  1166. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +858 -0
  1167. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +766 -0
  1168. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +7 -7
  1169. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +10 -0
  1170. data/third_party/boringssl-with-bazel/src/crypto/x509/asn1_gen.c +4 -4
  1171. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +5 -1
  1172. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  1173. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  1174. data/third_party/boringssl-with-bazel/src/crypto/x509/x509.c +0 -67
  1175. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +21 -9
  1176. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +27 -21
  1177. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  1178. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_r2x.c +1 -1
  1179. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_req.c +10 -0
  1180. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +89 -11
  1181. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +7 -4
  1182. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  1183. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +4 -4
  1184. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +62 -44
  1185. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +67 -25
  1186. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +13 -11
  1187. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  1188. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +38 -17
  1189. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  1190. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +2 -2
  1191. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pubkey.c +0 -154
  1192. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  1193. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +66 -9
  1194. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  1195. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  1196. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +5 -0
  1197. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +5 -3
  1198. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +3 -3
  1199. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +25 -24
  1200. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +3 -3
  1201. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +32 -28
  1202. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -2
  1203. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +2 -1
  1204. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +42 -22
  1205. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +3 -4
  1206. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  1207. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +25 -36
  1208. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +2 -2
  1209. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +126 -40
  1210. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +7 -7
  1211. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +6 -6
  1212. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +24 -0
  1213. data/third_party/boringssl-with-bazel/src/include/openssl/aes.h +16 -4
  1214. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +54 -0
  1215. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +662 -556
  1216. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +0 -167
  1217. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +19 -7
  1218. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +4 -0
  1219. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +62 -0
  1220. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +22 -7
  1221. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +21 -0
  1222. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +10 -5
  1223. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +6 -0
  1224. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +82 -20
  1225. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +11 -0
  1226. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +16 -0
  1227. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +15 -0
  1228. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +6 -0
  1229. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +2 -0
  1230. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +85 -3
  1231. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +5 -0
  1232. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +3 -0
  1233. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +202 -134
  1234. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +6 -17
  1235. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +31 -0
  1236. data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +26 -0
  1237. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +2 -1
  1238. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +335 -112
  1239. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +33 -10
  1240. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +310 -0
  1241. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +1141 -755
  1242. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +1 -0
  1243. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +593 -440
  1244. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +18 -5
  1245. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +0 -4
  1246. data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +3 -3
  1247. data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -4
  1248. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +181 -57
  1249. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +45 -26
  1250. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +43 -45
  1251. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +32 -10
  1252. data/third_party/boringssl-with-bazel/src/ssl/internal.h +160 -80
  1253. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +10 -10
  1254. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -3
  1255. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +21 -21
  1256. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +77 -8
  1257. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +7 -6
  1258. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  1259. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +131 -15
  1260. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +13 -2
  1261. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +50 -15
  1262. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +6 -0
  1263. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +2 -2
  1264. data/third_party/boringssl-with-bazel/src/ssl/ssl_versions.cc +5 -5
  1265. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +53 -30
  1266. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +611 -89
  1267. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +2 -3
  1268. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +187 -68
  1269. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +71 -90
  1270. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +247 -73
  1271. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +63 -25
  1272. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  1273. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +245 -175
  1274. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +135 -75
  1275. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +1593 -1672
  1276. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +512 -503
  1277. data/third_party/re2/re2/bitmap256.h +117 -0
  1278. data/third_party/re2/re2/bitstate.cc +385 -0
  1279. data/third_party/re2/re2/compile.cc +1279 -0
  1280. data/third_party/re2/re2/dfa.cc +2130 -0
  1281. data/third_party/re2/re2/filtered_re2.cc +121 -0
  1282. data/third_party/re2/re2/filtered_re2.h +109 -0
  1283. data/third_party/re2/re2/mimics_pcre.cc +197 -0
  1284. data/third_party/re2/re2/nfa.cc +713 -0
  1285. data/third_party/re2/re2/onepass.cc +623 -0
  1286. data/third_party/re2/re2/parse.cc +2464 -0
  1287. data/third_party/re2/re2/perl_groups.cc +119 -0
  1288. data/third_party/re2/re2/pod_array.h +55 -0
  1289. data/third_party/re2/re2/prefilter.cc +710 -0
  1290. data/third_party/re2/re2/prefilter.h +108 -0
  1291. data/third_party/re2/re2/prefilter_tree.cc +407 -0
  1292. data/third_party/re2/re2/prefilter_tree.h +139 -0
  1293. data/third_party/re2/re2/prog.cc +988 -0
  1294. data/third_party/re2/re2/prog.h +436 -0
  1295. data/third_party/re2/re2/re2.cc +1362 -0
  1296. data/third_party/re2/re2/re2.h +1002 -0
  1297. data/third_party/re2/re2/regexp.cc +980 -0
  1298. data/third_party/re2/re2/regexp.h +659 -0
  1299. data/third_party/re2/re2/set.cc +154 -0
  1300. data/third_party/re2/re2/set.h +80 -0
  1301. data/third_party/re2/re2/simplify.cc +657 -0
  1302. data/third_party/re2/re2/sparse_array.h +392 -0
  1303. data/third_party/re2/re2/sparse_set.h +264 -0
  1304. data/third_party/re2/re2/stringpiece.cc +65 -0
  1305. data/third_party/re2/re2/stringpiece.h +210 -0
  1306. data/third_party/re2/re2/tostring.cc +351 -0
  1307. data/third_party/re2/re2/unicode_casefold.cc +582 -0
  1308. data/third_party/re2/re2/unicode_casefold.h +78 -0
  1309. data/third_party/re2/re2/unicode_groups.cc +6269 -0
  1310. data/third_party/re2/re2/unicode_groups.h +67 -0
  1311. data/third_party/re2/re2/walker-inl.h +246 -0
  1312. data/third_party/re2/util/benchmark.h +156 -0
  1313. data/third_party/re2/util/flags.h +26 -0
  1314. data/third_party/re2/util/logging.h +109 -0
  1315. data/third_party/re2/util/malloc_counter.h +19 -0
  1316. data/third_party/re2/util/mix.h +41 -0
  1317. data/third_party/re2/util/mutex.h +148 -0
  1318. data/third_party/re2/util/pcre.cc +1025 -0
  1319. data/third_party/re2/util/pcre.h +681 -0
  1320. data/third_party/re2/util/rune.cc +260 -0
  1321. data/third_party/re2/util/strutil.cc +149 -0
  1322. data/third_party/re2/util/strutil.h +21 -0
  1323. data/third_party/re2/util/test.h +50 -0
  1324. data/third_party/re2/util/utf.h +44 -0
  1325. data/third_party/re2/util/util.h +42 -0
  1326. data/third_party/upb/third_party/wyhash/wyhash.h +145 -0
  1327. data/third_party/upb/upb/decode.c +604 -511
  1328. data/third_party/upb/upb/decode.h +20 -1
  1329. data/third_party/upb/upb/decode.int.h +163 -0
  1330. data/third_party/upb/upb/decode_fast.c +1040 -0
  1331. data/third_party/upb/upb/decode_fast.h +126 -0
  1332. data/third_party/upb/upb/def.c +2178 -0
  1333. data/third_party/upb/upb/def.h +315 -0
  1334. data/third_party/upb/upb/def.hpp +439 -0
  1335. data/third_party/upb/upb/encode.c +311 -211
  1336. data/third_party/upb/upb/encode.h +27 -2
  1337. data/third_party/upb/upb/json_decode.c +1443 -0
  1338. data/third_party/upb/upb/json_decode.h +23 -0
  1339. data/third_party/upb/upb/json_encode.c +713 -0
  1340. data/third_party/upb/upb/json_encode.h +36 -0
  1341. data/third_party/upb/upb/msg.c +215 -70
  1342. data/third_party/upb/upb/msg.h +558 -14
  1343. data/third_party/upb/upb/port_def.inc +105 -63
  1344. data/third_party/upb/upb/port_undef.inc +10 -7
  1345. data/third_party/upb/upb/reflection.c +408 -0
  1346. data/third_party/upb/upb/reflection.h +168 -0
  1347. data/third_party/upb/upb/table.c +73 -269
  1348. data/third_party/upb/upb/table.int.h +25 -57
  1349. data/third_party/upb/upb/text_encode.c +421 -0
  1350. data/third_party/upb/upb/text_encode.h +38 -0
  1351. data/third_party/upb/upb/upb.c +138 -135
  1352. data/third_party/upb/upb/upb.h +119 -146
  1353. data/third_party/upb/upb/upb.hpp +88 -0
  1354. data/third_party/upb/upb/upb.int.h +29 -0
  1355. metadata +646 -164
  1356. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +0 -1754
  1357. data/src/core/ext/filters/client_channel/parse_address.cc +0 -237
  1358. data/src/core/ext/filters/client_channel/parse_address.h +0 -53
  1359. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +0 -484
  1360. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +0 -65
  1361. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +0 -359
  1362. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +0 -122
  1363. data/src/core/ext/filters/client_channel/xds/xds_api.cc +0 -1779
  1364. data/src/core/ext/filters/client_channel/xds/xds_api.h +0 -280
  1365. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +0 -347
  1366. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +0 -87
  1367. data/src/core/ext/filters/client_channel/xds/xds_channel.h +0 -46
  1368. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +0 -104
  1369. data/src/core/ext/filters/client_channel/xds/xds_client.h +0 -274
  1370. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +0 -116
  1371. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -246
  1372. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -905
  1373. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -53
  1374. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -390
  1375. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1411
  1376. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -73
  1377. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -218
  1378. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -34
  1379. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  1380. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +0 -54
  1381. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -305
  1382. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -111
  1383. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -328
  1384. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -292
  1385. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -847
  1386. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -95
  1387. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -322
  1388. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -196
  1389. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -642
  1390. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -168
  1391. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -658
  1392. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -35
  1393. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  1394. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -132
  1395. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -436
  1396. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -128
  1397. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -392
  1398. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +0 -30
  1399. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -53
  1400. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -91
  1401. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -240
  1402. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -17
  1403. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -33
  1404. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -88
  1405. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -258
  1406. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -111
  1407. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -324
  1408. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +0 -30
  1409. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -53
  1410. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -104
  1411. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -383
  1412. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -17
  1413. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -33
  1414. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -144
  1415. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -527
  1416. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -42
  1417. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -112
  1418. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -53
  1419. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -62
  1420. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -199
  1421. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -17
  1422. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -33
  1423. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -793
  1424. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2936
  1425. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -58
  1426. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -134
  1427. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -53
  1428. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -227
  1429. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -725
  1430. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -296
  1431. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1072
  1432. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +0 -32
  1433. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  1434. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +0 -23
  1435. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -50
  1436. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -52
  1437. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -130
  1438. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -47
  1439. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -108
  1440. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -52
  1441. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  1442. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -87
  1443. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  1444. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -38
  1445. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -87
  1446. data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -49
  1447. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -112
  1448. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +0 -28
  1449. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -62
  1450. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -88
  1451. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -249
  1452. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  1453. data/src/core/lib/gprpp/map.h +0 -59
  1454. data/src/core/lib/gprpp/string_view.h +0 -60
  1455. data/src/core/lib/iomgr/iomgr_posix.h +0 -26
  1456. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  1457. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  1458. data/src/core/lib/slice/slice_hash_table.h +0 -199
  1459. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
  1460. data/src/core/tsi/grpc_shadow_boringssl.h +0 -3311
  1461. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +0 -129
  1462. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  1463. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
  1464. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256.c +0 -1063
  1465. data/third_party/upb/upb/generated_util.h +0 -105
  1466. data/third_party/upb/upb/port.c +0 -26
@@ -0,0 +1,151 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #ifndef GRPC_CORE_EXT_XDS_XDS_CERTIFICATE_PROVIDER_H
20
+ #define GRPC_CORE_EXT_XDS_XDS_CERTIFICATE_PROVIDER_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ #include "src/core/ext/xds/xds_api.h"
25
+ #include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h"
26
+
27
+ #define GRPC_ARG_XDS_CERTIFICATE_PROVIDER \
28
+ "grpc.internal.xds_certificate_provider"
29
+
30
+ namespace grpc_core {
31
+
32
+ class XdsCertificateProvider : public grpc_tls_certificate_provider {
33
+ public:
34
+ XdsCertificateProvider();
35
+ ~XdsCertificateProvider() override;
36
+
37
+ grpc_core::RefCountedPtr<grpc_tls_certificate_distributor> distributor()
38
+ const override {
39
+ return distributor_;
40
+ }
41
+
42
+ bool ProvidesRootCerts(const std::string& cert_name);
43
+ void UpdateRootCertNameAndDistributor(
44
+ const std::string& cert_name, absl::string_view root_cert_name,
45
+ RefCountedPtr<grpc_tls_certificate_distributor> root_cert_distributor);
46
+
47
+ bool ProvidesIdentityCerts(const std::string& cert_name);
48
+ void UpdateIdentityCertNameAndDistributor(
49
+ const std::string& cert_name, absl::string_view identity_cert_name,
50
+ RefCountedPtr<grpc_tls_certificate_distributor>
51
+ identity_cert_distributor);
52
+
53
+ bool GetRequireClientCertificate(const std::string& cert_name);
54
+ // Updating \a require_client_certificate for a non-existing \a cert_name has
55
+ // no effect.
56
+ void UpdateRequireClientCertificate(const std::string& cert_name,
57
+ bool require_client_certificate);
58
+
59
+ std::vector<StringMatcher> GetSanMatchers(const std::string& cluster);
60
+ void UpdateSubjectAlternativeNameMatchers(
61
+ const std::string& cluster, std::vector<StringMatcher> matchers);
62
+
63
+ grpc_arg MakeChannelArg() const;
64
+
65
+ static RefCountedPtr<XdsCertificateProvider> GetFromChannelArgs(
66
+ const grpc_channel_args* args);
67
+
68
+ private:
69
+ class ClusterCertificateState {
70
+ public:
71
+ explicit ClusterCertificateState(
72
+ XdsCertificateProvider* xds_certificate_provider)
73
+ : xds_certificate_provider_(xds_certificate_provider) {}
74
+
75
+ ~ClusterCertificateState();
76
+
77
+ // Returns true if the certs aren't being watched and there are no
78
+ // distributors configured.
79
+ bool IsSafeToRemove() const;
80
+
81
+ bool ProvidesRootCerts() const { return root_cert_distributor_ != nullptr; }
82
+ bool ProvidesIdentityCerts() const {
83
+ return identity_cert_distributor_ != nullptr;
84
+ }
85
+
86
+ void UpdateRootCertNameAndDistributor(
87
+ const std::string& cert_name, absl::string_view root_cert_name,
88
+ RefCountedPtr<grpc_tls_certificate_distributor> root_cert_distributor);
89
+ void UpdateIdentityCertNameAndDistributor(
90
+ const std::string& cert_name, absl::string_view identity_cert_name,
91
+ RefCountedPtr<grpc_tls_certificate_distributor>
92
+ identity_cert_distributor);
93
+
94
+ void UpdateRootCertWatcher(
95
+ const std::string& cert_name,
96
+ grpc_tls_certificate_distributor* root_cert_distributor);
97
+ void UpdateIdentityCertWatcher(
98
+ const std::string& cert_name,
99
+ grpc_tls_certificate_distributor* identity_cert_distributor);
100
+
101
+ bool require_client_certificate() const {
102
+ return require_client_certificate_;
103
+ }
104
+ void set_require_client_certificate(bool require_client_certificate) {
105
+ require_client_certificate_ = require_client_certificate;
106
+ }
107
+
108
+ void WatchStatusCallback(const std::string& cert_name,
109
+ bool root_being_watched,
110
+ bool identity_being_watched);
111
+
112
+ private:
113
+ XdsCertificateProvider* xds_certificate_provider_;
114
+ bool watching_root_certs_ = false;
115
+ bool watching_identity_certs_ = false;
116
+ std::string root_cert_name_;
117
+ std::string identity_cert_name_;
118
+ RefCountedPtr<grpc_tls_certificate_distributor> root_cert_distributor_;
119
+ RefCountedPtr<grpc_tls_certificate_distributor> identity_cert_distributor_;
120
+ grpc_tls_certificate_distributor::TlsCertificatesWatcherInterface*
121
+ root_cert_watcher_ = nullptr;
122
+ grpc_tls_certificate_distributor::TlsCertificatesWatcherInterface*
123
+ identity_cert_watcher_ = nullptr;
124
+ bool require_client_certificate_ = false;
125
+ };
126
+
127
+ void WatchStatusCallback(std::string cert_name, bool root_being_watched,
128
+ bool identity_being_watched);
129
+
130
+ Mutex mu_;
131
+ std::map<std::string /*cert_name*/, std::unique_ptr<ClusterCertificateState>>
132
+ certificate_state_map_;
133
+
134
+ // Use a separate mutex for san_matchers_ to avoid deadlocks since
135
+ // san_matchers_ needs to be accessed when a handshake is being done and we
136
+ // run into a possible deadlock scenario if using the same mutex. The mutex
137
+ // deadlock cycle is formed as -
138
+ // WatchStatusCallback() -> SetKeyMaterials() ->
139
+ // TlsChannelSecurityConnector::TlsChannelCertificateWatcher::OnCertificatesChanged()
140
+ // -> HandshakeManager::Add() -> SecurityHandshaker::DoHandshake() ->
141
+ // subject_alternative_names_matchers()
142
+ Mutex san_matchers_mu_;
143
+ std::map<std::string /*cluster_name*/, std::vector<StringMatcher>>
144
+ san_matcher_map_;
145
+
146
+ RefCountedPtr<grpc_tls_certificate_distributor> distributor_;
147
+ };
148
+
149
+ } // namespace grpc_core
150
+
151
+ #endif // GRPC_CORE_EXT_XDS_XDS_CERTIFICATE_PROVIDER_H
@@ -14,13 +14,16 @@
14
14
  // limitations under the License.
15
15
  //
16
16
 
17
- #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_XDS_XDS_CHANNEL_ARGS_H
18
- #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_XDS_XDS_CHANNEL_ARGS_H
19
-
20
- // Boolean channel arg indicating whether the target is an xds server.
21
- #define GRPC_ARG_ADDRESS_IS_XDS_SERVER "grpc.address_is_xds_server"
17
+ #ifndef GRPC_CORE_EXT_XDS_XDS_CHANNEL_ARGS_H
18
+ #define GRPC_CORE_EXT_XDS_XDS_CHANNEL_ARGS_H
22
19
 
23
20
  // Pointer channel arg containing a ref to the XdsClient object.
24
21
  #define GRPC_ARG_XDS_CLIENT "grpc.xds_client"
25
22
 
26
- #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_XDS_XDS_CHANNEL_ARGS_H */
23
+ // Timeout in milliseconds to wait for a resource to be returned from
24
+ // the xds server before assuming that it does not exist.
25
+ // The default is 15 seconds.
26
+ #define GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS \
27
+ "grpc.xds_resource_does_not_exist_timeout_ms"
28
+
29
+ #endif /* GRPC_CORE_EXT_XDS_XDS_CHANNEL_ARGS_H */
@@ -22,37 +22,33 @@
22
22
  #include <limits.h>
23
23
  #include <string.h>
24
24
 
25
+ #include "absl/container/inlined_vector.h"
26
+ #include "absl/strings/str_format.h"
25
27
  #include "absl/strings/str_join.h"
28
+ #include "absl/strings/string_view.h"
26
29
 
27
30
  #include <grpc/byte_buffer_reader.h>
28
31
  #include <grpc/grpc.h>
29
32
  #include <grpc/support/alloc.h>
30
- #include <grpc/support/string_util.h>
31
33
  #include <grpc/support/time.h>
32
34
 
33
35
  #include "src/core/ext/filters/client_channel/client_channel.h"
34
- #include "src/core/ext/filters/client_channel/parse_address.h"
35
- #include "src/core/ext/filters/client_channel/server_address.h"
36
36
  #include "src/core/ext/filters/client_channel/service_config.h"
37
- #include "src/core/ext/filters/client_channel/xds/xds_api.h"
38
- #include "src/core/ext/filters/client_channel/xds/xds_channel.h"
39
- #include "src/core/ext/filters/client_channel/xds/xds_channel_args.h"
40
- #include "src/core/ext/filters/client_channel/xds/xds_client.h"
41
- #include "src/core/ext/filters/client_channel/xds/xds_client_stats.h"
37
+ #include "src/core/ext/xds/xds_api.h"
38
+ #include "src/core/ext/xds/xds_channel_args.h"
39
+ #include "src/core/ext/xds/xds_client.h"
40
+ #include "src/core/ext/xds/xds_client_stats.h"
42
41
  #include "src/core/lib/backoff/backoff.h"
43
42
  #include "src/core/lib/channel/channel_args.h"
44
43
  #include "src/core/lib/channel/channel_stack.h"
45
44
  #include "src/core/lib/gpr/string.h"
46
- #include "src/core/lib/gprpp/map.h"
47
45
  #include "src/core/lib/gprpp/memory.h"
48
46
  #include "src/core/lib/gprpp/orphanable.h"
49
47
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
50
48
  #include "src/core/lib/gprpp/sync.h"
51
- #include "src/core/lib/iomgr/combiner.h"
52
49
  #include "src/core/lib/iomgr/sockaddr.h"
53
50
  #include "src/core/lib/iomgr/sockaddr_utils.h"
54
51
  #include "src/core/lib/iomgr/timer.h"
55
- #include "src/core/lib/slice/slice_hash_table.h"
56
52
  #include "src/core/lib/slice/slice_internal.h"
57
53
  #include "src/core/lib/slice/slice_string_helpers.h"
58
54
  #include "src/core/lib/surface/call.h"
@@ -69,6 +65,16 @@
69
65
  namespace grpc_core {
70
66
 
71
67
  TraceFlag grpc_xds_client_trace(false, "xds_client");
68
+ TraceFlag grpc_xds_client_refcount_trace(false, "xds_client_refcount");
69
+
70
+ namespace {
71
+
72
+ Mutex* g_mu = nullptr;
73
+ const grpc_channel_args* g_channel_args = nullptr;
74
+ XdsClient* g_xds_client = nullptr;
75
+ char* g_fallback_bootstrap_config = nullptr;
76
+
77
+ } // namespace
72
78
 
73
79
  //
74
80
  // Internal class declarations
@@ -95,7 +101,7 @@ class XdsClient::ChannelState::RetryableCall
95
101
  void StartNewCallLocked();
96
102
  void StartRetryTimerLocked();
97
103
  static void OnRetryTimer(void* arg, grpc_error* error);
98
- static void OnRetryTimerLocked(void* arg, grpc_error* error);
104
+ void OnRetryTimerLocked(grpc_error* error);
99
105
 
100
106
  // The wrapped xds call that talks to the xds server. It's instantiated
101
107
  // every time we start a new call. It's null during call retry backoff.
@@ -136,22 +142,25 @@ class XdsClient::ChannelState::AdsCallState
136
142
  private:
137
143
  class ResourceState : public InternallyRefCounted<ResourceState> {
138
144
  public:
139
- ResourceState(const std::string& type_url, const std::string& name)
140
- : type_url_(type_url), name_(name) {
145
+ ResourceState(const std::string& type_url, const std::string& name,
146
+ bool sent_initial_request)
147
+ : type_url_(type_url),
148
+ name_(name),
149
+ sent_initial_request_(sent_initial_request) {
141
150
  GRPC_CLOSURE_INIT(&timer_callback_, OnTimer, this,
142
151
  grpc_schedule_on_exec_ctx);
143
152
  }
144
153
 
145
154
  void Orphan() override {
146
155
  Finish();
147
- Unref();
156
+ Unref(DEBUG_LOCATION, "Orphan");
148
157
  }
149
158
 
150
159
  void Start(RefCountedPtr<AdsCallState> ads_calld) {
151
- if (sent_) return;
152
- sent_ = true;
160
+ if (sent_initial_request_) return;
161
+ sent_initial_request_ = true;
153
162
  ads_calld_ = std::move(ads_calld);
154
- Ref().release();
163
+ Ref(DEBUG_LOCATION, "timer").release();
155
164
  timer_pending_ = true;
156
165
  grpc_timer_init(
157
166
  &timer_,
@@ -169,58 +178,60 @@ class XdsClient::ChannelState::AdsCallState
169
178
  private:
170
179
  static void OnTimer(void* arg, grpc_error* error) {
171
180
  ResourceState* self = static_cast<ResourceState*>(arg);
172
- self->ads_calld_->xds_client()->combiner_->Run(
173
- GRPC_CLOSURE_INIT(&self->timer_callback_, OnTimerLocked, self,
174
- nullptr),
175
- GRPC_ERROR_REF(error));
181
+ {
182
+ MutexLock lock(&self->ads_calld_->xds_client()->mu_);
183
+ self->OnTimerLocked(GRPC_ERROR_REF(error));
184
+ }
185
+ self->ads_calld_.reset();
186
+ self->Unref(DEBUG_LOCATION, "timer");
176
187
  }
177
188
 
178
- static void OnTimerLocked(void* arg, grpc_error* error) {
179
- ResourceState* self = static_cast<ResourceState*>(arg);
180
- if (error == GRPC_ERROR_NONE && self->timer_pending_) {
181
- self->timer_pending_ = false;
182
- char* msg;
183
- gpr_asprintf(
184
- &msg,
185
- "timeout obtaining resource {type=%s name=%s} from xds server",
186
- self->type_url_.c_str(), self->name_.c_str());
187
- grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(msg);
188
- gpr_free(msg);
189
+ void OnTimerLocked(grpc_error* error) {
190
+ if (error == GRPC_ERROR_NONE && timer_pending_) {
191
+ timer_pending_ = false;
192
+ grpc_error* watcher_error = GRPC_ERROR_CREATE_FROM_COPIED_STRING(
193
+ absl::StrFormat(
194
+ "timeout obtaining resource {type=%s name=%s} from xds server",
195
+ type_url_, name_)
196
+ .c_str());
189
197
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
190
- gpr_log(GPR_INFO, "[xds_client %p] %s",
191
- self->ads_calld_->xds_client(), grpc_error_string(error));
198
+ gpr_log(GPR_INFO, "[xds_client %p] %s", ads_calld_->xds_client(),
199
+ grpc_error_string(watcher_error));
192
200
  }
193
- if (self->type_url_ == XdsApi::kLdsTypeUrl ||
194
- self->type_url_ == XdsApi::kRdsTypeUrl) {
195
- self->ads_calld_->xds_client()->service_config_watcher_->OnError(
196
- error);
197
- } else if (self->type_url_ == XdsApi::kCdsTypeUrl) {
198
- ClusterState& state =
199
- self->ads_calld_->xds_client()->cluster_map_[self->name_];
201
+ if (type_url_ == XdsApi::kLdsTypeUrl) {
202
+ ListenerState& state = ads_calld_->xds_client()->listener_map_[name_];
200
203
  for (const auto& p : state.watchers) {
201
- p.first->OnError(GRPC_ERROR_REF(error));
204
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
202
205
  }
203
- GRPC_ERROR_UNREF(error);
204
- } else if (self->type_url_ == XdsApi::kEdsTypeUrl) {
205
- EndpointState& state =
206
- self->ads_calld_->xds_client()->endpoint_map_[self->name_];
206
+ } else if (type_url_ == XdsApi::kRdsTypeUrl) {
207
+ RouteConfigState& state =
208
+ ads_calld_->xds_client()->route_config_map_[name_];
207
209
  for (const auto& p : state.watchers) {
208
- p.first->OnError(GRPC_ERROR_REF(error));
210
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
211
+ }
212
+ } else if (type_url_ == XdsApi::kCdsTypeUrl) {
213
+ ClusterState& state = ads_calld_->xds_client()->cluster_map_[name_];
214
+ for (const auto& p : state.watchers) {
215
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
216
+ }
217
+ } else if (type_url_ == XdsApi::kEdsTypeUrl) {
218
+ EndpointState& state = ads_calld_->xds_client()->endpoint_map_[name_];
219
+ for (const auto& p : state.watchers) {
220
+ p.first->OnError(GRPC_ERROR_REF(watcher_error));
209
221
  }
210
- GRPC_ERROR_UNREF(error);
211
222
  } else {
212
223
  GPR_UNREACHABLE_CODE(return );
213
224
  }
225
+ GRPC_ERROR_UNREF(watcher_error);
214
226
  }
215
- self->ads_calld_.reset();
216
- self->Unref();
227
+ GRPC_ERROR_UNREF(error);
217
228
  }
218
229
 
219
230
  const std::string type_url_;
220
231
  const std::string name_;
221
232
 
222
233
  RefCountedPtr<AdsCallState> ads_calld_;
223
- bool sent_ = false;
234
+ bool sent_initial_request_;
224
235
  bool timer_pending_ = false;
225
236
  grpc_timer timer_;
226
237
  grpc_closure timer_callback_;
@@ -229,8 +240,7 @@ class XdsClient::ChannelState::AdsCallState
229
240
  struct ResourceTypeState {
230
241
  ~ResourceTypeState() { GRPC_ERROR_UNREF(error); }
231
242
 
232
- // Version, nonce, and error for this resource type.
233
- std::string version;
243
+ // Nonce and error for this resource type.
234
244
  std::string nonce;
235
245
  grpc_error* error = GRPC_ERROR_NONE;
236
246
 
@@ -241,22 +251,22 @@ class XdsClient::ChannelState::AdsCallState
241
251
 
242
252
  void SendMessageLocked(const std::string& type_url);
243
253
 
244
- void AcceptLdsUpdate(absl::optional<XdsApi::LdsUpdate> lds_update);
245
- void AcceptRdsUpdate(absl::optional<XdsApi::RdsUpdate> rds_update);
254
+ void AcceptLdsUpdate(XdsApi::LdsUpdateMap lds_update_map);
255
+ void AcceptRdsUpdate(XdsApi::RdsUpdateMap rds_update_map);
246
256
  void AcceptCdsUpdate(XdsApi::CdsUpdateMap cds_update_map);
247
257
  void AcceptEdsUpdate(XdsApi::EdsUpdateMap eds_update_map);
248
258
 
249
259
  static void OnRequestSent(void* arg, grpc_error* error);
250
- static void OnRequestSentLocked(void* arg, grpc_error* error);
260
+ void OnRequestSentLocked(grpc_error* error);
251
261
  static void OnResponseReceived(void* arg, grpc_error* error);
252
- static void OnResponseReceivedLocked(void* arg, grpc_error* error);
262
+ bool OnResponseReceivedLocked();
253
263
  static void OnStatusReceived(void* arg, grpc_error* error);
254
- static void OnStatusReceivedLocked(void* arg, grpc_error* error);
264
+ void OnStatusReceivedLocked(grpc_error* error);
255
265
 
256
266
  bool IsCurrentCallOnChannel() const;
257
267
 
258
- std::set<StringView> ClusterNamesForRequest();
259
- std::set<StringView> EdsServiceNamesForRequest();
268
+ std::set<absl::string_view> ResourceNamesForRequest(
269
+ const std::string& type_url);
260
270
 
261
271
  // The owning RetryableCall<>.
262
272
  RefCountedPtr<RetryableCall<AdsCallState>> parent_;
@@ -314,6 +324,10 @@ class XdsClient::ChannelState::LrsCallState
314
324
  public:
315
325
  Reporter(RefCountedPtr<LrsCallState> parent, grpc_millis report_interval)
316
326
  : parent_(std::move(parent)), report_interval_(report_interval) {
327
+ GRPC_CLOSURE_INIT(&on_next_report_timer_, OnNextReportTimer, this,
328
+ grpc_schedule_on_exec_ctx);
329
+ GRPC_CLOSURE_INIT(&on_report_done_, OnReportDone, this,
330
+ grpc_schedule_on_exec_ctx);
317
331
  ScheduleNextReportLocked();
318
332
  }
319
333
 
@@ -322,10 +336,10 @@ class XdsClient::ChannelState::LrsCallState
322
336
  private:
323
337
  void ScheduleNextReportLocked();
324
338
  static void OnNextReportTimer(void* arg, grpc_error* error);
325
- static void OnNextReportTimerLocked(void* arg, grpc_error* error);
326
- void SendReportLocked();
339
+ bool OnNextReportTimerLocked(grpc_error* error);
340
+ bool SendReportLocked();
327
341
  static void OnReportDone(void* arg, grpc_error* error);
328
- static void OnReportDoneLocked(void* arg, grpc_error* error);
342
+ bool OnReportDoneLocked(grpc_error* error);
329
343
 
330
344
  bool IsCurrentReporterOnCall() const {
331
345
  return this == parent_->reporter_.get();
@@ -345,11 +359,11 @@ class XdsClient::ChannelState::LrsCallState
345
359
  };
346
360
 
347
361
  static void OnInitialRequestSent(void* arg, grpc_error* error);
362
+ void OnInitialRequestSentLocked();
348
363
  static void OnResponseReceived(void* arg, grpc_error* error);
364
+ bool OnResponseReceivedLocked();
349
365
  static void OnStatusReceived(void* arg, grpc_error* error);
350
- static void OnInitialRequestSentLocked(void* arg, grpc_error* error);
351
- static void OnResponseReceivedLocked(void* arg, grpc_error* error);
352
- static void OnStatusReceivedLocked(void* arg, grpc_error* error);
366
+ void OnStatusReceivedLocked(grpc_error* error);
353
367
 
354
368
  bool IsCurrentCallOnChannel() const;
355
369
 
@@ -378,6 +392,7 @@ class XdsClient::ChannelState::LrsCallState
378
392
  grpc_closure on_status_received_;
379
393
 
380
394
  // Load reporting state.
395
+ bool send_all_clusters_ = false;
381
396
  std::set<std::string> cluster_names_; // Asked for by the LRS server.
382
397
  grpc_millis load_reporting_interval_ = 0;
383
398
  OrphanablePtr<Reporter> reporter_;
@@ -391,19 +406,22 @@ class XdsClient::ChannelState::StateWatcher
391
406
  : public AsyncConnectivityStateWatcherInterface {
392
407
  public:
393
408
  explicit StateWatcher(RefCountedPtr<ChannelState> parent)
394
- : AsyncConnectivityStateWatcherInterface(parent->xds_client()->combiner_),
395
- parent_(std::move(parent)) {}
409
+ : parent_(std::move(parent)) {}
396
410
 
397
411
  private:
398
- void OnConnectivityStateChange(grpc_connectivity_state new_state) override {
412
+ void OnConnectivityStateChange(grpc_connectivity_state new_state,
413
+ const absl::Status& status) override {
414
+ MutexLock lock(&parent_->xds_client_->mu_);
399
415
  if (!parent_->shutting_down_ &&
400
416
  new_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
401
417
  // In TRANSIENT_FAILURE. Notify all watchers of error.
402
418
  gpr_log(GPR_INFO,
403
- "[xds_client %p] xds channel in state TRANSIENT_FAILURE",
404
- parent_->xds_client());
405
- parent_->xds_client()->NotifyOnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
406
- "xds channel in TRANSIENT_FAILURE"));
419
+ "[xds_client %p] xds channel in state:TRANSIENT_FAILURE "
420
+ "status_message:(%s)",
421
+ parent_->xds_client(), status.ToString().c_str());
422
+ parent_->xds_client()->NotifyOnErrorLocked(
423
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING(
424
+ "xds channel in TRANSIENT_FAILURE"));
407
425
  }
408
426
  }
409
427
 
@@ -416,69 +434,43 @@ class XdsClient::ChannelState::StateWatcher
416
434
 
417
435
  namespace {
418
436
 
419
- // Returns the channel args for the xds channel.
420
- grpc_channel_args* BuildXdsChannelArgs(const grpc_channel_args& args) {
421
- static const char* args_to_remove[] = {
422
- // LB policy name, since we want to use the default (pick_first) in
423
- // the LB channel.
424
- GRPC_ARG_LB_POLICY_NAME,
425
- // The service config that contains the LB config. We don't want to
426
- // recursively use xds in the LB channel.
427
- GRPC_ARG_SERVICE_CONFIG,
428
- // The channel arg for the server URI, since that will be different for
429
- // the xds channel than for the parent channel. The client channel
430
- // factory will re-add this arg with the right value.
431
- GRPC_ARG_SERVER_URI,
432
- // The xds channel should use the authority indicated by the target
433
- // authority table (see \a ModifyXdsChannelArgs),
434
- // as opposed to the authority from the parent channel.
435
- GRPC_ARG_DEFAULT_AUTHORITY,
436
- // Just as for \a GRPC_ARG_DEFAULT_AUTHORITY, the xds channel should be
437
- // treated as a stand-alone channel and not inherit this argument from the
438
- // args of the parent channel.
439
- GRPC_SSL_TARGET_NAME_OVERRIDE_ARG,
440
- // Don't want to pass down channelz node from parent; the balancer
441
- // channel will get its own.
442
- GRPC_ARG_CHANNELZ_CHANNEL_NODE,
443
- // Keepalive interval. We are explicitly setting our own value below.
444
- GRPC_ARG_KEEPALIVE_TIME_MS,
437
+ grpc_channel* CreateXdsChannel(const XdsBootstrap::XdsServer& server) {
438
+ // Build channel args.
439
+ absl::InlinedVector<grpc_arg, 2> args_to_add = {
440
+ grpc_channel_arg_integer_create(
441
+ const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS),
442
+ 5 * 60 * GPR_MS_PER_SEC),
443
+ grpc_channel_arg_integer_create(
444
+ const_cast<char*>(GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL), 1),
445
445
  };
446
- // Channel args to add.
447
- InlinedVector<grpc_arg, 3> args_to_add;
448
- // Keepalive interval.
449
- args_to_add.emplace_back(grpc_channel_arg_integer_create(
450
- const_cast<char*>(GRPC_ARG_KEEPALIVE_TIME_MS), 5000));
451
- // A channel arg indicating that the target is an xds server.
452
- // TODO(roth): Once we figure out our fallback and credentials story, decide
453
- // whether this is actually needed. Note that it's currently used by the
454
- // fake security connector as well.
455
- args_to_add.emplace_back(grpc_channel_arg_integer_create(
456
- const_cast<char*>(GRPC_ARG_ADDRESS_IS_XDS_SERVER), 1));
457
- // The parent channel's channelz uuid.
458
- channelz::ChannelNode* channelz_node = nullptr;
459
- const grpc_arg* arg =
460
- grpc_channel_args_find(&args, GRPC_ARG_CHANNELZ_CHANNEL_NODE);
461
- if (arg != nullptr && arg->type == GRPC_ARG_POINTER &&
462
- arg->value.pointer.p != nullptr) {
463
- channelz_node = static_cast<channelz::ChannelNode*>(arg->value.pointer.p);
464
- args_to_add.emplace_back(
465
- channelz::MakeParentUuidArg(channelz_node->uuid()));
466
- }
467
- // Construct channel args.
468
- grpc_channel_args* new_args = grpc_channel_args_copy_and_add_and_remove(
469
- &args, args_to_remove, GPR_ARRAY_SIZE(args_to_remove), args_to_add.data(),
470
- args_to_add.size());
471
- // Make any necessary modifications for security.
472
- return ModifyXdsChannelArgs(new_args);
446
+ grpc_channel_args* new_args = grpc_channel_args_copy_and_add(
447
+ g_channel_args, args_to_add.data(), args_to_add.size());
448
+ // Create channel creds.
449
+ RefCountedPtr<grpc_channel_credentials> channel_creds =
450
+ XdsChannelCredsRegistry::MakeChannelCreds(server.channel_creds_type,
451
+ server.channel_creds_config);
452
+ // Create channel.
453
+ grpc_channel* channel = grpc_secure_channel_create(
454
+ channel_creds.get(), server.server_uri.c_str(), new_args, nullptr);
455
+ grpc_channel_args_destroy(new_args);
456
+ return channel;
473
457
  }
474
458
 
475
459
  } // namespace
476
460
 
477
- XdsClient::ChannelState::ChannelState(RefCountedPtr<XdsClient> xds_client,
478
- grpc_channel* channel)
479
- : InternallyRefCounted<ChannelState>(&grpc_xds_client_trace),
461
+ XdsClient::ChannelState::ChannelState(WeakRefCountedPtr<XdsClient> xds_client,
462
+ const XdsBootstrap::XdsServer& server)
463
+ : InternallyRefCounted<ChannelState>(
464
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
465
+ ? "ChannelState"
466
+ : nullptr),
480
467
  xds_client_(std::move(xds_client)),
481
- channel_(channel) {
468
+ server_(server) {
469
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
470
+ gpr_log(GPR_INFO, "[xds_client %p] creating channel to %s",
471
+ xds_client_.get(), server.server_uri.c_str());
472
+ }
473
+ channel_ = CreateXdsChannel(server);
482
474
  GPR_ASSERT(channel_ != nullptr);
483
475
  StartConnectivityWatchLocked();
484
476
  }
@@ -489,6 +481,7 @@ XdsClient::ChannelState::~ChannelState() {
489
481
  this);
490
482
  }
491
483
  grpc_channel_destroy(channel_);
484
+ xds_client_.reset(DEBUG_LOCATION, "ChannelState");
492
485
  }
493
486
 
494
487
  void XdsClient::ChannelState::Orphan() {
@@ -525,7 +518,7 @@ void XdsClient::ChannelState::StartConnectivityWatchLocked() {
525
518
  grpc_channel_element* client_channel_elem =
526
519
  grpc_channel_stack_last_element(grpc_channel_get_channel_stack(channel_));
527
520
  GPR_ASSERT(client_channel_elem->filter == &grpc_client_channel_filter);
528
- watcher_ = new StateWatcher(Ref());
521
+ watcher_ = new StateWatcher(Ref(DEBUG_LOCATION, "ChannelState+watch"));
529
522
  grpc_client_channel_start_connectivity_watch(
530
523
  client_channel_elem, GRPC_CHANNEL_IDLE,
531
524
  OrphanablePtr<AsyncConnectivityStateWatcherInterface>(watcher_));
@@ -560,8 +553,11 @@ void XdsClient::ChannelState::Unsubscribe(const std::string& type_url,
560
553
  const std::string& name,
561
554
  bool delay_unsubscription) {
562
555
  if (ads_calld_ != nullptr) {
563
- ads_calld_->calld()->Unsubscribe(type_url, name, delay_unsubscription);
564
- if (!ads_calld_->calld()->HasSubscribedResources()) ads_calld_.reset();
556
+ auto* calld = ads_calld_->calld();
557
+ if (calld != nullptr) {
558
+ calld->Unsubscribe(type_url, name, delay_unsubscription);
559
+ if (!calld->HasSubscribedResources()) ads_calld_.reset();
560
+ }
565
561
  }
566
562
  }
567
563
 
@@ -580,6 +576,9 @@ XdsClient::ChannelState::RetryableCall<T>::RetryableCall(
580
576
  .set_multiplier(GRPC_XDS_RECONNECT_BACKOFF_MULTIPLIER)
581
577
  .set_jitter(GRPC_XDS_RECONNECT_JITTER)
582
578
  .set_max_backoff(GRPC_XDS_RECONNECT_MAX_BACKOFF_SECONDS * 1000)) {
579
+ // Closure Initialization
580
+ GRPC_CLOSURE_INIT(&on_retry_timer_, OnRetryTimer, this,
581
+ grpc_schedule_on_exec_ctx);
583
582
  StartNewCallLocked();
584
583
  }
585
584
 
@@ -633,8 +632,6 @@ void XdsClient::ChannelState::RetryableCall<T>::StartRetryTimerLocked() {
633
632
  chand()->xds_client(), chand(), timeout);
634
633
  }
635
634
  this->Ref(DEBUG_LOCATION, "RetryableCall+retry_timer_start").release();
636
- GRPC_CLOSURE_INIT(&on_retry_timer_, OnRetryTimer, this,
637
- grpc_schedule_on_exec_ctx);
638
635
  grpc_timer_init(&retry_timer_, next_attempt_time, &on_retry_timer_);
639
636
  retry_timer_callback_pending_ = true;
640
637
  }
@@ -643,27 +640,27 @@ template <typename T>
643
640
  void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimer(
644
641
  void* arg, grpc_error* error) {
645
642
  RetryableCall* calld = static_cast<RetryableCall*>(arg);
646
- calld->chand_->xds_client()->combiner_->Run(
647
- GRPC_CLOSURE_INIT(&calld->on_retry_timer_, OnRetryTimerLocked, calld,
648
- nullptr),
649
- GRPC_ERROR_REF(error));
643
+ {
644
+ MutexLock lock(&calld->chand_->xds_client()->mu_);
645
+ calld->OnRetryTimerLocked(GRPC_ERROR_REF(error));
646
+ }
647
+ calld->Unref(DEBUG_LOCATION, "RetryableCall+retry_timer_done");
650
648
  }
651
649
 
652
650
  template <typename T>
653
651
  void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
654
- void* arg, grpc_error* error) {
655
- RetryableCall* calld = static_cast<RetryableCall*>(arg);
656
- calld->retry_timer_callback_pending_ = false;
657
- if (!calld->shutting_down_ && error == GRPC_ERROR_NONE) {
652
+ grpc_error* error) {
653
+ retry_timer_callback_pending_ = false;
654
+ if (!shutting_down_ && error == GRPC_ERROR_NONE) {
658
655
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
659
656
  gpr_log(
660
657
  GPR_INFO,
661
658
  "[xds_client %p] Retry timer fires (chand: %p, retryable call: %p)",
662
- calld->chand()->xds_client(), calld->chand(), calld);
659
+ chand()->xds_client(), chand(), this);
663
660
  }
664
- calld->StartNewCallLocked();
661
+ StartNewCallLocked();
665
662
  }
666
- calld->Unref(DEBUG_LOCATION, "RetryableCall+retry_timer_done");
663
+ GRPC_ERROR_UNREF(error);
667
664
  }
668
665
 
669
666
  //
@@ -672,19 +669,24 @@ void XdsClient::ChannelState::RetryableCall<T>::OnRetryTimerLocked(
672
669
 
673
670
  XdsClient::ChannelState::AdsCallState::AdsCallState(
674
671
  RefCountedPtr<RetryableCall<AdsCallState>> parent)
675
- : InternallyRefCounted<AdsCallState>(&grpc_xds_client_trace),
672
+ : InternallyRefCounted<AdsCallState>(
673
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
674
+ ? "AdsCallState"
675
+ : nullptr),
676
676
  parent_(std::move(parent)) {
677
677
  // Init the ADS call. Note that the call will progress every time there's
678
678
  // activity in xds_client()->interested_parties_, which is comprised of
679
679
  // the polling entities from client_channel.
680
680
  GPR_ASSERT(xds_client() != nullptr);
681
- GPR_ASSERT(!xds_client()->server_name_.empty());
682
681
  // Create a call with the specified method name.
682
+ const auto& method =
683
+ chand()->server_.ShouldUseV3()
684
+ ? GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V3_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES
685
+ : GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES;
683
686
  call_ = grpc_channel_create_pollset_set_call(
684
687
  chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
685
- xds_client()->interested_parties_,
686
- GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_DISCOVERY_DOT_V2_DOT_AGGREGATEDDISCOVERYSERVICE_SLASH_STREAMAGGREGATEDRESOURCES,
687
- nullptr, GRPC_MILLIS_INF_FUTURE, nullptr);
688
+ xds_client()->interested_parties_, method, nullptr,
689
+ GRPC_MILLIS_INF_FUTURE, nullptr);
688
690
  GPR_ASSERT(call_ != nullptr);
689
691
  // Init data associated with the call.
690
692
  grpc_metadata_array_init(&initial_metadata_recv_);
@@ -708,19 +710,17 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
708
710
  GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET;
709
711
  op->reserved = nullptr;
710
712
  op++;
711
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
712
- nullptr);
713
+ call_error = grpc_call_start_batch_and_execute(
714
+ call_, ops, static_cast<size_t>(op - ops), nullptr);
713
715
  GPR_ASSERT(GRPC_CALL_OK == call_error);
714
716
  // Op: send request message.
715
717
  GRPC_CLOSURE_INIT(&on_request_sent_, OnRequestSent, this,
716
718
  grpc_schedule_on_exec_ctx);
717
- if (xds_client()->service_config_watcher_ != nullptr) {
718
- Subscribe(XdsApi::kLdsTypeUrl, xds_client()->server_name_);
719
- if (xds_client()->lds_result_.has_value() &&
720
- !xds_client()->lds_result_->route_config_name.empty()) {
721
- Subscribe(XdsApi::kRdsTypeUrl,
722
- xds_client()->lds_result_->route_config_name);
723
- }
719
+ for (const auto& p : xds_client()->listener_map_) {
720
+ Subscribe(XdsApi::kLdsTypeUrl, std::string(p.first));
721
+ }
722
+ for (const auto& p : xds_client()->route_config_map_) {
723
+ Subscribe(XdsApi::kRdsTypeUrl, std::string(p.first));
724
724
  }
725
725
  for (const auto& p : xds_client()->cluster_map_) {
726
726
  Subscribe(XdsApi::kCdsTypeUrl, std::string(p.first));
@@ -745,8 +745,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
745
745
  Ref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked").release();
746
746
  GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
747
747
  grpc_schedule_on_exec_ctx);
748
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
749
- &on_response_received_);
748
+ call_error = grpc_call_start_batch_and_execute(
749
+ call_, ops, static_cast<size_t>(op - ops), &on_response_received_);
750
750
  GPR_ASSERT(GRPC_CALL_OK == call_error);
751
751
  // Op: recv server status.
752
752
  op = ops;
@@ -762,8 +762,8 @@ XdsClient::ChannelState::AdsCallState::AdsCallState(
762
762
  // unreffed.
763
763
  GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
764
764
  grpc_schedule_on_exec_ctx);
765
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
766
- &on_status_received_);
765
+ call_error = grpc_call_start_batch_and_execute(
766
+ call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
767
767
  GPR_ASSERT(GRPC_CALL_OK == call_error);
768
768
  }
769
769
 
@@ -783,7 +783,7 @@ void XdsClient::ChannelState::AdsCallState::Orphan() {
783
783
  // on_status_received_ will complete the cancellation and clean up. Otherwise,
784
784
  // we are here because xds_client has to orphan a failed call, then the
785
785
  // following cancellation will be a no-op.
786
- grpc_call_cancel(call_, nullptr);
786
+ grpc_call_cancel_internal(call_);
787
787
  state_map_.clear();
788
788
  // Note that the initial ref is hold by on_status_received_. So the
789
789
  // corresponding unref happens in on_status_received_ instead of here.
@@ -798,33 +798,14 @@ void XdsClient::ChannelState::AdsCallState::SendMessageLocked(
798
798
  }
799
799
  auto& state = state_map_[type_url];
800
800
  grpc_slice request_payload_slice;
801
- std::set<StringView> resource_names;
802
- if (type_url == XdsApi::kLdsTypeUrl) {
803
- resource_names.insert(xds_client()->server_name_);
804
- request_payload_slice = xds_client()->api_.CreateLdsRequest(
805
- xds_client()->server_name_, state.version, state.nonce,
806
- GRPC_ERROR_REF(state.error), !sent_initial_message_);
807
- state.subscribed_resources[xds_client()->server_name_]->Start(Ref());
808
- } else if (type_url == XdsApi::kRdsTypeUrl) {
809
- resource_names.insert(xds_client()->lds_result_->route_config_name);
810
- request_payload_slice = xds_client()->api_.CreateRdsRequest(
811
- xds_client()->lds_result_->route_config_name, state.version,
812
- state.nonce, GRPC_ERROR_REF(state.error), !sent_initial_message_);
813
- state.subscribed_resources[xds_client()->lds_result_->route_config_name]
814
- ->Start(Ref());
815
- } else if (type_url == XdsApi::kCdsTypeUrl) {
816
- resource_names = ClusterNamesForRequest();
817
- request_payload_slice = xds_client()->api_.CreateCdsRequest(
818
- resource_names, state.version, state.nonce, GRPC_ERROR_REF(state.error),
819
- !sent_initial_message_);
820
- } else if (type_url == XdsApi::kEdsTypeUrl) {
821
- resource_names = EdsServiceNamesForRequest();
822
- request_payload_slice = xds_client()->api_.CreateEdsRequest(
823
- resource_names, state.version, state.nonce, GRPC_ERROR_REF(state.error),
824
- !sent_initial_message_);
825
- } else {
826
- request_payload_slice = xds_client()->api_.CreateUnsupportedTypeNackRequest(
827
- type_url, state.nonce, GRPC_ERROR_REF(state.error));
801
+ std::set<absl::string_view> resource_names =
802
+ ResourceNamesForRequest(type_url);
803
+ request_payload_slice = xds_client()->api_.CreateAdsRequest(
804
+ chand()->server_, type_url, resource_names,
805
+ xds_client()->resource_version_map_[type_url], state.nonce,
806
+ GRPC_ERROR_REF(state.error), !sent_initial_message_);
807
+ if (type_url != XdsApi::kLdsTypeUrl && type_url != XdsApi::kRdsTypeUrl &&
808
+ type_url != XdsApi::kCdsTypeUrl && type_url != XdsApi::kEdsTypeUrl) {
828
809
  state_map_.erase(type_url);
829
810
  }
830
811
  sent_initial_message_ = true;
@@ -832,7 +813,8 @@ void XdsClient::ChannelState::AdsCallState::SendMessageLocked(
832
813
  gpr_log(GPR_INFO,
833
814
  "[xds_client %p] sending ADS request: type=%s version=%s nonce=%s "
834
815
  "error=%s resources=%s",
835
- xds_client(), type_url.c_str(), state.version.c_str(),
816
+ xds_client(), type_url.c_str(),
817
+ xds_client()->resource_version_map_[type_url].c_str(),
836
818
  state.nonce.c_str(), grpc_error_string(state.error),
837
819
  absl::StrJoin(resource_names, " ").c_str());
838
820
  }
@@ -864,7 +846,8 @@ void XdsClient::ChannelState::AdsCallState::Subscribe(
864
846
  const std::string& type_url, const std::string& name) {
865
847
  auto& state = state_map_[type_url].subscribed_resources[name];
866
848
  if (state == nullptr) {
867
- state = MakeOrphanable<ResourceState>(type_url, name);
849
+ state = MakeOrphanable<ResourceState>(
850
+ type_url, name, !xds_client()->resource_version_map_[type_url].empty());
868
851
  SendMessageLocked(type_url);
869
852
  }
870
853
  }
@@ -884,110 +867,132 @@ bool XdsClient::ChannelState::AdsCallState::HasSubscribedResources() const {
884
867
  }
885
868
 
886
869
  void XdsClient::ChannelState::AdsCallState::AcceptLdsUpdate(
887
- absl::optional<XdsApi::LdsUpdate> lds_update) {
888
- if (!lds_update.has_value()) {
889
- gpr_log(GPR_INFO,
890
- "[xds_client %p] LDS update does not include requested resource",
891
- xds_client());
892
- xds_client()->service_config_watcher_->OnError(
893
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
894
- "LDS update does not include requested resource"));
895
- return;
896
- }
870
+ XdsApi::LdsUpdateMap lds_update_map) {
897
871
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
898
872
  gpr_log(GPR_INFO,
899
- "[xds_client %p] LDS update received: route_config_name=%s, "
900
- "cluster_name=%s",
901
- xds_client(),
902
- (!lds_update->route_config_name.empty()
903
- ? lds_update->route_config_name.c_str()
904
- : "<inlined>"),
905
- (lds_update->rds_update.has_value()
906
- ? lds_update->rds_update->cluster_name.c_str()
907
- : "<to be obtained via RDS>"));
873
+ "[xds_client %p] LDS update received containing %" PRIuPTR
874
+ " resources",
875
+ xds_client(), lds_update_map.size());
908
876
  }
909
877
  auto& lds_state = state_map_[XdsApi::kLdsTypeUrl];
910
- auto& state = lds_state.subscribed_resources[xds_client()->server_name_];
911
- if (state != nullptr) state->Finish();
912
- // Ignore identical update.
913
- if (xds_client()->lds_result_ == lds_update) {
878
+ std::set<std::string> rds_resource_names_seen;
879
+ for (auto& p : lds_update_map) {
880
+ const std::string& listener_name = p.first;
881
+ XdsApi::LdsUpdate& lds_update = p.second;
882
+ auto& state = lds_state.subscribed_resources[listener_name];
883
+ if (state != nullptr) state->Finish();
914
884
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
915
- gpr_log(GPR_INFO,
916
- "[xds_client %p] LDS update identical to current, ignoring.",
917
- xds_client());
885
+ gpr_log(GPR_INFO, "[xds_client %p] LDS resource %s: %s", xds_client(),
886
+ listener_name.c_str(), lds_update.ToString().c_str());
887
+ }
888
+ // Record the RDS resource names seen.
889
+ if (!lds_update.route_config_name.empty()) {
890
+ rds_resource_names_seen.insert(lds_update.route_config_name);
891
+ }
892
+ // Ignore identical update.
893
+ ListenerState& listener_state = xds_client()->listener_map_[listener_name];
894
+ if (listener_state.update.has_value() &&
895
+ *listener_state.update == lds_update) {
896
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
897
+ gpr_log(GPR_INFO,
898
+ "[xds_client %p] LDS update for %s identical to current, "
899
+ "ignoring.",
900
+ xds_client(), listener_name.c_str());
901
+ }
902
+ continue;
903
+ }
904
+ // Update the listener state.
905
+ listener_state.update = std::move(lds_update);
906
+ // Notify watchers.
907
+ for (const auto& p : listener_state.watchers) {
908
+ p.first->OnListenerChanged(*listener_state.update);
918
909
  }
919
- return;
920
910
  }
921
- if (xds_client()->lds_result_.has_value() &&
922
- !xds_client()->lds_result_->route_config_name.empty()) {
923
- Unsubscribe(
924
- XdsApi::kRdsTypeUrl, xds_client()->lds_result_->route_config_name,
925
- /*delay_unsubscription=*/!lds_update->route_config_name.empty());
926
- }
927
- xds_client()->lds_result_ = std::move(lds_update);
928
- if (xds_client()->lds_result_->rds_update.has_value()) {
929
- // If the RouteConfiguration was found inlined in LDS response, notify
930
- // the watcher immediately.
931
- RefCountedPtr<ServiceConfig> service_config;
932
- grpc_error* error = xds_client()->CreateServiceConfig(
933
- xds_client()->lds_result_->rds_update->cluster_name, &service_config);
934
- if (error == GRPC_ERROR_NONE) {
935
- xds_client()->service_config_watcher_->OnServiceConfigChanged(
936
- std::move(service_config));
937
- } else {
938
- xds_client()->service_config_watcher_->OnError(error);
911
+ // For any subscribed resource that is not present in the update,
912
+ // remove it from the cache and notify watchers that it does not exist.
913
+ for (const auto& p : lds_state.subscribed_resources) {
914
+ const std::string& listener_name = p.first;
915
+ if (lds_update_map.find(listener_name) == lds_update_map.end()) {
916
+ ListenerState& listener_state =
917
+ xds_client()->listener_map_[listener_name];
918
+ // If the resource was newly requested but has not yet been received,
919
+ // we don't want to generate an error for the watchers, because this LDS
920
+ // response may be in reaction to an earlier request that did not yet
921
+ // request the new resource, so its absence from the response does not
922
+ // necessarily indicate that the resource does not exist.
923
+ // For that case, we rely on the request timeout instead.
924
+ if (!listener_state.update.has_value()) continue;
925
+ listener_state.update.reset();
926
+ for (const auto& p : listener_state.watchers) {
927
+ p.first->OnResourceDoesNotExist();
928
+ }
929
+ }
930
+ }
931
+ // For any RDS resource that is no longer referred to by any LDS
932
+ // resources, remove it from the cache and notify watchers that it
933
+ // does not exist.
934
+ auto& rds_state = state_map_[XdsApi::kRdsTypeUrl];
935
+ for (const auto& p : rds_state.subscribed_resources) {
936
+ const std::string& rds_resource_name = p.first;
937
+ if (rds_resource_names_seen.find(rds_resource_name) ==
938
+ rds_resource_names_seen.end()) {
939
+ RouteConfigState& route_config_state =
940
+ xds_client()->route_config_map_[rds_resource_name];
941
+ route_config_state.update.reset();
942
+ for (const auto& p : route_config_state.watchers) {
943
+ p.first->OnResourceDoesNotExist();
944
+ }
939
945
  }
940
- } else {
941
- // Send RDS request for dynamic resolution.
942
- Subscribe(XdsApi::kRdsTypeUrl,
943
- xds_client()->lds_result_->route_config_name);
944
946
  }
945
947
  }
946
948
 
947
949
  void XdsClient::ChannelState::AdsCallState::AcceptRdsUpdate(
948
- absl::optional<XdsApi::RdsUpdate> rds_update) {
949
- if (!rds_update.has_value()) {
950
- gpr_log(GPR_INFO,
951
- "[xds_client %p] RDS update does not include requested resource",
952
- xds_client());
953
- xds_client()->service_config_watcher_->OnError(
954
- GRPC_ERROR_CREATE_FROM_STATIC_STRING(
955
- "RDS update does not include requested resource"));
956
- return;
957
- }
950
+ XdsApi::RdsUpdateMap rds_update_map) {
958
951
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
959
- gpr_log(GPR_INFO, "[xds_client %p] RDS update received: cluster_name=%s",
960
- xds_client(), rds_update->cluster_name.c_str());
952
+ gpr_log(GPR_INFO,
953
+ "[xds_client %p] RDS update received containing %" PRIuPTR
954
+ " resources",
955
+ xds_client(), rds_update_map.size());
961
956
  }
962
957
  auto& rds_state = state_map_[XdsApi::kRdsTypeUrl];
963
- auto& state =
964
- rds_state
965
- .subscribed_resources[xds_client()->lds_result_->route_config_name];
966
- if (state != nullptr) state->Finish();
967
- // Ignore identical update.
968
- if (xds_client()->rds_result_ == rds_update) {
958
+ for (auto& p : rds_update_map) {
959
+ const std::string& route_config_name = p.first;
960
+ XdsApi::RdsUpdate& rds_update = p.second;
961
+ auto& state = rds_state.subscribed_resources[route_config_name];
962
+ if (state != nullptr) state->Finish();
969
963
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
970
- gpr_log(GPR_INFO,
971
- "[xds_client %p] RDS update identical to current, ignoring.",
972
- xds_client());
964
+ gpr_log(GPR_INFO, "[xds_client %p] RDS resource:\n%s", xds_client(),
965
+ rds_update.ToString().c_str());
966
+ }
967
+ RouteConfigState& route_config_state =
968
+ xds_client()->route_config_map_[route_config_name];
969
+ // Ignore identical update.
970
+ if (route_config_state.update.has_value() &&
971
+ *route_config_state.update == rds_update) {
972
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
973
+ gpr_log(GPR_INFO,
974
+ "[xds_client %p] RDS resource identical to current, ignoring",
975
+ xds_client());
976
+ }
977
+ continue;
978
+ }
979
+ // Update the cache.
980
+ route_config_state.update = std::move(rds_update);
981
+ // Notify all watchers.
982
+ for (const auto& p : route_config_state.watchers) {
983
+ p.first->OnRouteConfigChanged(*route_config_state.update);
973
984
  }
974
- return;
975
- }
976
- xds_client()->rds_result_ = std::move(rds_update);
977
- // Notify the watcher.
978
- RefCountedPtr<ServiceConfig> service_config;
979
- grpc_error* error = xds_client()->CreateServiceConfig(
980
- xds_client()->rds_result_->cluster_name, &service_config);
981
- if (error == GRPC_ERROR_NONE) {
982
- xds_client()->service_config_watcher_->OnServiceConfigChanged(
983
- std::move(service_config));
984
- } else {
985
- xds_client()->service_config_watcher_->OnError(error);
986
985
  }
987
986
  }
988
987
 
989
988
  void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
990
989
  XdsApi::CdsUpdateMap cds_update_map) {
990
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
991
+ gpr_log(GPR_INFO,
992
+ "[xds_client %p] CDS update received containing %" PRIuPTR
993
+ " resources",
994
+ xds_client(), cds_update_map.size());
995
+ }
991
996
  auto& cds_state = state_map_[XdsApi::kCdsTypeUrl];
992
997
  std::set<std::string> eds_resource_names_seen;
993
998
  for (auto& p : cds_update_map) {
@@ -996,13 +1001,8 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
996
1001
  auto& state = cds_state.subscribed_resources[cluster_name];
997
1002
  if (state != nullptr) state->Finish();
998
1003
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
999
- gpr_log(GPR_INFO,
1000
- "[xds_client %p] CDS update (cluster=%s) received: "
1001
- "eds_service_name=%s, lrs_load_reporting_server_name=%s",
1002
- xds_client(), cluster_name, cds_update.eds_service_name.c_str(),
1003
- cds_update.lrs_load_reporting_server_name.has_value()
1004
- ? cds_update.lrs_load_reporting_server_name.value().c_str()
1005
- : "(N/A)");
1004
+ gpr_log(GPR_INFO, "[xds_client %p] cluster=%s: %s", xds_client(),
1005
+ cluster_name, cds_update.ToString().c_str());
1006
1006
  }
1007
1007
  // Record the EDS resource names seen.
1008
1008
  eds_resource_names_seen.insert(cds_update.eds_service_name.empty()
@@ -1011,9 +1011,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1011
1011
  // Ignore identical update.
1012
1012
  ClusterState& cluster_state = xds_client()->cluster_map_[cluster_name];
1013
1013
  if (cluster_state.update.has_value() &&
1014
- cds_update.eds_service_name == cluster_state.update->eds_service_name &&
1015
- cds_update.lrs_load_reporting_server_name ==
1016
- cluster_state.update->lrs_load_reporting_server_name) {
1014
+ *cluster_state.update == cds_update) {
1017
1015
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1018
1016
  gpr_log(GPR_INFO,
1019
1017
  "[xds_client %p] CDS update identical to current, ignoring.",
@@ -1029,20 +1027,27 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1029
1027
  }
1030
1028
  }
1031
1029
  // For any subscribed resource that is not present in the update,
1032
- // remove it from the cache and notify watchers of the error.
1030
+ // remove it from the cache and notify watchers that it does not exist.
1033
1031
  for (const auto& p : cds_state.subscribed_resources) {
1034
1032
  const std::string& cluster_name = p.first;
1035
1033
  if (cds_update_map.find(cluster_name) == cds_update_map.end()) {
1036
1034
  ClusterState& cluster_state = xds_client()->cluster_map_[cluster_name];
1035
+ // If the resource was newly requested but has not yet been received,
1036
+ // we don't want to generate an error for the watchers, because this CDS
1037
+ // response may be in reaction to an earlier request that did not yet
1038
+ // request the new resource, so its absence from the response does not
1039
+ // necessarily indicate that the resource does not exist.
1040
+ // For that case, we rely on the request timeout instead.
1041
+ if (!cluster_state.update.has_value()) continue;
1037
1042
  cluster_state.update.reset();
1038
1043
  for (const auto& p : cluster_state.watchers) {
1039
- p.first->OnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1040
- "Cluster not present in CDS update"));
1044
+ p.first->OnResourceDoesNotExist();
1041
1045
  }
1042
1046
  }
1043
1047
  }
1044
- // Also remove any EDS resources that are no longer referred to by any CDS
1045
- // resources.
1048
+ // For any EDS resource that is no longer referred to by any CDS
1049
+ // resources, remove it from the cache and notify watchers that it
1050
+ // does not exist.
1046
1051
  auto& eds_state = state_map_[XdsApi::kEdsTypeUrl];
1047
1052
  for (const auto& p : eds_state.subscribed_resources) {
1048
1053
  const std::string& eds_resource_name = p.first;
@@ -1052,8 +1057,7 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1052
1057
  xds_client()->endpoint_map_[eds_resource_name];
1053
1058
  endpoint_state.update.reset();
1054
1059
  for (const auto& p : endpoint_state.watchers) {
1055
- p.first->OnError(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1056
- "ClusterLoadAssignment resource removed due to CDS update"));
1060
+ p.first->OnResourceDoesNotExist();
1057
1061
  }
1058
1062
  }
1059
1063
  }
@@ -1061,6 +1065,12 @@ void XdsClient::ChannelState::AdsCallState::AcceptCdsUpdate(
1061
1065
 
1062
1066
  void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1063
1067
  XdsApi::EdsUpdateMap eds_update_map) {
1068
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1069
+ gpr_log(GPR_INFO,
1070
+ "[xds_client %p] EDS update received containing %" PRIuPTR
1071
+ " resources",
1072
+ xds_client(), eds_update_map.size());
1073
+ }
1064
1074
  auto& eds_state = state_map_[XdsApi::kEdsTypeUrl];
1065
1075
  for (auto& p : eds_update_map) {
1066
1076
  const char* eds_service_name = p.first.c_str();
@@ -1068,72 +1078,20 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1068
1078
  auto& state = eds_state.subscribed_resources[eds_service_name];
1069
1079
  if (state != nullptr) state->Finish();
1070
1080
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1071
- gpr_log(GPR_INFO,
1072
- "[xds_client %p] EDS response with %" PRIuPTR
1073
- " priorities and %" PRIuPTR
1074
- " drop categories received (drop_all=%d)",
1075
- xds_client(), eds_update.priority_list_update.size(),
1076
- eds_update.drop_config->drop_category_list().size(),
1077
- eds_update.drop_config->drop_all());
1078
- for (size_t priority = 0;
1079
- priority < eds_update.priority_list_update.size(); ++priority) {
1080
- const auto* locality_map_update = eds_update.priority_list_update.Find(
1081
- static_cast<uint32_t>(priority));
1082
- gpr_log(GPR_INFO,
1083
- "[xds_client %p] Priority %" PRIuPTR " contains %" PRIuPTR
1084
- " localities",
1085
- xds_client(), priority, locality_map_update->size());
1086
- size_t locality_count = 0;
1087
- for (const auto& p : locality_map_update->localities) {
1088
- const auto& locality = p.second;
1089
- gpr_log(GPR_INFO,
1090
- "[xds_client %p] Priority %" PRIuPTR ", locality %" PRIuPTR
1091
- " %s has weight %d, contains %" PRIuPTR " server addresses",
1092
- xds_client(), priority, locality_count,
1093
- locality.name->AsHumanReadableString(), locality.lb_weight,
1094
- locality.serverlist.size());
1095
- for (size_t i = 0; i < locality.serverlist.size(); ++i) {
1096
- char* ipport;
1097
- grpc_sockaddr_to_string(&ipport, &locality.serverlist[i].address(),
1098
- false);
1099
- gpr_log(GPR_INFO,
1100
- "[xds_client %p] Priority %" PRIuPTR ", locality %" PRIuPTR
1101
- " %s, server address %" PRIuPTR ": %s",
1102
- xds_client(), priority, locality_count,
1103
- locality.name->AsHumanReadableString(), i, ipport);
1104
- gpr_free(ipport);
1105
- }
1106
- ++locality_count;
1107
- }
1108
- }
1109
- for (size_t i = 0;
1110
- i < eds_update.drop_config->drop_category_list().size(); ++i) {
1111
- const XdsApi::DropConfig::DropCategory& drop_category =
1112
- eds_update.drop_config->drop_category_list()[i];
1113
- gpr_log(GPR_INFO,
1114
- "[xds_client %p] Drop category %s has drop rate %d per million",
1115
- xds_client(), drop_category.name.c_str(),
1116
- drop_category.parts_per_million);
1117
- }
1081
+ gpr_log(GPR_INFO, "[xds_client %p] EDS resource %s: %s", xds_client(),
1082
+ eds_service_name, eds_update.ToString().c_str());
1118
1083
  }
1119
1084
  EndpointState& endpoint_state =
1120
1085
  xds_client()->endpoint_map_[eds_service_name];
1121
1086
  // Ignore identical update.
1122
- if (endpoint_state.update.has_value()) {
1123
- const XdsApi::EdsUpdate& prev_update = endpoint_state.update.value();
1124
- const bool priority_list_changed =
1125
- prev_update.priority_list_update != eds_update.priority_list_update;
1126
- const bool drop_config_changed =
1127
- prev_update.drop_config == nullptr ||
1128
- *prev_update.drop_config != *eds_update.drop_config;
1129
- if (!priority_list_changed && !drop_config_changed) {
1130
- if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1131
- gpr_log(GPR_INFO,
1132
- "[xds_client %p] EDS update identical to current, ignoring.",
1133
- xds_client());
1134
- }
1135
- continue;
1087
+ if (endpoint_state.update.has_value() &&
1088
+ *endpoint_state.update == eds_update) {
1089
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1090
+ gpr_log(GPR_INFO,
1091
+ "[xds_client %p] EDS update identical to current, ignoring.",
1092
+ xds_client());
1136
1093
  }
1094
+ continue;
1137
1095
  }
1138
1096
  // Update the cluster state.
1139
1097
  endpoint_state.update = std::move(eds_update);
@@ -1147,19 +1105,19 @@ void XdsClient::ChannelState::AdsCallState::AcceptEdsUpdate(
1147
1105
  void XdsClient::ChannelState::AdsCallState::OnRequestSent(void* arg,
1148
1106
  grpc_error* error) {
1149
1107
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1150
- ads_calld->xds_client()->combiner_->Run(
1151
- GRPC_CLOSURE_INIT(&ads_calld->on_request_sent_, OnRequestSentLocked,
1152
- ads_calld, nullptr),
1153
- GRPC_ERROR_REF(error));
1108
+ {
1109
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1110
+ ads_calld->OnRequestSentLocked(GRPC_ERROR_REF(error));
1111
+ }
1112
+ ads_calld->Unref(DEBUG_LOCATION, "ADS+OnRequestSentLocked");
1154
1113
  }
1155
1114
 
1156
1115
  void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked(
1157
- void* arg, grpc_error* error) {
1158
- AdsCallState* self = static_cast<AdsCallState*>(arg);
1159
- if (self->IsCurrentCallOnChannel() && error == GRPC_ERROR_NONE) {
1116
+ grpc_error* error) {
1117
+ if (IsCurrentCallOnChannel() && error == GRPC_ERROR_NONE) {
1160
1118
  // Clean up the sent message.
1161
- grpc_byte_buffer_destroy(self->send_message_payload_);
1162
- self->send_message_payload_ = nullptr;
1119
+ grpc_byte_buffer_destroy(send_message_payload_);
1120
+ send_message_payload_ = nullptr;
1163
1121
  // Continue to send another pending message if any.
1164
1122
  // TODO(roth): The current code to handle buffered messages has the
1165
1123
  // advantage of sending only the most recent list of resource names for
@@ -1169,164 +1127,136 @@ void XdsClient::ChannelState::AdsCallState::OnRequestSentLocked(
1169
1127
  // order of resource types. We need to fix this if we are seeing some
1170
1128
  // resource type(s) starved due to frequent requests of other resource
1171
1129
  // type(s).
1172
- auto it = self->buffered_requests_.begin();
1173
- if (it != self->buffered_requests_.end()) {
1174
- self->SendMessageLocked(*it);
1175
- self->buffered_requests_.erase(it);
1130
+ auto it = buffered_requests_.begin();
1131
+ if (it != buffered_requests_.end()) {
1132
+ SendMessageLocked(*it);
1133
+ buffered_requests_.erase(it);
1176
1134
  }
1177
1135
  }
1178
- self->Unref(DEBUG_LOCATION, "ADS+OnRequestSentLocked");
1136
+ GRPC_ERROR_UNREF(error);
1179
1137
  }
1180
1138
 
1181
1139
  void XdsClient::ChannelState::AdsCallState::OnResponseReceived(
1182
- void* arg, grpc_error* error) {
1140
+ void* arg, grpc_error* /* error */) {
1183
1141
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1184
- ads_calld->xds_client()->combiner_->Run(
1185
- GRPC_CLOSURE_INIT(&ads_calld->on_response_received_,
1186
- OnResponseReceivedLocked, ads_calld, nullptr),
1187
- GRPC_ERROR_REF(error));
1142
+ bool done;
1143
+ {
1144
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1145
+ done = ads_calld->OnResponseReceivedLocked();
1146
+ }
1147
+ if (done) ads_calld->Unref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked");
1188
1148
  }
1189
1149
 
1190
- void XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked(
1191
- void* arg, grpc_error* /*error*/) {
1192
- AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1193
- XdsClient* xds_client = ads_calld->xds_client();
1150
+ bool XdsClient::ChannelState::AdsCallState::OnResponseReceivedLocked() {
1194
1151
  // Empty payload means the call was cancelled.
1195
- if (!ads_calld->IsCurrentCallOnChannel() ||
1196
- ads_calld->recv_message_payload_ == nullptr) {
1197
- ads_calld->Unref(DEBUG_LOCATION, "ADS+OnResponseReceivedLocked");
1198
- return;
1152
+ if (!IsCurrentCallOnChannel() || recv_message_payload_ == nullptr) {
1153
+ return true;
1199
1154
  }
1200
1155
  // Read the response.
1201
1156
  grpc_byte_buffer_reader bbr;
1202
- grpc_byte_buffer_reader_init(&bbr, ads_calld->recv_message_payload_);
1157
+ grpc_byte_buffer_reader_init(&bbr, recv_message_payload_);
1203
1158
  grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
1204
1159
  grpc_byte_buffer_reader_destroy(&bbr);
1205
- grpc_byte_buffer_destroy(ads_calld->recv_message_payload_);
1206
- ads_calld->recv_message_payload_ = nullptr;
1207
- // TODO(juanlishen): When we convert this to use the xds protocol, the
1208
- // balancer will send us a fallback timeout such that we should go into
1209
- // fallback mode if we have lost contact with the balancer after a certain
1210
- // period of time. We will need to save the timeout value here, and then
1211
- // when the balancer call ends, we will need to start a timer for the
1212
- // specified period of time, and if the timer fires, we go into fallback
1213
- // mode. We will also need to cancel the timer when we receive a serverlist
1214
- // from the balancer.
1215
- // Parse the response.
1216
- absl::optional<XdsApi::LdsUpdate> lds_update;
1217
- absl::optional<XdsApi::RdsUpdate> rds_update;
1218
- XdsApi::CdsUpdateMap cds_update_map;
1219
- XdsApi::EdsUpdateMap eds_update_map;
1220
- std::string version;
1221
- std::string nonce;
1222
- std::string type_url;
1223
- // Note that ParseAdsResponse() also validates the response.
1224
- grpc_error* parse_error = xds_client->api_.ParseAdsResponse(
1225
- response_slice, xds_client->server_name_,
1226
- (xds_client->lds_result_.has_value()
1227
- ? xds_client->lds_result_->route_config_name
1228
- : ""),
1229
- ads_calld->ClusterNamesForRequest(),
1230
- ads_calld->EdsServiceNamesForRequest(), &lds_update, &rds_update,
1231
- &cds_update_map, &eds_update_map, &version, &nonce, &type_url);
1160
+ grpc_byte_buffer_destroy(recv_message_payload_);
1161
+ recv_message_payload_ = nullptr;
1162
+ // Parse and validate the response.
1163
+ XdsApi::AdsParseResult result = xds_client()->api_.ParseAdsResponse(
1164
+ response_slice, ResourceNamesForRequest(XdsApi::kLdsTypeUrl),
1165
+ ResourceNamesForRequest(XdsApi::kRdsTypeUrl),
1166
+ ResourceNamesForRequest(XdsApi::kCdsTypeUrl),
1167
+ ResourceNamesForRequest(XdsApi::kEdsTypeUrl));
1232
1168
  grpc_slice_unref_internal(response_slice);
1233
- if (type_url.empty()) {
1169
+ if (result.type_url.empty()) {
1234
1170
  // Ignore unparsable response.
1235
1171
  gpr_log(GPR_ERROR,
1236
1172
  "[xds_client %p] Error parsing ADS response (%s) -- ignoring",
1237
- xds_client, grpc_error_string(parse_error));
1238
- GRPC_ERROR_UNREF(parse_error);
1173
+ xds_client(), grpc_error_string(result.parse_error));
1174
+ GRPC_ERROR_UNREF(result.parse_error);
1239
1175
  } else {
1240
1176
  // Update nonce.
1241
- auto& state = ads_calld->state_map_[type_url];
1242
- state.nonce = std::move(nonce);
1177
+ auto& state = state_map_[result.type_url];
1178
+ state.nonce = std::move(result.nonce);
1243
1179
  // NACK or ACK the response.
1244
- if (parse_error != GRPC_ERROR_NONE) {
1180
+ if (result.parse_error != GRPC_ERROR_NONE) {
1245
1181
  GRPC_ERROR_UNREF(state.error);
1246
- state.error = parse_error;
1182
+ state.error = result.parse_error;
1247
1183
  // NACK unacceptable update.
1248
1184
  gpr_log(GPR_ERROR,
1249
1185
  "[xds_client %p] ADS response invalid for resource type %s "
1250
1186
  "version %s, will NACK: nonce=%s error=%s",
1251
- xds_client, type_url.c_str(), version.c_str(),
1252
- state.nonce.c_str(), grpc_error_string(parse_error));
1253
- ads_calld->SendMessageLocked(type_url);
1187
+ xds_client(), result.type_url.c_str(), result.version.c_str(),
1188
+ state.nonce.c_str(), grpc_error_string(result.parse_error));
1189
+ SendMessageLocked(result.type_url);
1254
1190
  } else {
1255
- ads_calld->seen_response_ = true;
1191
+ seen_response_ = true;
1256
1192
  // Accept the ADS response according to the type_url.
1257
- if (type_url == XdsApi::kLdsTypeUrl) {
1258
- ads_calld->AcceptLdsUpdate(std::move(lds_update));
1259
- } else if (type_url == XdsApi::kRdsTypeUrl) {
1260
- ads_calld->AcceptRdsUpdate(std::move(rds_update));
1261
- } else if (type_url == XdsApi::kCdsTypeUrl) {
1262
- ads_calld->AcceptCdsUpdate(std::move(cds_update_map));
1263
- } else if (type_url == XdsApi::kEdsTypeUrl) {
1264
- ads_calld->AcceptEdsUpdate(std::move(eds_update_map));
1193
+ if (result.type_url == XdsApi::kLdsTypeUrl) {
1194
+ AcceptLdsUpdate(std::move(result.lds_update_map));
1195
+ } else if (result.type_url == XdsApi::kRdsTypeUrl) {
1196
+ AcceptRdsUpdate(std::move(result.rds_update_map));
1197
+ } else if (result.type_url == XdsApi::kCdsTypeUrl) {
1198
+ AcceptCdsUpdate(std::move(result.cds_update_map));
1199
+ } else if (result.type_url == XdsApi::kEdsTypeUrl) {
1200
+ AcceptEdsUpdate(std::move(result.eds_update_map));
1265
1201
  }
1266
- state.version = std::move(version);
1202
+ xds_client()->resource_version_map_[result.type_url] =
1203
+ std::move(result.version);
1267
1204
  // ACK the update.
1268
- ads_calld->SendMessageLocked(type_url);
1205
+ SendMessageLocked(result.type_url);
1269
1206
  // Start load reporting if needed.
1270
- auto& lrs_call = ads_calld->chand()->lrs_calld_;
1207
+ auto& lrs_call = chand()->lrs_calld_;
1271
1208
  if (lrs_call != nullptr) {
1272
1209
  LrsCallState* lrs_calld = lrs_call->calld();
1273
1210
  if (lrs_calld != nullptr) lrs_calld->MaybeStartReportingLocked();
1274
1211
  }
1275
1212
  }
1276
1213
  }
1277
- if (xds_client->shutting_down_) {
1278
- ads_calld->Unref(DEBUG_LOCATION,
1279
- "ADS+OnResponseReceivedLocked+xds_shutdown");
1280
- return;
1281
- }
1214
+ if (xds_client()->shutting_down_) return true;
1282
1215
  // Keep listening for updates.
1283
1216
  grpc_op op;
1284
1217
  memset(&op, 0, sizeof(op));
1285
1218
  op.op = GRPC_OP_RECV_MESSAGE;
1286
- op.data.recv_message.recv_message = &ads_calld->recv_message_payload_;
1219
+ op.data.recv_message.recv_message = &recv_message_payload_;
1287
1220
  op.flags = 0;
1288
1221
  op.reserved = nullptr;
1289
- GPR_ASSERT(ads_calld->call_ != nullptr);
1222
+ GPR_ASSERT(call_ != nullptr);
1290
1223
  // Reuse the "ADS+OnResponseReceivedLocked" ref taken in ctor.
1291
- GRPC_CLOSURE_INIT(&ads_calld->on_response_received_, OnResponseReceived,
1292
- ads_calld, grpc_schedule_on_exec_ctx);
1293
- const grpc_call_error call_error = grpc_call_start_batch_and_execute(
1294
- ads_calld->call_, &op, 1, &ads_calld->on_response_received_);
1224
+ const grpc_call_error call_error =
1225
+ grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_);
1295
1226
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1227
+ return false;
1296
1228
  }
1297
1229
 
1298
1230
  void XdsClient::ChannelState::AdsCallState::OnStatusReceived(
1299
1231
  void* arg, grpc_error* error) {
1300
1232
  AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1301
- ads_calld->xds_client()->combiner_->Run(
1302
- GRPC_CLOSURE_INIT(&ads_calld->on_status_received_, OnStatusReceivedLocked,
1303
- ads_calld, nullptr),
1304
- GRPC_ERROR_REF(error));
1233
+ {
1234
+ MutexLock lock(&ads_calld->xds_client()->mu_);
1235
+ ads_calld->OnStatusReceivedLocked(GRPC_ERROR_REF(error));
1236
+ }
1237
+ ads_calld->Unref(DEBUG_LOCATION, "ADS+OnStatusReceivedLocked");
1305
1238
  }
1306
1239
 
1307
1240
  void XdsClient::ChannelState::AdsCallState::OnStatusReceivedLocked(
1308
- void* arg, grpc_error* error) {
1309
- AdsCallState* ads_calld = static_cast<AdsCallState*>(arg);
1310
- ChannelState* chand = ads_calld->chand();
1311
- XdsClient* xds_client = ads_calld->xds_client();
1241
+ grpc_error* error) {
1312
1242
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1313
- char* status_details = grpc_slice_to_c_string(ads_calld->status_details_);
1243
+ char* status_details = grpc_slice_to_c_string(status_details_);
1314
1244
  gpr_log(GPR_INFO,
1315
1245
  "[xds_client %p] ADS call status received. Status = %d, details "
1316
1246
  "= '%s', (chand: %p, ads_calld: %p, call: %p), error '%s'",
1317
- xds_client, ads_calld->status_code_, status_details, chand,
1318
- ads_calld, ads_calld->call_, grpc_error_string(error));
1247
+ xds_client(), status_code_, status_details, chand(), this, call_,
1248
+ grpc_error_string(error));
1319
1249
  gpr_free(status_details);
1320
1250
  }
1321
1251
  // Ignore status from a stale call.
1322
- if (ads_calld->IsCurrentCallOnChannel()) {
1252
+ if (IsCurrentCallOnChannel()) {
1323
1253
  // Try to restart the call.
1324
- ads_calld->parent_->OnCallFinishedLocked();
1254
+ parent_->OnCallFinishedLocked();
1325
1255
  // Send error to all watchers.
1326
- xds_client->NotifyOnError(
1256
+ xds_client()->NotifyOnErrorLocked(
1327
1257
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("xds call failed"));
1328
1258
  }
1329
- ads_calld->Unref(DEBUG_LOCATION, "ADS+OnStatusReceivedLocked");
1259
+ GRPC_ERROR_UNREF(error);
1330
1260
  }
1331
1261
 
1332
1262
  bool XdsClient::ChannelState::AdsCallState::IsCurrentCallOnChannel() const {
@@ -1336,26 +1266,19 @@ bool XdsClient::ChannelState::AdsCallState::IsCurrentCallOnChannel() const {
1336
1266
  return this == chand()->ads_calld_->calld();
1337
1267
  }
1338
1268
 
1339
- std::set<StringView>
1340
- XdsClient::ChannelState::AdsCallState::ClusterNamesForRequest() {
1341
- std::set<StringView> cluster_names;
1342
- for (auto& p : state_map_[XdsApi::kCdsTypeUrl].subscribed_resources) {
1343
- cluster_names.insert(p.first);
1344
- OrphanablePtr<ResourceState>& state = p.second;
1345
- state->Start(Ref());
1346
- }
1347
- return cluster_names;
1348
- }
1349
-
1350
- std::set<StringView>
1351
- XdsClient::ChannelState::AdsCallState::EdsServiceNamesForRequest() {
1352
- std::set<StringView> eds_names;
1353
- for (auto& p : state_map_[XdsApi::kEdsTypeUrl].subscribed_resources) {
1354
- eds_names.insert(p.first);
1355
- OrphanablePtr<ResourceState>& state = p.second;
1356
- state->Start(Ref());
1269
+ std::set<absl::string_view>
1270
+ XdsClient::ChannelState::AdsCallState::ResourceNamesForRequest(
1271
+ const std::string& type_url) {
1272
+ std::set<absl::string_view> resource_names;
1273
+ auto it = state_map_.find(type_url);
1274
+ if (it != state_map_.end()) {
1275
+ for (auto& p : it->second.subscribed_resources) {
1276
+ resource_names.insert(p.first);
1277
+ OrphanablePtr<ResourceState>& state = p.second;
1278
+ state->Start(Ref(DEBUG_LOCATION, "ResourceState"));
1279
+ }
1357
1280
  }
1358
- return eds_names;
1281
+ return resource_names;
1359
1282
  }
1360
1283
 
1361
1284
  //
@@ -1371,8 +1294,6 @@ void XdsClient::ChannelState::LrsCallState::Reporter::Orphan() {
1371
1294
  void XdsClient::ChannelState::LrsCallState::Reporter::
1372
1295
  ScheduleNextReportLocked() {
1373
1296
  const grpc_millis next_report_time = ExecCtx::Get()->Now() + report_interval_;
1374
- GRPC_CLOSURE_INIT(&on_next_report_timer_, OnNextReportTimer, this,
1375
- grpc_schedule_on_exec_ctx);
1376
1297
  grpc_timer_init(&next_report_timer_, next_report_time,
1377
1298
  &on_next_report_timer_);
1378
1299
  next_report_timer_callback_pending_ = true;
@@ -1381,21 +1302,22 @@ void XdsClient::ChannelState::LrsCallState::Reporter::
1381
1302
  void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimer(
1382
1303
  void* arg, grpc_error* error) {
1383
1304
  Reporter* self = static_cast<Reporter*>(arg);
1384
- self->xds_client()->combiner_->Run(
1385
- GRPC_CLOSURE_INIT(&self->on_next_report_timer_, OnNextReportTimerLocked,
1386
- self, nullptr),
1387
- GRPC_ERROR_REF(error));
1305
+ bool done;
1306
+ {
1307
+ MutexLock lock(&self->xds_client()->mu_);
1308
+ done = self->OnNextReportTimerLocked(GRPC_ERROR_REF(error));
1309
+ }
1310
+ if (done) self->Unref(DEBUG_LOCATION, "Reporter+timer");
1388
1311
  }
1389
1312
 
1390
- void XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
1391
- void* arg, grpc_error* error) {
1392
- Reporter* self = static_cast<Reporter*>(arg);
1393
- self->next_report_timer_callback_pending_ = false;
1394
- if (error != GRPC_ERROR_NONE || !self->IsCurrentReporterOnCall()) {
1395
- self->Unref(DEBUG_LOCATION, "Reporter+timer");
1396
- return;
1313
+ bool XdsClient::ChannelState::LrsCallState::Reporter::OnNextReportTimerLocked(
1314
+ grpc_error* error) {
1315
+ next_report_timer_callback_pending_ = false;
1316
+ if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) {
1317
+ GRPC_ERROR_UNREF(error);
1318
+ return true;
1397
1319
  }
1398
- self->SendReportLocked();
1320
+ return SendReportLocked();
1399
1321
  }
1400
1322
 
1401
1323
  namespace {
@@ -1403,9 +1325,7 @@ namespace {
1403
1325
  bool LoadReportCountersAreZero(const XdsApi::ClusterLoadReportMap& snapshot) {
1404
1326
  for (const auto& p : snapshot) {
1405
1327
  const XdsApi::ClusterLoadReport& cluster_snapshot = p.second;
1406
- for (const auto& q : cluster_snapshot.dropped_requests) {
1407
- if (q.second > 0) return false;
1408
- }
1328
+ if (!cluster_snapshot.dropped_requests.IsZero()) return false;
1409
1329
  for (const auto& q : cluster_snapshot.locality_stats) {
1410
1330
  const XdsClusterLocalityStats::Snapshot& locality_snapshot = q.second;
1411
1331
  if (!locality_snapshot.IsZero()) return false;
@@ -1416,17 +1336,22 @@ bool LoadReportCountersAreZero(const XdsApi::ClusterLoadReportMap& snapshot) {
1416
1336
 
1417
1337
  } // namespace
1418
1338
 
1419
- void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1339
+ bool XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1420
1340
  // Construct snapshot from all reported stats.
1421
1341
  XdsApi::ClusterLoadReportMap snapshot =
1422
- xds_client()->BuildLoadReportSnapshot(parent_->cluster_names_);
1342
+ xds_client()->BuildLoadReportSnapshotLocked(parent_->send_all_clusters_,
1343
+ parent_->cluster_names_);
1423
1344
  // Skip client load report if the counters were all zero in the last
1424
1345
  // report and they are still zero in this one.
1425
1346
  const bool old_val = last_report_counters_were_zero_;
1426
1347
  last_report_counters_were_zero_ = LoadReportCountersAreZero(snapshot);
1427
1348
  if (old_val && last_report_counters_were_zero_) {
1349
+ if (xds_client()->load_report_map_.empty()) {
1350
+ parent_->chand()->StopLrsCall();
1351
+ return true;
1352
+ }
1428
1353
  ScheduleNextReportLocked();
1429
- return;
1354
+ return false;
1430
1355
  }
1431
1356
  // Create a request that contains the snapshot.
1432
1357
  grpc_slice request_payload_slice =
@@ -1439,8 +1364,6 @@ void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1439
1364
  memset(&op, 0, sizeof(op));
1440
1365
  op.op = GRPC_OP_SEND_MESSAGE;
1441
1366
  op.data.send_message.send_message = parent_->send_message_payload_;
1442
- GRPC_CLOSURE_INIT(&on_report_done_, OnReportDone, this,
1443
- grpc_schedule_on_exec_ctx);
1444
1367
  grpc_call_error call_error = grpc_call_start_batch_and_execute(
1445
1368
  parent_->call_, &op, 1, &on_report_done_);
1446
1369
  if (GPR_UNLIKELY(call_error != GRPC_CALL_OK)) {
@@ -1449,38 +1372,41 @@ void XdsClient::ChannelState::LrsCallState::Reporter::SendReportLocked() {
1449
1372
  xds_client(), this, call_error);
1450
1373
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1451
1374
  }
1375
+ return false;
1452
1376
  }
1453
1377
 
1454
1378
  void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDone(
1455
1379
  void* arg, grpc_error* error) {
1456
1380
  Reporter* self = static_cast<Reporter*>(arg);
1457
- self->xds_client()->combiner_->Run(
1458
- GRPC_CLOSURE_INIT(&self->on_report_done_, OnReportDoneLocked, self,
1459
- nullptr),
1460
- GRPC_ERROR_REF(error));
1381
+ bool done;
1382
+ {
1383
+ MutexLock lock(&self->xds_client()->mu_);
1384
+ done = self->OnReportDoneLocked(GRPC_ERROR_REF(error));
1385
+ }
1386
+ if (done) self->Unref(DEBUG_LOCATION, "Reporter+report_done");
1461
1387
  }
1462
1388
 
1463
- void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1464
- void* arg, grpc_error* error) {
1465
- Reporter* self = static_cast<Reporter*>(arg);
1466
- grpc_byte_buffer_destroy(self->parent_->send_message_payload_);
1467
- self->parent_->send_message_payload_ = nullptr;
1389
+ bool XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1390
+ grpc_error* error) {
1391
+ grpc_byte_buffer_destroy(parent_->send_message_payload_);
1392
+ parent_->send_message_payload_ = nullptr;
1468
1393
  // If there are no more registered stats to report, cancel the call.
1469
- if (self->xds_client()->load_report_map_.empty()) {
1470
- self->parent_->chand()->StopLrsCall();
1471
- self->Unref(DEBUG_LOCATION, "Reporter+report_done+no_more_reporters");
1472
- return;
1394
+ if (xds_client()->load_report_map_.empty()) {
1395
+ parent_->chand()->StopLrsCall();
1396
+ GRPC_ERROR_UNREF(error);
1397
+ return true;
1473
1398
  }
1474
- if (error != GRPC_ERROR_NONE || !self->IsCurrentReporterOnCall()) {
1399
+ if (error != GRPC_ERROR_NONE || !IsCurrentReporterOnCall()) {
1400
+ GRPC_ERROR_UNREF(error);
1475
1401
  // If this reporter is no longer the current one on the call, the reason
1476
1402
  // might be that it was orphaned for a new one due to config update.
1477
- if (!self->IsCurrentReporterOnCall()) {
1478
- self->parent_->MaybeStartReportingLocked();
1403
+ if (!IsCurrentReporterOnCall()) {
1404
+ parent_->MaybeStartReportingLocked();
1479
1405
  }
1480
- self->Unref(DEBUG_LOCATION, "Reporter+report_done");
1481
- return;
1406
+ return true;
1482
1407
  }
1483
- self->ScheduleNextReportLocked();
1408
+ ScheduleNextReportLocked();
1409
+ return false;
1484
1410
  }
1485
1411
 
1486
1412
  //
@@ -1489,22 +1415,27 @@ void XdsClient::ChannelState::LrsCallState::Reporter::OnReportDoneLocked(
1489
1415
 
1490
1416
  XdsClient::ChannelState::LrsCallState::LrsCallState(
1491
1417
  RefCountedPtr<RetryableCall<LrsCallState>> parent)
1492
- : InternallyRefCounted<LrsCallState>(&grpc_xds_client_trace),
1418
+ : InternallyRefCounted<LrsCallState>(
1419
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace)
1420
+ ? "LrsCallState"
1421
+ : nullptr),
1493
1422
  parent_(std::move(parent)) {
1494
1423
  // Init the LRS call. Note that the call will progress every time there's
1495
1424
  // activity in xds_client()->interested_parties_, which is comprised of
1496
1425
  // the polling entities from client_channel.
1497
1426
  GPR_ASSERT(xds_client() != nullptr);
1498
- GPR_ASSERT(!xds_client()->server_name_.empty());
1427
+ const auto& method =
1428
+ chand()->server_.ShouldUseV3()
1429
+ ? GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V3_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS
1430
+ : GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS;
1499
1431
  call_ = grpc_channel_create_pollset_set_call(
1500
1432
  chand()->channel_, nullptr, GRPC_PROPAGATE_DEFAULTS,
1501
- xds_client()->interested_parties_,
1502
- GRPC_MDSTR_SLASH_ENVOY_DOT_SERVICE_DOT_LOAD_STATS_DOT_V2_DOT_LOADREPORTINGSERVICE_SLASH_STREAMLOADSTATS,
1503
- nullptr, GRPC_MILLIS_INF_FUTURE, nullptr);
1433
+ xds_client()->interested_parties_, method, nullptr,
1434
+ GRPC_MILLIS_INF_FUTURE, nullptr);
1504
1435
  GPR_ASSERT(call_ != nullptr);
1505
1436
  // Init the request payload.
1506
1437
  grpc_slice request_payload_slice =
1507
- xds_client()->api_.CreateLrsInitialRequest(xds_client()->server_name_);
1438
+ xds_client()->api_.CreateLrsInitialRequest(chand()->server_);
1508
1439
  send_message_payload_ =
1509
1440
  grpc_raw_byte_buffer_create(&request_payload_slice, 1);
1510
1441
  grpc_slice_unref_internal(request_payload_slice);
@@ -1540,8 +1471,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1540
1471
  Ref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked").release();
1541
1472
  GRPC_CLOSURE_INIT(&on_initial_request_sent_, OnInitialRequestSent, this,
1542
1473
  grpc_schedule_on_exec_ctx);
1543
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1544
- &on_initial_request_sent_);
1474
+ call_error = grpc_call_start_batch_and_execute(
1475
+ call_, ops, static_cast<size_t>(op - ops), &on_initial_request_sent_);
1545
1476
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1546
1477
  // Op: recv initial metadata.
1547
1478
  op = ops;
@@ -1560,8 +1491,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1560
1491
  Ref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked").release();
1561
1492
  GRPC_CLOSURE_INIT(&on_response_received_, OnResponseReceived, this,
1562
1493
  grpc_schedule_on_exec_ctx);
1563
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1564
- &on_response_received_);
1494
+ call_error = grpc_call_start_batch_and_execute(
1495
+ call_, ops, static_cast<size_t>(op - ops), &on_response_received_);
1565
1496
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1566
1497
  // Op: recv server status.
1567
1498
  op = ops;
@@ -1577,8 +1508,8 @@ XdsClient::ChannelState::LrsCallState::LrsCallState(
1577
1508
  // unreffed.
1578
1509
  GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this,
1579
1510
  grpc_schedule_on_exec_ctx);
1580
- call_error = grpc_call_start_batch_and_execute(call_, ops, (size_t)(op - ops),
1581
- &on_status_received_);
1511
+ call_error = grpc_call_start_batch_and_execute(
1512
+ call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
1582
1513
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1583
1514
  }
1584
1515
 
@@ -1599,7 +1530,7 @@ void XdsClient::ChannelState::LrsCallState::Orphan() {
1599
1530
  // on_status_received_ will complete the cancellation and clean up. Otherwise,
1600
1531
  // we are here because xds_client has to orphan a failed call, then the
1601
1532
  // following cancellation will be a no-op.
1602
- grpc_call_cancel(call_, nullptr);
1533
+ grpc_call_cancel_internal(call_);
1603
1534
  // Note that the initial ref is hold by on_status_received_. So the
1604
1535
  // corresponding unref happens in on_status_received_ instead of here.
1605
1536
  }
@@ -1626,75 +1557,74 @@ void XdsClient::ChannelState::LrsCallState::MaybeStartReportingLocked() {
1626
1557
  }
1627
1558
 
1628
1559
  void XdsClient::ChannelState::LrsCallState::OnInitialRequestSent(
1629
- void* arg, grpc_error* error) {
1560
+ void* arg, grpc_error* /*error*/) {
1630
1561
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1631
- lrs_calld->xds_client()->combiner_->Run(
1632
- GRPC_CLOSURE_INIT(&lrs_calld->on_initial_request_sent_,
1633
- OnInitialRequestSentLocked, lrs_calld, nullptr),
1634
- GRPC_ERROR_REF(error));
1562
+ {
1563
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1564
+ lrs_calld->OnInitialRequestSentLocked();
1565
+ }
1566
+ lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked");
1635
1567
  }
1636
1568
 
1637
- void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked(
1638
- void* arg, grpc_error* /*error*/) {
1639
- LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1569
+ void XdsClient::ChannelState::LrsCallState::OnInitialRequestSentLocked() {
1640
1570
  // Clear the send_message_payload_.
1641
- grpc_byte_buffer_destroy(lrs_calld->send_message_payload_);
1642
- lrs_calld->send_message_payload_ = nullptr;
1643
- lrs_calld->MaybeStartReportingLocked();
1644
- lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnInitialRequestSentLocked");
1571
+ grpc_byte_buffer_destroy(send_message_payload_);
1572
+ send_message_payload_ = nullptr;
1573
+ MaybeStartReportingLocked();
1645
1574
  }
1646
1575
 
1647
1576
  void XdsClient::ChannelState::LrsCallState::OnResponseReceived(
1648
- void* arg, grpc_error* error) {
1577
+ void* arg, grpc_error* /*error*/) {
1649
1578
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1650
- lrs_calld->xds_client()->combiner_->Run(
1651
- GRPC_CLOSURE_INIT(&lrs_calld->on_response_received_,
1652
- OnResponseReceivedLocked, lrs_calld, nullptr),
1653
- GRPC_ERROR_REF(error));
1579
+ bool done;
1580
+ {
1581
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1582
+ done = lrs_calld->OnResponseReceivedLocked();
1583
+ }
1584
+ if (done) lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked");
1654
1585
  }
1655
1586
 
1656
- void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked(
1657
- void* arg, grpc_error* /*error*/) {
1658
- LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1659
- XdsClient* xds_client = lrs_calld->xds_client();
1587
+ bool XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked() {
1660
1588
  // Empty payload means the call was cancelled.
1661
- if (!lrs_calld->IsCurrentCallOnChannel() ||
1662
- lrs_calld->recv_message_payload_ == nullptr) {
1663
- lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnResponseReceivedLocked");
1664
- return;
1589
+ if (!IsCurrentCallOnChannel() || recv_message_payload_ == nullptr) {
1590
+ return true;
1665
1591
  }
1666
1592
  // Read the response.
1667
1593
  grpc_byte_buffer_reader bbr;
1668
- grpc_byte_buffer_reader_init(&bbr, lrs_calld->recv_message_payload_);
1594
+ grpc_byte_buffer_reader_init(&bbr, recv_message_payload_);
1669
1595
  grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr);
1670
1596
  grpc_byte_buffer_reader_destroy(&bbr);
1671
- grpc_byte_buffer_destroy(lrs_calld->recv_message_payload_);
1672
- lrs_calld->recv_message_payload_ = nullptr;
1597
+ grpc_byte_buffer_destroy(recv_message_payload_);
1598
+ recv_message_payload_ = nullptr;
1673
1599
  // This anonymous lambda is a hack to avoid the usage of goto.
1674
1600
  [&]() {
1675
1601
  // Parse the response.
1602
+ bool send_all_clusters = false;
1676
1603
  std::set<std::string> new_cluster_names;
1677
1604
  grpc_millis new_load_reporting_interval;
1678
- grpc_error* parse_error = xds_client->api_.ParseLrsResponse(
1679
- response_slice, &new_cluster_names, &new_load_reporting_interval);
1605
+ grpc_error* parse_error = xds_client()->api_.ParseLrsResponse(
1606
+ response_slice, &send_all_clusters, &new_cluster_names,
1607
+ &new_load_reporting_interval);
1680
1608
  if (parse_error != GRPC_ERROR_NONE) {
1681
1609
  gpr_log(GPR_ERROR,
1682
1610
  "[xds_client %p] LRS response parsing failed. error=%s",
1683
- xds_client, grpc_error_string(parse_error));
1611
+ xds_client(), grpc_error_string(parse_error));
1684
1612
  GRPC_ERROR_UNREF(parse_error);
1685
1613
  return;
1686
1614
  }
1687
- lrs_calld->seen_response_ = true;
1615
+ seen_response_ = true;
1688
1616
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1689
- gpr_log(GPR_INFO,
1690
- "[xds_client %p] LRS response received, %" PRIuPTR
1691
- " cluster names, load_report_interval=%" PRId64 "ms",
1692
- xds_client, new_cluster_names.size(),
1693
- new_load_reporting_interval);
1617
+ gpr_log(
1618
+ GPR_INFO,
1619
+ "[xds_client %p] LRS response received, %" PRIuPTR
1620
+ " cluster names, send_all_clusters=%d, load_report_interval=%" PRId64
1621
+ "ms",
1622
+ xds_client(), new_cluster_names.size(), send_all_clusters,
1623
+ new_load_reporting_interval);
1694
1624
  size_t i = 0;
1695
1625
  for (const auto& name : new_cluster_names) {
1696
1626
  gpr_log(GPR_INFO, "[xds_client %p] cluster_name %" PRIuPTR ": %s",
1697
- xds_client, i++, name.c_str());
1627
+ xds_client(), i++, name.c_str());
1698
1628
  }
1699
1629
  }
1700
1630
  if (new_load_reporting_interval <
@@ -1705,81 +1635,76 @@ void XdsClient::ChannelState::LrsCallState::OnResponseReceivedLocked(
1705
1635
  gpr_log(GPR_INFO,
1706
1636
  "[xds_client %p] Increased load_report_interval to minimum "
1707
1637
  "value %dms",
1708
- xds_client, GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS);
1638
+ xds_client(), GRPC_XDS_MIN_CLIENT_LOAD_REPORTING_INTERVAL_MS);
1709
1639
  }
1710
1640
  }
1711
1641
  // Ignore identical update.
1712
- if (lrs_calld->cluster_names_ == new_cluster_names &&
1713
- lrs_calld->load_reporting_interval_ == new_load_reporting_interval) {
1642
+ if (send_all_clusters == send_all_clusters_ &&
1643
+ cluster_names_ == new_cluster_names &&
1644
+ load_reporting_interval_ == new_load_reporting_interval) {
1714
1645
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1715
1646
  gpr_log(GPR_INFO,
1716
1647
  "[xds_client %p] Incoming LRS response identical to current, "
1717
1648
  "ignoring.",
1718
- xds_client);
1649
+ xds_client());
1719
1650
  }
1720
1651
  return;
1721
1652
  }
1722
1653
  // Stop current load reporting (if any) to adopt the new config.
1723
- lrs_calld->reporter_.reset();
1654
+ reporter_.reset();
1724
1655
  // Record the new config.
1725
- lrs_calld->cluster_names_ = std::move(new_cluster_names);
1726
- lrs_calld->load_reporting_interval_ = new_load_reporting_interval;
1656
+ send_all_clusters_ = send_all_clusters;
1657
+ cluster_names_ = std::move(new_cluster_names);
1658
+ load_reporting_interval_ = new_load_reporting_interval;
1727
1659
  // Try starting sending load report.
1728
- lrs_calld->MaybeStartReportingLocked();
1660
+ MaybeStartReportingLocked();
1729
1661
  }();
1730
1662
  grpc_slice_unref_internal(response_slice);
1731
- if (xds_client->shutting_down_) {
1732
- lrs_calld->Unref(DEBUG_LOCATION,
1733
- "LRS+OnResponseReceivedLocked+xds_shutdown");
1734
- return;
1735
- }
1663
+ if (xds_client()->shutting_down_) return true;
1736
1664
  // Keep listening for LRS config updates.
1737
1665
  grpc_op op;
1738
1666
  memset(&op, 0, sizeof(op));
1739
1667
  op.op = GRPC_OP_RECV_MESSAGE;
1740
- op.data.recv_message.recv_message = &lrs_calld->recv_message_payload_;
1668
+ op.data.recv_message.recv_message = &recv_message_payload_;
1741
1669
  op.flags = 0;
1742
1670
  op.reserved = nullptr;
1743
- GPR_ASSERT(lrs_calld->call_ != nullptr);
1671
+ GPR_ASSERT(call_ != nullptr);
1744
1672
  // Reuse the "OnResponseReceivedLocked" ref taken in ctor.
1745
- GRPC_CLOSURE_INIT(&lrs_calld->on_response_received_, OnResponseReceived,
1746
- lrs_calld, grpc_schedule_on_exec_ctx);
1747
- const grpc_call_error call_error = grpc_call_start_batch_and_execute(
1748
- lrs_calld->call_, &op, 1, &lrs_calld->on_response_received_);
1673
+ const grpc_call_error call_error =
1674
+ grpc_call_start_batch_and_execute(call_, &op, 1, &on_response_received_);
1749
1675
  GPR_ASSERT(GRPC_CALL_OK == call_error);
1676
+ return false;
1750
1677
  }
1751
1678
 
1752
1679
  void XdsClient::ChannelState::LrsCallState::OnStatusReceived(
1753
1680
  void* arg, grpc_error* error) {
1754
1681
  LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1755
- lrs_calld->xds_client()->combiner_->Run(
1756
- GRPC_CLOSURE_INIT(&lrs_calld->on_status_received_, OnStatusReceivedLocked,
1757
- lrs_calld, nullptr),
1758
- GRPC_ERROR_REF(error));
1682
+ {
1683
+ MutexLock lock(&lrs_calld->xds_client()->mu_);
1684
+ lrs_calld->OnStatusReceivedLocked(GRPC_ERROR_REF(error));
1685
+ }
1686
+ lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnStatusReceivedLocked");
1759
1687
  }
1760
1688
 
1761
1689
  void XdsClient::ChannelState::LrsCallState::OnStatusReceivedLocked(
1762
- void* arg, grpc_error* error) {
1763
- LrsCallState* lrs_calld = static_cast<LrsCallState*>(arg);
1764
- XdsClient* xds_client = lrs_calld->xds_client();
1765
- ChannelState* chand = lrs_calld->chand();
1766
- GPR_ASSERT(lrs_calld->call_ != nullptr);
1690
+ grpc_error* error) {
1691
+ GPR_ASSERT(call_ != nullptr);
1767
1692
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1768
- char* status_details = grpc_slice_to_c_string(lrs_calld->status_details_);
1693
+ char* status_details = grpc_slice_to_c_string(status_details_);
1769
1694
  gpr_log(GPR_INFO,
1770
1695
  "[xds_client %p] LRS call status received. Status = %d, details "
1771
1696
  "= '%s', (chand: %p, calld: %p, call: %p), error '%s'",
1772
- xds_client, lrs_calld->status_code_, status_details, chand,
1773
- lrs_calld, lrs_calld->call_, grpc_error_string(error));
1697
+ xds_client(), status_code_, status_details, chand(), this, call_,
1698
+ grpc_error_string(error));
1774
1699
  gpr_free(status_details);
1775
1700
  }
1776
1701
  // Ignore status from a stale call.
1777
- if (lrs_calld->IsCurrentCallOnChannel()) {
1778
- GPR_ASSERT(!xds_client->shutting_down_);
1702
+ if (IsCurrentCallOnChannel()) {
1703
+ GPR_ASSERT(!xds_client()->shutting_down_);
1779
1704
  // Try to restart the call.
1780
- lrs_calld->parent_->OnCallFinishedLocked();
1705
+ parent_->OnCallFinishedLocked();
1781
1706
  }
1782
- lrs_calld->Unref(DEBUG_LOCATION, "LRS+OnStatusReceivedLocked");
1707
+ GRPC_ERROR_UNREF(error);
1783
1708
  }
1784
1709
 
1785
1710
  bool XdsClient::ChannelState::LrsCallState::IsCurrentCallOnChannel() const {
@@ -1795,28 +1720,28 @@ bool XdsClient::ChannelState::LrsCallState::IsCurrentCallOnChannel() const {
1795
1720
 
1796
1721
  namespace {
1797
1722
 
1798
- grpc_millis GetRequestTimeout(const grpc_channel_args& args) {
1723
+ grpc_millis GetRequestTimeout() {
1799
1724
  return grpc_channel_args_find_integer(
1800
- &args, GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS,
1725
+ g_channel_args, GRPC_ARG_XDS_RESOURCE_DOES_NOT_EXIST_TIMEOUT_MS,
1801
1726
  {15000, 0, INT_MAX});
1802
1727
  }
1803
1728
 
1804
1729
  } // namespace
1805
1730
 
1806
- XdsClient::XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
1807
- StringView server_name,
1808
- std::unique_ptr<ServiceConfigWatcherInterface> watcher,
1809
- const grpc_channel_args& channel_args, grpc_error** error)
1810
- : InternallyRefCounted<XdsClient>(&grpc_xds_client_trace),
1811
- request_timeout_(GetRequestTimeout(channel_args)),
1812
- combiner_(GRPC_COMBINER_REF(combiner, "xds_client")),
1813
- interested_parties_(interested_parties),
1814
- bootstrap_(
1815
- XdsBootstrap::ReadFromFile(this, &grpc_xds_client_trace, error)),
1731
+ XdsClient::XdsClient(grpc_error** error)
1732
+ : DualRefCounted<XdsClient>(
1733
+ GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_refcount_trace) ? "XdsClient"
1734
+ : nullptr),
1735
+ request_timeout_(GetRequestTimeout()),
1736
+ interested_parties_(grpc_pollset_set_create()),
1737
+ bootstrap_(XdsBootstrap::Create(this, &grpc_xds_client_trace,
1738
+ g_fallback_bootstrap_config, error)),
1739
+ certificate_provider_store_(MakeOrphanable<CertificateProviderStore>(
1740
+ bootstrap_ == nullptr
1741
+ ? CertificateProviderStore::PluginDefinitionMap()
1742
+ : bootstrap_->certificate_providers())),
1816
1743
  api_(this, &grpc_xds_client_trace,
1817
- bootstrap_ == nullptr ? nullptr : bootstrap_->node()),
1818
- server_name_(server_name),
1819
- service_config_watcher_(std::move(watcher)) {
1744
+ bootstrap_ == nullptr ? nullptr : bootstrap_->node()) {
1820
1745
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1821
1746
  gpr_log(GPR_INFO, "[xds_client %p] creating xds client", this);
1822
1747
  }
@@ -1825,72 +1750,165 @@ XdsClient::XdsClient(Combiner* combiner, grpc_pollset_set* interested_parties,
1825
1750
  this, grpc_error_string(*error));
1826
1751
  return;
1827
1752
  }
1828
- if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1829
- gpr_log(GPR_INFO, "[xds_client %p] creating channel to %s", this,
1830
- bootstrap_->server().server_uri.c_str());
1831
- }
1832
- grpc_channel_args* new_args = BuildXdsChannelArgs(channel_args);
1833
- grpc_channel* channel = CreateXdsChannel(*bootstrap_, *new_args, error);
1834
- grpc_channel_args_destroy(new_args);
1835
- if (*error != GRPC_ERROR_NONE) {
1836
- gpr_log(GPR_ERROR, "[xds_client %p] failed to create xds channel: %s", this,
1837
- grpc_error_string(*error));
1838
- return;
1839
- }
1753
+ // Create ChannelState object.
1840
1754
  chand_ = MakeOrphanable<ChannelState>(
1841
- Ref(DEBUG_LOCATION, "XdsClient+ChannelState"), channel);
1842
- if (service_config_watcher_ != nullptr) {
1843
- chand_->Subscribe(XdsApi::kLdsTypeUrl, std::string(server_name));
1844
- }
1755
+ WeakRef(DEBUG_LOCATION, "XdsClient+ChannelState"), bootstrap_->server());
1845
1756
  }
1846
1757
 
1847
1758
  XdsClient::~XdsClient() {
1848
1759
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1849
1760
  gpr_log(GPR_INFO, "[xds_client %p] destroying xds client", this);
1850
1761
  }
1851
- GRPC_COMBINER_UNREF(combiner_, "xds_client");
1762
+ grpc_pollset_set_destroy(interested_parties_);
1763
+ }
1764
+
1765
+ void XdsClient::AddChannelzLinkage(
1766
+ channelz::ChannelNode* parent_channelz_node) {
1767
+ channelz::ChannelNode* xds_channelz_node =
1768
+ grpc_channel_get_channelz_node(chand_->channel());
1769
+ if (xds_channelz_node != nullptr) {
1770
+ parent_channelz_node->AddChildChannel(xds_channelz_node->uuid());
1771
+ }
1772
+ }
1773
+
1774
+ void XdsClient::RemoveChannelzLinkage(
1775
+ channelz::ChannelNode* parent_channelz_node) {
1776
+ channelz::ChannelNode* xds_channelz_node =
1777
+ grpc_channel_get_channelz_node(chand_->channel());
1778
+ if (xds_channelz_node != nullptr) {
1779
+ parent_channelz_node->RemoveChildChannel(xds_channelz_node->uuid());
1780
+ }
1852
1781
  }
1853
1782
 
1854
1783
  void XdsClient::Orphan() {
1855
1784
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1856
1785
  gpr_log(GPR_INFO, "[xds_client %p] shutting down xds client", this);
1857
1786
  }
1858
- shutting_down_ = true;
1859
- chand_.reset();
1860
- // We do not clear cluster_map_ and endpoint_map_ if the xds client was
1861
- // created by the XdsResolver because the maps contain refs for watchers which
1862
- // in turn hold refs to the loadbalancing policies. At this point, it is
1863
- // possible for ADS calls to be in progress. Unreffing the loadbalancing
1864
- // policies before those calls are done would lead to issues such as
1865
- // https://github.com/grpc/grpc/issues/20928.
1866
- if (service_config_watcher_ != nullptr) {
1867
- cluster_map_.clear();
1868
- endpoint_map_.clear();
1787
+ {
1788
+ MutexLock lock(g_mu);
1789
+ if (g_xds_client == this) g_xds_client = nullptr;
1790
+ }
1791
+ {
1792
+ MutexLock lock(&mu_);
1793
+ shutting_down_ = true;
1794
+ // Orphan ChannelState object.
1795
+ chand_.reset();
1796
+ // We do not clear cluster_map_ and endpoint_map_ if the xds client was
1797
+ // created by the XdsResolver because the maps contain refs for watchers
1798
+ // which in turn hold refs to the loadbalancing policies. At this point, it
1799
+ // is possible for ADS calls to be in progress. Unreffing the loadbalancing
1800
+ // policies before those calls are done would lead to issues such as
1801
+ // https://github.com/grpc/grpc/issues/20928.
1802
+ if (!listener_map_.empty()) {
1803
+ cluster_map_.clear();
1804
+ endpoint_map_.clear();
1805
+ }
1806
+ }
1807
+ }
1808
+
1809
+ void XdsClient::WatchListenerData(
1810
+ absl::string_view listener_name,
1811
+ std::unique_ptr<ListenerWatcherInterface> watcher) {
1812
+ std::string listener_name_str = std::string(listener_name);
1813
+ MutexLock lock(&mu_);
1814
+ ListenerState& listener_state = listener_map_[listener_name_str];
1815
+ ListenerWatcherInterface* w = watcher.get();
1816
+ listener_state.watchers[w] = std::move(watcher);
1817
+ // If we've already received an LDS update, notify the new watcher
1818
+ // immediately.
1819
+ if (listener_state.update.has_value()) {
1820
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1821
+ gpr_log(GPR_INFO, "[xds_client %p] returning cached listener data for %s",
1822
+ this, listener_name_str.c_str());
1823
+ }
1824
+ w->OnListenerChanged(*listener_state.update);
1825
+ }
1826
+ chand_->Subscribe(XdsApi::kLdsTypeUrl, listener_name_str);
1827
+ }
1828
+
1829
+ void XdsClient::CancelListenerDataWatch(absl::string_view listener_name,
1830
+ ListenerWatcherInterface* watcher,
1831
+ bool delay_unsubscription) {
1832
+ MutexLock lock(&mu_);
1833
+ if (shutting_down_) return;
1834
+ std::string listener_name_str = std::string(listener_name);
1835
+ ListenerState& listener_state = listener_map_[listener_name_str];
1836
+ auto it = listener_state.watchers.find(watcher);
1837
+ if (it != listener_state.watchers.end()) {
1838
+ listener_state.watchers.erase(it);
1839
+ if (listener_state.watchers.empty()) {
1840
+ listener_map_.erase(listener_name_str);
1841
+ chand_->Unsubscribe(XdsApi::kLdsTypeUrl, listener_name_str,
1842
+ delay_unsubscription);
1843
+ }
1844
+ }
1845
+ }
1846
+
1847
+ void XdsClient::WatchRouteConfigData(
1848
+ absl::string_view route_config_name,
1849
+ std::unique_ptr<RouteConfigWatcherInterface> watcher) {
1850
+ std::string route_config_name_str = std::string(route_config_name);
1851
+ MutexLock lock(&mu_);
1852
+ RouteConfigState& route_config_state =
1853
+ route_config_map_[route_config_name_str];
1854
+ RouteConfigWatcherInterface* w = watcher.get();
1855
+ route_config_state.watchers[w] = std::move(watcher);
1856
+ // If we've already received an RDS update, notify the new watcher
1857
+ // immediately.
1858
+ if (route_config_state.update.has_value()) {
1859
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1860
+ gpr_log(GPR_INFO,
1861
+ "[xds_client %p] returning cached route config data for %s", this,
1862
+ route_config_name_str.c_str());
1863
+ }
1864
+ w->OnRouteConfigChanged(*route_config_state.update);
1865
+ }
1866
+ chand_->Subscribe(XdsApi::kRdsTypeUrl, route_config_name_str);
1867
+ }
1868
+
1869
+ void XdsClient::CancelRouteConfigDataWatch(absl::string_view route_config_name,
1870
+ RouteConfigWatcherInterface* watcher,
1871
+ bool delay_unsubscription) {
1872
+ MutexLock lock(&mu_);
1873
+ if (shutting_down_) return;
1874
+ std::string route_config_name_str = std::string(route_config_name);
1875
+ RouteConfigState& route_config_state =
1876
+ route_config_map_[route_config_name_str];
1877
+ auto it = route_config_state.watchers.find(watcher);
1878
+ if (it != route_config_state.watchers.end()) {
1879
+ route_config_state.watchers.erase(it);
1880
+ if (route_config_state.watchers.empty()) {
1881
+ route_config_map_.erase(route_config_name_str);
1882
+ chand_->Unsubscribe(XdsApi::kRdsTypeUrl, route_config_name_str,
1883
+ delay_unsubscription);
1884
+ }
1869
1885
  }
1870
- Unref(DEBUG_LOCATION, "XdsClient::Orphan()");
1871
1886
  }
1872
1887
 
1873
1888
  void XdsClient::WatchClusterData(
1874
- StringView cluster_name, std::unique_ptr<ClusterWatcherInterface> watcher) {
1889
+ absl::string_view cluster_name,
1890
+ std::unique_ptr<ClusterWatcherInterface> watcher) {
1875
1891
  std::string cluster_name_str = std::string(cluster_name);
1892
+ MutexLock lock(&mu_);
1876
1893
  ClusterState& cluster_state = cluster_map_[cluster_name_str];
1877
1894
  ClusterWatcherInterface* w = watcher.get();
1878
1895
  cluster_state.watchers[w] = std::move(watcher);
1879
- // If we've already received an CDS update, notify the new watcher
1896
+ // If we've already received a CDS update, notify the new watcher
1880
1897
  // immediately.
1881
1898
  if (cluster_state.update.has_value()) {
1882
1899
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1883
1900
  gpr_log(GPR_INFO, "[xds_client %p] returning cached cluster data for %s",
1884
- this, StringViewToCString(cluster_name).get());
1901
+ this, cluster_name_str.c_str());
1885
1902
  }
1886
1903
  w->OnClusterChanged(cluster_state.update.value());
1887
1904
  }
1888
1905
  chand_->Subscribe(XdsApi::kCdsTypeUrl, cluster_name_str);
1889
1906
  }
1890
1907
 
1891
- void XdsClient::CancelClusterDataWatch(StringView cluster_name,
1908
+ void XdsClient::CancelClusterDataWatch(absl::string_view cluster_name,
1892
1909
  ClusterWatcherInterface* watcher,
1893
1910
  bool delay_unsubscription) {
1911
+ MutexLock lock(&mu_);
1894
1912
  if (shutting_down_) return;
1895
1913
  std::string cluster_name_str = std::string(cluster_name);
1896
1914
  ClusterState& cluster_state = cluster_map_[cluster_name_str];
@@ -1906,9 +1924,10 @@ void XdsClient::CancelClusterDataWatch(StringView cluster_name,
1906
1924
  }
1907
1925
 
1908
1926
  void XdsClient::WatchEndpointData(
1909
- StringView eds_service_name,
1927
+ absl::string_view eds_service_name,
1910
1928
  std::unique_ptr<EndpointWatcherInterface> watcher) {
1911
1929
  std::string eds_service_name_str = std::string(eds_service_name);
1930
+ MutexLock lock(&mu_);
1912
1931
  EndpointState& endpoint_state = endpoint_map_[eds_service_name_str];
1913
1932
  EndpointWatcherInterface* w = watcher.get();
1914
1933
  endpoint_state.watchers[w] = std::move(watcher);
@@ -1917,16 +1936,17 @@ void XdsClient::WatchEndpointData(
1917
1936
  if (endpoint_state.update.has_value()) {
1918
1937
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
1919
1938
  gpr_log(GPR_INFO, "[xds_client %p] returning cached endpoint data for %s",
1920
- this, StringViewToCString(eds_service_name).get());
1939
+ this, eds_service_name_str.c_str());
1921
1940
  }
1922
1941
  w->OnEndpointChanged(endpoint_state.update.value());
1923
1942
  }
1924
1943
  chand_->Subscribe(XdsApi::kEdsTypeUrl, eds_service_name_str);
1925
1944
  }
1926
1945
 
1927
- void XdsClient::CancelEndpointDataWatch(StringView eds_service_name,
1946
+ void XdsClient::CancelEndpointDataWatch(absl::string_view eds_service_name,
1928
1947
  EndpointWatcherInterface* watcher,
1929
1948
  bool delay_unsubscription) {
1949
+ MutexLock lock(&mu_);
1930
1950
  if (shutting_down_) return;
1931
1951
  std::string eds_service_name_str = std::string(eds_service_name);
1932
1952
  EndpointState& endpoint_state = endpoint_map_[eds_service_name_str];
@@ -1942,119 +1962,160 @@ void XdsClient::CancelEndpointDataWatch(StringView eds_service_name,
1942
1962
  }
1943
1963
 
1944
1964
  RefCountedPtr<XdsClusterDropStats> XdsClient::AddClusterDropStats(
1945
- StringView lrs_server, StringView cluster_name,
1946
- StringView eds_service_name) {
1965
+ absl::string_view lrs_server, absl::string_view cluster_name,
1966
+ absl::string_view eds_service_name) {
1947
1967
  // TODO(roth): When we add support for direct federation, use the
1948
1968
  // server name specified in lrs_server.
1949
1969
  auto key =
1950
1970
  std::make_pair(std::string(cluster_name), std::string(eds_service_name));
1951
- // We jump through some hoops here to make sure that the StringViews
1971
+ MutexLock lock(&mu_);
1972
+ // We jump through some hoops here to make sure that the absl::string_views
1952
1973
  // stored in the XdsClusterDropStats object point to the strings
1953
1974
  // in the load_report_map_ key, so that they have the same lifetime.
1954
1975
  auto it = load_report_map_
1955
1976
  .emplace(std::make_pair(std::move(key), LoadReportState()))
1956
1977
  .first;
1957
- auto cluster_drop_stats = MakeRefCounted<XdsClusterDropStats>(
1958
- Ref(DEBUG_LOCATION, "DropStats"), lrs_server,
1959
- it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/);
1960
- it->second.drop_stats.insert(cluster_drop_stats.get());
1978
+ LoadReportState& load_report_state = it->second;
1979
+ RefCountedPtr<XdsClusterDropStats> cluster_drop_stats;
1980
+ if (load_report_state.drop_stats != nullptr) {
1981
+ cluster_drop_stats = load_report_state.drop_stats->RefIfNonZero();
1982
+ }
1983
+ if (cluster_drop_stats == nullptr) {
1984
+ if (load_report_state.drop_stats != nullptr) {
1985
+ load_report_state.deleted_drop_stats +=
1986
+ load_report_state.drop_stats->GetSnapshotAndReset();
1987
+ }
1988
+ cluster_drop_stats = MakeRefCounted<XdsClusterDropStats>(
1989
+ Ref(DEBUG_LOCATION, "DropStats"), lrs_server,
1990
+ it->first.first /*cluster_name*/,
1991
+ it->first.second /*eds_service_name*/);
1992
+ load_report_state.drop_stats = cluster_drop_stats.get();
1993
+ }
1961
1994
  chand_->MaybeStartLrsCall();
1962
1995
  return cluster_drop_stats;
1963
1996
  }
1964
1997
 
1965
1998
  void XdsClient::RemoveClusterDropStats(
1966
- StringView /*lrs_server*/, StringView cluster_name,
1967
- StringView eds_service_name, XdsClusterDropStats* cluster_drop_stats) {
1968
- auto load_report_it = load_report_map_.find(
1969
- std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
1970
- if (load_report_it == load_report_map_.end()) return;
1971
- LoadReportState& load_report_state = load_report_it->second;
1999
+ absl::string_view /*lrs_server*/, absl::string_view cluster_name,
2000
+ absl::string_view eds_service_name,
2001
+ XdsClusterDropStats* cluster_drop_stats) {
2002
+ MutexLock lock(&mu_);
1972
2003
  // TODO(roth): When we add support for direct federation, use the
1973
2004
  // server name specified in lrs_server.
1974
- auto it = load_report_state.drop_stats.find(cluster_drop_stats);
1975
- if (it != load_report_state.drop_stats.end()) {
1976
- // Record final drop stats in deleted_drop_stats, which will be
2005
+ auto it = load_report_map_.find(
2006
+ std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
2007
+ if (it == load_report_map_.end()) return;
2008
+ LoadReportState& load_report_state = it->second;
2009
+ if (load_report_state.drop_stats == cluster_drop_stats) {
2010
+ // Record final snapshot in deleted_drop_stats, which will be
1977
2011
  // added to the next load report.
1978
- for (const auto& p : cluster_drop_stats->GetSnapshotAndReset()) {
1979
- load_report_state.deleted_drop_stats[p.first] += p.second;
1980
- }
1981
- load_report_state.drop_stats.erase(it);
2012
+ load_report_state.deleted_drop_stats +=
2013
+ load_report_state.drop_stats->GetSnapshotAndReset();
2014
+ load_report_state.drop_stats = nullptr;
1982
2015
  }
1983
2016
  }
1984
2017
 
1985
2018
  RefCountedPtr<XdsClusterLocalityStats> XdsClient::AddClusterLocalityStats(
1986
- StringView lrs_server, StringView cluster_name, StringView eds_service_name,
2019
+ absl::string_view lrs_server, absl::string_view cluster_name,
2020
+ absl::string_view eds_service_name,
1987
2021
  RefCountedPtr<XdsLocalityName> locality) {
1988
2022
  // TODO(roth): When we add support for direct federation, use the
1989
2023
  // server name specified in lrs_server.
1990
2024
  auto key =
1991
2025
  std::make_pair(std::string(cluster_name), std::string(eds_service_name));
1992
- // We jump through some hoops here to make sure that the StringViews
2026
+ MutexLock lock(&mu_);
2027
+ // We jump through some hoops here to make sure that the absl::string_views
1993
2028
  // stored in the XdsClusterLocalityStats object point to the strings
1994
2029
  // in the load_report_map_ key, so that they have the same lifetime.
1995
2030
  auto it = load_report_map_
1996
2031
  .emplace(std::make_pair(std::move(key), LoadReportState()))
1997
2032
  .first;
1998
- auto cluster_locality_stats = MakeRefCounted<XdsClusterLocalityStats>(
1999
- Ref(DEBUG_LOCATION, "LocalityStats"), lrs_server,
2000
- it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/,
2001
- locality);
2002
- it->second.locality_stats[std::move(locality)].locality_stats.insert(
2003
- cluster_locality_stats.get());
2033
+ LoadReportState& load_report_state = it->second;
2034
+ LoadReportState::LocalityState& locality_state =
2035
+ load_report_state.locality_stats[locality];
2036
+ RefCountedPtr<XdsClusterLocalityStats> cluster_locality_stats;
2037
+ if (locality_state.locality_stats != nullptr) {
2038
+ cluster_locality_stats = locality_state.locality_stats->RefIfNonZero();
2039
+ }
2040
+ if (cluster_locality_stats == nullptr) {
2041
+ if (locality_state.locality_stats != nullptr) {
2042
+ locality_state.deleted_locality_stats +=
2043
+ locality_state.locality_stats->GetSnapshotAndReset();
2044
+ }
2045
+ cluster_locality_stats = MakeRefCounted<XdsClusterLocalityStats>(
2046
+ Ref(DEBUG_LOCATION, "LocalityStats"), lrs_server,
2047
+ it->first.first /*cluster_name*/, it->first.second /*eds_service_name*/,
2048
+ std::move(locality));
2049
+ locality_state.locality_stats = cluster_locality_stats.get();
2050
+ }
2004
2051
  chand_->MaybeStartLrsCall();
2005
2052
  return cluster_locality_stats;
2006
2053
  }
2007
2054
 
2008
2055
  void XdsClient::RemoveClusterLocalityStats(
2009
- StringView /*lrs_server*/, StringView cluster_name,
2010
- StringView eds_service_name, const RefCountedPtr<XdsLocalityName>& locality,
2056
+ absl::string_view /*lrs_server*/, absl::string_view cluster_name,
2057
+ absl::string_view eds_service_name,
2058
+ const RefCountedPtr<XdsLocalityName>& locality,
2011
2059
  XdsClusterLocalityStats* cluster_locality_stats) {
2012
- auto load_report_it = load_report_map_.find(
2013
- std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
2014
- if (load_report_it == load_report_map_.end()) return;
2015
- LoadReportState& load_report_state = load_report_it->second;
2060
+ MutexLock lock(&mu_);
2016
2061
  // TODO(roth): When we add support for direct federation, use the
2017
2062
  // server name specified in lrs_server.
2063
+ auto it = load_report_map_.find(
2064
+ std::make_pair(std::string(cluster_name), std::string(eds_service_name)));
2065
+ if (it == load_report_map_.end()) return;
2066
+ LoadReportState& load_report_state = it->second;
2018
2067
  auto locality_it = load_report_state.locality_stats.find(locality);
2019
2068
  if (locality_it == load_report_state.locality_stats.end()) return;
2020
- auto& locality_set = locality_it->second.locality_stats;
2021
- auto it = locality_set.find(cluster_locality_stats);
2022
- if (it != locality_set.end()) {
2069
+ LoadReportState::LocalityState& locality_state = locality_it->second;
2070
+ if (locality_state.locality_stats == cluster_locality_stats) {
2023
2071
  // Record final snapshot in deleted_locality_stats, which will be
2024
2072
  // added to the next load report.
2025
- locality_it->second.deleted_locality_stats.emplace_back(
2026
- cluster_locality_stats->GetSnapshotAndReset());
2027
- locality_set.erase(it);
2073
+ locality_state.deleted_locality_stats +=
2074
+ locality_state.locality_stats->GetSnapshotAndReset();
2075
+ locality_state.locality_stats = nullptr;
2028
2076
  }
2029
2077
  }
2030
2078
 
2031
2079
  void XdsClient::ResetBackoff() {
2080
+ MutexLock lock(&mu_);
2032
2081
  if (chand_ != nullptr) {
2033
2082
  grpc_channel_reset_connect_backoff(chand_->channel());
2034
2083
  }
2035
2084
  }
2036
2085
 
2037
- grpc_error* XdsClient::CreateServiceConfig(
2038
- const std::string& cluster_name,
2039
- RefCountedPtr<ServiceConfig>* service_config) const {
2040
- char* json;
2041
- gpr_asprintf(&json,
2042
- "{\n"
2043
- " \"loadBalancingConfig\":[\n"
2044
- " { \"cds_experimental\":{\n"
2045
- " \"cluster\": \"%s\"\n"
2046
- " } }\n"
2047
- " ]\n"
2048
- "}",
2049
- cluster_name.c_str());
2050
- grpc_error* error = GRPC_ERROR_NONE;
2051
- *service_config = ServiceConfig::Create(json, &error);
2052
- gpr_free(json);
2053
- return error;
2054
- }
2055
-
2056
- XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2057
- const std::set<std::string>& clusters) {
2086
+ void XdsClient::NotifyOnErrorLocked(grpc_error* error) {
2087
+ for (const auto& p : listener_map_) {
2088
+ const ListenerState& listener_state = p.second;
2089
+ for (const auto& p : listener_state.watchers) {
2090
+ p.first->OnError(GRPC_ERROR_REF(error));
2091
+ }
2092
+ }
2093
+ for (const auto& p : route_config_map_) {
2094
+ const RouteConfigState& route_config_state = p.second;
2095
+ for (const auto& p : route_config_state.watchers) {
2096
+ p.first->OnError(GRPC_ERROR_REF(error));
2097
+ }
2098
+ }
2099
+ for (const auto& p : cluster_map_) {
2100
+ const ClusterState& cluster_state = p.second;
2101
+ for (const auto& p : cluster_state.watchers) {
2102
+ p.first->OnError(GRPC_ERROR_REF(error));
2103
+ }
2104
+ }
2105
+ for (const auto& p : endpoint_map_) {
2106
+ const EndpointState& endpoint_state = p.second;
2107
+ for (const auto& p : endpoint_state.watchers) {
2108
+ p.first->OnError(GRPC_ERROR_REF(error));
2109
+ }
2110
+ }
2111
+ GRPC_ERROR_UNREF(error);
2112
+ }
2113
+
2114
+ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshotLocked(
2115
+ bool send_all_clusters, const std::set<std::string>& clusters) {
2116
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2117
+ gpr_log(GPR_INFO, "[xds_client %p] start building load report", this);
2118
+ }
2058
2119
  XdsApi::ClusterLoadReportMap snapshot_map;
2059
2120
  for (auto load_report_it = load_report_map_.begin();
2060
2121
  load_report_it != load_report_map_.end();) {
@@ -2069,13 +2130,18 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2069
2130
  // asking for the data in the future, we don't incorrectly include
2070
2131
  // data from previous reporting intervals in that future report.
2071
2132
  const bool record_stats =
2072
- clusters.find(cluster_key.first) != clusters.end();
2133
+ send_all_clusters || clusters.find(cluster_key.first) != clusters.end();
2073
2134
  XdsApi::ClusterLoadReport snapshot;
2074
2135
  // Aggregate drop stats.
2075
2136
  snapshot.dropped_requests = std::move(load_report.deleted_drop_stats);
2076
- for (auto& drop_stats : load_report.drop_stats) {
2077
- for (const auto& p : drop_stats->GetSnapshotAndReset()) {
2078
- snapshot.dropped_requests[p.first] += p.second;
2137
+ if (load_report.drop_stats != nullptr) {
2138
+ snapshot.dropped_requests +=
2139
+ load_report.drop_stats->GetSnapshotAndReset();
2140
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2141
+ gpr_log(GPR_INFO,
2142
+ "[xds_client %p] cluster=%s eds_service_name=%s drop_stats=%p",
2143
+ this, cluster_key.first.c_str(), cluster_key.second.c_str(),
2144
+ load_report.drop_stats);
2079
2145
  }
2080
2146
  }
2081
2147
  // Aggregate locality stats.
@@ -2085,34 +2151,39 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2085
2151
  auto& locality_state = it->second;
2086
2152
  XdsClusterLocalityStats::Snapshot& locality_snapshot =
2087
2153
  snapshot.locality_stats[locality_name];
2088
- for (auto& locality_stats : locality_state.locality_stats) {
2089
- locality_snapshot += locality_stats->GetSnapshotAndReset();
2090
- }
2091
- // Add final snapshots from recently deleted locality stats objects.
2092
- for (auto& deleted_locality_stats :
2093
- locality_state.deleted_locality_stats) {
2094
- locality_snapshot += deleted_locality_stats;
2154
+ locality_snapshot = std::move(locality_state.deleted_locality_stats);
2155
+ if (locality_state.locality_stats != nullptr) {
2156
+ locality_snapshot +=
2157
+ locality_state.locality_stats->GetSnapshotAndReset();
2158
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_client_trace)) {
2159
+ gpr_log(GPR_INFO,
2160
+ "[xds_client %p] cluster=%s eds_service_name=%s "
2161
+ "locality=%s locality_stats=%p",
2162
+ this, cluster_key.first.c_str(), cluster_key.second.c_str(),
2163
+ locality_name->AsHumanReadableString().c_str(),
2164
+ locality_state.locality_stats);
2165
+ }
2095
2166
  }
2096
- locality_state.deleted_locality_stats.clear();
2097
2167
  // If the only thing left in this entry was final snapshots from
2098
2168
  // deleted locality stats objects, remove the entry.
2099
- if (locality_state.locality_stats.empty()) {
2169
+ if (locality_state.locality_stats == nullptr) {
2100
2170
  it = load_report.locality_stats.erase(it);
2101
2171
  } else {
2102
2172
  ++it;
2103
2173
  }
2104
2174
  }
2175
+ // Compute load report interval.
2176
+ const grpc_millis now = ExecCtx::Get()->Now();
2177
+ snapshot.load_report_interval = now - load_report.last_report_time;
2178
+ load_report.last_report_time = now;
2179
+ // Record snapshot.
2105
2180
  if (record_stats) {
2106
- // Compute load report interval.
2107
- const grpc_millis now = ExecCtx::Get()->Now();
2108
- snapshot.load_report_interval = now - load_report.last_report_time;
2109
- load_report.last_report_time = now;
2110
- // Record snapshot.
2111
2181
  snapshot_map[cluster_key] = std::move(snapshot);
2112
2182
  }
2113
2183
  // If the only thing left in this entry was final snapshots from
2114
2184
  // deleted stats objects, remove the entry.
2115
- if (load_report.locality_stats.empty() && load_report.drop_stats.empty()) {
2185
+ if (load_report.locality_stats.empty() &&
2186
+ load_report.drop_stats == nullptr) {
2116
2187
  load_report_it = load_report_map_.erase(load_report_it);
2117
2188
  } else {
2118
2189
  ++load_report_it;
@@ -2121,54 +2192,48 @@ XdsApi::ClusterLoadReportMap XdsClient::BuildLoadReportSnapshot(
2121
2192
  return snapshot_map;
2122
2193
  }
2123
2194
 
2124
- void XdsClient::NotifyOnError(grpc_error* error) {
2125
- if (service_config_watcher_ != nullptr) {
2126
- service_config_watcher_->OnError(GRPC_ERROR_REF(error));
2127
- }
2128
- for (const auto& p : cluster_map_) {
2129
- const ClusterState& cluster_state = p.second;
2130
- for (const auto& p : cluster_state.watchers) {
2131
- p.first->OnError(GRPC_ERROR_REF(error));
2132
- }
2133
- }
2134
- for (const auto& p : endpoint_map_) {
2135
- const EndpointState& endpoint_state = p.second;
2136
- for (const auto& p : endpoint_state.watchers) {
2137
- p.first->OnError(GRPC_ERROR_REF(error));
2138
- }
2139
- }
2140
- GRPC_ERROR_UNREF(error);
2141
- }
2195
+ //
2196
+ // accessors for global state
2197
+ //
2142
2198
 
2143
- void* XdsClient::ChannelArgCopy(void* p) {
2144
- XdsClient* xds_client = static_cast<XdsClient*>(p);
2145
- xds_client->Ref(DEBUG_LOCATION, "channel arg").release();
2146
- return p;
2199
+ void XdsClientGlobalInit() { g_mu = new Mutex; }
2200
+
2201
+ void XdsClientGlobalShutdown() {
2202
+ delete g_mu;
2203
+ g_mu = nullptr;
2204
+ gpr_free(g_fallback_bootstrap_config);
2205
+ g_fallback_bootstrap_config = nullptr;
2147
2206
  }
2148
2207
 
2149
- void XdsClient::ChannelArgDestroy(void* p) {
2150
- XdsClient* xds_client = static_cast<XdsClient*>(p);
2151
- xds_client->Unref(DEBUG_LOCATION, "channel arg");
2208
+ RefCountedPtr<XdsClient> XdsClient::GetOrCreate(grpc_error** error) {
2209
+ MutexLock lock(g_mu);
2210
+ if (g_xds_client != nullptr) {
2211
+ auto xds_client = g_xds_client->RefIfNonZero();
2212
+ if (xds_client != nullptr) return xds_client;
2213
+ }
2214
+ auto xds_client = MakeRefCounted<XdsClient>(error);
2215
+ g_xds_client = xds_client.get();
2216
+ return xds_client;
2152
2217
  }
2153
2218
 
2154
- int XdsClient::ChannelArgCmp(void* p, void* q) { return GPR_ICMP(p, q); }
2219
+ namespace internal {
2155
2220
 
2156
- const grpc_arg_pointer_vtable XdsClient::kXdsClientVtable = {
2157
- XdsClient::ChannelArgCopy, XdsClient::ChannelArgDestroy,
2158
- XdsClient::ChannelArgCmp};
2221
+ void SetXdsChannelArgsForTest(grpc_channel_args* args) {
2222
+ MutexLock lock(g_mu);
2223
+ g_channel_args = args;
2224
+ }
2159
2225
 
2160
- grpc_arg XdsClient::MakeChannelArg() const {
2161
- return grpc_channel_arg_pointer_create(const_cast<char*>(GRPC_ARG_XDS_CLIENT),
2162
- const_cast<XdsClient*>(this),
2163
- &XdsClient::kXdsClientVtable);
2226
+ void UnsetGlobalXdsClientForTest() {
2227
+ MutexLock lock(g_mu);
2228
+ g_xds_client = nullptr;
2164
2229
  }
2165
2230
 
2166
- RefCountedPtr<XdsClient> XdsClient::GetFromChannelArgs(
2167
- const grpc_channel_args& args) {
2168
- XdsClient* xds_client =
2169
- grpc_channel_args_find_pointer<XdsClient>(&args, GRPC_ARG_XDS_CLIENT);
2170
- if (xds_client != nullptr) return xds_client->Ref();
2171
- return nullptr;
2231
+ void SetXdsFallbackBootstrapConfig(const char* config) {
2232
+ MutexLock lock(g_mu);
2233
+ gpr_free(g_fallback_bootstrap_config);
2234
+ g_fallback_bootstrap_config = gpr_strdup(config);
2172
2235
  }
2173
2236
 
2237
+ } // namespace internal
2238
+
2174
2239
  } // namespace grpc_core