grpc 1.43.1 → 1.44.0.pre2

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 (382) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +84 -64
  3. data/include/grpc/grpc_security.h +10 -0
  4. data/include/grpc/impl/codegen/compression_types.h +0 -2
  5. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  6. data/src/core/ext/filters/client_channel/backend_metric.h +1 -1
  7. data/src/core/ext/filters/client_channel/client_channel.cc +62 -68
  8. data/src/core/ext/filters/client_channel/client_channel.h +8 -8
  9. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  10. data/src/core/ext/filters/client_channel/config_selector.h +4 -4
  11. data/src/core/ext/filters/client_channel/dynamic_filters.h +1 -1
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -14
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +4 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +6 -5
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +3 -7
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +31 -32
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -7
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +1 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -1
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +43 -29
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +6 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +120 -68
  26. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +60 -48
  27. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +62 -61
  28. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +16 -11
  29. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +11 -5
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +19 -15
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -1
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +14 -12
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +3 -2
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +50 -105
  35. data/src/core/ext/filters/client_channel/lb_policy.cc +15 -14
  36. data/src/core/ext/filters/client_channel/lb_policy.h +19 -3
  37. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +3 -3
  38. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +207 -81
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +22 -12
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +19 -15
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +23 -38
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +118 -207
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +25 -32
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  45. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +82 -73
  46. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +10 -10
  47. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +2 -1
  48. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +2 -5
  49. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -5
  50. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +157 -67
  51. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +2 -2
  53. data/src/core/ext/filters/client_channel/retry_filter.cc +37 -64
  54. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  55. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  56. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  57. data/src/core/ext/filters/client_channel/subchannel.cc +12 -16
  58. data/src/core/ext/filters/client_channel/subchannel.h +2 -3
  59. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +37 -48
  60. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -8
  61. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  62. data/src/core/ext/filters/http/client/http_client_filter.cc +51 -122
  63. data/src/core/ext/filters/http/client_authority_filter.cc +8 -24
  64. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +42 -140
  65. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +5 -25
  66. data/src/core/ext/filters/http/server/http_server_filter.cc +50 -135
  67. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  68. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  69. data/src/core/ext/filters/rbac/rbac_filter.cc +157 -0
  70. data/src/core/ext/filters/rbac/rbac_filter.h +74 -0
  71. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +605 -0
  72. data/src/core/ext/filters/rbac/rbac_service_config_parser.h +70 -0
  73. data/src/core/ext/filters/server_config_selector/server_config_selector.h +3 -2
  74. data/src/core/ext/filters/server_config_selector/server_config_selector_filter.cc +11 -6
  75. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +1 -1
  76. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +1 -1
  77. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +89 -29
  78. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +0 -1
  79. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +45 -186
  80. data/src/core/ext/transport/chttp2/transport/frame_data.cc +0 -1
  81. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +341 -279
  82. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +69 -159
  83. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +1 -1
  84. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +2 -0
  85. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +19 -32
  86. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +0 -1
  87. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +94 -1
  88. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +2 -24
  89. data/src/core/ext/transport/chttp2/transport/internal.h +0 -33
  90. data/src/core/ext/transport/chttp2/transport/parsing.cc +0 -6
  91. data/src/core/ext/transport/chttp2/transport/writing.cc +47 -116
  92. data/src/core/ext/transport/inproc/inproc_plugin.cc +0 -4
  93. data/src/core/ext/transport/inproc/inproc_transport.cc +11 -63
  94. data/src/core/ext/transport/inproc/inproc_transport.h +0 -3
  95. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.c +61 -0
  96. data/src/core/ext/upb-generated/envoy/extensions/filters/http/rbac/v3/rbac.upb.h +146 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.c +188 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/rbac/v3/rbac.upbdefs.h +70 -0
  99. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.c +56 -0
  100. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/rbac/v3/rbac.upbdefs.h +40 -0
  101. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.c +154 -0
  102. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/checked.upbdefs.h +95 -0
  103. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.c +58 -0
  104. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/eval.upbdefs.h +55 -0
  105. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.c +44 -0
  106. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/explain.upbdefs.h +40 -0
  107. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.c +153 -0
  108. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/syntax.upbdefs.h +100 -0
  109. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.c +75 -0
  110. data/src/core/ext/upbdefs-generated/google/api/expr/v1alpha1/value.upbdefs.h +55 -0
  111. data/src/core/ext/xds/upb_utils.h +65 -0
  112. data/src/core/ext/xds/xds_api.cc +81 -3458
  113. data/src/core/ext/xds/xds_api.h +56 -611
  114. data/src/core/ext/xds/xds_bootstrap.cc +189 -125
  115. data/src/core/ext/xds/xds_bootstrap.h +20 -15
  116. data/src/core/ext/xds/xds_certificate_provider.h +1 -0
  117. data/src/core/ext/xds/xds_channel_creds.cc +108 -0
  118. data/src/core/ext/xds/xds_channel_creds.h +50 -0
  119. data/src/core/ext/xds/xds_client.cc +584 -994
  120. data/src/core/ext/xds/xds_client.h +78 -135
  121. data/src/core/ext/xds/xds_cluster.cc +451 -0
  122. data/src/core/ext/xds/xds_cluster.h +111 -0
  123. data/src/core/ext/xds/xds_common_types.cc +388 -0
  124. data/src/core/ext/xds/xds_common_types.h +110 -0
  125. data/src/core/ext/xds/xds_endpoint.cc +364 -0
  126. data/src/core/ext/xds/xds_endpoint.h +135 -0
  127. data/src/core/ext/xds/xds_http_filters.cc +5 -0
  128. data/src/core/ext/xds/xds_http_rbac_filter.cc +563 -0
  129. data/src/core/ext/xds/xds_http_rbac_filter.h +54 -0
  130. data/src/core/ext/xds/xds_listener.cc +1036 -0
  131. data/src/core/ext/xds/xds_listener.h +220 -0
  132. data/src/core/ext/{transport/chttp2/transport/hpack_utils.h → xds/xds_resource_type.cc} +12 -9
  133. data/src/core/ext/xds/xds_resource_type.h +98 -0
  134. data/src/core/ext/xds/xds_resource_type_impl.h +87 -0
  135. data/src/core/ext/xds/xds_route_config.cc +993 -0
  136. data/src/core/ext/xds/xds_route_config.h +215 -0
  137. data/src/core/ext/xds/xds_routing.cc +11 -8
  138. data/src/core/ext/xds/xds_routing.h +8 -5
  139. data/src/core/ext/xds/xds_server_config_fetcher.cc +159 -99
  140. data/src/core/lib/address_utils/parse_address.cc +20 -0
  141. data/src/core/lib/address_utils/parse_address.h +5 -0
  142. data/src/core/lib/address_utils/sockaddr_utils.cc +33 -36
  143. data/src/core/lib/address_utils/sockaddr_utils.h +1 -16
  144. data/src/core/lib/backoff/backoff.cc +4 -30
  145. data/src/core/lib/backoff/backoff.h +3 -3
  146. data/src/core/lib/channel/channel_args.cc +0 -1
  147. data/src/core/lib/channel/channel_stack.cc +8 -0
  148. data/src/core/lib/channel/channel_stack.h +1 -1
  149. data/src/core/lib/channel/channel_stack_builder.cc +5 -9
  150. data/src/core/lib/channel/channel_stack_builder.h +4 -7
  151. data/src/core/lib/channel/channelz.cc +1 -0
  152. data/src/core/lib/compression/compression.cc +19 -111
  153. data/src/core/lib/compression/compression_internal.cc +142 -202
  154. data/src/core/lib/compression/compression_internal.h +64 -69
  155. data/src/core/lib/compression/message_compress.cc +11 -11
  156. data/src/core/lib/compression/message_compress.h +2 -2
  157. data/src/core/lib/gpr/useful.h +4 -0
  158. data/src/core/lib/gprpp/bitset.h +7 -0
  159. data/src/core/lib/gprpp/chunked_vector.h +45 -3
  160. data/src/core/lib/gprpp/status_helper.cc +20 -28
  161. data/src/core/lib/gprpp/status_helper.h +6 -19
  162. data/src/core/lib/gprpp/table.h +11 -0
  163. data/src/core/lib/http/httpcli.cc +37 -46
  164. data/src/core/lib/http/httpcli.h +3 -15
  165. data/src/core/lib/iomgr/call_combiner.cc +15 -4
  166. data/src/core/lib/iomgr/closure.h +29 -9
  167. data/src/core/lib/iomgr/combiner.cc +25 -3
  168. data/src/core/lib/iomgr/error.cc +2 -0
  169. data/src/core/lib/iomgr/error.h +3 -0
  170. data/src/core/lib/iomgr/event_engine/iomgr.cc +3 -2
  171. data/src/core/lib/iomgr/event_engine/resolved_address_internal.cc +6 -0
  172. data/src/core/lib/iomgr/event_engine/resolved_address_internal.h +2 -0
  173. data/src/core/lib/iomgr/event_engine/resolver.cc +66 -48
  174. data/src/core/lib/iomgr/event_engine/resolver.h +56 -0
  175. data/src/core/lib/iomgr/exec_ctx.cc +22 -9
  176. data/src/core/lib/iomgr/executor.cc +10 -1
  177. data/src/core/lib/iomgr/fork_posix.cc +3 -2
  178. data/src/core/lib/iomgr/iomgr_custom.cc +4 -1
  179. data/src/core/lib/iomgr/iomgr_posix.cc +2 -2
  180. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +2 -2
  181. data/src/core/lib/iomgr/iomgr_windows.cc +2 -2
  182. data/src/core/lib/iomgr/port.h +2 -2
  183. data/src/core/lib/iomgr/resolve_address.cc +5 -24
  184. data/src/core/lib/iomgr/resolve_address.h +47 -44
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +131 -109
  186. data/src/core/lib/iomgr/resolve_address_custom.h +101 -19
  187. data/src/core/lib/iomgr/resolve_address_impl.h +59 -0
  188. data/src/core/lib/iomgr/resolve_address_posix.cc +82 -66
  189. data/src/core/lib/iomgr/resolve_address_posix.h +47 -0
  190. data/src/core/lib/iomgr/resolve_address_windows.cc +93 -74
  191. data/src/core/lib/iomgr/resolve_address_windows.h +47 -0
  192. data/src/core/lib/iomgr/resolved_address.h +39 -0
  193. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -0
  194. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +1 -0
  195. data/src/core/lib/iomgr/unix_sockets_posix.cc +22 -34
  196. data/src/core/lib/iomgr/unix_sockets_posix.h +4 -7
  197. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +6 -15
  198. data/src/core/lib/matchers/matchers.cc +1 -1
  199. data/src/core/lib/promise/activity.h +49 -20
  200. data/src/core/lib/promise/detail/status.h +5 -0
  201. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.cc +17 -25
  202. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver.h +43 -44
  203. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_factory.h +10 -5
  204. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.cc +3 -2
  205. data/src/core/{ext/filters/client_channel → lib/resolver}/resolver_registry.h +4 -5
  206. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.cc +1 -1
  207. data/src/core/{ext/filters/client_channel → lib/resolver}/server_address.h +4 -4
  208. data/src/core/lib/resource_quota/api.h +0 -1
  209. data/src/core/lib/{gprpp → resource_quota}/arena.cc +16 -13
  210. data/src/core/lib/{gprpp → resource_quota}/arena.h +24 -13
  211. data/src/core/lib/security/authorization/evaluate_args.cc +30 -15
  212. data/src/core/lib/security/authorization/evaluate_args.h +1 -0
  213. data/src/core/lib/security/authorization/grpc_authorization_engine.cc +60 -0
  214. data/src/core/lib/security/authorization/grpc_authorization_engine.h +62 -0
  215. data/src/core/lib/security/authorization/matchers.cc +227 -0
  216. data/src/core/lib/security/authorization/matchers.h +211 -0
  217. data/src/core/lib/security/authorization/rbac_policy.cc +442 -0
  218. data/src/core/lib/security/authorization/rbac_policy.h +170 -0
  219. data/src/core/lib/security/context/security_context.cc +4 -2
  220. data/src/core/lib/security/context/security_context.h +1 -1
  221. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -5
  222. data/src/core/lib/security/credentials/composite/composite_credentials.h +4 -3
  223. data/src/core/lib/security/credentials/credentials.h +10 -20
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +6 -9
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +7 -9
  226. data/src/core/lib/security/credentials/external/external_account_credentials.h +2 -7
  227. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -3
  228. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -4
  229. data/src/core/lib/security/credentials/fake/fake_credentials.h +8 -7
  230. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +2 -5
  231. data/src/core/lib/security/credentials/iam/iam_credentials.cc +16 -19
  232. data/src/core/lib/security/credentials/iam/iam_credentials.h +6 -5
  233. data/src/core/lib/security/credentials/jwt/json_token.cc +4 -6
  234. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +16 -28
  235. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +8 -8
  236. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +6 -13
  237. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +44 -57
  238. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +13 -15
  239. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -7
  240. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +5 -4
  241. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -10
  242. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +6 -0
  243. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +7 -0
  244. data/src/core/lib/security/credentials/xds/xds_credentials.h +1 -1
  245. data/src/core/lib/security/security_connector/security_connector.cc +0 -4
  246. data/src/core/lib/security/security_connector/security_connector.h +5 -1
  247. data/src/core/lib/security/security_connector/ssl_utils.cc +14 -24
  248. data/src/core/lib/security/security_connector/ssl_utils.h +5 -14
  249. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +2 -3
  250. data/src/core/lib/security/transport/auth_filters.h +7 -0
  251. data/src/core/lib/security/transport/client_auth_filter.cc +53 -33
  252. data/src/core/lib/security/transport/server_auth_filter.cc +40 -35
  253. data/src/core/{ext → lib}/service_config/service_config.cc +2 -2
  254. data/src/core/{ext → lib}/service_config/service_config.h +4 -4
  255. data/src/core/{ext → lib}/service_config/service_config_call_data.h +5 -5
  256. data/src/core/{ext → lib}/service_config/service_config_parser.cc +1 -1
  257. data/src/core/{ext → lib}/service_config/service_config_parser.h +3 -3
  258. data/src/core/lib/slice/slice.cc +3 -1
  259. data/src/core/lib/slice/slice.h +43 -13
  260. data/src/core/lib/slice/slice_intern.cc +3 -101
  261. data/src/core/lib/slice/slice_internal.h +1 -2
  262. data/src/core/lib/slice/slice_refcount.h +4 -13
  263. data/src/core/lib/slice/slice_refcount_base.h +0 -16
  264. data/src/core/lib/surface/call.cc +140 -382
  265. data/src/core/lib/surface/call.h +4 -4
  266. data/src/core/lib/surface/channel.cc +42 -44
  267. data/src/core/lib/surface/channel.h +4 -4
  268. data/src/core/lib/surface/init.cc +0 -2
  269. data/src/core/lib/surface/lame_client.cc +0 -1
  270. data/src/core/lib/surface/server.cc +12 -29
  271. data/src/core/lib/surface/server.h +2 -2
  272. data/src/core/lib/surface/version.cc +2 -2
  273. data/src/core/lib/transport/error_utils.h +14 -0
  274. data/src/core/lib/transport/metadata_batch.h +799 -717
  275. data/src/core/lib/transport/parsed_metadata.cc +2 -0
  276. data/src/core/lib/transport/parsed_metadata.h +95 -92
  277. data/src/core/lib/transport/timeout_encoding.cc +200 -66
  278. data/src/core/lib/transport/timeout_encoding.h +40 -10
  279. data/src/core/lib/transport/transport.h +1 -1
  280. data/src/core/lib/transport/transport_op_string.cc +6 -39
  281. data/src/core/lib/uri/uri_parser.cc +223 -53
  282. data/src/core/lib/uri/uri_parser.h +36 -23
  283. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -3
  284. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  285. data/src/core/tsi/ssl/session_cache/ssl_session.h +2 -4
  286. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -5
  287. data/src/core/tsi/ssl_transport_security.cc +53 -13
  288. data/src/core/tsi/ssl_transport_security.h +18 -6
  289. data/src/ruby/ext/grpc/extconf.rb +10 -3
  290. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  291. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  292. data/src/ruby/lib/grpc/version.rb +1 -1
  293. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -1
  294. data/third_party/abseil-cpp/absl/base/internal/fast_type_id.h +48 -0
  295. data/third_party/abseil-cpp/absl/random/bernoulli_distribution.h +200 -0
  296. data/third_party/abseil-cpp/absl/random/beta_distribution.h +427 -0
  297. data/third_party/abseil-cpp/absl/random/discrete_distribution.cc +98 -0
  298. data/third_party/abseil-cpp/absl/random/discrete_distribution.h +247 -0
  299. data/third_party/abseil-cpp/absl/random/distributions.h +452 -0
  300. data/third_party/abseil-cpp/absl/random/exponential_distribution.h +165 -0
  301. data/third_party/abseil-cpp/absl/random/gaussian_distribution.cc +104 -0
  302. data/third_party/abseil-cpp/absl/random/gaussian_distribution.h +275 -0
  303. data/third_party/abseil-cpp/absl/random/internal/distribution_caller.h +92 -0
  304. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +268 -0
  305. data/third_party/abseil-cpp/absl/random/internal/fastmath.h +57 -0
  306. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +144 -0
  307. data/third_party/abseil-cpp/absl/random/internal/iostream_state_saver.h +245 -0
  308. data/third_party/abseil-cpp/absl/random/internal/nonsecure_base.h +150 -0
  309. data/third_party/abseil-cpp/absl/random/internal/pcg_engine.h +308 -0
  310. data/third_party/abseil-cpp/absl/random/internal/platform.h +171 -0
  311. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.cc +253 -0
  312. data/third_party/abseil-cpp/absl/random/internal/pool_urbg.h +131 -0
  313. data/third_party/abseil-cpp/absl/random/internal/randen.cc +91 -0
  314. data/third_party/abseil-cpp/absl/random/internal/randen.h +102 -0
  315. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +221 -0
  316. data/third_party/abseil-cpp/absl/random/internal/randen_detect.h +33 -0
  317. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +239 -0
  318. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +526 -0
  319. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.h +50 -0
  320. data/third_party/abseil-cpp/absl/random/internal/randen_round_keys.cc +462 -0
  321. data/third_party/abseil-cpp/absl/random/internal/randen_slow.cc +471 -0
  322. data/third_party/abseil-cpp/absl/random/internal/randen_slow.h +40 -0
  323. data/third_party/abseil-cpp/absl/random/internal/randen_traits.h +88 -0
  324. data/third_party/abseil-cpp/absl/random/internal/salted_seed_seq.h +167 -0
  325. data/third_party/abseil-cpp/absl/random/internal/seed_material.cc +267 -0
  326. data/third_party/abseil-cpp/absl/random/internal/seed_material.h +104 -0
  327. data/third_party/abseil-cpp/absl/random/internal/traits.h +101 -0
  328. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +244 -0
  329. data/third_party/abseil-cpp/absl/random/internal/wide_multiply.h +111 -0
  330. data/third_party/abseil-cpp/absl/random/log_uniform_int_distribution.h +257 -0
  331. data/third_party/abseil-cpp/absl/random/poisson_distribution.h +258 -0
  332. data/third_party/abseil-cpp/absl/random/random.h +189 -0
  333. data/third_party/abseil-cpp/absl/random/seed_gen_exception.cc +46 -0
  334. data/third_party/abseil-cpp/absl/random/seed_gen_exception.h +55 -0
  335. data/third_party/abseil-cpp/absl/random/seed_sequences.cc +29 -0
  336. data/third_party/abseil-cpp/absl/random/seed_sequences.h +110 -0
  337. data/third_party/abseil-cpp/absl/random/uniform_int_distribution.h +275 -0
  338. data/third_party/abseil-cpp/absl/random/uniform_real_distribution.h +202 -0
  339. data/third_party/abseil-cpp/absl/random/zipf_distribution.h +271 -0
  340. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +1 -0
  341. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +13 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +21 -0
  343. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +12 -0
  344. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +1 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +2 -2
  346. data/third_party/boringssl-with-bazel/src/crypto/mem.c +1 -1
  347. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +29 -0
  348. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/internal.h +0 -1
  349. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  351. data/third_party/boringssl-with-bazel/src/include/openssl/base64.h +8 -0
  352. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +13 -1
  353. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +10 -0
  354. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +1 -1
  355. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +9 -4
  356. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs8.h +6 -1
  357. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +23 -2
  358. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +4 -0
  359. data/third_party/xxhash/xxhash.h +607 -352
  360. metadata +149 -77
  361. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +0 -107
  362. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +0 -46
  363. data/src/core/ext/transport/chttp2/transport/popularity_count.h +0 -60
  364. data/src/core/lib/compression/algorithm_metadata.h +0 -62
  365. data/src/core/lib/compression/compression_args.cc +0 -140
  366. data/src/core/lib/compression/compression_args.h +0 -58
  367. data/src/core/lib/compression/stream_compression.cc +0 -81
  368. data/src/core/lib/compression/stream_compression.h +0 -117
  369. data/src/core/lib/compression/stream_compression_gzip.cc +0 -231
  370. data/src/core/lib/compression/stream_compression_gzip.h +0 -28
  371. data/src/core/lib/compression/stream_compression_identity.cc +0 -91
  372. data/src/core/lib/compression/stream_compression_identity.h +0 -29
  373. data/src/core/lib/security/credentials/credentials_metadata.cc +0 -61
  374. data/src/core/lib/slice/static_slice.cc +0 -377
  375. data/src/core/lib/slice/static_slice.h +0 -300
  376. data/src/core/lib/transport/metadata.cc +0 -714
  377. data/src/core/lib/transport/metadata.h +0 -449
  378. data/src/core/lib/transport/metadata_batch.cc +0 -99
  379. data/src/core/lib/transport/static_metadata.cc +0 -1032
  380. data/src/core/lib/transport/static_metadata.h +0 -322
  381. data/src/core/lib/transport/status_metadata.cc +0 -63
  382. data/src/core/lib/transport/status_metadata.h +0 -48
@@ -20,6 +20,7 @@
20
20
 
21
21
  #include "absl/strings/match.h"
22
22
  #include "absl/strings/str_join.h"
23
+ #include "absl/strings/str_replace.h"
23
24
  #include "absl/strings/str_split.h"
24
25
  #include "re2/re2.h"
25
26
  #define XXH_INLINE_ALL
@@ -27,14 +28,17 @@
27
28
 
28
29
  #include "src/core/ext/filters/client_channel/config_selector.h"
29
30
  #include "src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h"
30
- #include "src/core/ext/filters/client_channel/resolver_registry.h"
31
31
  #include "src/core/ext/xds/xds_channel_args.h"
32
32
  #include "src/core/ext/xds/xds_client.h"
33
33
  #include "src/core/ext/xds/xds_http_filters.h"
34
+ #include "src/core/ext/xds/xds_listener.h"
35
+ #include "src/core/ext/xds/xds_route_config.h"
34
36
  #include "src/core/ext/xds/xds_routing.h"
35
37
  #include "src/core/lib/channel/channel_args.h"
36
38
  #include "src/core/lib/iomgr/closure.h"
37
39
  #include "src/core/lib/iomgr/exec_ctx.h"
40
+ #include "src/core/lib/resolver/resolver_registry.h"
41
+ #include "src/core/lib/transport/error_utils.h"
38
42
  #include "src/core/lib/transport/timeout_encoding.h"
39
43
 
40
44
  namespace grpc_core {
@@ -45,6 +49,24 @@ const char* kXdsClusterAttribute = "xds_cluster_name";
45
49
 
46
50
  namespace {
47
51
 
52
+ std::string GetDefaultAuthorityInternal(const URI& uri) {
53
+ // Obtain the authority to use for the data plane connections, which is
54
+ // also used to select the right VirtualHost from the RouteConfiguration.
55
+ // We need to take the part of the URI path following the last
56
+ // "/" character or the entire path if the path contains no "/" character.
57
+ size_t pos = uri.path().find_last_of('/');
58
+ if (pos == uri.path().npos) return uri.path();
59
+ return uri.path().substr(pos + 1);
60
+ }
61
+
62
+ std::string GetDataPlaneAuthority(const grpc_channel_args& args,
63
+ const URI& uri) {
64
+ const char* authority =
65
+ grpc_channel_args_find_string(&args, GRPC_ARG_DEFAULT_AUTHORITY);
66
+ if (authority != nullptr) return authority;
67
+ return GetDefaultAuthorityInternal(uri);
68
+ }
69
+
48
70
  //
49
71
  // XdsResolver
50
72
  //
@@ -54,12 +76,15 @@ class XdsResolver : public Resolver {
54
76
  explicit XdsResolver(ResolverArgs args)
55
77
  : work_serializer_(std::move(args.work_serializer)),
56
78
  result_handler_(std::move(args.result_handler)),
57
- server_name_(absl::StripPrefix(args.uri.path(), "/")),
58
79
  args_(grpc_channel_args_copy(args.args)),
59
- interested_parties_(args.pollset_set) {
80
+ interested_parties_(args.pollset_set),
81
+ uri_(std::move(args.uri)),
82
+ data_plane_authority_(GetDataPlaneAuthority(*args.args, uri_)) {
60
83
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) {
61
- gpr_log(GPR_INFO, "[xds_resolver %p] created for server name %s", this,
62
- server_name_.c_str());
84
+ gpr_log(
85
+ GPR_INFO,
86
+ "[xds_resolver %p] created for URI %s; data plane authority is %s",
87
+ this, uri_.ToString().c_str(), data_plane_authority_.c_str());
63
88
  }
64
89
  }
65
90
 
@@ -79,11 +104,11 @@ class XdsResolver : public Resolver {
79
104
  }
80
105
 
81
106
  private:
82
- class ListenerWatcher : public XdsClient::ListenerWatcherInterface {
107
+ class ListenerWatcher : public XdsListenerResourceType::WatcherInterface {
83
108
  public:
84
109
  explicit ListenerWatcher(RefCountedPtr<XdsResolver> resolver)
85
110
  : resolver_(std::move(resolver)) {}
86
- void OnListenerChanged(XdsApi::LdsUpdate listener) override {
111
+ void OnResourceChanged(XdsListenerResource listener) override {
87
112
  Ref().release(); // ref held by lambda
88
113
  resolver_->work_serializer_->Run(
89
114
  // TODO(yashykt): When we move to C++14, capture listener with
@@ -117,11 +142,12 @@ class XdsResolver : public Resolver {
117
142
  RefCountedPtr<XdsResolver> resolver_;
118
143
  };
119
144
 
120
- class RouteConfigWatcher : public XdsClient::RouteConfigWatcherInterface {
145
+ class RouteConfigWatcher
146
+ : public XdsRouteConfigResourceType::WatcherInterface {
121
147
  public:
122
148
  explicit RouteConfigWatcher(RefCountedPtr<XdsResolver> resolver)
123
149
  : resolver_(std::move(resolver)) {}
124
- void OnRouteConfigChanged(XdsApi::RdsUpdate route_config) override {
150
+ void OnResourceChanged(XdsRouteConfigResource route_config) override {
125
151
  Ref().release(); // ref held by lambda
126
152
  resolver_->work_serializer_->Run(
127
153
  // TODO(yashykt): When we move to C++14, capture route_config with
@@ -250,7 +276,7 @@ class XdsResolver : public Resolver {
250
276
  bool operator==(const ClusterWeightState& other) const;
251
277
  };
252
278
 
253
- XdsApi::Route route;
279
+ XdsRouteConfigResource::Route route;
254
280
  RefCountedPtr<ServiceConfig> method_config;
255
281
  absl::InlinedVector<ClusterWeightState, 2> weighted_cluster_state;
256
282
 
@@ -262,8 +288,9 @@ class XdsResolver : public Resolver {
262
288
 
263
289
  void MaybeAddCluster(const std::string& name);
264
290
  grpc_error_handle CreateMethodConfig(
265
- const XdsApi::Route& route,
266
- const XdsApi::Route::RouteAction::ClusterWeight* cluster_weight,
291
+ const XdsRouteConfigResource::Route& route,
292
+ const XdsRouteConfigResource::Route::RouteAction::ClusterWeight*
293
+ cluster_weight,
267
294
  RefCountedPtr<ServiceConfig>* method_config);
268
295
 
269
296
  RefCountedPtr<XdsResolver> resolver_;
@@ -272,33 +299,33 @@ class XdsResolver : public Resolver {
272
299
  std::vector<const grpc_channel_filter*> filters_;
273
300
  };
274
301
 
275
- void OnListenerUpdate(XdsApi::LdsUpdate listener);
276
- void OnRouteConfigUpdate(XdsApi::RdsUpdate rds_update);
302
+ void OnListenerUpdate(XdsListenerResource listener);
303
+ void OnRouteConfigUpdate(XdsRouteConfigResource rds_update);
277
304
  void OnError(grpc_error_handle error);
278
305
  void OnResourceDoesNotExist();
279
306
 
280
- grpc_error_handle CreateServiceConfig(
281
- RefCountedPtr<ServiceConfig>* service_config);
307
+ absl::StatusOr<RefCountedPtr<ServiceConfig>> CreateServiceConfig();
282
308
  void GenerateResult();
283
309
  void MaybeRemoveUnusedClusters();
284
310
 
285
311
  std::shared_ptr<WorkSerializer> work_serializer_;
286
312
  std::unique_ptr<ResultHandler> result_handler_;
287
- std::string server_name_;
288
313
  const grpc_channel_args* args_;
289
314
  grpc_pollset_set* interested_parties_;
290
-
315
+ URI uri_;
291
316
  RefCountedPtr<XdsClient> xds_client_;
317
+ std::string lds_resource_name_;
318
+ std::string data_plane_authority_;
292
319
 
293
- XdsClient::ListenerWatcherInterface* listener_watcher_ = nullptr;
320
+ ListenerWatcher* listener_watcher_ = nullptr;
294
321
  // This will not contain the RouteConfiguration, even if it comes with the
295
322
  // LDS response; instead, the relevant VirtualHost from the
296
323
  // RouteConfiguration will be saved in current_virtual_host_.
297
- XdsApi::LdsUpdate current_listener_;
324
+ XdsListenerResource current_listener_;
298
325
 
299
326
  std::string route_config_name_;
300
- XdsClient::RouteConfigWatcherInterface* route_config_watcher_ = nullptr;
301
- XdsApi::RdsUpdate::VirtualHost current_virtual_host_;
327
+ RouteConfigWatcher* route_config_watcher_ = nullptr;
328
+ XdsRouteConfigResource::VirtualHost current_virtual_host_;
302
329
 
303
330
  ClusterState::ClusterStateMap cluster_state_map_;
304
331
  };
@@ -336,7 +363,7 @@ class XdsResolver::XdsConfigSelector::RouteListIterator
336
363
 
337
364
  size_t Size() const override { return route_table_->size(); }
338
365
 
339
- const XdsApi::Route::Matchers& GetMatchersForRoute(
366
+ const XdsRouteConfigResource::Route::Matchers& GetMatchersForRoute(
340
367
  size_t index) const override {
341
368
  return (*route_table_)[index].route.matchers;
342
369
  }
@@ -375,7 +402,8 @@ XdsResolver::XdsConfigSelector::XdsConfigSelector(
375
402
  auto& route_entry = route_table_.back();
376
403
  route_entry.route = route;
377
404
  auto* route_action =
378
- absl::get_if<XdsApi::Route::RouteAction>(&route_entry.route.action);
405
+ absl::get_if<XdsRouteConfigResource::Route::RouteAction>(
406
+ &route_entry.route.action);
379
407
  if (route_action != nullptr) {
380
408
  // If the route doesn't specify a timeout, set its timeout to the global
381
409
  // one.
@@ -431,12 +459,13 @@ XdsResolver::XdsConfigSelector::~XdsConfigSelector() {
431
459
  }
432
460
 
433
461
  grpc_error_handle XdsResolver::XdsConfigSelector::CreateMethodConfig(
434
- const XdsApi::Route& route,
435
- const XdsApi::Route::RouteAction::ClusterWeight* cluster_weight,
462
+ const XdsRouteConfigResource::Route& route,
463
+ const XdsRouteConfigResource::Route::RouteAction::ClusterWeight*
464
+ cluster_weight,
436
465
  RefCountedPtr<ServiceConfig>* method_config) {
437
466
  std::vector<std::string> fields;
438
467
  const auto& route_action =
439
- absl::get<XdsApi::Route::RouteAction>(route.action);
468
+ absl::get<XdsRouteConfigResource::Route::RouteAction>(route.action);
440
469
  // Set retry policy if any.
441
470
  if (route_action.retry_policy.has_value() &&
442
471
  !route_action.retry_policy->retry_on.Empty()) {
@@ -536,9 +565,10 @@ void XdsResolver::XdsConfigSelector::MaybeAddCluster(const std::string& name) {
536
565
  }
537
566
 
538
567
  absl::optional<uint64_t> HeaderHashHelper(
539
- const XdsApi::Route::RouteAction::HashPolicy& policy,
568
+ const XdsRouteConfigResource::Route::RouteAction::HashPolicy& policy,
540
569
  grpc_metadata_batch* initial_metadata) {
541
- GPR_ASSERT(policy.type == XdsApi::Route::RouteAction::HashPolicy::HEADER);
570
+ GPR_ASSERT(policy.type ==
571
+ XdsRouteConfigResource::Route::RouteAction::HashPolicy::HEADER);
542
572
  std::string value_buffer;
543
573
  absl::optional<absl::string_view> header_value = XdsRouting::GetHeaderValue(
544
574
  initial_metadata, policy.header_name, &value_buffer);
@@ -568,7 +598,8 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
568
598
  auto& entry = route_table_[*route_index];
569
599
  // Found a route match
570
600
  const auto* route_action =
571
- absl::get_if<XdsApi::Route::RouteAction>(&entry.route.action);
601
+ absl::get_if<XdsRouteConfigResource::Route::RouteAction>(
602
+ &entry.route.action);
572
603
  if (route_action == nullptr) {
573
604
  CallConfig call_config;
574
605
  call_config.error =
@@ -615,10 +646,10 @@ ConfigSelector::CallConfig XdsResolver::XdsConfigSelector::GetCallConfig(
615
646
  for (const auto& hash_policy : route_action->hash_policies) {
616
647
  absl::optional<uint64_t> new_hash;
617
648
  switch (hash_policy.type) {
618
- case XdsApi::Route::RouteAction::HashPolicy::HEADER:
649
+ case XdsRouteConfigResource::Route::RouteAction::HashPolicy::HEADER:
619
650
  new_hash = HeaderHashHelper(hash_policy, args.initial_metadata);
620
651
  break;
621
- case XdsApi::Route::RouteAction::HashPolicy::CHANNEL_ID:
652
+ case XdsRouteConfigResource::Route::RouteAction::HashPolicy::CHANNEL_ID:
622
653
  new_hash =
623
654
  static_cast<uint64_t>(reinterpret_cast<uintptr_t>(resolver_.get()));
624
655
  break;
@@ -677,14 +708,61 @@ void XdsResolver::StartLocked() {
677
708
  "Failed to create xds client -- channel will remain in "
678
709
  "TRANSIENT_FAILURE: %s",
679
710
  grpc_error_std_string(error).c_str());
680
- result_handler_->ReturnError(error);
711
+ std::string error_message;
712
+ grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION, &error_message);
713
+ Result result;
714
+ result.service_config = absl::UnavailableError(
715
+ absl::StrCat("Failed to create XdsClient: ", error_message));
716
+ result_handler_->ReportResult(std::move(result));
717
+ GRPC_ERROR_UNREF(error);
681
718
  return;
682
719
  }
720
+ std::string resource_name_fragment(absl::StripPrefix(uri_.path(), "/"));
721
+ if (!uri_.authority().empty()) {
722
+ // target_uri.authority is set case
723
+ const auto* authority_config =
724
+ xds_client_->bootstrap().LookupAuthority(uri_.authority());
725
+ if (authority_config == nullptr) {
726
+ Result result;
727
+ result.service_config = absl::UnavailableError(
728
+ absl::StrCat("Invalid target URI -- authority not found for %s.",
729
+ uri_.authority().c_str()));
730
+ result_handler_->ReportResult(std::move(result));
731
+ return;
732
+ }
733
+ std::string name_template =
734
+ authority_config->client_listener_resource_name_template;
735
+ if (name_template.empty()) {
736
+ name_template = absl::StrCat("xdstp://", uri_.authority(),
737
+ "/envoy.config.listener.v3.Listener/%s");
738
+ }
739
+ lds_resource_name_ = absl::StrReplaceAll(
740
+ name_template,
741
+ {{"%s", URI::PercentEncodePath(resource_name_fragment)}});
742
+ } else {
743
+ // target_uri.authority not set
744
+ absl::string_view name_template =
745
+ xds_client_->bootstrap()
746
+ .client_default_listener_resource_name_template();
747
+ if (name_template.empty()) {
748
+ name_template = "%s";
749
+ }
750
+ if (absl::StartsWith(name_template, "xdstp:")) {
751
+ resource_name_fragment = URI::PercentEncodePath(resource_name_fragment);
752
+ }
753
+ lds_resource_name_ =
754
+ absl::StrReplaceAll(name_template, {{"%s", resource_name_fragment}});
755
+ }
756
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) {
757
+ gpr_log(GPR_INFO, "[xds_resolver %p] Started with lds_resource_name %s.",
758
+ this, lds_resource_name_.c_str());
759
+ }
683
760
  grpc_pollset_set_add_pollset_set(xds_client_->interested_parties(),
684
761
  interested_parties_);
685
762
  auto watcher = MakeRefCounted<ListenerWatcher>(Ref());
686
763
  listener_watcher_ = watcher.get();
687
- xds_client_->WatchListenerData(server_name_, std::move(watcher));
764
+ XdsListenerResourceType::StartWatch(xds_client_.get(), lds_resource_name_,
765
+ std::move(watcher));
688
766
  }
689
767
 
690
768
  void XdsResolver::ShutdownLocked() {
@@ -693,12 +771,14 @@ void XdsResolver::ShutdownLocked() {
693
771
  }
694
772
  if (xds_client_ != nullptr) {
695
773
  if (listener_watcher_ != nullptr) {
696
- xds_client_->CancelListenerDataWatch(server_name_, listener_watcher_,
697
- /*delay_unsubscription=*/false);
774
+ XdsListenerResourceType::CancelWatch(
775
+ xds_client_.get(), lds_resource_name_, listener_watcher_,
776
+ /*delay_unsubscription=*/false);
698
777
  }
699
778
  if (route_config_watcher_ != nullptr) {
700
- xds_client_->CancelRouteConfigDataWatch(
701
- server_name_, route_config_watcher_, /*delay_unsubscription=*/false);
779
+ XdsRouteConfigResourceType::CancelWatch(
780
+ xds_client_.get(), route_config_name_, route_config_watcher_,
781
+ /*delay_unsubscription=*/false);
702
782
  }
703
783
  grpc_pollset_set_del_pollset_set(xds_client_->interested_parties(),
704
784
  interested_parties_);
@@ -706,7 +786,7 @@ void XdsResolver::ShutdownLocked() {
706
786
  }
707
787
  }
708
788
 
709
- void XdsResolver::OnListenerUpdate(XdsApi::LdsUpdate listener) {
789
+ void XdsResolver::OnListenerUpdate(XdsListenerResource listener) {
710
790
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) {
711
791
  gpr_log(GPR_INFO, "[xds_resolver %p] received updated listener data", this);
712
792
  }
@@ -716,8 +796,8 @@ void XdsResolver::OnListenerUpdate(XdsApi::LdsUpdate listener) {
716
796
  if (listener.http_connection_manager.route_config_name !=
717
797
  route_config_name_) {
718
798
  if (route_config_watcher_ != nullptr) {
719
- xds_client_->CancelRouteConfigDataWatch(
720
- route_config_name_, route_config_watcher_,
799
+ XdsRouteConfigResourceType::CancelWatch(
800
+ xds_client_.get(), route_config_name_, route_config_watcher_,
721
801
  /*delay_unsubscription=*/
722
802
  !listener.http_connection_manager.route_config_name.empty());
723
803
  route_config_watcher_ = nullptr;
@@ -728,7 +808,8 @@ void XdsResolver::OnListenerUpdate(XdsApi::LdsUpdate listener) {
728
808
  current_virtual_host_.routes.clear();
729
809
  auto watcher = MakeRefCounted<RouteConfigWatcher>(Ref());
730
810
  route_config_watcher_ = watcher.get();
731
- xds_client_->WatchRouteConfigData(route_config_name_, std::move(watcher));
811
+ XdsRouteConfigResourceType::StartWatch(
812
+ xds_client_.get(), route_config_name_, std::move(watcher));
732
813
  }
733
814
  }
734
815
  current_listener_ = std::move(listener);
@@ -748,7 +829,7 @@ namespace {
748
829
  class VirtualHostListIterator : public XdsRouting::VirtualHostListIterator {
749
830
  public:
750
831
  explicit VirtualHostListIterator(
751
- const std::vector<XdsApi::RdsUpdate::VirtualHost>* virtual_hosts)
832
+ const std::vector<XdsRouteConfigResource::VirtualHost>* virtual_hosts)
752
833
  : virtual_hosts_(virtual_hosts) {}
753
834
 
754
835
  size_t Size() const override { return virtual_hosts_->size(); }
@@ -759,11 +840,11 @@ class VirtualHostListIterator : public XdsRouting::VirtualHostListIterator {
759
840
  }
760
841
 
761
842
  private:
762
- const std::vector<XdsApi::RdsUpdate::VirtualHost>* virtual_hosts_;
843
+ const std::vector<XdsRouteConfigResource::VirtualHost>* virtual_hosts_;
763
844
  };
764
845
  } // namespace
765
846
 
766
- void XdsResolver::OnRouteConfigUpdate(XdsApi::RdsUpdate rds_update) {
847
+ void XdsResolver::OnRouteConfigUpdate(XdsRouteConfigResource rds_update) {
767
848
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) {
768
849
  gpr_log(GPR_INFO, "[xds_resolver %p] received updated route config", this);
769
850
  }
@@ -772,10 +853,11 @@ void XdsResolver::OnRouteConfigUpdate(XdsApi::RdsUpdate rds_update) {
772
853
  }
773
854
  // Find the relevant VirtualHost from the RouteConfiguration.
774
855
  auto vhost_index = XdsRouting::FindVirtualHostForDomain(
775
- VirtualHostListIterator(&rds_update.virtual_hosts), server_name_);
856
+ VirtualHostListIterator(&rds_update.virtual_hosts),
857
+ data_plane_authority_);
776
858
  if (!vhost_index.has_value()) {
777
859
  OnError(GRPC_ERROR_CREATE_FROM_CPP_STRING(
778
- absl::StrCat("could not find VirtualHost for ", server_name_,
860
+ absl::StrCat("could not find VirtualHost for ", data_plane_authority_,
779
861
  " in RouteConfiguration")));
780
862
  return;
781
863
  }
@@ -795,8 +877,9 @@ void XdsResolver::OnError(grpc_error_handle error) {
795
877
  Result result;
796
878
  grpc_arg new_arg = xds_client_->MakeChannelArg();
797
879
  result.args = grpc_channel_args_copy_and_add(args_, &new_arg, 1);
798
- result.service_config_error = error;
799
- result_handler_->ReturnResult(std::move(result));
880
+ result.service_config = grpc_error_to_absl_status(error);
881
+ result_handler_->ReportResult(std::move(result));
882
+ GRPC_ERROR_UNREF(error);
800
883
  }
801
884
 
802
885
  void XdsResolver::OnResourceDoesNotExist() {
@@ -809,15 +892,15 @@ void XdsResolver::OnResourceDoesNotExist() {
809
892
  }
810
893
  current_virtual_host_.routes.clear();
811
894
  Result result;
812
- result.service_config =
813
- ServiceConfig::Create(args_, "{}", &result.service_config_error);
814
- GPR_ASSERT(result.service_config != nullptr);
895
+ grpc_error_handle error = GRPC_ERROR_NONE;
896
+ result.service_config = ServiceConfig::Create(args_, "{}", &error);
897
+ GPR_ASSERT(*result.service_config != nullptr);
815
898
  result.args = grpc_channel_args_copy(args_);
816
- result_handler_->ReturnResult(std::move(result));
899
+ result_handler_->ReportResult(std::move(result));
817
900
  }
818
901
 
819
- grpc_error_handle XdsResolver::CreateServiceConfig(
820
- RefCountedPtr<ServiceConfig>* service_config) {
902
+ absl::StatusOr<RefCountedPtr<ServiceConfig>>
903
+ XdsResolver::CreateServiceConfig() {
821
904
  std::vector<std::string> clusters;
822
905
  for (const auto& cluster : cluster_state_map_) {
823
906
  clusters.push_back(
@@ -844,8 +927,13 @@ grpc_error_handle XdsResolver::CreateServiceConfig(
844
927
  "}");
845
928
  std::string json = absl::StrJoin(config_parts, "");
846
929
  grpc_error_handle error = GRPC_ERROR_NONE;
847
- *service_config = ServiceConfig::Create(args_, json.c_str(), &error);
848
- return error;
930
+ absl::StatusOr<RefCountedPtr<ServiceConfig>> result =
931
+ ServiceConfig::Create(args_, json.c_str(), &error);
932
+ if (error != GRPC_ERROR_NONE) {
933
+ result = grpc_error_to_absl_status(error);
934
+ GRPC_ERROR_UNREF(error);
935
+ }
936
+ return result;
849
937
  }
850
938
 
851
939
  void XdsResolver::GenerateResult() {
@@ -860,15 +948,12 @@ void XdsResolver::GenerateResult() {
860
948
  return;
861
949
  }
862
950
  Result result;
863
- error = CreateServiceConfig(&result.service_config);
864
- if (error != GRPC_ERROR_NONE) {
865
- OnError(grpc_error_set_int(error, GRPC_ERROR_INT_GRPC_STATUS,
866
- GRPC_STATUS_UNAVAILABLE));
867
- return;
868
- }
951
+ result.service_config = CreateServiceConfig();
869
952
  if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_resolver_trace)) {
870
953
  gpr_log(GPR_INFO, "[xds_resolver %p] generated service config: %s", this,
871
- result.service_config->json_string().c_str());
954
+ result.service_config.ok()
955
+ ? (*result.service_config)->json_string().c_str()
956
+ : result.service_config.status().ToString().c_str());
872
957
  }
873
958
  grpc_arg new_args[] = {
874
959
  xds_client_->MakeChannelArg(),
@@ -876,7 +961,7 @@ void XdsResolver::GenerateResult() {
876
961
  };
877
962
  result.args =
878
963
  grpc_channel_args_copy_and_add(args_, new_args, GPR_ARRAY_SIZE(new_args));
879
- result_handler_->ReturnResult(std::move(result));
964
+ result_handler_->ReportResult(std::move(result));
880
965
  }
881
966
 
882
967
  void XdsResolver::MaybeRemoveUnusedClusters() {
@@ -903,13 +988,18 @@ void XdsResolver::MaybeRemoveUnusedClusters() {
903
988
  class XdsResolverFactory : public ResolverFactory {
904
989
  public:
905
990
  bool IsValidUri(const URI& uri) const override {
906
- if (GPR_UNLIKELY(!uri.authority().empty())) {
907
- gpr_log(GPR_ERROR, "URI authority not supported");
991
+ if (uri.path().empty() || uri.path().back() == '/') {
992
+ gpr_log(GPR_ERROR,
993
+ "URI path does not contain valid data plane authority");
908
994
  return false;
909
995
  }
910
996
  return true;
911
997
  }
912
998
 
999
+ std::string GetDefaultAuthority(const URI& uri) const override {
1000
+ return GetDefaultAuthorityInternal(uri);
1001
+ }
1002
+
913
1003
  OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override {
914
1004
  if (!IsValidUri(args.uri)) return nullptr;
915
1005
  return MakeOrphanable<XdsResolver>(std::move(args));
@@ -31,12 +31,12 @@
31
31
 
32
32
  #include "src/core/ext/filters/client_channel/client_channel.h"
33
33
  #include "src/core/ext/filters/client_channel/lb_policy_registry.h"
34
- #include "src/core/ext/filters/client_channel/server_address.h"
35
34
  #include "src/core/lib/channel/channel_args.h"
36
35
  #include "src/core/lib/channel/status_util.h"
37
36
  #include "src/core/lib/gpr/string.h"
38
37
  #include "src/core/lib/gprpp/memory.h"
39
38
  #include "src/core/lib/json/json_util.h"
39
+ #include "src/core/lib/resolver/server_address.h"
40
40
  #include "src/core/lib/uri/uri_parser.h"
41
41
 
42
42
  // As per the retry design, we do not allow more than 5 retry attempts.
@@ -23,13 +23,13 @@
23
23
 
24
24
  #include "src/core/ext/filters/client_channel/lb_policy.h"
25
25
  #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
26
- #include "src/core/ext/filters/client_channel/resolver.h"
27
- #include "src/core/ext/service_config/service_config_parser.h"
28
26
  #include "src/core/lib/channel/status_util.h"
29
27
  #include "src/core/lib/gprpp/ref_counted.h"
30
28
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
31
29
  #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
32
30
  #include "src/core/lib/json/json.h"
31
+ #include "src/core/lib/resolver/resolver.h"
32
+ #include "src/core/lib/service_config/service_config_parser.h"
33
33
 
34
34
  namespace grpc_core {
35
35
  namespace internal {