grpc 1.40.0.pre1 → 1.42.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (1093) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +68 -64
  3. data/etc/roots.pem +335 -326
  4. data/include/grpc/byte_buffer.h +1 -1
  5. data/include/grpc/byte_buffer_reader.h +1 -1
  6. data/include/grpc/event_engine/endpoint_config.h +6 -11
  7. data/include/grpc/event_engine/event_engine.h +131 -86
  8. data/include/grpc/event_engine/internal/memory_allocator_impl.h +98 -0
  9. data/include/grpc/event_engine/memory_allocator.h +210 -0
  10. data/include/grpc/event_engine/port.h +1 -3
  11. data/include/grpc/fork.h +1 -1
  12. data/include/grpc/grpc.h +14 -4
  13. data/include/grpc/grpc_posix.h +5 -2
  14. data/include/grpc/grpc_security.h +18 -0
  15. data/include/grpc/grpc_security_constants.h +1 -0
  16. data/include/grpc/impl/codegen/atm.h +5 -3
  17. data/include/grpc/impl/codegen/atm_gcc_atomic.h +2 -0
  18. data/include/grpc/impl/codegen/atm_gcc_sync.h +2 -0
  19. data/include/grpc/impl/codegen/atm_windows.h +2 -0
  20. data/include/grpc/impl/codegen/byte_buffer.h +2 -0
  21. data/include/grpc/impl/codegen/byte_buffer_reader.h +2 -0
  22. data/include/grpc/impl/codegen/compression_types.h +2 -0
  23. data/include/grpc/impl/codegen/connectivity_state.h +2 -0
  24. data/include/grpc/impl/codegen/fork.h +2 -0
  25. data/include/grpc/impl/codegen/gpr_slice.h +2 -0
  26. data/include/grpc/impl/codegen/gpr_types.h +2 -0
  27. data/include/grpc/impl/codegen/grpc_types.h +4 -5
  28. data/include/grpc/impl/codegen/log.h +2 -0
  29. data/include/grpc/impl/codegen/port_platform.h +33 -22
  30. data/include/grpc/impl/codegen/propagation_bits.h +2 -0
  31. data/include/grpc/impl/codegen/slice.h +2 -0
  32. data/include/grpc/impl/codegen/status.h +2 -0
  33. data/include/grpc/impl/codegen/sync.h +8 -5
  34. data/include/grpc/impl/codegen/sync_abseil.h +2 -0
  35. data/include/grpc/impl/codegen/sync_custom.h +2 -0
  36. data/include/grpc/impl/codegen/sync_generic.h +3 -0
  37. data/include/grpc/impl/codegen/sync_posix.h +4 -2
  38. data/include/grpc/impl/codegen/sync_windows.h +2 -0
  39. data/include/grpc/slice.h +1 -1
  40. data/include/grpc/status.h +1 -1
  41. data/include/grpc/support/atm.h +1 -1
  42. data/include/grpc/support/atm_gcc_atomic.h +1 -1
  43. data/include/grpc/support/atm_gcc_sync.h +1 -1
  44. data/include/grpc/support/atm_windows.h +1 -1
  45. data/include/grpc/support/log.h +1 -1
  46. data/include/grpc/support/port_platform.h +1 -1
  47. data/include/grpc/support/sync.h +1 -1
  48. data/include/grpc/support/sync_abseil.h +1 -1
  49. data/include/grpc/support/sync_custom.h +1 -1
  50. data/include/grpc/support/sync_generic.h +1 -1
  51. data/include/grpc/support/sync_posix.h +1 -1
  52. data/include/grpc/support/sync_windows.h +1 -1
  53. data/include/grpc/support/time.h +2 -2
  54. data/src/core/ext/filters/census/grpc_context.cc +1 -0
  55. data/src/core/ext/filters/client_channel/backend_metric.cc +18 -20
  56. data/src/core/ext/filters/client_channel/backup_poller.cc +2 -1
  57. data/src/core/ext/filters/client_channel/backup_poller.h +1 -0
  58. data/src/core/ext/filters/client_channel/channel_connectivity.cc +72 -91
  59. data/src/core/ext/filters/client_channel/client_channel.cc +196 -289
  60. data/src/core/ext/filters/client_channel/client_channel.h +75 -28
  61. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +6 -5
  62. data/src/core/ext/filters/client_channel/client_channel_channelz.h +1 -1
  63. data/src/core/ext/filters/client_channel/client_channel_factory.cc +2 -1
  64. data/src/core/ext/filters/client_channel/client_channel_factory.h +17 -19
  65. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +16 -15
  66. data/src/core/ext/filters/client_channel/config_selector.cc +2 -1
  67. data/src/core/ext/filters/client_channel/config_selector.h +4 -5
  68. data/src/core/ext/filters/client_channel/connector.h +18 -18
  69. data/src/core/ext/filters/client_channel/dynamic_filters.cc +1 -1
  70. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +0 -1
  71. data/src/core/ext/filters/client_channel/health/health_check_client.cc +19 -17
  72. data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -3
  73. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +8 -7
  74. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +10 -2
  75. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -2
  76. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -15
  77. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +168 -90
  78. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +4 -0
  79. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +1 -1
  80. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -2
  81. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +2 -2
  82. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +2 -2
  83. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -3
  84. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +23 -7
  85. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +29 -33
  86. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +3 -3
  87. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2502 -0
  88. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -1
  89. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +2 -2
  90. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +9 -9
  91. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +21 -20
  92. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +1 -1
  93. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +15 -7
  94. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +10 -9
  95. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +9 -19
  96. data/src/core/ext/filters/client_channel/lb_policy.h +21 -44
  97. data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -0
  98. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +4 -7
  99. data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +139 -0
  100. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +13 -15
  101. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -0
  102. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -3
  103. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
  104. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +26 -58
  105. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +21 -1
  106. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +7 -2
  107. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +5 -3
  108. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +5 -5
  109. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +82 -76
  110. data/src/core/ext/filters/client_channel/resolver.h +1 -1
  111. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
  112. data/src/core/ext/filters/client_channel/resolver_registry.cc +6 -8
  113. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +3 -4
  114. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +1 -1
  115. data/src/core/ext/filters/client_channel/retry_filter.cc +64 -89
  116. data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
  117. data/src/core/ext/filters/client_channel/retry_throttle.cc +17 -48
  118. data/src/core/ext/filters/client_channel/server_address.h +1 -1
  119. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +49 -36
  120. data/src/core/ext/filters/client_channel/subchannel.cc +85 -143
  121. data/src/core/ext/filters/client_channel/subchannel.h +29 -49
  122. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +22 -7
  123. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +11 -2
  124. data/src/core/ext/filters/client_idle/client_idle_filter.cc +29 -206
  125. data/src/core/ext/filters/client_idle/idle_filter_state.cc +96 -0
  126. data/src/core/ext/filters/client_idle/idle_filter_state.h +66 -0
  127. data/src/core/ext/filters/deadline/deadline_filter.cc +23 -26
  128. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +27 -25
  129. data/src/core/ext/filters/fault_injection/service_config_parser.cc +6 -14
  130. data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
  131. data/src/core/ext/filters/http/client/http_client_filter.cc +44 -46
  132. data/src/core/ext/filters/http/client_authority_filter.cc +16 -16
  133. data/src/core/ext/filters/http/http_filters_plugin.cc +53 -71
  134. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +19 -13
  135. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +8 -9
  136. data/src/core/ext/filters/http/server/http_server_filter.cc +77 -72
  137. data/src/core/ext/filters/max_age/max_age_filter.cc +24 -26
  138. data/src/core/ext/filters/message_size/message_size_filter.cc +28 -29
  139. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  140. data/src/core/ext/{filters/client_channel → service_config}/service_config.cc +2 -2
  141. data/src/core/ext/{filters/client_channel → service_config}/service_config.h +4 -4
  142. data/src/core/ext/service_config/service_config_call_data.h +72 -0
  143. data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.cc +3 -3
  144. data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.h +8 -6
  145. data/src/core/ext/transport/chttp2/alpn/alpn.cc +2 -1
  146. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +29 -15
  147. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +2 -0
  148. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +21 -27
  149. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +10 -6
  150. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +29 -53
  151. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +74 -53
  152. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +0 -1
  153. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -6
  154. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -9
  155. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +3 -1
  156. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -1
  157. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -0
  158. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +83 -88
  159. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -1
  160. data/src/core/ext/transport/chttp2/transport/context_list.h +1 -2
  161. data/src/core/ext/transport/chttp2/transport/flow_control.cc +56 -37
  162. data/src/core/ext/transport/chttp2/transport/flow_control.h +13 -7
  163. data/src/core/ext/transport/chttp2/transport/frame_data.cc +11 -11
  164. data/src/core/ext/transport/chttp2/transport/frame_data.h +1 -0
  165. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +6 -4
  166. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -0
  167. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +6 -5
  168. data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -0
  169. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +5 -8
  170. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -0
  171. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +38 -7
  172. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -0
  173. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +12 -7
  174. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +1 -0
  175. data/src/core/ext/transport/chttp2/transport/hpack_constants.h +41 -0
  176. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +311 -665
  177. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +240 -70
  178. data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +107 -0
  179. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.cc +86 -0
  180. data/src/core/ext/transport/chttp2/transport/hpack_encoder_table.h +69 -0
  181. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +816 -1039
  182. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +75 -177
  183. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +146 -0
  184. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +137 -0
  185. data/src/core/ext/transport/chttp2/transport/hpack_utils.cc +46 -0
  186. data/src/core/{lib/transport/authority_override.h → ext/transport/chttp2/transport/hpack_utils.h} +8 -15
  187. data/src/core/ext/transport/chttp2/transport/internal.h +6 -5
  188. data/src/core/ext/transport/chttp2/transport/parsing.cc +50 -203
  189. data/src/core/ext/transport/chttp2/transport/popularity_count.h +60 -0
  190. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -2
  191. data/src/core/ext/transport/chttp2/transport/varint.cc +7 -3
  192. data/src/core/ext/transport/chttp2/transport/varint.h +39 -28
  193. data/src/core/ext/transport/chttp2/transport/writing.cc +61 -50
  194. data/src/core/ext/transport/inproc/inproc_transport.cc +111 -113
  195. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +96 -96
  196. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +221 -89
  197. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.c +1 -1
  198. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -1
  199. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +3 -3
  200. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +11 -5
  201. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +48 -48
  202. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +151 -61
  203. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +99 -99
  204. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +171 -69
  205. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +15 -15
  206. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +31 -13
  207. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +164 -131
  208. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +368 -102
  209. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +4 -4
  210. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +11 -5
  211. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +23 -23
  212. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +11 -5
  213. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +28 -28
  214. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +71 -29
  215. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
  216. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +11 -5
  217. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +95 -83
  218. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +254 -85
  219. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +24 -24
  220. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +51 -21
  221. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +3 -3
  222. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +11 -5
  223. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +9 -9
  224. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +21 -9
  225. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +62 -62
  226. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +131 -53
  227. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +53 -52
  228. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +96 -33
  229. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +5 -5
  230. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +11 -5
  231. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +71 -66
  232. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +164 -57
  233. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +3 -3
  234. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +11 -5
  235. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.c +7 -7
  236. data/src/core/ext/upb-generated/envoy/config/core/v3/resolver.upb.h +21 -9
  237. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +8 -8
  238. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +11 -5
  239. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +8 -8
  240. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +11 -5
  241. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.c +4 -4
  242. data/src/core/ext/upb-generated/envoy/config/core/v3/udp_socket_config.upb.h +11 -5
  243. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +16 -16
  244. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +31 -13
  245. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +56 -22
  246. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +174 -17
  247. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +32 -32
  248. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +51 -21
  249. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +3 -3
  250. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -5
  251. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +37 -37
  252. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +61 -25
  253. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +40 -40
  254. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +71 -29
  255. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.c +9 -9
  256. data/src/core/ext/upb-generated/envoy/config/listener/v3/quic_config.upb.h +11 -5
  257. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +5 -5
  258. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +21 -9
  259. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +30 -30
  260. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +81 -33
  261. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +41 -29
  262. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +141 -43
  263. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +49 -43
  264. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +105 -29
  265. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +18 -18
  266. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +31 -13
  267. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +286 -279
  268. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +618 -267
  269. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +10 -10
  270. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +31 -13
  271. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +6 -6
  272. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +21 -9
  273. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +3 -3
  274. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +11 -5
  275. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +13 -13
  276. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +51 -21
  277. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +23 -23
  278. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +31 -13
  279. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +9 -9
  280. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +11 -5
  281. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +115 -116
  282. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +191 -77
  283. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +1 -1
  284. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -1
  285. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +46 -32
  286. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +118 -34
  287. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +12 -12
  288. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +31 -13
  289. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +44 -42
  290. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +108 -55
  291. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +2 -2
  292. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +11 -5
  293. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +2 -2
  294. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +11 -5
  295. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +42 -42
  296. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +61 -25
  297. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +2 -2
  298. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +11 -5
  299. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +2 -2
  300. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +11 -5
  301. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +9 -9
  302. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +21 -9
  303. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +2 -2
  304. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +11 -5
  305. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +2 -2
  306. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +11 -5
  307. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +28 -28
  308. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +51 -21
  309. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.c +8 -8
  310. data/src/core/ext/upb-generated/envoy/type/http/v3/path_transformation.upb.h +41 -17
  311. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +9 -8
  312. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -9
  313. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +4 -4
  314. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +11 -5
  315. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +4 -4
  316. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +11 -5
  317. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +3 -3
  318. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +11 -5
  319. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +9 -9
  320. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +31 -13
  321. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +10 -10
  322. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +21 -9
  323. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +6 -6
  324. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +21 -9
  325. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +11 -11
  326. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +31 -13
  327. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +15 -15
  328. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +71 -29
  329. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +19 -19
  330. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +51 -21
  331. data/src/core/ext/upb-generated/envoy/type/v3/http.upb.c +1 -1
  332. data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -1
  333. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +6 -6
  334. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +21 -9
  335. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +10 -10
  336. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +31 -13
  337. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +5 -5
  338. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +11 -5
  339. data/src/core/ext/upb-generated/google/api/annotations.upb.c +1 -1
  340. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -1
  341. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +58 -58
  342. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +111 -45
  343. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +68 -68
  344. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +121 -49
  345. data/src/core/ext/upb-generated/google/api/http.upb.c +18 -18
  346. data/src/core/ext/upb-generated/google/api/http.upb.h +31 -13
  347. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +4 -4
  348. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +11 -5
  349. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +153 -153
  350. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +271 -109
  351. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +4 -4
  352. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +11 -5
  353. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +2 -2
  354. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +11 -5
  355. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +15 -15
  356. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +31 -13
  357. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +4 -4
  358. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +11 -5
  359. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +19 -19
  360. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +91 -37
  361. data/src/core/ext/upb-generated/google/rpc/status.upb.c +5 -5
  362. data/src/core/ext/upb-generated/google/rpc/status.upb.h +11 -5
  363. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +12 -12
  364. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -5
  365. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +60 -60
  366. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +101 -41
  367. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +7 -7
  368. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -9
  369. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +5 -5
  370. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +21 -9
  371. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +31 -31
  372. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +91 -37
  373. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +55 -0
  374. data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +154 -0
  375. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +8 -8
  376. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +31 -13
  377. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +4 -6
  378. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +11 -5
  379. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.c +1 -1
  380. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -1
  381. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +4 -4
  382. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +11 -5
  383. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +3 -3
  384. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +11 -5
  385. data/src/core/ext/upb-generated/validate/validate.upb.c +220 -220
  386. data/src/core/ext/upb-generated/validate/validate.upb.h +231 -93
  387. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +58 -0
  388. data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +182 -0
  389. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +4 -4
  390. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +11 -5
  391. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +9 -9
  392. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +21 -9
  393. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +7 -7
  394. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +11 -5
  395. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +6 -6
  396. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +11 -5
  397. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +12 -12
  398. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +21 -9
  399. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +7 -7
  400. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +11 -5
  401. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +58 -0
  402. data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +130 -0
  403. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.c +33 -0
  404. data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +83 -0
  405. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +410 -384
  406. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +10 -0
  407. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +101 -88
  408. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +5 -0
  409. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +59 -56
  410. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +59 -46
  411. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +90 -63
  412. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +10 -0
  413. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +30 -19
  414. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +5 -0
  415. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +801 -783
  416. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +96 -100
  417. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +133 -115
  418. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +5 -0
  419. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +178 -173
  420. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +14 -13
  421. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +103 -103
  422. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +5 -4
  423. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +19 -23
  424. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +4 -3
  425. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +5 -3
  426. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +5 -4
  427. data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c +75 -0
  428. data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.h +50 -0
  429. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +13 -12
  430. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +25 -24
  431. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +16 -15
  432. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +17 -16
  433. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +33 -32
  434. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +19 -18
  435. data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c +45 -0
  436. data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.h +35 -0
  437. data/src/core/ext/xds/certificate_provider_registry.cc +2 -2
  438. data/src/core/ext/xds/xds_api.cc +1140 -1314
  439. data/src/core/ext/xds/xds_api.h +150 -115
  440. data/src/core/ext/xds/xds_bootstrap.cc +27 -52
  441. data/src/core/ext/xds/xds_bootstrap.h +10 -0
  442. data/src/core/ext/xds/xds_certificate_provider.cc +3 -3
  443. data/src/core/ext/xds/xds_channel_stack_modifier.cc +113 -0
  444. data/src/core/ext/xds/xds_channel_stack_modifier.h +52 -0
  445. data/src/core/ext/xds/xds_client.cc +572 -320
  446. data/src/core/ext/xds/xds_client.h +42 -37
  447. data/src/core/ext/xds/xds_client_stats.cc +16 -15
  448. data/src/core/ext/xds/xds_client_stats.h +7 -7
  449. data/src/core/ext/xds/xds_http_fault_filter.cc +4 -3
  450. data/src/core/ext/xds/xds_http_fault_filter.h +3 -2
  451. data/src/core/ext/xds/xds_http_filters.cc +1 -0
  452. data/src/core/ext/xds/xds_server_config_fetcher.cc +15 -17
  453. data/src/core/lib/address_utils/parse_address.cc +6 -8
  454. data/src/core/lib/address_utils/sockaddr_utils.cc +2 -2
  455. data/src/core/lib/avl/avl.cc +5 -5
  456. data/src/core/lib/backoff/backoff.cc +1 -1
  457. data/src/core/lib/channel/channel_args.cc +26 -7
  458. data/src/core/lib/channel/channel_args.h +9 -0
  459. data/src/core/lib/channel/channel_stack.cc +5 -3
  460. data/src/core/lib/channel/channel_stack_builder.cc +4 -14
  461. data/src/core/lib/channel/channel_stack_builder.h +0 -8
  462. data/src/core/lib/channel/channel_trace.cc +5 -4
  463. data/src/core/lib/channel/channel_trace.h +2 -1
  464. data/src/core/lib/channel/channelz.cc +43 -39
  465. data/src/core/lib/channel/channelz.h +29 -29
  466. data/src/core/lib/channel/channelz_registry.cc +8 -7
  467. data/src/core/lib/channel/channelz_registry.h +1 -1
  468. data/src/core/lib/channel/connected_channel.cc +2 -3
  469. data/src/core/lib/channel/connected_channel.h +1 -2
  470. data/src/core/lib/channel/handshaker.cc +2 -1
  471. data/src/core/lib/channel/handshaker.h +1 -2
  472. data/src/core/lib/channel/handshaker_factory.h +10 -2
  473. data/src/core/lib/channel/handshaker_registry.cc +15 -70
  474. data/src/core/lib/channel/handshaker_registry.h +29 -12
  475. data/src/core/lib/channel/status_util.h +2 -2
  476. data/src/core/lib/compression/algorithm_metadata.h +1 -0
  477. data/src/core/lib/compression/compression.cc +2 -2
  478. data/src/core/lib/compression/compression_args.cc +8 -5
  479. data/src/core/lib/compression/compression_internal.cc +4 -6
  480. data/src/core/lib/compression/compression_internal.h +1 -1
  481. data/src/core/lib/compression/message_compress.cc +2 -2
  482. data/src/core/lib/compression/stream_compression.cc +2 -1
  483. data/src/core/lib/compression/stream_compression.h +2 -1
  484. data/src/core/lib/compression/stream_compression_gzip.cc +2 -1
  485. data/src/core/lib/compression/stream_compression_identity.cc +2 -1
  486. data/src/core/lib/config/core_configuration.cc +96 -0
  487. data/src/core/lib/config/core_configuration.h +146 -0
  488. data/src/core/lib/debug/stats.cc +1 -1
  489. data/src/core/lib/debug/stats.h +1 -0
  490. data/src/core/lib/debug/stats_data.cc +15 -14
  491. data/src/core/lib/debug/stats_data.h +1 -0
  492. data/src/core/lib/debug/trace.cc +1 -0
  493. data/src/core/lib/debug/trace.h +2 -1
  494. data/src/core/lib/event_engine/endpoint_config.cc +0 -1
  495. data/src/core/lib/event_engine/event_engine.cc +3 -3
  496. data/src/core/lib/event_engine/sockaddr.cc +3 -3
  497. data/src/core/lib/gpr/alloc.cc +4 -3
  498. data/src/core/lib/gpr/atm.cc +1 -1
  499. data/src/core/lib/gpr/cpu_posix.cc +1 -1
  500. data/src/core/lib/gpr/env_linux.cc +1 -2
  501. data/src/core/lib/gpr/env_posix.cc +2 -3
  502. data/src/core/lib/gpr/log.cc +3 -3
  503. data/src/core/lib/gpr/log_android.cc +3 -2
  504. data/src/core/lib/gpr/log_linux.cc +7 -4
  505. data/src/core/lib/gpr/log_posix.cc +6 -3
  506. data/src/core/lib/gpr/string.cc +2 -2
  507. data/src/core/lib/gpr/string.h +2 -2
  508. data/src/core/lib/gpr/sync.cc +2 -2
  509. data/src/core/lib/gpr/sync_abseil.cc +7 -6
  510. data/src/core/lib/gpr/sync_posix.cc +3 -3
  511. data/src/core/lib/gpr/time.cc +3 -2
  512. data/src/core/lib/gpr/time_windows.cc +3 -2
  513. data/src/core/lib/gpr/tls.h +119 -40
  514. data/src/core/lib/gpr/tmpfile_posix.cc +1 -2
  515. data/src/core/lib/gpr/useful.h +79 -32
  516. data/src/core/lib/gprpp/arena.cc +2 -1
  517. data/src/core/lib/gprpp/arena.h +15 -5
  518. data/src/core/lib/gprpp/atomic_utils.h +47 -0
  519. data/src/core/lib/gprpp/bitset.h +188 -0
  520. data/src/core/lib/gprpp/chunked_vector.h +211 -0
  521. data/src/core/lib/{transport/authority_override.cc → gprpp/construct_destruct.h} +16 -17
  522. data/src/core/lib/gprpp/dual_ref_counted.h +25 -26
  523. data/src/core/lib/gprpp/fork.cc +14 -12
  524. data/src/core/lib/gprpp/fork.h +4 -4
  525. data/src/core/lib/gprpp/global_config.h +1 -2
  526. data/src/core/lib/gprpp/global_config_env.cc +7 -7
  527. data/src/core/lib/gprpp/global_config_generic.h +2 -2
  528. data/src/core/lib/gprpp/manual_constructor.h +8 -5
  529. data/src/core/lib/gprpp/match.h +73 -0
  530. data/src/core/lib/gprpp/memory.h +9 -3
  531. data/src/core/lib/gprpp/mpscq.cc +7 -7
  532. data/src/core/lib/gprpp/mpscq.h +6 -5
  533. data/src/core/lib/gprpp/orphanable.h +3 -3
  534. data/src/core/lib/gprpp/overload.h +59 -0
  535. data/src/core/lib/gprpp/ref_counted.h +18 -18
  536. data/src/core/lib/gprpp/status_helper.cc +27 -7
  537. data/src/core/lib/gprpp/status_helper.h +12 -1
  538. data/src/core/lib/gprpp/sync.h +3 -1
  539. data/src/core/lib/gprpp/table.h +411 -0
  540. data/src/core/lib/gprpp/thd_posix.cc +5 -5
  541. data/src/core/lib/gprpp/thd_windows.cc +4 -11
  542. data/src/core/lib/gprpp/time_util.cc +2 -2
  543. data/src/core/lib/gprpp/time_util.h +2 -2
  544. data/src/core/lib/http/format_request.cc +1 -0
  545. data/src/core/lib/http/format_request.h +1 -0
  546. data/src/core/lib/http/httpcli.cc +202 -184
  547. data/src/core/lib/http/httpcli.h +3 -0
  548. data/src/core/lib/http/httpcli_security_connector.cc +5 -8
  549. data/src/core/lib/http/parser.cc +2 -2
  550. data/src/core/lib/http/parser.h +1 -0
  551. data/src/core/lib/iomgr/buffer_list.cc +2 -1
  552. data/src/core/lib/iomgr/buffer_list.h +1 -2
  553. data/src/core/lib/iomgr/call_combiner.cc +29 -10
  554. data/src/core/lib/iomgr/cfstream_handle.cc +1 -1
  555. data/src/core/lib/iomgr/combiner.cc +9 -23
  556. data/src/core/lib/iomgr/combiner.h +1 -0
  557. data/src/core/lib/iomgr/dualstack_socket_posix.cc +1 -0
  558. data/src/core/lib/iomgr/endpoint.cc +0 -4
  559. data/src/core/lib/iomgr/endpoint.h +1 -3
  560. data/src/core/lib/iomgr/endpoint_cfstream.cc +16 -26
  561. data/src/core/lib/iomgr/endpoint_cfstream.h +1 -1
  562. data/src/core/lib/iomgr/endpoint_pair.h +1 -0
  563. data/src/core/lib/iomgr/endpoint_pair_event_engine.cc +1 -2
  564. data/src/core/lib/iomgr/endpoint_pair_posix.cc +15 -11
  565. data/src/core/lib/iomgr/endpoint_pair_windows.cc +17 -9
  566. data/src/core/lib/iomgr/error.cc +113 -52
  567. data/src/core/lib/iomgr/error.h +73 -18
  568. data/src/core/lib/iomgr/error_cfstream.cc +7 -2
  569. data/src/core/lib/iomgr/error_internal.h +1 -0
  570. data/src/core/lib/iomgr/ev_epoll1_linux.cc +17 -24
  571. data/src/core/lib/iomgr/ev_epollex_linux.cc +22 -29
  572. data/src/core/lib/iomgr/ev_poll_posix.cc +42 -45
  573. data/src/core/lib/iomgr/ev_posix.cc +1 -2
  574. data/src/core/lib/iomgr/event_engine/closure.cc +41 -18
  575. data/src/core/lib/iomgr/event_engine/closure.h +10 -1
  576. data/src/core/lib/iomgr/event_engine/endpoint.cc +6 -25
  577. data/src/core/lib/iomgr/event_engine/endpoint.h +1 -2
  578. data/src/core/lib/iomgr/event_engine/iomgr.cc +18 -19
  579. data/src/core/lib/iomgr/event_engine/iomgr.h +20 -2
  580. data/src/core/lib/iomgr/event_engine/pollset.cc +5 -4
  581. data/src/core/lib/iomgr/event_engine/resolver.cc +12 -8
  582. data/src/core/lib/iomgr/event_engine/tcp.cc +60 -30
  583. data/src/core/lib/iomgr/event_engine/timer.cc +7 -2
  584. data/src/core/lib/iomgr/exec_ctx.cc +4 -13
  585. data/src/core/lib/iomgr/exec_ctx.h +11 -19
  586. data/src/core/lib/iomgr/executor/mpmcqueue.cc +15 -16
  587. data/src/core/lib/iomgr/executor/mpmcqueue.h +7 -11
  588. data/src/core/lib/iomgr/executor/threadpool.cc +2 -2
  589. data/src/core/lib/iomgr/executor/threadpool.h +2 -1
  590. data/src/core/lib/iomgr/executor.cc +11 -26
  591. data/src/core/lib/iomgr/grpc_if_nametoindex_posix.cc +2 -2
  592. data/src/core/lib/iomgr/grpc_if_nametoindex_unsupported.cc +2 -2
  593. data/src/core/lib/iomgr/internal_errqueue.cc +3 -2
  594. data/src/core/lib/iomgr/iocp_windows.cc +1 -0
  595. data/src/core/lib/iomgr/iomgr.cc +3 -1
  596. data/src/core/lib/iomgr/iomgr.h +2 -2
  597. data/src/core/lib/iomgr/iomgr_custom.cc +2 -2
  598. data/src/core/lib/iomgr/iomgr_custom.h +2 -2
  599. data/src/core/lib/iomgr/iomgr_internal.cc +6 -10
  600. data/src/core/lib/iomgr/iomgr_internal.h +3 -2
  601. data/src/core/lib/iomgr/iomgr_windows.cc +1 -2
  602. data/src/core/lib/iomgr/is_epollexclusive_available.cc +4 -4
  603. data/src/core/lib/iomgr/load_file.cc +2 -2
  604. data/src/core/lib/iomgr/lockfree_event.cc +18 -0
  605. data/src/core/lib/iomgr/polling_entity.cc +2 -2
  606. data/src/core/lib/iomgr/pollset_custom.cc +4 -5
  607. data/src/core/lib/iomgr/pollset_custom.h +3 -3
  608. data/src/core/lib/iomgr/pollset_set_custom.cc +1 -2
  609. data/src/core/lib/iomgr/pollset_set_windows.cc +1 -0
  610. data/src/core/lib/iomgr/port.h +0 -5
  611. data/src/core/lib/iomgr/python_util.h +1 -0
  612. data/src/core/lib/iomgr/resolve_address.cc +2 -1
  613. data/src/core/lib/iomgr/resolve_address.h +0 -4
  614. data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
  615. data/src/core/lib/iomgr/resolve_address_custom.h +0 -1
  616. data/src/core/lib/iomgr/resolve_address_posix.cc +7 -11
  617. data/src/core/lib/iomgr/resolve_address_windows.cc +6 -8
  618. data/src/core/lib/iomgr/resource_quota.cc +136 -49
  619. data/src/core/lib/iomgr/resource_quota.h +66 -17
  620. data/src/core/lib/iomgr/sockaddr.h +1 -1
  621. data/src/core/lib/iomgr/socket_factory_posix.cc +5 -5
  622. data/src/core/lib/iomgr/socket_factory_posix.h +1 -0
  623. data/src/core/lib/iomgr/socket_mutator.cc +2 -2
  624. data/src/core/lib/iomgr/socket_mutator.h +2 -2
  625. data/src/core/lib/iomgr/socket_utils_common_posix.cc +4 -5
  626. data/src/core/lib/iomgr/socket_utils_linux.cc +4 -4
  627. data/src/core/lib/iomgr/socket_utils_posix.cc +2 -2
  628. data/src/core/lib/iomgr/socket_utils_posix.h +2 -2
  629. data/src/core/lib/iomgr/socket_utils_windows.cc +2 -2
  630. data/src/core/lib/iomgr/tcp_client.cc +4 -2
  631. data/src/core/lib/iomgr/tcp_client.h +4 -0
  632. data/src/core/lib/iomgr/tcp_client_cfstream.cc +14 -22
  633. data/src/core/lib/iomgr/tcp_client_custom.cc +10 -18
  634. data/src/core/lib/iomgr/tcp_client_posix.cc +33 -27
  635. data/src/core/lib/iomgr/tcp_client_posix.h +5 -2
  636. data/src/core/lib/iomgr/tcp_client_windows.cc +16 -9
  637. data/src/core/lib/iomgr/tcp_custom.cc +11 -23
  638. data/src/core/lib/iomgr/tcp_custom.h +2 -1
  639. data/src/core/lib/iomgr/tcp_posix.cc +33 -64
  640. data/src/core/lib/iomgr/tcp_posix.h +11 -12
  641. data/src/core/lib/iomgr/tcp_server.cc +6 -4
  642. data/src/core/lib/iomgr/tcp_server.h +12 -9
  643. data/src/core/lib/iomgr/tcp_server_custom.cc +17 -34
  644. data/src/core/lib/iomgr/tcp_server_posix.cc +23 -17
  645. data/src/core/lib/iomgr/tcp_server_utils_posix.h +3 -0
  646. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -2
  647. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +3 -4
  648. data/src/core/lib/iomgr/tcp_server_utils_posix_noifaddrs.cc +4 -4
  649. data/src/core/lib/iomgr/tcp_server_windows.cc +17 -14
  650. data/src/core/lib/iomgr/tcp_windows.cc +8 -27
  651. data/src/core/lib/iomgr/tcp_windows.h +2 -1
  652. data/src/core/lib/iomgr/timer.cc +1 -0
  653. data/src/core/lib/iomgr/timer.h +1 -2
  654. data/src/core/lib/iomgr/timer_custom.cc +2 -2
  655. data/src/core/lib/iomgr/timer_generic.cc +21 -51
  656. data/src/core/lib/iomgr/timer_generic.h +1 -0
  657. data/src/core/lib/iomgr/timer_heap.cc +2 -3
  658. data/src/core/lib/iomgr/unix_sockets_posix.cc +3 -5
  659. data/src/core/lib/iomgr/unix_sockets_posix.h +2 -3
  660. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -0
  661. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -3
  662. data/src/core/lib/iomgr/wakeup_fd_posix.cc +1 -0
  663. data/src/core/lib/iomgr/work_serializer.cc +4 -4
  664. data/src/core/lib/iomgr/work_serializer.h +1 -1
  665. data/src/core/lib/json/json_reader.cc +9 -17
  666. data/src/core/lib/json/json_util.cc +68 -0
  667. data/src/core/lib/json/json_util.h +65 -115
  668. data/src/core/lib/json/json_writer.cc +0 -3
  669. data/src/core/lib/matchers/matchers.h +0 -1
  670. data/src/core/lib/profiling/basic_timers.cc +8 -6
  671. data/src/core/lib/profiling/stap_timers.cc +2 -2
  672. data/src/core/lib/security/authorization/authorization_policy_provider.h +5 -4
  673. data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +1 -1
  674. data/src/core/lib/security/authorization/evaluate_args.cc +16 -12
  675. data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +171 -0
  676. data/src/core/lib/security/authorization/sdk_server_authz_filter.h +67 -0
  677. data/src/core/lib/security/context/security_context.cc +11 -8
  678. data/src/core/lib/security/credentials/alts/check_gcp_environment_linux.cc +2 -2
  679. data/src/core/lib/security/credentials/alts/check_gcp_environment_no_op.cc +2 -2
  680. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +2 -2
  681. data/src/core/lib/security/credentials/composite/composite_credentials.cc +5 -4
  682. data/src/core/lib/security/credentials/credentials.cc +10 -8
  683. data/src/core/lib/security/credentials/credentials.h +7 -2
  684. data/src/core/lib/security/credentials/credentials_metadata.cc +2 -3
  685. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +13 -26
  686. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +1 -2
  687. data/src/core/lib/security/credentials/external/aws_request_signer.cc +3 -3
  688. data/src/core/lib/security/credentials/external/external_account_credentials.cc +60 -33
  689. data/src/core/lib/security/credentials/external/external_account_credentials.h +1 -0
  690. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +2 -4
  691. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +1 -2
  692. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -4
  693. data/src/core/lib/security/credentials/iam/iam_credentials.cc +2 -1
  694. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  695. data/src/core/lib/security/credentials/jwt/json_token.h +2 -1
  696. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +31 -14
  697. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +11 -3
  698. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +5 -11
  699. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +3 -3
  700. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +3 -7
  701. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +1 -0
  702. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +4 -6
  703. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
  704. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -1
  705. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +3 -2
  706. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +10 -6
  707. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +2 -1
  708. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +7 -5
  709. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +2 -2
  710. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +6 -8
  711. data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +1 -0
  712. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -3
  713. data/src/core/lib/security/security_connector/security_connector.cc +9 -4
  714. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  715. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -7
  716. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +1 -2
  717. data/src/core/lib/security/security_connector/ssl_utils.cc +3 -4
  718. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +10 -14
  719. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +0 -2
  720. data/src/core/lib/security/transport/auth_filters.h +1 -0
  721. data/src/core/lib/security/transport/client_auth_filter.cc +9 -11
  722. data/src/core/lib/security/transport/secure_endpoint.cc +4 -14
  723. data/src/core/lib/security/transport/secure_endpoint.h +1 -0
  724. data/src/core/lib/security/transport/security_handshaker.cc +78 -47
  725. data/src/core/lib/security/transport/security_handshaker.h +2 -1
  726. data/src/core/lib/security/transport/server_auth_filter.cc +3 -5
  727. data/src/core/lib/security/transport/tsi_error.cc +3 -5
  728. data/src/core/lib/security/util/json_util.cc +6 -8
  729. data/src/core/lib/slice/percent_encoding.cc +73 -30
  730. data/src/core/lib/slice/percent_encoding.h +29 -28
  731. data/src/core/lib/slice/slice.cc +14 -21
  732. data/src/core/lib/{gpr/tls_pthread.cc → slice/slice_api.cc} +15 -6
  733. data/src/core/lib/slice/slice_buffer.cc +6 -7
  734. data/src/core/lib/slice/slice_intern.cc +10 -16
  735. data/src/core/lib/slice/slice_internal.h +3 -246
  736. data/src/core/lib/slice/slice_refcount.cc +17 -0
  737. data/src/core/lib/slice/slice_refcount.h +121 -0
  738. data/src/core/lib/slice/slice_refcount_base.h +173 -0
  739. data/src/core/lib/slice/slice_split.cc +100 -0
  740. data/src/core/lib/slice/slice_split.h +40 -0
  741. data/src/core/lib/slice/slice_string_helpers.cc +0 -83
  742. data/src/core/lib/slice/slice_string_helpers.h +0 -11
  743. data/src/core/lib/slice/static_slice.cc +529 -0
  744. data/src/core/lib/slice/static_slice.h +331 -0
  745. data/src/core/lib/surface/api_trace.cc +2 -1
  746. data/src/core/lib/surface/api_trace.h +1 -0
  747. data/src/core/lib/surface/builtins.cc +49 -0
  748. data/src/core/{ext/filters/workarounds/workaround_cronet_compression_filter.h → lib/surface/builtins.h} +8 -9
  749. data/src/core/lib/surface/byte_buffer_reader.cc +1 -1
  750. data/src/core/lib/surface/call.cc +112 -128
  751. data/src/core/lib/surface/call.h +3 -9
  752. data/src/core/lib/surface/call_details.cc +2 -2
  753. data/src/core/lib/surface/call_log_batch.cc +2 -2
  754. data/src/core/lib/surface/channel.cc +41 -41
  755. data/src/core/lib/surface/channel.h +14 -11
  756. data/src/core/lib/surface/channel_init.cc +23 -76
  757. data/src/core/lib/surface/channel_init.h +52 -44
  758. data/src/core/lib/surface/channel_ping.cc +1 -2
  759. data/src/core/lib/surface/channel_stack_type.cc +2 -1
  760. data/src/core/lib/surface/completion_queue.cc +60 -69
  761. data/src/core/lib/surface/completion_queue_factory.cc +2 -1
  762. data/src/core/lib/surface/completion_queue_factory.h +1 -0
  763. data/src/core/lib/surface/event_string.cc +1 -0
  764. data/src/core/lib/surface/init.cc +4 -48
  765. data/src/core/lib/surface/init.h +0 -1
  766. data/src/core/lib/surface/init_secure.cc +36 -14
  767. data/src/core/lib/surface/lame_client.cc +24 -16
  768. data/src/core/lib/surface/lame_client.h +1 -1
  769. data/src/core/lib/surface/metadata_array.cc +2 -2
  770. data/src/core/lib/surface/server.cc +42 -50
  771. data/src/core/lib/surface/server.h +28 -23
  772. data/src/core/lib/surface/validate_metadata.cc +49 -18
  773. data/src/core/lib/surface/version.cc +2 -2
  774. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  775. data/src/core/lib/transport/byte_stream.h +1 -0
  776. data/src/core/lib/transport/connectivity_state.cc +8 -5
  777. data/src/core/lib/transport/connectivity_state.h +2 -2
  778. data/src/core/lib/transport/error_utils.cc +43 -17
  779. data/src/core/lib/transport/error_utils.h +1 -1
  780. data/src/core/lib/transport/metadata.cc +41 -20
  781. data/src/core/lib/transport/metadata.h +15 -12
  782. data/src/core/lib/transport/metadata_batch.cc +39 -364
  783. data/src/core/lib/transport/metadata_batch.h +916 -67
  784. data/src/core/lib/transport/parsed_metadata.h +263 -0
  785. data/src/core/lib/transport/pid_controller.cc +4 -4
  786. data/src/core/lib/transport/static_metadata.cc +714 -846
  787. data/src/core/lib/transport/static_metadata.h +115 -379
  788. data/src/core/lib/transport/status_metadata.cc +1 -0
  789. data/src/core/lib/transport/transport.cc +4 -5
  790. data/src/core/lib/transport/transport_op_string.cc +40 -20
  791. data/src/core/plugin_registry/grpc_plugin_registry.cc +76 -41
  792. data/src/core/tsi/alts/crypt/aes_gcm.cc +6 -3
  793. data/src/core/tsi/alts/crypt/gsec.h +2 -3
  794. data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +13 -12
  795. data/src/core/tsi/alts/frame_protector/frame_handler.cc +10 -11
  796. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +3 -4
  797. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +2 -3
  798. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +12 -2
  799. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_integrity_only_record_protocol.cc +2 -2
  800. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +1 -1
  801. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +2 -2
  802. data/src/core/tsi/fake_transport_security.cc +15 -7
  803. data/src/core/tsi/local_transport_security.cc +36 -73
  804. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +20 -53
  805. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -3
  806. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +2 -2
  807. data/src/core/tsi/ssl_transport_security.cc +21 -11
  808. data/src/core/tsi/ssl_transport_security.h +3 -1
  809. data/src/core/tsi/transport_security.cc +15 -3
  810. data/src/core/tsi/transport_security.h +16 -1
  811. data/src/core/tsi/transport_security_grpc.h +1 -0
  812. data/src/core/tsi/transport_security_interface.h +26 -0
  813. data/src/ruby/ext/grpc/extconf.rb +12 -9
  814. data/src/ruby/ext/grpc/rb_byte_buffer.c +2 -1
  815. data/src/ruby/ext/grpc/rb_call.c +5 -5
  816. data/src/ruby/ext/grpc/rb_call_credentials.c +5 -5
  817. data/src/ruby/ext/grpc/rb_channel.c +10 -8
  818. data/src/ruby/ext/grpc/rb_channel_args.c +2 -2
  819. data/src/ruby/ext/grpc/rb_channel_credentials.c +4 -4
  820. data/src/ruby/ext/grpc/rb_channel_credentials.h +1 -0
  821. data/src/ruby/ext/grpc/rb_completion_queue.c +3 -2
  822. data/src/ruby/ext/grpc/rb_compression_options.c +5 -4
  823. data/src/ruby/ext/grpc/rb_event_thread.c +4 -4
  824. data/src/ruby/ext/grpc/rb_grpc.c +5 -4
  825. data/src/ruby/ext/grpc/rb_grpc.h +1 -0
  826. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  827. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  828. data/src/ruby/ext/grpc/rb_server.c +6 -5
  829. data/src/ruby/ext/grpc/rb_server_credentials.c +3 -3
  830. data/src/ruby/ext/grpc/rb_server_credentials.h +1 -0
  831. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +8 -5
  832. data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +3 -1
  833. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +6 -5
  834. data/src/ruby/ext/grpc/rb_xds_server_credentials.h +3 -1
  835. data/src/ruby/lib/grpc/version.rb +1 -1
  836. data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -2
  837. data/src/ruby/spec/client_server_spec.rb +1 -1
  838. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +4 -4
  839. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -6
  840. data/third_party/address_sorting/address_sorting_posix.c +1 -0
  841. data/third_party/boringssl-with-bazel/err_data.c +300 -292
  842. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +52 -47
  843. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +21 -22
  844. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_d2i_fp.c +0 -2
  845. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +6 -1
  846. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_mbstr.c +16 -23
  847. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +14 -7
  848. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_print.c +19 -29
  849. data/third_party/boringssl-with-bazel/src/crypto/{x509 → asn1}/a_strex.c +269 -272
  850. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +106 -153
  851. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_time.c +3 -3
  852. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +1 -1
  853. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +1 -40
  854. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utf8.c +1 -1
  855. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_par.c +1 -1
  856. data/third_party/boringssl-with-bazel/src/crypto/{x509 → asn1}/charmap.h +0 -0
  857. data/third_party/boringssl-with-bazel/src/crypto/asn1/{asn1_locl.h → internal.h} +58 -1
  858. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +9 -9
  859. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +290 -199
  860. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +9 -9
  861. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +10 -14
  862. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +2 -1
  863. data/third_party/boringssl-with-bazel/src/crypto/asn1/time_support.c +1 -1
  864. data/third_party/boringssl-with-bazel/src/crypto/base64/base64.c +11 -8
  865. data/third_party/boringssl-with-bazel/src/crypto/bio/bio_mem.c +1 -7
  866. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +1 -5
  867. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +0 -4
  868. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +1 -7
  869. data/third_party/boringssl-with-bazel/src/crypto/bio/pair.c +1 -6
  870. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +3 -17
  871. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +4 -6
  872. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbb.c +9 -0
  873. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +8 -0
  874. data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +38 -47
  875. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/cipher_extra.c +45 -65
  876. data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +14 -3
  877. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +6 -3
  878. data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +32 -34
  879. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +26 -9
  880. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/gcd_extra.c +3 -2
  881. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +5 -2
  882. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +5 -9
  883. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +10 -0
  884. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +10 -11
  885. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +1 -3
  886. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  887. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +4 -7
  888. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +4 -7
  889. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/modes/gcm_nohw.c +1 -1
  890. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +5 -9
  891. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +2 -2
  892. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +4 -6
  893. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +24 -9
  894. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +4 -2
  895. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +35 -35
  896. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +11 -10
  897. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +10 -37
  898. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +34 -0
  899. data/third_party/boringssl-with-bazel/src/crypto/hrss/hrss.c +219 -121
  900. data/third_party/boringssl-with-bazel/src/crypto/hrss/internal.h +9 -2
  901. data/third_party/boringssl-with-bazel/src/crypto/internal.h +62 -2
  902. data/third_party/boringssl-with-bazel/src/crypto/lhash/internal.h +253 -0
  903. data/third_party/boringssl-with-bazel/src/crypto/lhash/lhash.c +28 -23
  904. data/third_party/boringssl-with-bazel/src/crypto/mem.c +14 -9
  905. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +7 -3
  906. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_all.c +0 -9
  907. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_info.c +0 -2
  908. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_lib.c +0 -8
  909. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pk8.c +0 -2
  910. data/third_party/boringssl-with-bazel/src/crypto/pem/pem_pkey.c +0 -4
  911. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/internal.h +16 -7
  912. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7.c +9 -4
  913. data/third_party/boringssl-with-bazel/src/crypto/pkcs7/pkcs7_x509.c +151 -12
  914. data/third_party/boringssl-with-bazel/src/crypto/pkcs8/pkcs8_x509.c +1 -1
  915. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +1 -1
  916. data/third_party/boringssl-with-bazel/src/crypto/pool/pool.c +1 -0
  917. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +4 -0
  918. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/fuchsia.c +4 -0
  919. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +4 -0
  920. data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +6 -6
  921. data/third_party/boringssl-with-bazel/src/crypto/x509/a_verify.c +15 -11
  922. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +1 -1
  923. data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -0
  924. data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +2 -0
  925. data/third_party/boringssl-with-bazel/src/crypto/x509/internal.h +225 -2
  926. data/third_party/boringssl-with-bazel/src/crypto/x509/name_print.c +246 -0
  927. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +15 -4
  928. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +10 -5
  929. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +0 -179
  930. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509a.c +4 -2
  931. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_att.c +6 -23
  932. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +2 -2
  933. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_lu.c +1 -5
  934. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -0
  935. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +25 -22
  936. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +11 -54
  937. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vpm.c +1 -1
  938. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +1 -0
  939. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +2 -4
  940. data/third_party/boringssl-with-bazel/src/crypto/x509/x_algor.c +1 -3
  941. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +0 -16
  942. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +9 -11
  943. data/third_party/boringssl-with-bazel/src/crypto/x509/x_exten.c +2 -0
  944. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +23 -21
  945. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +12 -11
  946. data/third_party/boringssl-with-bazel/src/crypto/x509v3/internal.h +16 -0
  947. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_cache.c +1 -0
  948. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +1 -1
  949. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_int.h +1 -1
  950. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_map.c +1 -0
  951. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_tree.c +4 -3
  952. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +24 -5
  953. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +17 -8
  954. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +3 -0
  955. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +1 -0
  956. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +6 -6
  957. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_crld.c +4 -2
  958. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +5 -0
  959. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +2 -0
  960. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ncons.c +112 -55
  961. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pci.c +2 -1
  962. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +14 -13
  963. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +1 -1
  964. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +76 -31
  965. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +521 -296
  966. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +2 -9
  967. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +10 -5
  968. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +3 -1
  969. data/third_party/boringssl-with-bazel/src/include/openssl/bn.h +3 -3
  970. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +9 -0
  971. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +8 -2
  972. data/third_party/boringssl-with-bazel/src/include/openssl/conf.h +8 -5
  973. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +3 -0
  974. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +6 -0
  975. data/third_party/boringssl-with-bazel/src/include/openssl/hkdf.h +4 -0
  976. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +25 -0
  977. data/third_party/boringssl-with-bazel/src/include/openssl/hrss.h +14 -12
  978. data/third_party/boringssl-with-bazel/src/include/openssl/lhash.h +4 -205
  979. data/third_party/boringssl-with-bazel/src/include/openssl/mem.h +12 -3
  980. data/third_party/boringssl-with-bazel/src/include/openssl/obj.h +5 -4
  981. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +0 -20
  982. data/third_party/boringssl-with-bazel/src/include/openssl/pkcs7.h +12 -5
  983. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +5 -0
  984. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +37 -15
  985. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +81 -15
  986. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +31 -32
  987. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +713 -146
  988. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +16 -695
  989. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +48 -13
  990. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +9 -16
  991. data/third_party/boringssl-with-bazel/src/ssl/encrypted_client_hello.cc +310 -359
  992. data/third_party/boringssl-with-bazel/src/ssl/{t1_lib.cc → extensions.cc} +110 -159
  993. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +24 -13
  994. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +145 -142
  995. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +106 -99
  996. data/third_party/boringssl-with-bazel/src/ssl/internal.h +87 -48
  997. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +1 -2
  998. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +2 -2
  999. data/third_party/boringssl-with-bazel/src/ssl/ssl_key_share.cc +11 -5
  1000. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +2 -51
  1001. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +121 -65
  1002. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +6 -12
  1003. data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +28 -23
  1004. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +14 -27
  1005. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +210 -212
  1006. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +30 -41
  1007. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +48 -34
  1008. data/third_party/re2/re2/compile.cc +91 -109
  1009. data/third_party/re2/re2/dfa.cc +27 -39
  1010. data/third_party/re2/re2/filtered_re2.cc +18 -2
  1011. data/third_party/re2/re2/filtered_re2.h +10 -5
  1012. data/third_party/re2/re2/nfa.cc +1 -1
  1013. data/third_party/re2/re2/parse.cc +42 -23
  1014. data/third_party/re2/re2/perl_groups.cc +34 -34
  1015. data/third_party/re2/re2/prefilter.cc +3 -2
  1016. data/third_party/re2/re2/prog.cc +182 -4
  1017. data/third_party/re2/re2/prog.h +28 -9
  1018. data/third_party/re2/re2/re2.cc +87 -118
  1019. data/third_party/re2/re2/re2.h +156 -141
  1020. data/third_party/re2/re2/regexp.cc +12 -5
  1021. data/third_party/re2/re2/regexp.h +8 -2
  1022. data/third_party/re2/re2/set.cc +31 -9
  1023. data/third_party/re2/re2/set.h +9 -4
  1024. data/third_party/re2/re2/simplify.cc +11 -3
  1025. data/third_party/re2/re2/tostring.cc +1 -1
  1026. data/third_party/re2/re2/walker-inl.h +1 -1
  1027. data/third_party/re2/util/mutex.h +2 -2
  1028. data/third_party/re2/util/pcre.h +3 -3
  1029. data/third_party/upb/upb/decode.c +129 -60
  1030. data/third_party/upb/upb/decode.h +32 -4
  1031. data/third_party/upb/upb/decode_fast.c +513 -500
  1032. data/third_party/upb/upb/decode_fast.h +27 -0
  1033. data/third_party/upb/upb/{decode.int.h → decode_internal.h} +38 -8
  1034. data/third_party/upb/upb/def.c +171 -181
  1035. data/third_party/upb/upb/def.h +41 -19
  1036. data/third_party/upb/upb/def.hpp +29 -0
  1037. data/third_party/upb/upb/encode.c +49 -16
  1038. data/third_party/upb/upb/encode.h +29 -2
  1039. data/third_party/upb/upb/msg.c +169 -28
  1040. data/third_party/upb/upb/msg.h +75 -580
  1041. data/third_party/upb/upb/msg_internal.h +687 -0
  1042. data/third_party/upb/upb/port_def.inc +85 -24
  1043. data/third_party/upb/upb/port_undef.inc +38 -1
  1044. data/third_party/upb/upb/reflection.c +29 -37
  1045. data/third_party/upb/upb/reflection.h +36 -8
  1046. data/third_party/upb/upb/reflection.hpp +37 -0
  1047. data/third_party/upb/upb/table.c +211 -86
  1048. data/third_party/upb/upb/{table.int.h → table_internal.h} +56 -180
  1049. data/third_party/upb/upb/text_encode.c +32 -4
  1050. data/third_party/upb/upb/text_encode.h +26 -0
  1051. data/third_party/upb/upb/upb.c +59 -8
  1052. data/third_party/upb/upb/upb.h +36 -6
  1053. data/third_party/upb/upb/upb.hpp +24 -0
  1054. data/third_party/upb/upb/upb_internal.h +58 -0
  1055. metadata +102 -87
  1056. data/include/grpc/event_engine/slice_allocator.h +0 -66
  1057. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +0 -179
  1058. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +0 -38
  1059. data/src/core/ext/filters/client_channel/service_config_call_data.h +0 -126
  1060. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +0 -211
  1061. data/src/core/ext/filters/workarounds/workaround_utils.cc +0 -53
  1062. data/src/core/ext/filters/workarounds/workaround_utils.h +0 -39
  1063. data/src/core/ext/transport/chttp2/client/authority.cc +0 -42
  1064. data/src/core/ext/transport/chttp2/client/authority.h +0 -36
  1065. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +0 -66
  1066. data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +0 -74
  1067. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +0 -243
  1068. data/src/core/ext/transport/chttp2/transport/hpack_table.h +0 -148
  1069. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -66
  1070. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +0 -58
  1071. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +0 -58
  1072. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +0 -124
  1073. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +0 -33
  1074. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +0 -77
  1075. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +0 -44
  1076. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +0 -35
  1077. data/src/core/lib/gpr/tls_gcc.h +0 -52
  1078. data/src/core/lib/gpr/tls_msvc.h +0 -54
  1079. data/src/core/lib/gpr/tls_pthread.h +0 -56
  1080. data/src/core/lib/gpr/tls_stdcpp.h +0 -48
  1081. data/src/core/lib/gprpp/atomic.h +0 -104
  1082. data/src/core/lib/iomgr/endpoint_pair_uv.cc +0 -40
  1083. data/src/core/lib/iomgr/iomgr_uv.cc +0 -43
  1084. data/src/core/lib/iomgr/pollset_uv.cc +0 -95
  1085. data/src/core/lib/iomgr/pollset_uv.h +0 -36
  1086. data/src/core/lib/iomgr/sockaddr_custom.h +0 -54
  1087. data/src/core/lib/iomgr/socket_utils_uv.cc +0 -49
  1088. data/src/core/lib/iomgr/tcp_uv.cc +0 -421
  1089. data/src/core/lib/iomgr/timer_uv.cc +0 -66
  1090. data/src/core/lib/iomgr/udp_server.cc +0 -748
  1091. data/src/core/lib/iomgr/udp_server.h +0 -103
  1092. data/third_party/upb/third_party/wyhash/wyhash.h +0 -145
  1093. data/third_party/upb/upb/upb.int.h +0 -29
@@ -18,6 +18,8 @@
18
18
 
19
19
  #include <grpc/support/port_platform.h>
20
20
 
21
+ #include "src/core/ext/xds/xds_api.h"
22
+
21
23
  #include <algorithm>
22
24
  #include <cctype>
23
25
  #include <cstdint>
@@ -80,25 +82,24 @@
80
82
  #include "google/protobuf/timestamp.upb.h"
81
83
  #include "google/protobuf/wrappers.upb.h"
82
84
  #include "google/rpc/status.upb.h"
83
- #include "udpa/type/v1/typed_struct.upb.h"
84
85
  #include "upb/text_encode.h"
85
86
  #include "upb/upb.h"
86
87
  #include "upb/upb.hpp"
88
+ #include "xds/type/v3/typed_struct.upb.h"
87
89
 
88
90
  #include <grpc/impl/codegen/log.h>
89
91
  #include <grpc/support/alloc.h>
90
92
  #include <grpc/support/string_util.h>
91
93
 
92
- #include "src/core/ext/xds/xds_api.h"
93
94
  #include "src/core/lib/address_utils/sockaddr_utils.h"
94
95
  #include "src/core/lib/gpr/env.h"
95
96
  #include "src/core/lib/gpr/string.h"
96
- #include "src/core/lib/gpr/useful.h"
97
97
  #include "src/core/lib/gprpp/host_port.h"
98
98
  #include "src/core/lib/iomgr/error.h"
99
99
  #include "src/core/lib/iomgr/sockaddr.h"
100
100
  #include "src/core/lib/iomgr/socket_utils.h"
101
101
  #include "src/core/lib/slice/slice_utils.h"
102
+ #include "src/core/lib/uri/uri_parser.h"
102
103
 
103
104
  namespace grpc_core {
104
105
 
@@ -115,33 +116,58 @@ bool XdsAggregateAndLogicalDnsClusterEnabled() {
115
116
  return parse_succeeded && parsed_value;
116
117
  }
117
118
 
118
- // TODO(donnadionne): Check to see if ring hash policy is enabled, this will be
119
- // removed once ring hash policy is fully integration-tested and enabled by
120
- // default.
121
- bool XdsRingHashEnabled() {
122
- char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_RING_HASH");
119
+ // TODO(yashykt): Remove once RBAC is no longer experimental
120
+ bool XdsRbacEnabled() {
121
+ char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_RBAC");
123
122
  bool parsed_value;
124
123
  bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
125
124
  gpr_free(value);
126
125
  return parse_succeeded && parsed_value;
127
126
  }
128
127
 
129
- // TODO(yashykt): Check to see if xDS security is enabled. This will be
130
- // removed once this feature is fully integration-tested and enabled by
131
- // default.
132
- bool XdsSecurityEnabled() {
133
- char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT");
134
- bool parsed_value;
135
- bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
136
- gpr_free(value);
137
- return parse_succeeded && parsed_value;
128
+ //
129
+ // XdsApi::RetryPolicy
130
+ //
131
+
132
+ std::string XdsApi::RetryPolicy::RetryBackOff::ToString() const {
133
+ std::vector<std::string> contents;
134
+ contents.push_back(
135
+ absl::StrCat("RetryBackOff Base: ", base_interval.ToString()));
136
+ contents.push_back(
137
+ absl::StrCat("RetryBackOff max: ", max_interval.ToString()));
138
+ return absl::StrJoin(contents, ",");
139
+ }
140
+
141
+ std::string XdsApi::RetryPolicy::ToString() const {
142
+ std::vector<std::string> contents;
143
+ contents.push_back(absl::StrFormat("num_retries=%d", num_retries));
144
+ contents.push_back(retry_back_off.ToString());
145
+ return absl::StrCat("{", absl::StrJoin(contents, ","), "}");
146
+ }
147
+
148
+ //
149
+ // XdsApi::Route::Matchers
150
+ //
151
+
152
+ std::string XdsApi::Route::Matchers::ToString() const {
153
+ std::vector<std::string> contents;
154
+ contents.push_back(
155
+ absl::StrFormat("PathMatcher{%s}", path_matcher.ToString()));
156
+ for (const HeaderMatcher& header_matcher : header_matchers) {
157
+ contents.push_back(header_matcher.ToString());
158
+ }
159
+ if (fraction_per_million.has_value()) {
160
+ contents.push_back(absl::StrFormat("Fraction Per Million %d",
161
+ fraction_per_million.value()));
162
+ }
163
+ return absl::StrJoin(contents, "\n");
138
164
  }
139
165
 
140
166
  //
141
- // XdsApi::Route::HashPolicy
167
+ // XdsApi::Route::RouteAction::HashPolicy
142
168
  //
143
169
 
144
- XdsApi::Route::HashPolicy::HashPolicy(const HashPolicy& other)
170
+ XdsApi::Route::RouteAction::HashPolicy::HashPolicy(const HashPolicy& other)
145
171
  : type(other.type),
146
172
  header_name(other.header_name),
147
173
  regex_substitution(other.regex_substitution) {
@@ -151,8 +177,8 @@ XdsApi::Route::HashPolicy::HashPolicy(const HashPolicy& other)
151
177
  }
152
178
  }
153
179
 
154
- XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
155
- const HashPolicy& other) {
180
+ XdsApi::Route::RouteAction::HashPolicy&
181
+ XdsApi::Route::RouteAction::HashPolicy::operator=(const HashPolicy& other) {
156
182
  type = other.type;
157
183
  header_name = other.header_name;
158
184
  if (other.regex != nullptr) {
@@ -163,14 +189,14 @@ XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
163
189
  return *this;
164
190
  }
165
191
 
166
- XdsApi::Route::HashPolicy::HashPolicy(HashPolicy&& other) noexcept
192
+ XdsApi::Route::RouteAction::HashPolicy::HashPolicy(HashPolicy&& other) noexcept
167
193
  : type(other.type),
168
194
  header_name(std::move(other.header_name)),
169
195
  regex(std::move(other.regex)),
170
196
  regex_substitution(std::move(other.regex_substitution)) {}
171
197
 
172
- XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
173
- HashPolicy&& other) noexcept {
198
+ XdsApi::Route::RouteAction::HashPolicy&
199
+ XdsApi::Route::RouteAction::HashPolicy::operator=(HashPolicy&& other) noexcept {
174
200
  type = other.type;
175
201
  header_name = std::move(other.header_name);
176
202
  regex = std::move(other.regex);
@@ -178,7 +204,7 @@ XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
178
204
  return *this;
179
205
  }
180
206
 
181
- bool XdsApi::Route::HashPolicy::HashPolicy::operator==(
207
+ bool XdsApi::Route::RouteAction::HashPolicy::HashPolicy::operator==(
182
208
  const HashPolicy& other) const {
183
209
  if (type != other.type) return false;
184
210
  if (type == Type::HEADER) {
@@ -194,7 +220,7 @@ bool XdsApi::Route::HashPolicy::HashPolicy::operator==(
194
220
  return true;
195
221
  }
196
222
 
197
- std::string XdsApi::Route::HashPolicy::ToString() const {
223
+ std::string XdsApi::Route::RouteAction::HashPolicy::ToString() const {
198
224
  std::vector<std::string> contents;
199
225
  switch (type) {
200
226
  case Type::HEADER:
@@ -215,43 +241,10 @@ std::string XdsApi::Route::HashPolicy::ToString() const {
215
241
  }
216
242
 
217
243
  //
218
- // XdsApi::Route::RetryPolicy
219
- //
220
- std::string XdsApi::Route::RetryPolicy::RetryBackOff::ToString() const {
221
- std::vector<std::string> contents;
222
- contents.push_back(
223
- absl::StrCat("RetryBackOff Base: ", base_interval.ToString()));
224
- contents.push_back(
225
- absl::StrCat("RetryBackOff max: ", max_interval.ToString()));
226
- return absl::StrJoin(contents, ",");
227
- }
228
-
229
- std::string XdsApi::Route::RetryPolicy::ToString() const {
230
- std::vector<std::string> contents;
231
- contents.push_back(absl::StrFormat("num_retries=%d", num_retries));
232
- contents.push_back(retry_back_off.ToString());
233
- return absl::StrJoin(contents, ",");
234
- }
235
-
236
- //
237
- // XdsApi::Route
244
+ // XdsApi::Route::RouteAction::ClusterWeight
238
245
  //
239
246
 
240
- std::string XdsApi::Route::Matchers::ToString() const {
241
- std::vector<std::string> contents;
242
- contents.push_back(
243
- absl::StrFormat("PathMatcher{%s}", path_matcher.ToString()));
244
- for (const HeaderMatcher& header_matcher : header_matchers) {
245
- contents.push_back(header_matcher.ToString());
246
- }
247
- if (fraction_per_million.has_value()) {
248
- contents.push_back(absl::StrFormat("Fraction Per Million %d",
249
- fraction_per_million.value()));
250
- }
251
- return absl::StrJoin(contents, "\n");
252
- }
253
-
254
- std::string XdsApi::Route::ClusterWeight::ToString() const {
247
+ std::string XdsApi::Route::RouteAction::ClusterWeight::ToString() const {
255
248
  std::vector<std::string> contents;
256
249
  contents.push_back(absl::StrCat("cluster=", name));
257
250
  contents.push_back(absl::StrCat("weight=", weight));
@@ -268,15 +261,17 @@ std::string XdsApi::Route::ClusterWeight::ToString() const {
268
261
  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
269
262
  }
270
263
 
271
- std::string XdsApi::Route::ToString() const {
264
+ //
265
+ // XdsApi::Route::RouteAction
266
+ //
267
+
268
+ std::string XdsApi::Route::RouteAction::ToString() const {
272
269
  std::vector<std::string> contents;
273
- contents.push_back(matchers.ToString());
274
270
  for (const HashPolicy& hash_policy : hash_policies) {
275
271
  contents.push_back(absl::StrCat("hash_policy=", hash_policy.ToString()));
276
272
  }
277
273
  if (retry_policy.has_value()) {
278
- contents.push_back(
279
- absl::StrCat("retry_policy={", retry_policy->ToString(), "}"));
274
+ contents.push_back(absl::StrCat("retry_policy=", retry_policy->ToString()));
280
275
  }
281
276
  if (!cluster_name.empty()) {
282
277
  contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
@@ -287,6 +282,25 @@ std::string XdsApi::Route::ToString() const {
287
282
  if (max_stream_duration.has_value()) {
288
283
  contents.push_back(max_stream_duration->ToString());
289
284
  }
285
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
286
+ }
287
+
288
+ //
289
+ // XdsApi::Route
290
+ //
291
+
292
+ std::string XdsApi::Route::ToString() const {
293
+ std::vector<std::string> contents;
294
+ contents.push_back(matchers.ToString());
295
+ auto* route_action = absl::get_if<XdsApi::Route::RouteAction>(&action);
296
+ if (route_action != nullptr) {
297
+ contents.push_back(absl::StrCat("route=", route_action->ToString()));
298
+ } else if (absl::holds_alternative<XdsApi::Route::NonForwardingAction>(
299
+ action)) {
300
+ contents.push_back("non_forwarding_action={}");
301
+ } else {
302
+ contents.push_back("unknown_action={}");
303
+ }
290
304
  if (!typed_per_filter_config.empty()) {
291
305
  contents.push_back("typed_per_filter_config={");
292
306
  for (const auto& p : typed_per_filter_config) {
@@ -448,11 +462,11 @@ bool XdsApi::CommonTlsContext::CertificateValidationContext::Empty() const {
448
462
  }
449
463
 
450
464
  //
451
- // XdsApi::CommonTlsContext::CertificateValidationContext
465
+ // XdsApi::CommonTlsContext::CertificateProviderPluginInstance
452
466
  //
453
467
 
454
- std::string XdsApi::CommonTlsContext::CertificateProviderInstance::ToString()
455
- const {
468
+ std::string
469
+ XdsApi::CommonTlsContext::CertificateProviderPluginInstance::ToString() const {
456
470
  absl::InlinedVector<std::string, 2> contents;
457
471
  if (!instance_name.empty()) {
458
472
  contents.push_back(absl::StrFormat("instance_name=%s", instance_name));
@@ -464,34 +478,9 @@ std::string XdsApi::CommonTlsContext::CertificateProviderInstance::ToString()
464
478
  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
465
479
  }
466
480
 
467
- bool XdsApi::CommonTlsContext::CertificateProviderInstance::Empty() const {
468
- return instance_name.empty() && certificate_name.empty();
469
- }
470
-
471
- //
472
- // XdsApi::CommonTlsContext::CombinedCertificateValidationContext
473
- //
474
-
475
- std::string
476
- XdsApi::CommonTlsContext::CombinedCertificateValidationContext::ToString()
481
+ bool XdsApi::CommonTlsContext::CertificateProviderPluginInstance::Empty()
477
482
  const {
478
- absl::InlinedVector<std::string, 2> contents;
479
- if (!default_validation_context.Empty()) {
480
- contents.push_back(absl::StrFormat("default_validation_context=%s",
481
- default_validation_context.ToString()));
482
- }
483
- if (!validation_context_certificate_provider_instance.Empty()) {
484
- contents.push_back(absl::StrFormat(
485
- "validation_context_certificate_provider_instance=%s",
486
- validation_context_certificate_provider_instance.ToString()));
487
- }
488
- return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
489
- }
490
-
491
- bool XdsApi::CommonTlsContext::CombinedCertificateValidationContext::Empty()
492
- const {
493
- return default_validation_context.Empty() &&
494
- validation_context_certificate_provider_instance.Empty();
483
+ return instance_name.empty() && certificate_name.empty();
495
484
  }
496
485
 
497
486
  //
@@ -500,21 +489,22 @@ bool XdsApi::CommonTlsContext::CombinedCertificateValidationContext::Empty()
500
489
 
501
490
  std::string XdsApi::CommonTlsContext::ToString() const {
502
491
  absl::InlinedVector<std::string, 2> contents;
503
- if (!tls_certificate_certificate_provider_instance.Empty()) {
504
- contents.push_back(absl::StrFormat(
505
- "tls_certificate_certificate_provider_instance=%s",
506
- tls_certificate_certificate_provider_instance.ToString()));
492
+ if (!tls_certificate_provider_instance.Empty()) {
493
+ contents.push_back(
494
+ absl::StrFormat("tls_certificate_provider_instance=%s",
495
+ tls_certificate_provider_instance.ToString()));
507
496
  }
508
- if (!combined_validation_context.Empty()) {
509
- contents.push_back(absl::StrFormat("combined_validation_context=%s",
510
- combined_validation_context.ToString()));
497
+ if (!certificate_validation_context.Empty()) {
498
+ contents.push_back(
499
+ absl::StrFormat("certificate_validation_context=%s",
500
+ certificate_validation_context.ToString()));
511
501
  }
512
502
  return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
513
503
  }
514
504
 
515
505
  bool XdsApi::CommonTlsContext::Empty() const {
516
- return tls_certificate_certificate_provider_instance.Empty() &&
517
- combined_validation_context.Empty();
506
+ return tls_certificate_provider_instance.Empty() &&
507
+ certificate_validation_context.Empty();
518
508
  }
519
509
 
520
510
  //
@@ -849,7 +839,7 @@ const char* kCdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
849
839
  const char* kEdsV2TypeUrl =
850
840
  "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
851
841
 
852
- bool IsLds(absl::string_view type_url, bool* is_v2 = nullptr) {
842
+ bool IsLdsInternal(absl::string_view type_url, bool* is_v2 = nullptr) {
853
843
  if (type_url == XdsApi::kLdsTypeUrl) return true;
854
844
  if (type_url == kLdsV2TypeUrl) {
855
845
  if (is_v2 != nullptr) *is_v2 = true;
@@ -858,18 +848,46 @@ bool IsLds(absl::string_view type_url, bool* is_v2 = nullptr) {
858
848
  return false;
859
849
  }
860
850
 
861
- bool IsRds(absl::string_view type_url) {
851
+ bool IsRdsInternal(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
862
852
  return type_url == XdsApi::kRdsTypeUrl || type_url == kRdsV2TypeUrl;
863
853
  }
864
854
 
865
- bool IsCds(absl::string_view type_url) {
855
+ bool IsCdsInternal(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
866
856
  return type_url == XdsApi::kCdsTypeUrl || type_url == kCdsV2TypeUrl;
867
857
  }
868
858
 
869
- bool IsEds(absl::string_view type_url) {
859
+ bool IsEdsInternal(absl::string_view type_url, bool* /*is_v2*/ = nullptr) {
870
860
  return type_url == XdsApi::kEdsTypeUrl || type_url == kEdsV2TypeUrl;
871
861
  }
872
862
 
863
+ absl::StatusOr<XdsApi::ResourceName> ParseResourceNameInternal(
864
+ absl::string_view name,
865
+ std::function<bool(absl::string_view, bool*)> is_expected_type) {
866
+ // Old-style names use the empty string for authority.
867
+ // ID is prefixed with "old:" to indicate that it's an old-style name.
868
+ if (!absl::StartsWith(name, "xdstp:")) {
869
+ return XdsApi::ResourceName{"", absl::StrCat("old:", name)};
870
+ }
871
+ // New style name. Parse URI.
872
+ auto uri = URI::Parse(name);
873
+ if (!uri.ok()) return uri.status();
874
+ // Split the resource type off of the path to get the id.
875
+ std::pair<absl::string_view, absl::string_view> path_parts =
876
+ absl::StrSplit(uri->path(), absl::MaxSplits('/', 1));
877
+ if (!is_expected_type(path_parts.first, nullptr)) {
878
+ return absl::InvalidArgumentError(
879
+ "xdstp URI path must indicate valid xDS resource type");
880
+ }
881
+ std::vector<std::pair<absl::string_view, absl::string_view>> query_parameters(
882
+ uri->query_parameter_map().begin(), uri->query_parameter_map().end());
883
+ std::sort(query_parameters.begin(), query_parameters.end());
884
+ return XdsApi::ResourceName{
885
+ uri->authority(),
886
+ absl::StrCat(
887
+ "xdstp:", path_parts.second, (query_parameters.empty() ? "?" : ""),
888
+ absl::StrJoin(query_parameters, "&", absl::PairFormatter("=")))};
889
+ }
890
+
873
891
  } // namespace
874
892
 
875
893
  // If gRPC is built with -DGRPC_XDS_USER_AGENT_NAME_SUFFIX="...", that string
@@ -926,6 +944,41 @@ XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
926
944
  XdsHttpFilterRegistry::PopulateSymtab(symtab_.ptr());
927
945
  }
928
946
 
947
+ bool XdsApi::IsLds(absl::string_view type_url) {
948
+ return IsLdsInternal(type_url);
949
+ }
950
+
951
+ bool XdsApi::IsRds(absl::string_view type_url) {
952
+ return IsRdsInternal(type_url);
953
+ }
954
+
955
+ bool XdsApi::IsCds(absl::string_view type_url) {
956
+ return IsCdsInternal(type_url);
957
+ }
958
+
959
+ bool XdsApi::IsEds(absl::string_view type_url) {
960
+ return IsEdsInternal(type_url);
961
+ }
962
+
963
+ absl::StatusOr<XdsApi::ResourceName> XdsApi::ParseResourceName(
964
+ absl::string_view name, bool (*is_expected_type)(absl::string_view)) {
965
+ return ParseResourceNameInternal(
966
+ name, [is_expected_type](absl::string_view type, bool*) {
967
+ return is_expected_type(type);
968
+ });
969
+ }
970
+
971
+ std::string XdsApi::ConstructFullResourceName(absl::string_view authority,
972
+ absl::string_view resource_type,
973
+ absl::string_view name) {
974
+ if (absl::StartsWith(name, "xdstp:")) {
975
+ return absl::StrCat("xdstp://", authority, "/", resource_type,
976
+ absl::StripPrefix(name, "xdstp:"));
977
+ } else {
978
+ return std::string(absl::StripPrefix(name, "old:"));
979
+ }
980
+ }
981
+
929
982
  namespace {
930
983
 
931
984
  struct EncodingContext {
@@ -1140,7 +1193,8 @@ absl::string_view TypeUrlExternalToInternal(bool use_v3,
1140
1193
 
1141
1194
  grpc_slice XdsApi::CreateAdsRequest(
1142
1195
  const XdsBootstrap::XdsServer& server, const std::string& type_url,
1143
- const std::set<absl::string_view>& resource_names,
1196
+ const std::map<absl::string_view /*authority*/,
1197
+ std::set<absl::string_view /*name*/>>& resource_names,
1144
1198
  const std::string& version, const std::string& nonce,
1145
1199
  grpc_error_handle error, bool populate_node) {
1146
1200
  upb::Arena arena;
@@ -1193,10 +1247,27 @@ grpc_slice XdsApi::CreateAdsRequest(
1193
1247
  PopulateNode(context, node_, build_version_, user_agent_name_,
1194
1248
  user_agent_version_, node_msg);
1195
1249
  }
1250
+ // A vector for temporary local storage of resource name strings.
1251
+ std::vector<std::string> resource_name_storage;
1252
+ // Make sure the vector is sized right up-front, so that reallocations
1253
+ // don't move the strings out from under the upb proto object that
1254
+ // points to them.
1255
+ size_t size = 0;
1256
+ for (const auto& p : resource_names) {
1257
+ size += p.second.size();
1258
+ }
1259
+ resource_name_storage.reserve(size);
1196
1260
  // Add resource_names.
1197
- for (const auto& resource_name : resource_names) {
1198
- envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
1199
- request, StdStringToUpbString(resource_name), arena.ptr());
1261
+ for (const auto& a : resource_names) {
1262
+ absl::string_view authority = a.first;
1263
+ for (const auto& p : a.second) {
1264
+ absl::string_view resource_id = p;
1265
+ resource_name_storage.push_back(
1266
+ ConstructFullResourceName(authority, type_url, resource_id));
1267
+ envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
1268
+ request, StdStringToUpbString(resource_name_storage.back()),
1269
+ arena.ptr());
1270
+ }
1200
1271
  }
1201
1272
  MaybeLogDiscoveryRequest(context, request);
1202
1273
  return SerializeDiscoveryRequest(context, request);
@@ -1218,6 +1289,18 @@ void MaybeLogDiscoveryResponse(
1218
1289
  }
1219
1290
  }
1220
1291
 
1292
+ void MaybeLogListener(const EncodingContext& context,
1293
+ const envoy_config_listener_v3_Listener* listener) {
1294
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
1295
+ gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1296
+ const upb_msgdef* msg_type =
1297
+ envoy_config_listener_v3_Listener_getmsgdef(context.symtab);
1298
+ char buf[10240];
1299
+ upb_text_encode(listener, msg_type, nullptr, 0, buf, sizeof(buf));
1300
+ gpr_log(GPR_DEBUG, "[xds_client %p] Listener: %s", context.client, buf);
1301
+ }
1302
+ }
1303
+
1221
1304
  void MaybeLogHttpConnectionManager(
1222
1305
  const EncodingContext& context,
1223
1306
  const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
@@ -1361,10 +1444,8 @@ grpc_error_handle RoutePathMatchParse(
1361
1444
  absl::StatusOr<StringMatcher> string_matcher =
1362
1445
  StringMatcher::Create(type, match_string, case_sensitive);
1363
1446
  if (!string_matcher.ok()) {
1364
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1365
- absl::StrCat("path matcher: ", string_matcher.status().message())
1366
- .c_str());
1367
- ;
1447
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1448
+ absl::StrCat("path matcher: ", string_matcher.status().message()));
1368
1449
  }
1369
1450
  route->matchers.path_matcher = std::move(string_matcher.value());
1370
1451
  return GRPC_ERROR_NONE;
@@ -1427,9 +1508,8 @@ grpc_error_handle RouteHeaderMatchersParse(
1427
1508
  HeaderMatcher::Create(name, type, match_string, range_start, range_end,
1428
1509
  present_match, invert_match);
1429
1510
  if (!header_matcher.ok()) {
1430
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1431
- absl::StrCat("header matcher: ", header_matcher.status().message())
1432
- .c_str());
1511
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1512
+ absl::StrCat("header matcher: ", header_matcher.status().message()));
1433
1513
  }
1434
1514
  route->matchers.header_matchers.emplace_back(
1435
1515
  std::move(header_matcher.value()));
@@ -1474,16 +1554,17 @@ grpc_error_handle ExtractHttpFilterTypeName(const EncodingContext& context,
1474
1554
  const google_protobuf_Any* any,
1475
1555
  absl::string_view* filter_type) {
1476
1556
  *filter_type = UpbStringToAbsl(google_protobuf_Any_type_url(any));
1477
- if (*filter_type == "type.googleapis.com/udpa.type.v1.TypedStruct") {
1557
+ if (*filter_type == "type.googleapis.com/xds.type.v3.TypedStruct" ||
1558
+ *filter_type == "type.googleapis.com/udpa.type.v1.TypedStruct") {
1478
1559
  upb_strview any_value = google_protobuf_Any_value(any);
1479
- const auto* typed_struct = udpa_type_v1_TypedStruct_parse(
1560
+ const auto* typed_struct = xds_type_v3_TypedStruct_parse(
1480
1561
  any_value.data, any_value.size, context.arena);
1481
1562
  if (typed_struct == nullptr) {
1482
1563
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1483
1564
  "could not parse TypedStruct from filter config");
1484
1565
  }
1485
1566
  *filter_type =
1486
- UpbStringToAbsl(udpa_type_v1_TypedStruct_type_url(typed_struct));
1567
+ UpbStringToAbsl(xds_type_v3_TypedStruct_type_url(typed_struct));
1487
1568
  }
1488
1569
  *filter_type = absl::StripPrefix(*filter_type, "type.googleapis.com/");
1489
1570
  return GRPC_ERROR_NONE;
@@ -1509,9 +1590,8 @@ grpc_error_handle ParseTypedPerFilterConfig(
1509
1590
  absl::string_view filter_type =
1510
1591
  UpbStringToAbsl(google_protobuf_Any_type_url(any));
1511
1592
  if (filter_type.empty()) {
1512
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1513
- absl::StrCat("no filter config specified for filter name ", key)
1514
- .c_str());
1593
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1594
+ absl::StrCat("no filter config specified for filter name ", key));
1515
1595
  }
1516
1596
  bool is_optional = false;
1517
1597
  if (filter_type ==
@@ -1520,18 +1600,16 @@ grpc_error_handle ParseTypedPerFilterConfig(
1520
1600
  const auto* filter_config = envoy_config_route_v3_FilterConfig_parse(
1521
1601
  any_value.data, any_value.size, context.arena);
1522
1602
  if (filter_config == nullptr) {
1523
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1524
- absl::StrCat("could not parse FilterConfig wrapper for ", key)
1525
- .c_str());
1603
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1604
+ absl::StrCat("could not parse FilterConfig wrapper for ", key));
1526
1605
  }
1527
1606
  is_optional =
1528
1607
  envoy_config_route_v3_FilterConfig_is_optional(filter_config);
1529
1608
  any = envoy_config_route_v3_FilterConfig_config(filter_config);
1530
1609
  if (any == nullptr) {
1531
1610
  if (is_optional) continue;
1532
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1533
- absl::StrCat("no filter config specified for filter name ", key)
1534
- .c_str());
1611
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1612
+ absl::StrCat("no filter config specified for filter name ", key));
1535
1613
  }
1536
1614
  }
1537
1615
  grpc_error_handle error =
@@ -1541,18 +1619,16 @@ grpc_error_handle ParseTypedPerFilterConfig(
1541
1619
  XdsHttpFilterRegistry::GetFilterForType(filter_type);
1542
1620
  if (filter_impl == nullptr) {
1543
1621
  if (is_optional) continue;
1544
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1545
- absl::StrCat("no filter registered for config type ", filter_type)
1546
- .c_str());
1622
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1623
+ absl::StrCat("no filter registered for config type ", filter_type));
1547
1624
  }
1548
1625
  absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
1549
1626
  filter_impl->GenerateFilterConfigOverride(
1550
1627
  google_protobuf_Any_value(any), context.arena);
1551
1628
  if (!filter_config.ok()) {
1552
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1553
- absl::StrCat("filter config for type ", filter_type,
1554
- " failed to parse: ", filter_config.status().ToString())
1555
- .c_str());
1629
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
1630
+ "filter config for type ", filter_type,
1631
+ " failed to parse: ", filter_config.status().ToString()));
1556
1632
  }
1557
1633
  (*typed_per_filter_config)[std::string(key)] = std::move(*filter_config);
1558
1634
  }
@@ -1569,9 +1645,9 @@ XdsApi::Duration DurationParse(const google_protobuf_Duration* proto_duration) {
1569
1645
  grpc_error_handle RetryPolicyParse(
1570
1646
  const EncodingContext& context,
1571
1647
  const envoy_config_route_v3_RetryPolicy* retry_policy,
1572
- absl::optional<XdsApi::Route::RetryPolicy>* retry) {
1648
+ absl::optional<XdsApi::RetryPolicy>* retry) {
1573
1649
  std::vector<grpc_error_handle> errors;
1574
- XdsApi::Route::RetryPolicy retry_to_return;
1650
+ XdsApi::RetryPolicy retry_to_return;
1575
1651
  auto retry_on = UpbStringToStdString(
1576
1652
  envoy_config_route_v3_RetryPolicy_retry_on(retry_policy));
1577
1653
  std::vector<absl::string_view> codes = absl::StrSplit(retry_on, ',');
@@ -1593,16 +1669,12 @@ grpc_error_handle RetryPolicyParse(
1593
1669
  }
1594
1670
  }
1595
1671
  }
1596
- // TODO(donnadionne): when we add support for per_try_timeout, we will need to
1597
- // return a policy if per_try_timeout is set even if retry_on specified no
1598
- // supported policies.
1599
- if (retry_to_return.retry_on.Empty()) return GRPC_ERROR_NONE;
1600
1672
  const google_protobuf_UInt32Value* num_retries =
1601
1673
  envoy_config_route_v3_RetryPolicy_num_retries(retry_policy);
1602
1674
  if (num_retries != nullptr) {
1603
1675
  uint32_t num_retries_value = google_protobuf_UInt32Value_value(num_retries);
1604
1676
  if (num_retries_value == 0) {
1605
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1677
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1606
1678
  "RouteAction RetryPolicy num_retries set to invalid value 0."));
1607
1679
  } else {
1608
1680
  retry_to_return.num_retries = num_retries_value;
@@ -1616,7 +1688,7 @@ grpc_error_handle RetryPolicyParse(
1616
1688
  const google_protobuf_Duration* base_interval =
1617
1689
  envoy_config_route_v3_RetryPolicy_RetryBackOff_base_interval(backoff);
1618
1690
  if (base_interval == nullptr) {
1619
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1691
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1620
1692
  "RouteAction RetryPolicy RetryBackoff missing base interval."));
1621
1693
  } else {
1622
1694
  retry_to_return.retry_back_off.base_interval =
@@ -1655,11 +1727,8 @@ grpc_error_handle RetryPolicyParse(
1655
1727
 
1656
1728
  grpc_error_handle RouteActionParse(const EncodingContext& context,
1657
1729
  const envoy_config_route_v3_Route* route_msg,
1658
- XdsApi::Route* route, bool* ignore_route) {
1659
- if (!envoy_config_route_v3_Route_has_route(route_msg)) {
1660
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1661
- "No RouteAction found in route.");
1662
- }
1730
+ XdsApi::Route::RouteAction* route,
1731
+ bool* ignore_route) {
1663
1732
  const envoy_config_route_v3_RouteAction* route_action =
1664
1733
  envoy_config_route_v3_Route_route(route_msg);
1665
1734
  // Get the cluster or weighted_clusters in the RouteAction.
@@ -1688,7 +1757,7 @@ grpc_error_handle RouteActionParse(const EncodingContext& context,
1688
1757
  for (size_t j = 0; j < clusters_size; ++j) {
1689
1758
  const envoy_config_route_v3_WeightedCluster_ClusterWeight*
1690
1759
  cluster_weight = clusters[j];
1691
- XdsApi::Route::ClusterWeight cluster;
1760
+ XdsApi::Route::RouteAction::ClusterWeight cluster;
1692
1761
  cluster.name = UpbStringToStdString(
1693
1762
  envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
1694
1763
  cluster_weight));
@@ -1751,87 +1820,84 @@ grpc_error_handle RouteActionParse(const EncodingContext& context,
1751
1820
  }
1752
1821
  }
1753
1822
  // Get HashPolicy from RouteAction
1754
- if (XdsRingHashEnabled()) {
1755
- size_t size = 0;
1756
- const envoy_config_route_v3_RouteAction_HashPolicy* const* hash_policies =
1757
- envoy_config_route_v3_RouteAction_hash_policy(route_action, &size);
1758
- for (size_t i = 0; i < size; ++i) {
1759
- const envoy_config_route_v3_RouteAction_HashPolicy* hash_policy =
1760
- hash_policies[i];
1761
- XdsApi::Route::HashPolicy policy;
1762
- policy.terminal =
1763
- envoy_config_route_v3_RouteAction_HashPolicy_terminal(hash_policy);
1764
- const envoy_config_route_v3_RouteAction_HashPolicy_Header* header;
1765
- const envoy_config_route_v3_RouteAction_HashPolicy_FilterState*
1766
- filter_state;
1767
- if ((header = envoy_config_route_v3_RouteAction_HashPolicy_header(
1768
- hash_policy)) != nullptr) {
1769
- policy.type = XdsApi::Route::HashPolicy::Type::HEADER;
1770
- policy.header_name = UpbStringToStdString(
1771
- envoy_config_route_v3_RouteAction_HashPolicy_Header_header_name(
1772
- header));
1773
- const struct envoy_type_matcher_v3_RegexMatchAndSubstitute*
1774
- regex_rewrite =
1775
- envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
1776
- header);
1777
- if (regex_rewrite != nullptr) {
1778
- const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1779
- envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
1780
- regex_rewrite);
1781
- if (regex_matcher == nullptr) {
1782
- gpr_log(
1783
- GPR_DEBUG,
1784
- "RouteAction HashPolicy contains policy specifier Header with "
1785
- "RegexMatchAndSubstitution but RegexMatcher pattern is "
1786
- "missing");
1787
- continue;
1788
- }
1789
- RE2::Options options;
1790
- policy.regex = absl::make_unique<RE2>(
1791
- UpbStringToStdString(
1792
- envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
1793
- options);
1794
- if (!policy.regex->ok()) {
1795
- gpr_log(
1796
- GPR_DEBUG,
1797
- "RouteAction HashPolicy contains policy specifier Header with "
1798
- "RegexMatchAndSubstitution but RegexMatcher pattern does not "
1799
- "compile");
1800
- continue;
1801
- }
1802
- policy.regex_substitution = UpbStringToStdString(
1803
- envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
1804
- regex_rewrite));
1823
+ size_t size = 0;
1824
+ const envoy_config_route_v3_RouteAction_HashPolicy* const* hash_policies =
1825
+ envoy_config_route_v3_RouteAction_hash_policy(route_action, &size);
1826
+ for (size_t i = 0; i < size; ++i) {
1827
+ const envoy_config_route_v3_RouteAction_HashPolicy* hash_policy =
1828
+ hash_policies[i];
1829
+ XdsApi::Route::RouteAction::HashPolicy policy;
1830
+ policy.terminal =
1831
+ envoy_config_route_v3_RouteAction_HashPolicy_terminal(hash_policy);
1832
+ const envoy_config_route_v3_RouteAction_HashPolicy_Header* header;
1833
+ const envoy_config_route_v3_RouteAction_HashPolicy_FilterState*
1834
+ filter_state;
1835
+ if ((header = envoy_config_route_v3_RouteAction_HashPolicy_header(
1836
+ hash_policy)) != nullptr) {
1837
+ policy.type = XdsApi::Route::RouteAction::HashPolicy::Type::HEADER;
1838
+ policy.header_name = UpbStringToStdString(
1839
+ envoy_config_route_v3_RouteAction_HashPolicy_Header_header_name(
1840
+ header));
1841
+ const struct envoy_type_matcher_v3_RegexMatchAndSubstitute*
1842
+ regex_rewrite =
1843
+ envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
1844
+ header);
1845
+ if (regex_rewrite != nullptr) {
1846
+ const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1847
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
1848
+ regex_rewrite);
1849
+ if (regex_matcher == nullptr) {
1850
+ gpr_log(
1851
+ GPR_DEBUG,
1852
+ "RouteAction HashPolicy contains policy specifier Header with "
1853
+ "RegexMatchAndSubstitution but RegexMatcher pattern is "
1854
+ "missing");
1855
+ continue;
1805
1856
  }
1806
- } else if ((filter_state =
1807
- envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
1808
- hash_policy)) != nullptr) {
1809
- std::string key = UpbStringToStdString(
1810
- envoy_config_route_v3_RouteAction_HashPolicy_FilterState_key(
1811
- filter_state));
1812
- if (key == "io.grpc.channel_id") {
1813
- policy.type = XdsApi::Route::HashPolicy::Type::CHANNEL_ID;
1814
- } else {
1815
- gpr_log(GPR_DEBUG,
1816
- "RouteAction HashPolicy contains policy specifier "
1817
- "FilterState but "
1818
- "key is not io.grpc.channel_id.");
1857
+ RE2::Options options;
1858
+ policy.regex = absl::make_unique<RE2>(
1859
+ UpbStringToStdString(
1860
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
1861
+ options);
1862
+ if (!policy.regex->ok()) {
1863
+ gpr_log(
1864
+ GPR_DEBUG,
1865
+ "RouteAction HashPolicy contains policy specifier Header with "
1866
+ "RegexMatchAndSubstitution but RegexMatcher pattern does not "
1867
+ "compile");
1819
1868
  continue;
1820
1869
  }
1870
+ policy.regex_substitution = UpbStringToStdString(
1871
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
1872
+ regex_rewrite));
1873
+ }
1874
+ } else if ((filter_state =
1875
+ envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
1876
+ hash_policy)) != nullptr) {
1877
+ std::string key = UpbStringToStdString(
1878
+ envoy_config_route_v3_RouteAction_HashPolicy_FilterState_key(
1879
+ filter_state));
1880
+ if (key == "io.grpc.channel_id") {
1881
+ policy.type = XdsApi::Route::RouteAction::HashPolicy::Type::CHANNEL_ID;
1821
1882
  } else {
1822
- gpr_log(
1823
- GPR_DEBUG,
1824
- "RouteAction HashPolicy contains unsupported policy specifier.");
1883
+ gpr_log(GPR_DEBUG,
1884
+ "RouteAction HashPolicy contains policy specifier "
1885
+ "FilterState but "
1886
+ "key is not io.grpc.channel_id.");
1825
1887
  continue;
1826
1888
  }
1827
- route->hash_policies.emplace_back(std::move(policy));
1889
+ } else {
1890
+ gpr_log(GPR_DEBUG,
1891
+ "RouteAction HashPolicy contains unsupported policy specifier.");
1892
+ continue;
1828
1893
  }
1894
+ route->hash_policies.emplace_back(std::move(policy));
1829
1895
  }
1830
1896
  // Get retry policy
1831
1897
  const envoy_config_route_v3_RetryPolicy* retry_policy =
1832
1898
  envoy_config_route_v3_RouteAction_retry_policy(route_action);
1833
1899
  if (retry_policy != nullptr) {
1834
- absl::optional<XdsApi::Route::RetryPolicy> retry;
1900
+ absl::optional<XdsApi::RetryPolicy> retry;
1835
1901
  grpc_error_handle error = RetryPolicyParse(context, retry_policy, &retry);
1836
1902
  if (error != GRPC_ERROR_NONE) return error;
1837
1903
  route->retry_policy = retry;
@@ -1842,7 +1908,7 @@ grpc_error_handle RouteActionParse(const EncodingContext& context,
1842
1908
  grpc_error_handle RouteConfigParse(
1843
1909
  const EncodingContext& context,
1844
1910
  const envoy_config_route_v3_RouteConfiguration* route_config,
1845
- XdsApi::RdsUpdate* rds_update) {
1911
+ bool /*is_v2*/, XdsApi::RdsUpdate* rds_update) {
1846
1912
  MaybeLogRouteConfiguration(context, route_config);
1847
1913
  // Get the virtual hosts.
1848
1914
  size_t num_virtual_hosts;
@@ -1860,9 +1926,8 @@ grpc_error_handle RouteConfigParse(
1860
1926
  std::string domain_pattern = UpbStringToStdString(domains[j]);
1861
1927
  const MatchType match_type = DomainPatternMatchType(domain_pattern);
1862
1928
  if (match_type == INVALID_MATCH) {
1863
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1864
- absl::StrCat("Invalid domain pattern \"", domain_pattern, "\".")
1865
- .c_str());
1929
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1930
+ absl::StrCat("Invalid domain pattern \"", domain_pattern, "\"."));
1866
1931
  }
1867
1932
  vhost.domains.emplace_back(std::move(domain_pattern));
1868
1933
  }
@@ -1882,7 +1947,7 @@ grpc_error_handle RouteConfigParse(
1882
1947
  if (error != GRPC_ERROR_NONE) return error;
1883
1948
  }
1884
1949
  // Parse retry policy.
1885
- absl::optional<XdsApi::Route::RetryPolicy> virtual_host_retry_policy;
1950
+ absl::optional<XdsApi::RetryPolicy> virtual_host_retry_policy;
1886
1951
  const envoy_config_route_v3_RetryPolicy* retry_policy =
1887
1952
  envoy_config_route_v3_VirtualHost_retry_policy(virtual_hosts[i]);
1888
1953
  if (retry_policy != nullptr) {
@@ -1921,11 +1986,21 @@ grpc_error_handle RouteConfigParse(
1921
1986
  if (error != GRPC_ERROR_NONE) return error;
1922
1987
  error = RouteRuntimeFractionParse(match, &route);
1923
1988
  if (error != GRPC_ERROR_NONE) return error;
1924
- error = RouteActionParse(context, routes[j], &route, &ignore_route);
1925
- if (error != GRPC_ERROR_NONE) return error;
1926
- if (ignore_route) continue;
1927
- if (route.retry_policy == absl::nullopt && retry_policy != nullptr) {
1928
- route.retry_policy = virtual_host_retry_policy;
1989
+ if (envoy_config_route_v3_Route_has_route(routes[j])) {
1990
+ route.action.emplace<XdsApi::Route::RouteAction>();
1991
+ auto& route_action =
1992
+ absl::get<XdsApi::Route::RouteAction>(route.action);
1993
+ error =
1994
+ RouteActionParse(context, routes[j], &route_action, &ignore_route);
1995
+ if (error != GRPC_ERROR_NONE) return error;
1996
+ if (ignore_route) continue;
1997
+ if (route_action.retry_policy == absl::nullopt &&
1998
+ retry_policy != nullptr) {
1999
+ route_action.retry_policy = virtual_host_retry_policy;
2000
+ }
2001
+ } else if (envoy_config_route_v3_Route_has_non_forwarding_action(
2002
+ routes[j])) {
2003
+ route.action.emplace<XdsApi::Route::NonForwardingAction>();
1929
2004
  }
1930
2005
  if (context.use_v3) {
1931
2006
  grpc_error_handle error = ParseTypedPerFilterConfig<
@@ -1947,13 +2022,18 @@ grpc_error_handle RouteConfigParse(
1947
2022
  return GRPC_ERROR_NONE;
1948
2023
  }
1949
2024
 
2025
+ // CertificateProviderInstance is deprecated but we are still supporting it for
2026
+ // backward compatibility reasons. Note that we still parse the data into the
2027
+ // same CertificateProviderPluginInstance struct since the fields are the same.
2028
+ // TODO(yashykt): Remove this once we stop supporting the old way of fetching
2029
+ // certificate provider instances.
1950
2030
  grpc_error_handle CertificateProviderInstanceParse(
1951
2031
  const EncodingContext& context,
1952
2032
  const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
1953
2033
  certificate_provider_instance_proto,
1954
- XdsApi::CommonTlsContext::CertificateProviderInstance*
1955
- certificate_provider_instance) {
1956
- *certificate_provider_instance = {
2034
+ XdsApi::CommonTlsContext::CertificateProviderPluginInstance*
2035
+ certificate_provider_plugin_instance) {
2036
+ *certificate_provider_plugin_instance = {
1957
2037
  UpbStringToStdString(
1958
2038
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1959
2039
  certificate_provider_instance_proto)),
@@ -1961,21 +2041,157 @@ grpc_error_handle CertificateProviderInstanceParse(
1961
2041
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
1962
2042
  certificate_provider_instance_proto))};
1963
2043
  if (context.certificate_provider_definition_map->find(
1964
- certificate_provider_instance->instance_name) ==
2044
+ certificate_provider_plugin_instance->instance_name) ==
2045
+ context.certificate_provider_definition_map->end()) {
2046
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2047
+ absl::StrCat("Unrecognized certificate provider instance name: ",
2048
+ certificate_provider_plugin_instance->instance_name));
2049
+ }
2050
+ return GRPC_ERROR_NONE;
2051
+ }
2052
+
2053
+ grpc_error_handle CertificateProviderPluginInstanceParse(
2054
+ const EncodingContext& context,
2055
+ const envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*
2056
+ certificate_provider_plugin_instance_proto,
2057
+ XdsApi::CommonTlsContext::CertificateProviderPluginInstance*
2058
+ certificate_provider_plugin_instance) {
2059
+ *certificate_provider_plugin_instance = {
2060
+ UpbStringToStdString(
2061
+ envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_instance_name(
2062
+ certificate_provider_plugin_instance_proto)),
2063
+ UpbStringToStdString(
2064
+ envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_certificate_name(
2065
+ certificate_provider_plugin_instance_proto))};
2066
+ if (context.certificate_provider_definition_map->find(
2067
+ certificate_provider_plugin_instance->instance_name) ==
1965
2068
  context.certificate_provider_definition_map->end()) {
1966
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2069
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
1967
2070
  absl::StrCat("Unrecognized certificate provider instance name: ",
1968
- certificate_provider_instance->instance_name)
1969
- .c_str());
2071
+ certificate_provider_plugin_instance->instance_name));
1970
2072
  }
1971
2073
  return GRPC_ERROR_NONE;
1972
2074
  }
1973
2075
 
2076
+ grpc_error_handle CertificateValidationContextParse(
2077
+ const EncodingContext& context,
2078
+ const envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*
2079
+ certificate_validation_context_proto,
2080
+ XdsApi::CommonTlsContext::CertificateValidationContext*
2081
+ certificate_validation_context) {
2082
+ std::vector<grpc_error_handle> errors;
2083
+ size_t len = 0;
2084
+ auto* subject_alt_names_matchers =
2085
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
2086
+ certificate_validation_context_proto, &len);
2087
+ for (size_t i = 0; i < len; ++i) {
2088
+ StringMatcher::Type type;
2089
+ std::string matcher;
2090
+ if (envoy_type_matcher_v3_StringMatcher_has_exact(
2091
+ subject_alt_names_matchers[i])) {
2092
+ type = StringMatcher::Type::kExact;
2093
+ matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
2094
+ subject_alt_names_matchers[i]));
2095
+ } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
2096
+ subject_alt_names_matchers[i])) {
2097
+ type = StringMatcher::Type::kPrefix;
2098
+ matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
2099
+ subject_alt_names_matchers[i]));
2100
+ } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
2101
+ subject_alt_names_matchers[i])) {
2102
+ type = StringMatcher::Type::kSuffix;
2103
+ matcher = UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
2104
+ subject_alt_names_matchers[i]));
2105
+ } else if (envoy_type_matcher_v3_StringMatcher_has_contains(
2106
+ subject_alt_names_matchers[i])) {
2107
+ type = StringMatcher::Type::kContains;
2108
+ matcher =
2109
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
2110
+ subject_alt_names_matchers[i]));
2111
+ } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
2112
+ subject_alt_names_matchers[i])) {
2113
+ type = StringMatcher::Type::kSafeRegex;
2114
+ auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
2115
+ subject_alt_names_matchers[i]);
2116
+ matcher = UpbStringToStdString(
2117
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
2118
+ } else {
2119
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2120
+ "Invalid StringMatcher specified"));
2121
+ continue;
2122
+ }
2123
+ bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
2124
+ subject_alt_names_matchers[i]);
2125
+ absl::StatusOr<StringMatcher> string_matcher =
2126
+ StringMatcher::Create(type, matcher,
2127
+ /*case_sensitive=*/!ignore_case);
2128
+ if (!string_matcher.ok()) {
2129
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
2130
+ absl::StrCat("string matcher: ", string_matcher.status().message())));
2131
+ continue;
2132
+ }
2133
+ if (type == StringMatcher::Type::kSafeRegex && ignore_case) {
2134
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2135
+ "StringMatcher: ignore_case has no effect for SAFE_REGEX."));
2136
+ continue;
2137
+ }
2138
+ certificate_validation_context->match_subject_alt_names.push_back(
2139
+ std::move(string_matcher.value()));
2140
+ }
2141
+ auto* ca_certificate_provider_instance =
2142
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_ca_certificate_provider_instance(
2143
+ certificate_validation_context_proto);
2144
+ if (ca_certificate_provider_instance != nullptr) {
2145
+ grpc_error_handle error = CertificateProviderPluginInstanceParse(
2146
+ context, ca_certificate_provider_instance,
2147
+ &certificate_validation_context->ca_certificate_provider_instance);
2148
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2149
+ }
2150
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_spki(
2151
+ certificate_validation_context_proto, nullptr) != nullptr) {
2152
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2153
+ "CertificateValidationContext: verify_certificate_spki "
2154
+ "unsupported"));
2155
+ }
2156
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_hash(
2157
+ certificate_validation_context_proto, nullptr) != nullptr) {
2158
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2159
+ "CertificateValidationContext: verify_certificate_hash "
2160
+ "unsupported"));
2161
+ }
2162
+ auto* require_signed_certificate_timestamp =
2163
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_require_signed_certificate_timestamp(
2164
+ certificate_validation_context_proto);
2165
+ if (require_signed_certificate_timestamp != nullptr &&
2166
+ google_protobuf_BoolValue_value(require_signed_certificate_timestamp)) {
2167
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2168
+ "CertificateValidationContext: "
2169
+ "require_signed_certificate_timestamp unsupported"));
2170
+ }
2171
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_crl(
2172
+ certificate_validation_context_proto)) {
2173
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2174
+ "CertificateValidationContext: crl unsupported"));
2175
+ }
2176
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_custom_validator_config(
2177
+ certificate_validation_context_proto)) {
2178
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2179
+ "CertificateValidationContext: custom_validator_config "
2180
+ "unsupported"));
2181
+ }
2182
+ return GRPC_ERROR_CREATE_FROM_VECTOR(
2183
+ "Error parsing CertificateValidationContext", &errors);
2184
+ }
2185
+
1974
2186
  grpc_error_handle CommonTlsContextParse(
1975
2187
  const EncodingContext& context,
1976
2188
  const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1977
2189
  common_tls_context_proto,
1978
2190
  XdsApi::CommonTlsContext* common_tls_context) {
2191
+ std::vector<grpc_error_handle> errors;
2192
+ // The validation context is derived from the oneof in
2193
+ // 'validation_context_type'. 'validation_context_sds_secret_config' is not
2194
+ // supported.
1979
2195
  auto* combined_validation_context =
1980
2196
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
1981
2197
  common_tls_context_proto);
@@ -1984,89 +2200,92 @@ grpc_error_handle CommonTlsContextParse(
1984
2200
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
1985
2201
  combined_validation_context);
1986
2202
  if (default_validation_context != nullptr) {
1987
- size_t len = 0;
1988
- auto* subject_alt_names_matchers =
1989
- envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
1990
- default_validation_context, &len);
1991
- for (size_t i = 0; i < len; ++i) {
1992
- StringMatcher::Type type;
1993
- std::string matcher;
1994
- if (envoy_type_matcher_v3_StringMatcher_has_exact(
1995
- subject_alt_names_matchers[i])) {
1996
- type = StringMatcher::Type::kExact;
1997
- matcher =
1998
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
1999
- subject_alt_names_matchers[i]));
2000
- } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
2001
- subject_alt_names_matchers[i])) {
2002
- type = StringMatcher::Type::kPrefix;
2003
- matcher =
2004
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
2005
- subject_alt_names_matchers[i]));
2006
- } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
2007
- subject_alt_names_matchers[i])) {
2008
- type = StringMatcher::Type::kSuffix;
2009
- matcher =
2010
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
2011
- subject_alt_names_matchers[i]));
2012
- } else if (envoy_type_matcher_v3_StringMatcher_has_contains(
2013
- subject_alt_names_matchers[i])) {
2014
- type = StringMatcher::Type::kContains;
2015
- matcher =
2016
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
2017
- subject_alt_names_matchers[i]));
2018
- } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
2019
- subject_alt_names_matchers[i])) {
2020
- type = StringMatcher::Type::kSafeRegex;
2021
- auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
2022
- subject_alt_names_matchers[i]);
2023
- matcher = UpbStringToStdString(
2024
- envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
2025
- } else {
2026
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2027
- "Invalid StringMatcher specified");
2028
- }
2029
- bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
2030
- subject_alt_names_matchers[i]);
2031
- absl::StatusOr<StringMatcher> string_matcher =
2032
- StringMatcher::Create(type, matcher,
2033
- /*case_sensitive=*/!ignore_case);
2034
- if (!string_matcher.ok()) {
2035
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2036
- absl::StrCat("string matcher: ",
2037
- string_matcher.status().message())
2038
- .c_str());
2039
- }
2040
- if (type == StringMatcher::Type::kSafeRegex && ignore_case) {
2041
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2042
- "StringMatcher: ignore_case has no effect for SAFE_REGEX.");
2043
- }
2044
- common_tls_context->combined_validation_context
2045
- .default_validation_context.match_subject_alt_names.push_back(
2046
- std::move(string_matcher.value()));
2047
- }
2048
- }
2203
+ grpc_error_handle error = CertificateValidationContextParse(
2204
+ context, default_validation_context,
2205
+ &common_tls_context->certificate_validation_context);
2206
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2207
+ }
2208
+ // If after parsing default_validation_context,
2209
+ // common_tls_context->certificate_validation_context.ca_certificate_provider_instance
2210
+ // is empty, fall back onto
2211
+ // 'validation_context_certificate_provider_instance' inside
2212
+ // 'combined_validation_context'. Note that this way of fetching root
2213
+ // certificates is deprecated and will be removed in the future.
2214
+ // TODO(yashykt): Remove this once it's no longer needed.
2049
2215
  auto* validation_context_certificate_provider_instance =
2050
2216
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
2051
2217
  combined_validation_context);
2052
- if (validation_context_certificate_provider_instance != nullptr) {
2218
+ if (common_tls_context->certificate_validation_context
2219
+ .ca_certificate_provider_instance.Empty() &&
2220
+ validation_context_certificate_provider_instance != nullptr) {
2053
2221
  grpc_error_handle error = CertificateProviderInstanceParse(
2054
2222
  context, validation_context_certificate_provider_instance,
2055
- &common_tls_context->combined_validation_context
2056
- .validation_context_certificate_provider_instance);
2057
- if (error != GRPC_ERROR_NONE) return error;
2223
+ &common_tls_context->certificate_validation_context
2224
+ .ca_certificate_provider_instance);
2225
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2058
2226
  }
2059
- }
2060
- auto* tls_certificate_certificate_provider_instance =
2061
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
2227
+ } else {
2228
+ auto* validation_context =
2229
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context(
2230
+ common_tls_context_proto);
2231
+ if (validation_context != nullptr) {
2232
+ grpc_error_handle error = CertificateValidationContextParse(
2233
+ context, validation_context,
2234
+ &common_tls_context->certificate_validation_context);
2235
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2236
+ } else if (
2237
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config(
2238
+ common_tls_context_proto)) {
2239
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2240
+ "validation_context_sds_secret_config unsupported"));
2241
+ }
2242
+ }
2243
+ auto* tls_certificate_provider_instance =
2244
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_provider_instance(
2062
2245
  common_tls_context_proto);
2063
- if (tls_certificate_certificate_provider_instance != nullptr) {
2064
- grpc_error_handle error = CertificateProviderInstanceParse(
2065
- context, tls_certificate_certificate_provider_instance,
2066
- &common_tls_context->tls_certificate_certificate_provider_instance);
2067
- if (error != GRPC_ERROR_NONE) return error;
2246
+ if (tls_certificate_provider_instance != nullptr) {
2247
+ grpc_error_handle error = CertificateProviderPluginInstanceParse(
2248
+ context, tls_certificate_provider_instance,
2249
+ &common_tls_context->tls_certificate_provider_instance);
2250
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2251
+ } else {
2252
+ // Fall back onto 'tls_certificate_certificate_provider_instance'. Note that
2253
+ // this way of fetching identity certificates is deprecated and will be
2254
+ // removed in the future.
2255
+ // TODO(yashykt): Remove this once it's no longer needed.
2256
+ auto* tls_certificate_certificate_provider_instance =
2257
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
2258
+ common_tls_context_proto);
2259
+ if (tls_certificate_certificate_provider_instance != nullptr) {
2260
+ grpc_error_handle error = CertificateProviderInstanceParse(
2261
+ context, tls_certificate_certificate_provider_instance,
2262
+ &common_tls_context->tls_certificate_provider_instance);
2263
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2264
+ } else {
2265
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificates(
2266
+ common_tls_context_proto)) {
2267
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2268
+ "tls_certificates unsupported"));
2269
+ }
2270
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_certificate_sds_secret_configs(
2271
+ common_tls_context_proto)) {
2272
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2273
+ "tls_certificate_sds_secret_configs unsupported"));
2274
+ }
2275
+ }
2068
2276
  }
2069
- return GRPC_ERROR_NONE;
2277
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_params(
2278
+ common_tls_context_proto)) {
2279
+ errors.push_back(
2280
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("tls_params unsupported"));
2281
+ }
2282
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_custom_handshaker(
2283
+ common_tls_context_proto)) {
2284
+ errors.push_back(
2285
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("custom_handshaker unsupported"));
2286
+ }
2287
+ return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing CommonTlsContext",
2288
+ &errors);
2070
2289
  }
2071
2290
 
2072
2291
  grpc_error_handle HttpConnectionManagerParse(
@@ -2101,12 +2320,12 @@ grpc_error_handle HttpConnectionManagerParse(
2101
2320
  envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name(
2102
2321
  http_filter));
2103
2322
  if (name.empty()) {
2104
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2105
- absl::StrCat("empty filter name at index ", i).c_str());
2323
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2324
+ absl::StrCat("empty filter name at index ", i));
2106
2325
  }
2107
2326
  if (names_seen.find(name) != names_seen.end()) {
2108
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2109
- absl::StrCat("duplicate HTTP filter name: ", name).c_str());
2327
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2328
+ absl::StrCat("duplicate HTTP filter name: ", name));
2110
2329
  }
2111
2330
  names_seen.insert(name);
2112
2331
  const bool is_optional =
@@ -2117,9 +2336,8 @@ grpc_error_handle HttpConnectionManagerParse(
2117
2336
  http_filter);
2118
2337
  if (any == nullptr) {
2119
2338
  if (is_optional) continue;
2120
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2121
- absl::StrCat("no filter config specified for filter name ", name)
2122
- .c_str());
2339
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2340
+ absl::StrCat("no filter config specified for filter name ", name));
2123
2341
  }
2124
2342
  absl::string_view filter_type;
2125
2343
  grpc_error_handle error =
@@ -2129,49 +2347,58 @@ grpc_error_handle HttpConnectionManagerParse(
2129
2347
  XdsHttpFilterRegistry::GetFilterForType(filter_type);
2130
2348
  if (filter_impl == nullptr) {
2131
2349
  if (is_optional) continue;
2132
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2133
- absl::StrCat("no filter registered for config type ", filter_type)
2134
- .c_str());
2350
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2351
+ absl::StrCat("no filter registered for config type ", filter_type));
2135
2352
  }
2136
2353
  if ((is_client && !filter_impl->IsSupportedOnClients()) ||
2137
2354
  (!is_client && !filter_impl->IsSupportedOnServers())) {
2138
2355
  if (is_optional) continue;
2139
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2356
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2140
2357
  absl::StrFormat("Filter %s is not supported on %s", filter_type,
2141
- is_client ? "clients" : "servers")
2142
- .c_str());
2143
- }
2144
- if (i < num_filters - 1) {
2145
- // Filters before the last filter must not be terminal.
2146
- if (filter_impl->IsTerminalFilter()) {
2147
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2148
- absl::StrCat("terminal filter for config type ", filter_type,
2149
- " must be the last filter in the chain")
2150
- .c_str());
2151
- }
2152
- } else {
2153
- // The last filter must be terminal.
2154
- if (!filter_impl->IsTerminalFilter()) {
2155
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2156
- absl::StrCat("non-terminal filter for config type ", filter_type,
2157
- " is the last filter in the chain")
2158
- .c_str());
2159
- }
2358
+ is_client ? "clients" : "servers"));
2160
2359
  }
2161
2360
  absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
2162
2361
  filter_impl->GenerateFilterConfig(google_protobuf_Any_value(any),
2163
2362
  context.arena);
2164
2363
  if (!filter_config.ok()) {
2165
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2166
- absl::StrCat(
2167
- "filter config for type ", filter_type,
2168
- " failed to parse: ", filter_config.status().ToString())
2169
- .c_str());
2364
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
2365
+ "filter config for type ", filter_type,
2366
+ " failed to parse: ", filter_config.status().ToString()));
2170
2367
  }
2171
2368
  http_connection_manager->http_filters.emplace_back(
2172
2369
  XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
2173
2370
  std::string(name), std::move(*filter_config)});
2174
2371
  }
2372
+ if (http_connection_manager->http_filters.empty()) {
2373
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2374
+ "Expected at least one HTTP filter");
2375
+ }
2376
+ // Make sure that the last filter is terminal and non-last filters are
2377
+ // non-terminal. Note that this check is being performed in a separate loop
2378
+ // to take care of the case where there are two terminal filters in the list
2379
+ // out of which only one gets added in the final list.
2380
+ for (const auto& http_filter : http_connection_manager->http_filters) {
2381
+ const XdsHttpFilterImpl* filter_impl =
2382
+ XdsHttpFilterRegistry::GetFilterForType(
2383
+ http_filter.config.config_proto_type_name);
2384
+ if (&http_filter != &http_connection_manager->http_filters.back()) {
2385
+ // Filters before the last filter must not be terminal.
2386
+ if (filter_impl->IsTerminalFilter()) {
2387
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2388
+ absl::StrCat("terminal filter for config type ",
2389
+ http_filter.config.config_proto_type_name,
2390
+ " must be the last filter in the chain"));
2391
+ }
2392
+ } else {
2393
+ // The last filter must be terminal.
2394
+ if (!filter_impl->IsTerminalFilter()) {
2395
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2396
+ absl::StrCat("non-terminal filter for config type ",
2397
+ http_filter.config.config_proto_type_name,
2398
+ " is the last filter in the chain"));
2399
+ }
2400
+ }
2401
+ }
2175
2402
  } else {
2176
2403
  // If using a v2 config, we just hard-code a list containing only the
2177
2404
  // router filter without actually looking at the config. This ensures
@@ -2181,7 +2408,10 @@ grpc_error_handle HttpConnectionManagerParse(
2181
2408
  XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
2182
2409
  "router", {kXdsHttpRouterFilterConfigName, Json()}});
2183
2410
  }
2184
- if (is_client) {
2411
+ // Guarding parsing of RouteConfig on the server side with the environmental
2412
+ // variable since that's the first feature on the server side that will be
2413
+ // using this.
2414
+ if (is_client || XdsRbacEnabled()) {
2185
2415
  // Found inlined route_config. Parse it to find the cluster_name.
2186
2416
  if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
2187
2417
  http_connection_manager_proto)) {
@@ -2190,7 +2420,7 @@ grpc_error_handle HttpConnectionManagerParse(
2190
2420
  http_connection_manager_proto);
2191
2421
  XdsApi::RdsUpdate rds_update;
2192
2422
  grpc_error_handle error =
2193
- RouteConfigParse(context, route_config, &rds_update);
2423
+ RouteConfigParse(context, route_config, is_v2, &rds_update);
2194
2424
  if (error != GRPC_ERROR_NONE) return error;
2195
2425
  http_connection_manager->rds_update = std::move(rds_update);
2196
2426
  return GRPC_ERROR_NONE;
@@ -2223,7 +2453,7 @@ grpc_error_handle HttpConnectionManagerParse(
2223
2453
  return GRPC_ERROR_NONE;
2224
2454
  }
2225
2455
 
2226
- grpc_error_handle LdsResponseParseClient(
2456
+ grpc_error_handle LdsResourceParseClient(
2227
2457
  const EncodingContext& context,
2228
2458
  const envoy_config_listener_v3_ApiListener* api_listener, bool is_v2,
2229
2459
  XdsApi::LdsUpdate* lds_update) {
@@ -2249,11 +2479,12 @@ grpc_error_handle DownstreamTlsContextParse(
2249
2479
  absl::string_view name = UpbStringToAbsl(
2250
2480
  envoy_config_core_v3_TransportSocket_name(transport_socket));
2251
2481
  if (name != "envoy.transport_sockets.tls") {
2252
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2253
- absl::StrCat("Unrecognized transport socket: ", name).c_str());
2482
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
2483
+ absl::StrCat("Unrecognized transport socket: ", name));
2254
2484
  }
2255
2485
  auto* typed_config =
2256
2486
  envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
2487
+ std::vector<grpc_error_handle> errors;
2257
2488
  if (typed_config != nullptr) {
2258
2489
  const upb_strview encoded_downstream_tls_context =
2259
2490
  google_protobuf_Any_value(typed_config);
@@ -2272,7 +2503,7 @@ grpc_error_handle DownstreamTlsContextParse(
2272
2503
  grpc_error_handle error =
2273
2504
  CommonTlsContextParse(context, common_tls_context,
2274
2505
  &downstream_tls_context->common_tls_context);
2275
- if (error != GRPC_ERROR_NONE) return error;
2506
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2276
2507
  }
2277
2508
  auto* require_client_certificate =
2278
2509
  envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(
@@ -2281,23 +2512,41 @@ grpc_error_handle DownstreamTlsContextParse(
2281
2512
  downstream_tls_context->require_client_certificate =
2282
2513
  google_protobuf_BoolValue_value(require_client_certificate);
2283
2514
  }
2515
+ auto* require_sni =
2516
+ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_sni(
2517
+ downstream_tls_context_proto);
2518
+ if (require_sni != nullptr &&
2519
+ google_protobuf_BoolValue_value(require_sni)) {
2520
+ errors.push_back(
2521
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("require_sni: unsupported"));
2522
+ }
2523
+ if (envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_ocsp_staple_policy(
2524
+ downstream_tls_context_proto) !=
2525
+ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_LENIENT_STAPLING) {
2526
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2527
+ "ocsp_staple_policy: Only LENIENT_STAPLING supported"));
2528
+ }
2284
2529
  }
2285
2530
  if (downstream_tls_context->common_tls_context
2286
- .tls_certificate_certificate_provider_instance.instance_name
2287
- .empty()) {
2288
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2531
+ .tls_certificate_provider_instance.instance_name.empty()) {
2532
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2289
2533
  "TLS configuration provided but no "
2290
- "tls_certificate_certificate_provider_instance found.");
2534
+ "tls_certificate_provider_instance found."));
2291
2535
  }
2292
2536
  if (downstream_tls_context->require_client_certificate &&
2293
- downstream_tls_context->common_tls_context.combined_validation_context
2294
- .validation_context_certificate_provider_instance.instance_name
2295
- .empty()) {
2296
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2537
+ downstream_tls_context->common_tls_context.certificate_validation_context
2538
+ .ca_certificate_provider_instance.instance_name.empty()) {
2539
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2297
2540
  "TLS configuration requires client certificates but no certificate "
2298
- "provider instance specified for validation.");
2541
+ "provider instance specified for validation."));
2299
2542
  }
2300
- return GRPC_ERROR_NONE;
2543
+ if (!downstream_tls_context->common_tls_context.certificate_validation_context
2544
+ .match_subject_alt_names.empty()) {
2545
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2546
+ "match_subject_alt_names not supported on servers"));
2547
+ }
2548
+ return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing DownstreamTlsContext",
2549
+ &errors);
2301
2550
  }
2302
2551
 
2303
2552
  grpc_error_handle CidrRangeParse(
@@ -2388,67 +2637,69 @@ grpc_error_handle FilterChainParse(
2388
2637
  const EncodingContext& context,
2389
2638
  const envoy_config_listener_v3_FilterChain* filter_chain_proto, bool is_v2,
2390
2639
  FilterChain* filter_chain) {
2391
- grpc_error_handle error = GRPC_ERROR_NONE;
2640
+ std::vector<grpc_error_handle> errors;
2392
2641
  auto* filter_chain_match =
2393
2642
  envoy_config_listener_v3_FilterChain_filter_chain_match(
2394
2643
  filter_chain_proto);
2395
2644
  if (filter_chain_match != nullptr) {
2396
- error = FilterChainMatchParse(filter_chain_match,
2397
- &filter_chain->filter_chain_match);
2398
- if (error != GRPC_ERROR_NONE) return error;
2645
+ grpc_error_handle error = FilterChainMatchParse(
2646
+ filter_chain_match, &filter_chain->filter_chain_match);
2647
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2399
2648
  }
2649
+ filter_chain->filter_chain_data =
2650
+ std::make_shared<XdsApi::LdsUpdate::FilterChainData>();
2400
2651
  // Parse the filters list. Currently we only support HttpConnectionManager.
2401
2652
  size_t size = 0;
2402
2653
  auto* filters =
2403
2654
  envoy_config_listener_v3_FilterChain_filters(filter_chain_proto, &size);
2404
2655
  if (size != 1) {
2405
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2656
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2406
2657
  "FilterChain should have exactly one filter: HttpConnectionManager; no "
2407
- "other filter is supported at the moment");
2408
- }
2409
- auto* typed_config = envoy_config_listener_v3_Filter_typed_config(filters[0]);
2410
- if (typed_config == nullptr) {
2411
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2412
- "No typed_config found in filter.");
2413
- }
2414
- absl::string_view type_url =
2415
- UpbStringToAbsl(google_protobuf_Any_type_url(typed_config));
2416
- if (type_url !=
2417
- "type.googleapis.com/"
2418
- "envoy.extensions.filters.network.http_connection_manager.v3."
2419
- "HttpConnectionManager") {
2420
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2421
- absl::StrCat("Unsupported filter type ", type_url).c_str());
2422
- }
2423
- const upb_strview encoded_http_connection_manager =
2424
- google_protobuf_Any_value(typed_config);
2425
- const auto* http_connection_manager =
2426
- envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
2427
- encoded_http_connection_manager.data,
2428
- encoded_http_connection_manager.size, context.arena);
2429
- if (http_connection_manager == nullptr) {
2430
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2431
- "Could not parse HttpConnectionManager config from filter "
2432
- "typed_config");
2433
- }
2434
- filter_chain->filter_chain_data =
2435
- std::make_shared<XdsApi::LdsUpdate::FilterChainData>();
2436
- error = HttpConnectionManagerParse(
2437
- false /* is_client */, context, http_connection_manager, is_v2,
2438
- &filter_chain->filter_chain_data->http_connection_manager);
2439
- if (error != GRPC_ERROR_NONE) return error;
2440
- // Get the DownstreamTlsContext for the filter chain
2441
- if (XdsSecurityEnabled()) {
2442
- auto* transport_socket =
2443
- envoy_config_listener_v3_FilterChain_transport_socket(
2444
- filter_chain_proto);
2445
- if (transport_socket != nullptr) {
2446
- error = DownstreamTlsContextParse(
2447
- context, transport_socket,
2448
- &filter_chain->filter_chain_data->downstream_tls_context);
2658
+ "other filter is supported at the moment"));
2659
+ } else {
2660
+ auto* typed_config =
2661
+ envoy_config_listener_v3_Filter_typed_config(filters[0]);
2662
+ if (typed_config == nullptr) {
2663
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2664
+ "No typed_config found in filter."));
2665
+ } else {
2666
+ absl::string_view type_url =
2667
+ UpbStringToAbsl(google_protobuf_Any_type_url(typed_config));
2668
+ if (type_url !=
2669
+ "type.googleapis.com/"
2670
+ "envoy.extensions.filters.network.http_connection_manager.v3."
2671
+ "HttpConnectionManager") {
2672
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
2673
+ absl::StrCat("Unsupported filter type ", type_url)));
2674
+ } else {
2675
+ const upb_strview encoded_http_connection_manager =
2676
+ google_protobuf_Any_value(typed_config);
2677
+ const auto* http_connection_manager =
2678
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
2679
+ encoded_http_connection_manager.data,
2680
+ encoded_http_connection_manager.size, context.arena);
2681
+ if (http_connection_manager == nullptr) {
2682
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2683
+ "Could not parse HttpConnectionManager config from filter "
2684
+ "typed_config"));
2685
+ } else {
2686
+ grpc_error_handle error = HttpConnectionManagerParse(
2687
+ false /* is_client */, context, http_connection_manager, is_v2,
2688
+ &filter_chain->filter_chain_data->http_connection_manager);
2689
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2690
+ }
2691
+ }
2449
2692
  }
2450
2693
  }
2451
- return error;
2694
+ auto* transport_socket =
2695
+ envoy_config_listener_v3_FilterChain_transport_socket(filter_chain_proto);
2696
+ if (transport_socket != nullptr) {
2697
+ grpc_error_handle error = DownstreamTlsContextParse(
2698
+ context, transport_socket,
2699
+ &filter_chain->filter_chain_data->downstream_tls_context);
2700
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
2701
+ }
2702
+ return GRPC_ERROR_CREATE_FROM_VECTOR("Error parsing FilterChain", &errors);
2452
2703
  }
2453
2704
 
2454
2705
  grpc_error_handle AddressParse(
@@ -2456,7 +2707,7 @@ grpc_error_handle AddressParse(
2456
2707
  const auto* socket_address =
2457
2708
  envoy_config_core_v3_Address_socket_address(address_proto);
2458
2709
  if (socket_address == nullptr) {
2459
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2710
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2460
2711
  "Address does not have socket_address");
2461
2712
  }
2462
2713
  if (envoy_config_core_v3_SocketAddress_protocol(socket_address) !=
@@ -2499,11 +2750,9 @@ grpc_error_handle AddFilterChainDataForSourcePort(
2499
2750
  port, XdsApi::LdsUpdate::FilterChainMap::FilterChainDataSharedPtr{
2500
2751
  filter_chain.filter_chain_data});
2501
2752
  if (!insert_result.second) {
2502
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2503
- absl::StrCat(
2504
- "Duplicate matching rules detected when adding filter chain: ",
2505
- filter_chain.filter_chain_match.ToString())
2506
- .c_str());
2753
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
2754
+ "Duplicate matching rules detected when adding filter chain: ",
2755
+ filter_chain.filter_chain_match.ToString()));
2507
2756
  }
2508
2757
  return GRPC_ERROR_NONE;
2509
2758
  }
@@ -2668,7 +2917,7 @@ grpc_error_handle BuildFilterChainMap(
2668
2917
  return GRPC_ERROR_NONE;
2669
2918
  }
2670
2919
 
2671
- grpc_error_handle LdsResponseParseServer(
2920
+ grpc_error_handle LdsResourceParseServer(
2672
2921
  const EncodingContext& context,
2673
2922
  const envoy_config_listener_v3_Listener* listener, bool is_v2,
2674
2923
  XdsApi::LdsUpdate* lds_update) {
@@ -2717,166 +2966,31 @@ grpc_error_handle LdsResponseParseServer(
2717
2966
  return GRPC_ERROR_NONE;
2718
2967
  }
2719
2968
 
2720
- grpc_error_handle LdsResponseParse(
2969
+ grpc_error_handle LdsResourceParse(
2721
2970
  const EncodingContext& context,
2722
- const envoy_service_discovery_v3_DiscoveryResponse* response,
2723
- const std::set<absl::string_view>& expected_listener_names,
2724
- XdsApi::LdsUpdateMap* lds_update_map,
2725
- std::set<std::string>* resource_names_failed) {
2726
- std::vector<grpc_error_handle> errors;
2727
- // Get the resources from the response.
2728
- size_t size;
2729
- const google_protobuf_Any* const* resources =
2730
- envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
2731
- for (size_t i = 0; i < size; ++i) {
2732
- // Check the type_url of the resource.
2733
- absl::string_view type_url =
2734
- UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
2735
- bool is_v2 = false;
2736
- if (!IsLds(type_url, &is_v2)) {
2737
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2738
- absl::StrCat("resource index ", i, ": Resource is not LDS.")
2739
- .c_str()));
2740
- continue;
2741
- }
2742
- // Decode the listener.
2743
- const upb_strview encoded_listener =
2744
- google_protobuf_Any_value(resources[i]);
2745
- const envoy_config_listener_v3_Listener* listener =
2746
- envoy_config_listener_v3_Listener_parse(
2747
- encoded_listener.data, encoded_listener.size, context.arena);
2748
- if (listener == nullptr) {
2749
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2750
- absl::StrCat("resource index ", i, ": Can't decode listener.")
2751
- .c_str()));
2752
- continue;
2753
- }
2754
- // Check listener name. Ignore unexpected listeners.
2755
- std::string listener_name =
2756
- UpbStringToStdString(envoy_config_listener_v3_Listener_name(listener));
2757
- if (expected_listener_names.find(listener_name) ==
2758
- expected_listener_names.end()) {
2759
- continue;
2760
- }
2761
- // Fail if listener name is duplicated.
2762
- if (lds_update_map->find(listener_name) != lds_update_map->end()) {
2763
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2764
- absl::StrCat("duplicate listener name \"", listener_name, "\"")
2765
- .c_str()));
2766
- resource_names_failed->insert(listener_name);
2767
- continue;
2768
- }
2769
- // Serialize into JSON and store it in the LdsUpdateMap
2770
- XdsApi::LdsResourceData& lds_resource_data =
2771
- (*lds_update_map)[listener_name];
2772
- XdsApi::LdsUpdate& lds_update = lds_resource_data.resource;
2773
- lds_resource_data.serialized_proto = UpbStringToStdString(encoded_listener);
2774
- // Check whether it's a client or server listener.
2775
- const envoy_config_listener_v3_ApiListener* api_listener =
2776
- envoy_config_listener_v3_Listener_api_listener(listener);
2777
- const envoy_config_core_v3_Address* address =
2778
- envoy_config_listener_v3_Listener_address(listener);
2779
- if (api_listener != nullptr && address != nullptr) {
2780
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2781
- absl::StrCat(listener_name,
2782
- ": Listener has both address and ApiListener")
2783
- .c_str()));
2784
- resource_names_failed->insert(listener_name);
2785
- continue;
2786
- }
2787
- if (api_listener == nullptr && address == nullptr) {
2788
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2789
- absl::StrCat(listener_name,
2790
- ": Listener has neither address nor ApiListener")
2791
- .c_str()));
2792
- resource_names_failed->insert(listener_name);
2793
- continue;
2794
- }
2795
- grpc_error_handle error = GRPC_ERROR_NONE;
2796
- if (api_listener != nullptr) {
2797
- error = LdsResponseParseClient(context, api_listener, is_v2, &lds_update);
2798
- } else {
2799
- error = LdsResponseParseServer(context, listener, is_v2, &lds_update);
2800
- }
2801
- if (error != GRPC_ERROR_NONE) {
2802
- errors.push_back(grpc_error_add_child(
2803
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2804
- absl::StrCat(listener_name, ": validation error").c_str()),
2805
- error));
2806
- resource_names_failed->insert(listener_name);
2807
- }
2971
+ const envoy_config_listener_v3_Listener* listener, bool is_v2,
2972
+ XdsApi::LdsUpdate* lds_update) {
2973
+ // Check whether it's a client or server listener.
2974
+ const envoy_config_listener_v3_ApiListener* api_listener =
2975
+ envoy_config_listener_v3_Listener_api_listener(listener);
2976
+ const envoy_config_core_v3_Address* address =
2977
+ envoy_config_listener_v3_Listener_address(listener);
2978
+ if (api_listener != nullptr && address != nullptr) {
2979
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2980
+ "Listener has both address and ApiListener");
2808
2981
  }
2809
- return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing LDS response", &errors);
2810
- }
2811
-
2812
- grpc_error_handle RdsResponseParse(
2813
- const EncodingContext& context,
2814
- const envoy_service_discovery_v3_DiscoveryResponse* response,
2815
- const std::set<absl::string_view>& expected_route_configuration_names,
2816
- XdsApi::RdsUpdateMap* rds_update_map,
2817
- std::set<std::string>* resource_names_failed) {
2818
- std::vector<grpc_error_handle> errors;
2819
- // Get the resources from the response.
2820
- size_t size;
2821
- const google_protobuf_Any* const* resources =
2822
- envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
2823
- for (size_t i = 0; i < size; ++i) {
2824
- // Check the type_url of the resource.
2825
- absl::string_view type_url =
2826
- UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
2827
- if (!IsRds(type_url)) {
2828
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2829
- absl::StrCat("resource index ", i, ": Resource is not RDS.")
2830
- .c_str()));
2831
- continue;
2832
- }
2833
- // Decode the route_config.
2834
- const upb_strview encoded_route_config =
2835
- google_protobuf_Any_value(resources[i]);
2836
- const envoy_config_route_v3_RouteConfiguration* route_config =
2837
- envoy_config_route_v3_RouteConfiguration_parse(
2838
- encoded_route_config.data, encoded_route_config.size,
2839
- context.arena);
2840
- if (route_config == nullptr) {
2841
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2842
- absl::StrCat("resource index ", i, ": Can't decode route_config.")
2843
- .c_str()));
2844
- continue;
2845
- }
2846
- // Check route_config_name. Ignore unexpected route_config.
2847
- std::string route_config_name = UpbStringToStdString(
2848
- envoy_config_route_v3_RouteConfiguration_name(route_config));
2849
- if (expected_route_configuration_names.find(route_config_name) ==
2850
- expected_route_configuration_names.end()) {
2851
- continue;
2852
- }
2853
- // Fail if route config name is duplicated.
2854
- if (rds_update_map->find(route_config_name) != rds_update_map->end()) {
2855
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2856
- absl::StrCat("duplicate route config name \"", route_config_name,
2857
- "\"")
2858
- .c_str()));
2859
- resource_names_failed->insert(route_config_name);
2860
- continue;
2861
- }
2862
- // Serialize into JSON and store it in the RdsUpdateMap
2863
- XdsApi::RdsResourceData& rds_resource_data =
2864
- (*rds_update_map)[route_config_name];
2865
- XdsApi::RdsUpdate& rds_update = rds_resource_data.resource;
2866
- rds_resource_data.serialized_proto =
2867
- UpbStringToStdString(encoded_route_config);
2868
- // Parse the route_config.
2869
- grpc_error_handle error =
2870
- RouteConfigParse(context, route_config, &rds_update);
2871
- if (error != GRPC_ERROR_NONE) {
2872
- errors.push_back(grpc_error_add_child(
2873
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2874
- absl::StrCat(route_config_name, ": validation error").c_str()),
2875
- error));
2876
- resource_names_failed->insert(route_config_name);
2877
- }
2982
+ if (api_listener == nullptr && address == nullptr) {
2983
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2984
+ "Listener has neither address nor ApiListener");
2878
2985
  }
2879
- return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing RDS response", &errors);
2986
+ // Validate Listener fields.
2987
+ grpc_error_handle error = GRPC_ERROR_NONE;
2988
+ if (api_listener != nullptr) {
2989
+ error = LdsResourceParseClient(context, api_listener, is_v2, lds_update);
2990
+ } else {
2991
+ error = LdsResourceParseServer(context, listener, is_v2, lds_update);
2992
+ }
2993
+ return error;
2880
2994
  }
2881
2995
 
2882
2996
  grpc_error_handle UpstreamTlsContextParse(
@@ -2887,8 +3001,8 @@ grpc_error_handle UpstreamTlsContextParse(
2887
3001
  absl::string_view name = UpbStringToAbsl(
2888
3002
  envoy_config_core_v3_TransportSocket_name(transport_socket));
2889
3003
  if (name != "envoy.transport_sockets.tls") {
2890
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2891
- absl::StrCat("Unrecognized transport socket: ", name).c_str());
3004
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
3005
+ absl::StrCat("Unrecognized transport socket: ", name));
2892
3006
  }
2893
3007
  auto* typed_config =
2894
3008
  envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
@@ -2916,392 +3030,263 @@ grpc_error_handle UpstreamTlsContextParse(
2916
3030
  }
2917
3031
  }
2918
3032
  }
2919
- if (common_tls_context->combined_validation_context
2920
- .validation_context_certificate_provider_instance.instance_name
2921
- .empty()) {
2922
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3033
+ if (common_tls_context->certificate_validation_context
3034
+ .ca_certificate_provider_instance.instance_name.empty()) {
3035
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2923
3036
  "UpstreamTlsContext: TLS configuration provided but no "
2924
- "validation_context_certificate_provider_instance "
2925
- "found.");
3037
+ "ca_certificate_provider_instance found.");
2926
3038
  }
2927
3039
  return GRPC_ERROR_NONE;
2928
3040
  }
2929
3041
 
2930
- grpc_error_handle CdsResponseParse(
3042
+ grpc_error_handle CdsLogicalDnsParse(
3043
+ const envoy_config_cluster_v3_Cluster* cluster,
3044
+ XdsApi::CdsUpdate* cds_update) {
3045
+ const auto* load_assignment =
3046
+ envoy_config_cluster_v3_Cluster_load_assignment(cluster);
3047
+ if (load_assignment == nullptr) {
3048
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3049
+ "load_assignment not present for LOGICAL_DNS cluster");
3050
+ }
3051
+ size_t num_localities;
3052
+ const auto* const* localities =
3053
+ envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(load_assignment,
3054
+ &num_localities);
3055
+ if (num_localities != 1) {
3056
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
3057
+ absl::StrCat("load_assignment for LOGICAL_DNS cluster must have "
3058
+ "exactly one locality, found ",
3059
+ num_localities));
3060
+ }
3061
+ size_t num_endpoints;
3062
+ const auto* const* endpoints =
3063
+ envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(localities[0],
3064
+ &num_endpoints);
3065
+ if (num_endpoints != 1) {
3066
+ return GRPC_ERROR_CREATE_FROM_CPP_STRING(
3067
+ absl::StrCat("locality for LOGICAL_DNS cluster must have "
3068
+ "exactly one endpoint, found ",
3069
+ num_endpoints));
3070
+ }
3071
+ const auto* endpoint =
3072
+ envoy_config_endpoint_v3_LbEndpoint_endpoint(endpoints[0]);
3073
+ if (endpoint == nullptr) {
3074
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3075
+ "LbEndpoint endpoint field not set");
3076
+ }
3077
+ const auto* address = envoy_config_endpoint_v3_Endpoint_address(endpoint);
3078
+ if (address == nullptr) {
3079
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3080
+ "Endpoint address field not set");
3081
+ }
3082
+ const auto* socket_address =
3083
+ envoy_config_core_v3_Address_socket_address(address);
3084
+ if (socket_address == nullptr) {
3085
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3086
+ "Address socket_address field not set");
3087
+ }
3088
+ if (envoy_config_core_v3_SocketAddress_resolver_name(socket_address).size !=
3089
+ 0) {
3090
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3091
+ "LOGICAL_DNS clusters must NOT have a custom resolver name set");
3092
+ }
3093
+ absl::string_view address_str = UpbStringToAbsl(
3094
+ envoy_config_core_v3_SocketAddress_address(socket_address));
3095
+ if (address_str.empty()) {
3096
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3097
+ "SocketAddress address field not set");
3098
+ }
3099
+ if (!envoy_config_core_v3_SocketAddress_has_port_value(socket_address)) {
3100
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3101
+ "SocketAddress port_value field not set");
3102
+ }
3103
+ cds_update->dns_hostname = JoinHostPort(
3104
+ address_str,
3105
+ envoy_config_core_v3_SocketAddress_port_value(socket_address));
3106
+ return GRPC_ERROR_NONE;
3107
+ }
3108
+
3109
+ grpc_error_handle CdsResourceParse(
2931
3110
  const EncodingContext& context,
2932
- const envoy_service_discovery_v3_DiscoveryResponse* response,
2933
- const std::set<absl::string_view>& expected_cluster_names,
2934
- XdsApi::CdsUpdateMap* cds_update_map,
2935
- std::set<std::string>* resource_names_failed) {
3111
+ const envoy_config_cluster_v3_Cluster* cluster, bool /*is_v2*/,
3112
+ XdsApi::CdsUpdate* cds_update) {
2936
3113
  std::vector<grpc_error_handle> errors;
2937
- // Get the resources from the response.
2938
- size_t size;
2939
- const google_protobuf_Any* const* resources =
2940
- envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
2941
- // Parse all the resources in the CDS response.
2942
- for (size_t i = 0; i < size; ++i) {
2943
- // Check the type_url of the resource.
2944
- absl::string_view type_url =
2945
- UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
2946
- if (!IsCds(type_url)) {
2947
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2948
- absl::StrCat("resource index ", i, ": Resource is not CDS.")
2949
- .c_str()));
2950
- continue;
2951
- }
2952
- // Decode the cluster.
2953
- const upb_strview encoded_cluster = google_protobuf_Any_value(resources[i]);
2954
- const envoy_config_cluster_v3_Cluster* cluster =
2955
- envoy_config_cluster_v3_Cluster_parse(
2956
- encoded_cluster.data, encoded_cluster.size, context.arena);
2957
- if (cluster == nullptr) {
2958
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2959
- absl::StrCat("resource index ", i, ": Can't decode cluster.")
2960
- .c_str()));
2961
- continue;
2962
- }
2963
- MaybeLogCluster(context, cluster);
2964
- // Ignore unexpected cluster names.
2965
- std::string cluster_name =
2966
- UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
2967
- if (expected_cluster_names.find(cluster_name) ==
2968
- expected_cluster_names.end()) {
2969
- continue;
2970
- }
2971
- // Fail on duplicate resources.
2972
- if (cds_update_map->find(cluster_name) != cds_update_map->end()) {
2973
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2974
- absl::StrCat("duplicate resource name \"", cluster_name, "\"")
2975
- .c_str()));
2976
- resource_names_failed->insert(cluster_name);
2977
- continue;
2978
- }
2979
- // Add the cluster to cds_update_map.
2980
- XdsApi::CdsResourceData& cds_resource_data =
2981
- (*cds_update_map)[cluster_name];
2982
- XdsApi::CdsUpdate& cds_update = cds_resource_data.resource;
2983
- // Store serialized proto.
2984
- cds_resource_data.serialized_proto = UpbStringToStdString(encoded_cluster);
2985
- // Check the cluster_discovery_type.
2986
- if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
2987
- !envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
2988
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2989
- absl::StrCat(cluster_name, ": DiscoveryType not found.").c_str()));
2990
- resource_names_failed->insert(cluster_name);
2991
- continue;
2992
- }
2993
- if (envoy_config_cluster_v3_Cluster_type(cluster) ==
2994
- envoy_config_cluster_v3_Cluster_EDS) {
2995
- cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::EDS;
2996
- // Check the EDS config source.
2997
- const envoy_config_cluster_v3_Cluster_EdsClusterConfig*
2998
- eds_cluster_config =
2999
- envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
3000
- const envoy_config_core_v3_ConfigSource* eds_config =
3001
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
3002
- eds_cluster_config);
3003
- if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
3004
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3005
- absl::StrCat(cluster_name, ": EDS ConfigSource is not ADS.")
3006
- .c_str()));
3007
- resource_names_failed->insert(cluster_name);
3008
- continue;
3009
- }
3010
- // Record EDS service_name (if any).
3011
- upb_strview service_name =
3012
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
3013
- eds_cluster_config);
3014
- if (service_name.size != 0) {
3015
- cds_update.eds_service_name = UpbStringToStdString(service_name);
3016
- }
3017
- } else if (!XdsAggregateAndLogicalDnsClusterEnabled()) {
3018
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3019
- absl::StrCat(cluster_name, ": DiscoveryType is not valid.").c_str()));
3020
- resource_names_failed->insert(cluster_name);
3021
- continue;
3022
- } else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
3023
- envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
3024
- cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
3025
- const auto* load_assignment =
3026
- envoy_config_cluster_v3_Cluster_load_assignment(cluster);
3027
- if (load_assignment == nullptr) {
3028
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3029
- absl::StrCat(
3030
- cluster_name,
3031
- ": load_assignment not present for LOGICAL_DNS cluster")
3032
- .c_str()));
3033
- resource_names_failed->insert(cluster_name);
3034
- continue;
3035
- }
3036
- size_t num_localities;
3037
- const auto* const* localities =
3038
- envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
3039
- load_assignment, &num_localities);
3040
- if (num_localities != 1) {
3041
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3042
- absl::StrCat(cluster_name,
3043
- ": load_assignment for LOGICAL_DNS cluster must have "
3044
- "exactly one locality, found ",
3045
- num_localities)
3046
- .c_str()));
3047
- resource_names_failed->insert(cluster_name);
3048
- continue;
3049
- }
3050
- size_t num_endpoints;
3051
- const auto* const* endpoints =
3052
- envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
3053
- localities[0], &num_endpoints);
3054
- if (num_endpoints != 1) {
3055
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3056
- absl::StrCat(cluster_name,
3057
- ": locality for LOGICAL_DNS cluster must have "
3058
- "exactly one endpoint, found ",
3059
- num_endpoints)
3060
- .c_str()));
3061
- resource_names_failed->insert(cluster_name);
3062
- continue;
3063
- }
3064
- const auto* endpoint =
3065
- envoy_config_endpoint_v3_LbEndpoint_endpoint(endpoints[0]);
3066
- if (endpoint == nullptr) {
3067
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3068
- absl::StrCat(cluster_name, ": LbEndpoint endpoint field not set")
3069
- .c_str()));
3070
- resource_names_failed->insert(cluster_name);
3071
- continue;
3072
- }
3073
- const auto* address = envoy_config_endpoint_v3_Endpoint_address(endpoint);
3074
- if (address == nullptr) {
3075
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3076
- absl::StrCat(cluster_name, ": Endpoint address field not set")
3077
- .c_str()));
3078
- resource_names_failed->insert(cluster_name);
3079
- continue;
3080
- }
3081
- const auto* socket_address =
3082
- envoy_config_core_v3_Address_socket_address(address);
3083
- if (socket_address == nullptr) {
3084
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3085
- absl::StrCat(cluster_name, ": Address socket_address field not set")
3086
- .c_str()));
3087
- resource_names_failed->insert(cluster_name);
3088
- continue;
3089
- }
3090
- if (envoy_config_core_v3_SocketAddress_resolver_name(socket_address)
3091
- .size != 0) {
3092
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3093
- absl::StrCat(
3094
- cluster_name,
3095
- ": LOGICAL_DNS clusters must NOT have a custom resolver "
3096
- "name set")
3097
- .c_str()));
3098
- resource_names_failed->insert(cluster_name);
3099
- continue;
3100
- }
3101
- absl::string_view address_str = UpbStringToAbsl(
3102
- envoy_config_core_v3_SocketAddress_address(socket_address));
3103
- if (address_str.empty()) {
3104
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3105
- absl::StrCat(cluster_name, ": SocketAddress address field not set")
3106
- .c_str()));
3107
- resource_names_failed->insert(cluster_name);
3108
- continue;
3109
- }
3110
- if (!envoy_config_core_v3_SocketAddress_has_port_value(socket_address)) {
3111
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3112
- absl::StrCat(cluster_name,
3113
- ": SocketAddress port_value field not set")
3114
- .c_str()));
3115
- resource_names_failed->insert(cluster_name);
3116
- continue;
3117
- }
3118
- cds_update.dns_hostname = JoinHostPort(
3119
- address_str,
3120
- envoy_config_core_v3_SocketAddress_port_value(socket_address));
3114
+ // Check the cluster_discovery_type.
3115
+ if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
3116
+ !envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
3117
+ errors.push_back(
3118
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found."));
3119
+ } else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
3120
+ envoy_config_cluster_v3_Cluster_EDS) {
3121
+ cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::EDS;
3122
+ // Check the EDS config source.
3123
+ const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
3124
+ envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
3125
+ const envoy_config_core_v3_ConfigSource* eds_config =
3126
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
3127
+ eds_cluster_config);
3128
+ if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
3129
+ errors.push_back(
3130
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("EDS ConfigSource is not ADS."));
3131
+ }
3132
+ // Record EDS service_name (if any).
3133
+ upb_strview service_name =
3134
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
3135
+ eds_cluster_config);
3136
+ if (service_name.size != 0) {
3137
+ cds_update->eds_service_name = UpbStringToStdString(service_name);
3138
+ }
3139
+ } else if (!XdsAggregateAndLogicalDnsClusterEnabled()) {
3140
+ errors.push_back(
3141
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not valid."));
3142
+ } else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
3143
+ envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
3144
+ cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
3145
+ grpc_error_handle error = CdsLogicalDnsParse(cluster, cds_update);
3146
+ if (error != GRPC_ERROR_NONE) errors.push_back(error);
3147
+ } else {
3148
+ if (!envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
3149
+ errors.push_back(
3150
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not valid."));
3121
3151
  } else {
3122
- if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
3123
- const envoy_config_cluster_v3_Cluster_CustomClusterType*
3124
- custom_cluster_type =
3125
- envoy_config_cluster_v3_Cluster_cluster_type(cluster);
3126
- upb_strview type_name =
3127
- envoy_config_cluster_v3_Cluster_CustomClusterType_name(
3152
+ const envoy_config_cluster_v3_Cluster_CustomClusterType*
3153
+ custom_cluster_type =
3154
+ envoy_config_cluster_v3_Cluster_cluster_type(cluster);
3155
+ upb_strview type_name =
3156
+ envoy_config_cluster_v3_Cluster_CustomClusterType_name(
3157
+ custom_cluster_type);
3158
+ if (UpbStringToAbsl(type_name) != "envoy.clusters.aggregate") {
3159
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3160
+ "DiscoveryType is not valid."));
3161
+ } else {
3162
+ cds_update->cluster_type = XdsApi::CdsUpdate::ClusterType::AGGREGATE;
3163
+ // Retrieve aggregate clusters.
3164
+ const google_protobuf_Any* typed_config =
3165
+ envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
3128
3166
  custom_cluster_type);
3129
- if (UpbStringToAbsl(type_name) == "envoy.clusters.aggregate") {
3130
- cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::AGGREGATE;
3131
- // Retrieve aggregate clusters.
3132
- const google_protobuf_Any* typed_config =
3133
- envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
3134
- custom_cluster_type);
3135
- const upb_strview aggregate_cluster_config_upb_strview =
3136
- google_protobuf_Any_value(typed_config);
3137
- const envoy_extensions_clusters_aggregate_v3_ClusterConfig*
3138
- aggregate_cluster_config =
3139
- envoy_extensions_clusters_aggregate_v3_ClusterConfig_parse(
3140
- aggregate_cluster_config_upb_strview.data,
3141
- aggregate_cluster_config_upb_strview.size, context.arena);
3142
- if (aggregate_cluster_config == nullptr) {
3143
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3144
- absl::StrCat(cluster_name, ": Can't parse aggregate cluster.")
3145
- .c_str()));
3146
- resource_names_failed->insert(cluster_name);
3147
- continue;
3148
- }
3167
+ const upb_strview aggregate_cluster_config_upb_strview =
3168
+ google_protobuf_Any_value(typed_config);
3169
+ const envoy_extensions_clusters_aggregate_v3_ClusterConfig*
3170
+ aggregate_cluster_config =
3171
+ envoy_extensions_clusters_aggregate_v3_ClusterConfig_parse(
3172
+ aggregate_cluster_config_upb_strview.data,
3173
+ aggregate_cluster_config_upb_strview.size, context.arena);
3174
+ if (aggregate_cluster_config == nullptr) {
3175
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3176
+ "Can't parse aggregate cluster."));
3177
+ } else {
3149
3178
  size_t size;
3150
3179
  const upb_strview* clusters =
3151
3180
  envoy_extensions_clusters_aggregate_v3_ClusterConfig_clusters(
3152
3181
  aggregate_cluster_config, &size);
3153
3182
  for (size_t i = 0; i < size; ++i) {
3154
3183
  const upb_strview cluster = clusters[i];
3155
- cds_update.prioritized_cluster_names.emplace_back(
3184
+ cds_update->prioritized_cluster_names.emplace_back(
3156
3185
  UpbStringToStdString(cluster));
3157
3186
  }
3158
- } else {
3159
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3160
- absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
3161
- .c_str()));
3162
- resource_names_failed->insert(cluster_name);
3163
- continue;
3164
3187
  }
3165
- } else {
3166
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3167
- absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
3168
- .c_str()));
3169
- resource_names_failed->insert(cluster_name);
3170
- continue;
3171
3188
  }
3172
3189
  }
3173
- // Check the LB policy.
3174
- if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
3175
- envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
3176
- cds_update.lb_policy = "ROUND_ROBIN";
3177
- } else if (XdsRingHashEnabled() &&
3178
- envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
3179
- envoy_config_cluster_v3_Cluster_RING_HASH) {
3180
- cds_update.lb_policy = "RING_HASH";
3181
- // Record ring hash lb config
3182
- auto* ring_hash_config =
3183
- envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
3184
- if (ring_hash_config != nullptr) {
3185
- const google_protobuf_UInt64Value* max_ring_size =
3186
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
3187
- ring_hash_config);
3188
- if (max_ring_size != nullptr) {
3189
- cds_update.max_ring_size =
3190
- google_protobuf_UInt64Value_value(max_ring_size);
3191
- if (cds_update.max_ring_size > 8388608 ||
3192
- cds_update.max_ring_size == 0) {
3193
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3194
- absl::StrCat(
3195
- cluster_name,
3196
- ": max_ring_size is not in the range of 1 to 8388608.")
3197
- .c_str()));
3198
- resource_names_failed->insert(cluster_name);
3199
- continue;
3200
- }
3201
- }
3202
- const google_protobuf_UInt64Value* min_ring_size =
3203
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
3204
- ring_hash_config);
3205
- if (min_ring_size != nullptr) {
3206
- cds_update.min_ring_size =
3207
- google_protobuf_UInt64Value_value(min_ring_size);
3208
- if (cds_update.min_ring_size > 8388608 ||
3209
- cds_update.min_ring_size == 0) {
3210
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3211
- absl::StrCat(
3212
- cluster_name,
3213
- ": min_ring_size is not in the range of 1 to 8388608.")
3214
- .c_str()));
3215
- resource_names_failed->insert(cluster_name);
3216
- continue;
3217
- }
3218
- if (cds_update.min_ring_size > cds_update.max_ring_size) {
3219
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3220
- absl::StrCat(
3221
- cluster_name,
3222
- ": min_ring_size cannot be greater than max_ring_size.")
3223
- .c_str()));
3224
- resource_names_failed->insert(cluster_name);
3225
- continue;
3226
- }
3227
- }
3228
- if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
3229
- ring_hash_config) !=
3230
- envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
3231
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3232
- absl::StrCat(cluster_name,
3233
- ": ring hash lb config has invalid hash function.")
3234
- .c_str()));
3235
- resource_names_failed->insert(cluster_name);
3236
- continue;
3190
+ }
3191
+ // Check the LB policy.
3192
+ if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
3193
+ envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
3194
+ cds_update->lb_policy = "ROUND_ROBIN";
3195
+ } else if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
3196
+ envoy_config_cluster_v3_Cluster_RING_HASH) {
3197
+ cds_update->lb_policy = "RING_HASH";
3198
+ // Record ring hash lb config
3199
+ auto* ring_hash_config =
3200
+ envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
3201
+ if (ring_hash_config != nullptr) {
3202
+ const google_protobuf_UInt64Value* max_ring_size =
3203
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
3204
+ ring_hash_config);
3205
+ if (max_ring_size != nullptr) {
3206
+ cds_update->max_ring_size =
3207
+ google_protobuf_UInt64Value_value(max_ring_size);
3208
+ if (cds_update->max_ring_size > 8388608 ||
3209
+ cds_update->max_ring_size == 0) {
3210
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3211
+ "max_ring_size is not in the range of 1 to 8388608."));
3237
3212
  }
3238
3213
  }
3239
- } else {
3240
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3241
- absl::StrCat(cluster_name, ": LB policy is not supported.").c_str()));
3242
- resource_names_failed->insert(cluster_name);
3243
- continue;
3244
- }
3245
- if (XdsSecurityEnabled()) {
3246
- auto* transport_socket =
3247
- envoy_config_cluster_v3_Cluster_transport_socket(cluster);
3248
- if (transport_socket != nullptr) {
3249
- grpc_error_handle error = UpstreamTlsContextParse(
3250
- context, transport_socket, &cds_update.common_tls_context);
3251
- if (error != GRPC_ERROR_NONE) {
3252
- errors.push_back(grpc_error_add_child(
3253
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3254
- absl::StrCat(
3255
- "Error parsing security configuration for cluster: ",
3256
- cluster_name)
3257
- .c_str()),
3258
- error));
3259
- resource_names_failed->insert(cluster_name);
3260
- continue;
3214
+ const google_protobuf_UInt64Value* min_ring_size =
3215
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
3216
+ ring_hash_config);
3217
+ if (min_ring_size != nullptr) {
3218
+ cds_update->min_ring_size =
3219
+ google_protobuf_UInt64Value_value(min_ring_size);
3220
+ if (cds_update->min_ring_size > 8388608 ||
3221
+ cds_update->min_ring_size == 0) {
3222
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3223
+ "min_ring_size is not in the range of 1 to 8388608."));
3224
+ }
3225
+ if (cds_update->min_ring_size > cds_update->max_ring_size) {
3226
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3227
+ "min_ring_size cannot be greater than max_ring_size."));
3261
3228
  }
3262
3229
  }
3263
- }
3264
- // Record LRS server name (if any).
3265
- const envoy_config_core_v3_ConfigSource* lrs_server =
3266
- envoy_config_cluster_v3_Cluster_lrs_server(cluster);
3267
- if (lrs_server != nullptr) {
3268
- if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
3269
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3270
- absl::StrCat(cluster_name, ": LRS ConfigSource is not self.")
3271
- .c_str()));
3272
- resource_names_failed->insert(cluster_name);
3273
- continue;
3230
+ if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
3231
+ ring_hash_config) !=
3232
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
3233
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3234
+ "ring hash lb config has invalid hash function."));
3274
3235
  }
3275
- cds_update.lrs_load_reporting_server_name.emplace("");
3276
3236
  }
3277
- // The Cluster resource encodes the circuit breaking parameters in a list of
3278
- // Thresholds messages, where each message specifies the parameters for a
3279
- // particular RoutingPriority. we will look only at the first entry in the
3280
- // list for priority DEFAULT and default to 1024 if not found.
3281
- if (envoy_config_cluster_v3_Cluster_has_circuit_breakers(cluster)) {
3282
- const envoy_config_cluster_v3_CircuitBreakers* circuit_breakers =
3283
- envoy_config_cluster_v3_Cluster_circuit_breakers(cluster);
3284
- size_t num_thresholds;
3285
- const envoy_config_cluster_v3_CircuitBreakers_Thresholds* const*
3286
- thresholds = envoy_config_cluster_v3_CircuitBreakers_thresholds(
3287
- circuit_breakers, &num_thresholds);
3288
- for (size_t i = 0; i < num_thresholds; ++i) {
3289
- const auto* threshold = thresholds[i];
3290
- if (envoy_config_cluster_v3_CircuitBreakers_Thresholds_priority(
3291
- threshold) == envoy_config_core_v3_DEFAULT) {
3292
- const google_protobuf_UInt32Value* max_requests =
3293
- envoy_config_cluster_v3_CircuitBreakers_Thresholds_max_requests(
3294
- threshold);
3295
- if (max_requests != nullptr) {
3296
- cds_update.max_concurrent_requests =
3297
- google_protobuf_UInt32Value_value(max_requests);
3298
- }
3299
- break;
3237
+ } else {
3238
+ errors.push_back(
3239
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("LB policy is not supported."));
3240
+ }
3241
+ auto* transport_socket =
3242
+ envoy_config_cluster_v3_Cluster_transport_socket(cluster);
3243
+ if (transport_socket != nullptr) {
3244
+ grpc_error_handle error = UpstreamTlsContextParse(
3245
+ context, transport_socket, &cds_update->common_tls_context);
3246
+ if (error != GRPC_ERROR_NONE) {
3247
+ errors.push_back(
3248
+ grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3249
+ "Error parsing security configuration"),
3250
+ error));
3251
+ }
3252
+ }
3253
+ // Record LRS server name (if any).
3254
+ const envoy_config_core_v3_ConfigSource* lrs_server =
3255
+ envoy_config_cluster_v3_Cluster_lrs_server(cluster);
3256
+ if (lrs_server != nullptr) {
3257
+ if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
3258
+ errors.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3259
+ ": LRS ConfigSource is not self."));
3260
+ }
3261
+ cds_update->lrs_load_reporting_server_name.emplace("");
3262
+ }
3263
+ // The Cluster resource encodes the circuit breaking parameters in a list of
3264
+ // Thresholds messages, where each message specifies the parameters for a
3265
+ // particular RoutingPriority. we will look only at the first entry in the
3266
+ // list for priority DEFAULT and default to 1024 if not found.
3267
+ if (envoy_config_cluster_v3_Cluster_has_circuit_breakers(cluster)) {
3268
+ const envoy_config_cluster_v3_CircuitBreakers* circuit_breakers =
3269
+ envoy_config_cluster_v3_Cluster_circuit_breakers(cluster);
3270
+ size_t num_thresholds;
3271
+ const envoy_config_cluster_v3_CircuitBreakers_Thresholds* const*
3272
+ thresholds = envoy_config_cluster_v3_CircuitBreakers_thresholds(
3273
+ circuit_breakers, &num_thresholds);
3274
+ for (size_t i = 0; i < num_thresholds; ++i) {
3275
+ const auto* threshold = thresholds[i];
3276
+ if (envoy_config_cluster_v3_CircuitBreakers_Thresholds_priority(
3277
+ threshold) == envoy_config_core_v3_DEFAULT) {
3278
+ const google_protobuf_UInt32Value* max_requests =
3279
+ envoy_config_cluster_v3_CircuitBreakers_Thresholds_max_requests(
3280
+ threshold);
3281
+ if (max_requests != nullptr) {
3282
+ cds_update->max_concurrent_requests =
3283
+ google_protobuf_UInt32Value_value(max_requests);
3300
3284
  }
3285
+ break;
3301
3286
  }
3302
3287
  }
3303
3288
  }
3304
- return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing CDS response", &errors);
3289
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing CDS resource", &errors);
3305
3290
  }
3306
3291
 
3307
3292
  grpc_error_handle ServerAddressParseAndAppend(
@@ -3430,17 +3415,87 @@ grpc_error_handle DropParseAndAppend(
3430
3415
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unknown denominator type");
3431
3416
  }
3432
3417
  // Cap numerator to 1000000.
3433
- numerator = GPR_MIN(numerator, 1000000);
3418
+ numerator = std::min(numerator, 1000000u);
3434
3419
  drop_config->AddCategory(std::move(category), numerator);
3435
3420
  return GRPC_ERROR_NONE;
3436
3421
  }
3437
3422
 
3438
- grpc_error_handle EdsResponseParse(
3439
- const EncodingContext& context,
3423
+ grpc_error_handle EdsResourceParse(
3424
+ const EncodingContext& /*context*/,
3425
+ const envoy_config_endpoint_v3_ClusterLoadAssignment*
3426
+ cluster_load_assignment,
3427
+ bool /*is_v2*/, XdsApi::EdsUpdate* eds_update) {
3428
+ std::vector<grpc_error_handle> errors;
3429
+ // Get the endpoints.
3430
+ size_t locality_size;
3431
+ const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
3432
+ envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
3433
+ cluster_load_assignment, &locality_size);
3434
+ for (size_t j = 0; j < locality_size; ++j) {
3435
+ size_t priority;
3436
+ XdsApi::EdsUpdate::Priority::Locality locality;
3437
+ grpc_error_handle error = LocalityParse(endpoints[j], &locality, &priority);
3438
+ if (error != GRPC_ERROR_NONE) {
3439
+ errors.push_back(error);
3440
+ continue;
3441
+ }
3442
+ // Filter out locality with weight 0.
3443
+ if (locality.lb_weight == 0) continue;
3444
+ // Make sure prorities is big enough. Note that they might not
3445
+ // arrive in priority order.
3446
+ while (eds_update->priorities.size() < priority + 1) {
3447
+ eds_update->priorities.emplace_back();
3448
+ }
3449
+ eds_update->priorities[priority].localities.emplace(locality.name.get(),
3450
+ std::move(locality));
3451
+ }
3452
+ for (const auto& priority : eds_update->priorities) {
3453
+ if (priority.localities.empty()) {
3454
+ errors.push_back(
3455
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("sparse priority list"));
3456
+ }
3457
+ }
3458
+ // Get the drop config.
3459
+ eds_update->drop_config = MakeRefCounted<XdsApi::EdsUpdate::DropConfig>();
3460
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
3461
+ envoy_config_endpoint_v3_ClusterLoadAssignment_policy(
3462
+ cluster_load_assignment);
3463
+ if (policy != nullptr) {
3464
+ size_t drop_size;
3465
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
3466
+ drop_overload =
3467
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
3468
+ policy, &drop_size);
3469
+ for (size_t j = 0; j < drop_size; ++j) {
3470
+ grpc_error_handle error =
3471
+ DropParseAndAppend(drop_overload[j], eds_update->drop_config.get());
3472
+ if (error != GRPC_ERROR_NONE) {
3473
+ errors.push_back(
3474
+ grpc_error_add_child(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
3475
+ "drop config validation error"),
3476
+ error));
3477
+ }
3478
+ }
3479
+ }
3480
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing EDS resource", &errors);
3481
+ }
3482
+
3483
+ template <typename ProtoParseFunction, typename ProtoResourceNameFunction,
3484
+ typename ResourceTypeSelectorFunction, typename ProtoLogFunction,
3485
+ typename ResourceParseFunction, typename UpdateMap>
3486
+ grpc_error_handle AdsResponseParse(
3487
+ const EncodingContext& context, ProtoParseFunction proto_parse_function,
3488
+ ProtoResourceNameFunction proto_resource_name_function,
3489
+ ResourceTypeSelectorFunction resource_type_selector_function,
3490
+ ProtoLogFunction proto_log_function,
3491
+ ResourceParseFunction resource_parse_function,
3492
+ const char* resource_type_string,
3440
3493
  const envoy_service_discovery_v3_DiscoveryResponse* response,
3441
- const std::set<absl::string_view>& expected_eds_service_names,
3442
- XdsApi::EdsUpdateMap* eds_update_map,
3443
- std::set<std::string>* resource_names_failed) {
3494
+ const std::map<absl::string_view /*authority*/,
3495
+ std::set<absl::string_view /*name*/>>&
3496
+ subscribed_resource_names,
3497
+ UpdateMap* update_map,
3498
+ std::set<XdsApi::ResourceName>* resource_names_failed) {
3444
3499
  std::vector<grpc_error_handle> errors;
3445
3500
  // Get the resources from the response.
3446
3501
  size_t size;
@@ -3450,115 +3505,65 @@ grpc_error_handle EdsResponseParse(
3450
3505
  // Check the type_url of the resource.
3451
3506
  absl::string_view type_url =
3452
3507
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
3453
- if (!IsEds(type_url)) {
3454
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3455
- absl::StrCat("resource index ", i, ": Resource is not EDS.")
3456
- .c_str()));
3508
+ bool is_v2 = false;
3509
+ if (!resource_type_selector_function(type_url, &is_v2)) {
3510
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
3511
+ absl::StrCat("resource index ", i, ": Resource is not ",
3512
+ resource_type_string, ".")));
3457
3513
  continue;
3458
3514
  }
3459
- // Get the cluster_load_assignment.
3460
- upb_strview encoded_cluster_load_assignment =
3461
- google_protobuf_Any_value(resources[i]);
3462
- envoy_config_endpoint_v3_ClusterLoadAssignment* cluster_load_assignment =
3463
- envoy_config_endpoint_v3_ClusterLoadAssignment_parse(
3464
- encoded_cluster_load_assignment.data,
3465
- encoded_cluster_load_assignment.size, context.arena);
3466
- if (cluster_load_assignment == nullptr) {
3467
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3468
- absl::StrCat("resource index ", i,
3469
- ": Can't parse cluster_load_assignment.")
3470
- .c_str()));
3515
+ // Parse the resource.
3516
+ upb_strview serialized_resource = google_protobuf_Any_value(resources[i]);
3517
+ auto* resource = proto_parse_function(
3518
+ serialized_resource.data, serialized_resource.size, context.arena);
3519
+ if (resource == nullptr) {
3520
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
3521
+ absl::StrCat("resource index ", i, ": Can't parse ",
3522
+ resource_type_string, " resource.")));
3471
3523
  continue;
3472
3524
  }
3473
- MaybeLogClusterLoadAssignment(context, cluster_load_assignment);
3474
- // Check the EDS service name. Ignore unexpected names.
3475
- std::string eds_service_name = UpbStringToStdString(
3476
- envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
3477
- cluster_load_assignment));
3478
- if (expected_eds_service_names.find(eds_service_name) ==
3479
- expected_eds_service_names.end()) {
3525
+ proto_log_function(context, resource);
3526
+ // Check the resource name. Ignore unexpected names.
3527
+ std::string resource_name =
3528
+ UpbStringToStdString(proto_resource_name_function(resource));
3529
+ auto resource_name_status = ParseResourceNameInternal(
3530
+ resource_name, resource_type_selector_function);
3531
+ if (!resource_name_status.ok()) {
3532
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
3533
+ "Cannot parse xDS resource name \"", resource_name, "\"")));
3480
3534
  continue;
3481
3535
  }
3482
- // Fail on duplicate resources.
3483
- if (eds_update_map->find(eds_service_name) != eds_update_map->end()) {
3484
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3485
- absl::StrCat("duplicate resource name \"", eds_service_name, "\"")
3486
- .c_str()));
3487
- resource_names_failed->insert(eds_service_name);
3536
+ auto iter = subscribed_resource_names.find(resource_name_status->authority);
3537
+ if (iter == subscribed_resource_names.end() ||
3538
+ iter->second.find(resource_name_status->id) == iter->second.end()) {
3488
3539
  continue;
3489
3540
  }
3490
- // Serialize into JSON and store it in the EdsUpdateMap
3491
- XdsApi::EdsResourceData& eds_resource_data =
3492
- (*eds_update_map)[eds_service_name];
3493
- XdsApi::EdsUpdate& eds_update = eds_resource_data.resource;
3494
- eds_resource_data.serialized_proto =
3495
- UpbStringToStdString(encoded_cluster_load_assignment);
3496
- // Get the endpoints.
3497
- size_t locality_size;
3498
- const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
3499
- envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
3500
- cluster_load_assignment, &locality_size);
3501
- grpc_error_handle error = GRPC_ERROR_NONE;
3502
- for (size_t j = 0; j < locality_size; ++j) {
3503
- size_t priority;
3504
- XdsApi::EdsUpdate::Priority::Locality locality;
3505
- error = LocalityParse(endpoints[j], &locality, &priority);
3506
- if (error != GRPC_ERROR_NONE) break;
3507
- // Filter out locality with weight 0.
3508
- if (locality.lb_weight == 0) continue;
3509
- // Make sure prorities is big enough. Note that they might not
3510
- // arrive in priority order.
3511
- while (eds_update.priorities.size() < priority + 1) {
3512
- eds_update.priorities.emplace_back();
3513
- }
3514
- eds_update.priorities[priority].localities.emplace(locality.name.get(),
3515
- std::move(locality));
3516
- }
3517
- if (error != GRPC_ERROR_NONE) {
3518
- errors.push_back(grpc_error_add_child(
3519
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3520
- absl::StrCat(eds_service_name, ": locality validation error")
3521
- .c_str()),
3522
- error));
3523
- resource_names_failed->insert(eds_service_name);
3541
+ // Fail on duplicate resources.
3542
+ if (update_map->find(*resource_name_status) != update_map->end()) {
3543
+ errors.push_back(GRPC_ERROR_CREATE_FROM_CPP_STRING(
3544
+ absl::StrCat("duplicate resource name \"", resource_name, "\"")));
3545
+ resource_names_failed->insert(*resource_name_status);
3524
3546
  continue;
3525
3547
  }
3526
- for (const auto& priority : eds_update.priorities) {
3527
- if (priority.localities.empty()) {
3528
- errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3529
- absl::StrCat(eds_service_name, ": sparse priority list").c_str()));
3530
- resource_names_failed->insert(eds_service_name);
3531
- continue;
3532
- }
3533
- }
3534
- // Get the drop config.
3535
- eds_update.drop_config = MakeRefCounted<XdsApi::EdsUpdate::DropConfig>();
3536
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
3537
- envoy_config_endpoint_v3_ClusterLoadAssignment_policy(
3538
- cluster_load_assignment);
3539
- if (policy != nullptr) {
3540
- size_t drop_size;
3541
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
3542
- drop_overload =
3543
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
3544
- policy, &drop_size);
3545
- for (size_t j = 0; j < drop_size; ++j) {
3546
- error =
3547
- DropParseAndAppend(drop_overload[j], eds_update.drop_config.get());
3548
- if (error != GRPC_ERROR_NONE) break;
3549
- }
3550
- if (error != GRPC_ERROR_NONE) {
3551
- errors.push_back(grpc_error_add_child(
3552
- GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3553
- absl::StrCat(eds_service_name, ": drop config validation error")
3554
- .c_str()),
3555
- error));
3556
- resource_names_failed->insert(eds_service_name);
3557
- continue;
3558
- }
3548
+ // Validate resource.
3549
+ decltype(UpdateMap::mapped_type::resource) update;
3550
+ grpc_error_handle error =
3551
+ resource_parse_function(context, resource, is_v2, &update);
3552
+ if (error != GRPC_ERROR_NONE) {
3553
+ errors.push_back(
3554
+ grpc_error_add_child(GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrCat(
3555
+ resource_name, ": validation error")),
3556
+ error));
3557
+ resource_names_failed->insert(*resource_name_status);
3558
+ } else {
3559
+ // Store result in update map, in both validated and serialized form.
3560
+ auto& resource_data = (*update_map)[*resource_name_status];
3561
+ resource_data.resource = std::move(update);
3562
+ resource_data.serialized_proto =
3563
+ UpbStringToStdString(serialized_resource);
3559
3564
  }
3560
3565
  }
3561
- return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing EDS response", &errors);
3566
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing ADS response", &errors);
3562
3567
  }
3563
3568
 
3564
3569
  std::string TypeUrlInternalToExternal(absl::string_view type_url) {
@@ -3574,23 +3579,43 @@ std::string TypeUrlInternalToExternal(absl::string_view type_url) {
3574
3579
  return std::string(type_url);
3575
3580
  }
3576
3581
 
3577
- template <typename UpdateMap>
3578
- void MoveUpdatesToFailedSet(UpdateMap* update_map,
3579
- std::set<std::string>* resource_names_failed) {
3580
- for (const auto& p : *update_map) {
3581
- resource_names_failed->insert(p.first);
3582
- }
3583
- update_map->clear();
3582
+ upb_strview LdsResourceName(
3583
+ const envoy_config_listener_v3_Listener* lds_resource) {
3584
+ return envoy_config_listener_v3_Listener_name(lds_resource);
3585
+ }
3586
+
3587
+ upb_strview RdsResourceName(
3588
+ const envoy_config_route_v3_RouteConfiguration* rds_resource) {
3589
+ return envoy_config_route_v3_RouteConfiguration_name(rds_resource);
3590
+ }
3591
+
3592
+ upb_strview CdsResourceName(
3593
+ const envoy_config_cluster_v3_Cluster* cds_resource) {
3594
+ return envoy_config_cluster_v3_Cluster_name(cds_resource);
3595
+ }
3596
+
3597
+ upb_strview EdsResourceName(
3598
+ const envoy_config_endpoint_v3_ClusterLoadAssignment* eds_resource) {
3599
+ return envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
3600
+ eds_resource);
3584
3601
  }
3585
3602
 
3586
3603
  } // namespace
3587
3604
 
3588
3605
  XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
3589
3606
  const XdsBootstrap::XdsServer& server, const grpc_slice& encoded_response,
3590
- const std::set<absl::string_view>& expected_listener_names,
3591
- const std::set<absl::string_view>& expected_route_configuration_names,
3592
- const std::set<absl::string_view>& expected_cluster_names,
3593
- const std::set<absl::string_view>& expected_eds_service_names) {
3607
+ const std::map<absl::string_view /*authority*/,
3608
+ std::set<absl::string_view /*name*/>>&
3609
+ subscribed_listener_names,
3610
+ const std::map<absl::string_view /*authority*/,
3611
+ std::set<absl::string_view /*name*/>>&
3612
+ subscribed_route_config_names,
3613
+ const std::map<absl::string_view /*authority*/,
3614
+ std::set<absl::string_view /*name*/>>&
3615
+ subscribed_cluster_names,
3616
+ const std::map<absl::string_view /*authority*/,
3617
+ std::set<absl::string_view /*name*/>>&
3618
+ subscribed_eds_service_names) {
3594
3619
  AdsParseResult result;
3595
3620
  upb::Arena arena;
3596
3621
  const EncodingContext context = {client_,
@@ -3619,38 +3644,33 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
3619
3644
  result.nonce = UpbStringToStdString(
3620
3645
  envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
3621
3646
  // Parse the response according to the resource type.
3647
+ // TODO(roth): When we have time, consider defining an interface for the
3648
+ // methods of each resource type, so that we don't have to pass
3649
+ // individual functions into each call to AdsResponseParse().
3622
3650
  if (IsLds(result.type_url)) {
3623
- result.parse_error =
3624
- LdsResponseParse(context, response, expected_listener_names,
3625
- &result.lds_update_map, &result.resource_names_failed);
3626
- if (result.parse_error != GRPC_ERROR_NONE) {
3627
- MoveUpdatesToFailedSet(&result.lds_update_map,
3628
- &result.resource_names_failed);
3629
- }
3651
+ result.parse_error = AdsResponseParse(
3652
+ context, envoy_config_listener_v3_Listener_parse, LdsResourceName,
3653
+ IsLdsInternal, MaybeLogListener, LdsResourceParse, "LDS", response,
3654
+ subscribed_listener_names, &result.lds_update_map,
3655
+ &result.resource_names_failed);
3630
3656
  } else if (IsRds(result.type_url)) {
3631
- result.parse_error =
3632
- RdsResponseParse(context, response, expected_route_configuration_names,
3633
- &result.rds_update_map, &result.resource_names_failed);
3634
- if (result.parse_error != GRPC_ERROR_NONE) {
3635
- MoveUpdatesToFailedSet(&result.rds_update_map,
3636
- &result.resource_names_failed);
3637
- }
3657
+ result.parse_error = AdsResponseParse(
3658
+ context, envoy_config_route_v3_RouteConfiguration_parse,
3659
+ RdsResourceName, IsRdsInternal, MaybeLogRouteConfiguration,
3660
+ RouteConfigParse, "RDS", response, subscribed_route_config_names,
3661
+ &result.rds_update_map, &result.resource_names_failed);
3638
3662
  } else if (IsCds(result.type_url)) {
3639
- result.parse_error =
3640
- CdsResponseParse(context, response, expected_cluster_names,
3641
- &result.cds_update_map, &result.resource_names_failed);
3642
- if (result.parse_error != GRPC_ERROR_NONE) {
3643
- MoveUpdatesToFailedSet(&result.cds_update_map,
3644
- &result.resource_names_failed);
3645
- }
3663
+ result.parse_error = AdsResponseParse(
3664
+ context, envoy_config_cluster_v3_Cluster_parse, CdsResourceName,
3665
+ IsCdsInternal, MaybeLogCluster, CdsResourceParse, "CDS", response,
3666
+ subscribed_cluster_names, &result.cds_update_map,
3667
+ &result.resource_names_failed);
3646
3668
  } else if (IsEds(result.type_url)) {
3647
- result.parse_error =
3648
- EdsResponseParse(context, response, expected_eds_service_names,
3649
- &result.eds_update_map, &result.resource_names_failed);
3650
- if (result.parse_error != GRPC_ERROR_NONE) {
3651
- MoveUpdatesToFailedSet(&result.eds_update_map,
3652
- &result.resource_names_failed);
3653
- }
3669
+ result.parse_error = AdsResponseParse(
3670
+ context, envoy_config_endpoint_v3_ClusterLoadAssignment_parse,
3671
+ EdsResourceName, IsEdsInternal, MaybeLogClusterLoadAssignment,
3672
+ EdsResourceParse, "EDS", response, subscribed_eds_service_names,
3673
+ &result.eds_update_map, &result.resource_names_failed);
3654
3674
  }
3655
3675
  return result;
3656
3676
  }
@@ -3863,6 +3883,7 @@ grpc_error_handle XdsApi::ParseLrsResponse(
3863
3883
  }
3864
3884
 
3865
3885
  namespace {
3886
+
3866
3887
  google_protobuf_Timestamp* GrpcMillisToTimestamp(const EncodingContext& context,
3867
3888
  grpc_millis value) {
3868
3889
  google_protobuf_Timestamp* timestamp =
@@ -3873,218 +3894,6 @@ google_protobuf_Timestamp* GrpcMillisToTimestamp(const EncodingContext& context,
3873
3894
  return timestamp;
3874
3895
  }
3875
3896
 
3876
- envoy_admin_v3_UpdateFailureState* CreateUpdateFailureStateUpb(
3877
- const EncodingContext& context,
3878
- const XdsApi::ResourceMetadata* resource_metadata) {
3879
- auto* update_failure_state =
3880
- envoy_admin_v3_UpdateFailureState_new(context.arena);
3881
- envoy_admin_v3_UpdateFailureState_set_details(
3882
- update_failure_state,
3883
- StdStringToUpbString(resource_metadata->failed_details));
3884
- envoy_admin_v3_UpdateFailureState_set_version_info(
3885
- update_failure_state,
3886
- StdStringToUpbString(resource_metadata->failed_version));
3887
- envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
3888
- update_failure_state,
3889
- GrpcMillisToTimestamp(context, resource_metadata->failed_update_time));
3890
- return update_failure_state;
3891
- }
3892
-
3893
- void DumpLdsConfig(const EncodingContext& context,
3894
- const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3895
- envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3896
- upb_strview kLdsTypeUrlUpb = upb_strview_makez(XdsApi::kLdsTypeUrl);
3897
- auto* listener_config_dump =
3898
- envoy_service_status_v3_PerXdsConfig_mutable_listener_config(
3899
- per_xds_config, context.arena);
3900
- envoy_admin_v3_ListenersConfigDump_set_version_info(
3901
- listener_config_dump,
3902
- StdStringToUpbString(resource_type_metadata.version));
3903
- for (auto& p : resource_type_metadata.resource_metadata_map) {
3904
- absl::string_view name = p.first;
3905
- const XdsApi::ResourceMetadata* meta = p.second;
3906
- const upb_strview name_upb = StdStringToUpbString(name);
3907
- auto* dynamic_listener =
3908
- envoy_admin_v3_ListenersConfigDump_add_dynamic_listeners(
3909
- listener_config_dump, context.arena);
3910
- envoy_admin_v3_ListenersConfigDump_DynamicListener_set_name(
3911
- dynamic_listener, name_upb);
3912
- envoy_admin_v3_ListenersConfigDump_DynamicListener_set_client_status(
3913
- dynamic_listener, meta->client_status);
3914
- if (!meta->serialized_proto.empty()) {
3915
- // Set in-effective listeners
3916
- auto* dynamic_listener_state =
3917
- envoy_admin_v3_ListenersConfigDump_DynamicListener_mutable_active_state(
3918
- dynamic_listener, context.arena);
3919
- envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_version_info(
3920
- dynamic_listener_state, StdStringToUpbString(meta->version));
3921
- envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_last_updated(
3922
- dynamic_listener_state,
3923
- GrpcMillisToTimestamp(context, meta->update_time));
3924
- auto* listener_any =
3925
- envoy_admin_v3_ListenersConfigDump_DynamicListenerState_mutable_listener(
3926
- dynamic_listener_state, context.arena);
3927
- google_protobuf_Any_set_type_url(listener_any, kLdsTypeUrlUpb);
3928
- google_protobuf_Any_set_value(
3929
- listener_any, StdStringToUpbString(meta->serialized_proto));
3930
- }
3931
- if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3932
- // Set error_state if NACKED
3933
- envoy_admin_v3_ListenersConfigDump_DynamicListener_set_error_state(
3934
- dynamic_listener, CreateUpdateFailureStateUpb(context, meta));
3935
- }
3936
- }
3937
- }
3938
-
3939
- void DumpRdsConfig(const EncodingContext& context,
3940
- const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3941
- envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3942
- upb_strview kRdsTypeUrlUpb = upb_strview_makez(XdsApi::kRdsTypeUrl);
3943
- auto* route_config_dump =
3944
- envoy_service_status_v3_PerXdsConfig_mutable_route_config(per_xds_config,
3945
- context.arena);
3946
- for (auto& p : resource_type_metadata.resource_metadata_map) {
3947
- absl::string_view name = p.first;
3948
- const XdsApi::ResourceMetadata* meta = p.second;
3949
- const upb_strview name_upb = StdStringToUpbString(name);
3950
- auto* dynamic_route_config =
3951
- envoy_admin_v3_RoutesConfigDump_add_dynamic_route_configs(
3952
- route_config_dump, context.arena);
3953
- envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_client_status(
3954
- dynamic_route_config, meta->client_status);
3955
- auto* route_config_any =
3956
- envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_mutable_route_config(
3957
- dynamic_route_config, context.arena);
3958
- if (!meta->serialized_proto.empty()) {
3959
- // Set in-effective route configs
3960
- envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_version_info(
3961
- dynamic_route_config, StdStringToUpbString(meta->version));
3962
- envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_last_updated(
3963
- dynamic_route_config,
3964
- GrpcMillisToTimestamp(context, meta->update_time));
3965
- google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
3966
- google_protobuf_Any_set_value(
3967
- route_config_any, StdStringToUpbString(meta->serialized_proto));
3968
- } else {
3969
- // If there isn't a working route config, we still need to print the
3970
- // name.
3971
- auto* route_config =
3972
- envoy_config_route_v3_RouteConfiguration_new(context.arena);
3973
- envoy_config_route_v3_RouteConfiguration_set_name(route_config, name_upb);
3974
- size_t length;
3975
- char* bytes = envoy_config_route_v3_RouteConfiguration_serialize(
3976
- route_config, context.arena, &length);
3977
- google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
3978
- google_protobuf_Any_set_value(route_config_any,
3979
- upb_strview_make(bytes, length));
3980
- }
3981
- if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3982
- // Set error_state if NACKED
3983
- envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_error_state(
3984
- dynamic_route_config, CreateUpdateFailureStateUpb(context, meta));
3985
- }
3986
- }
3987
- }
3988
-
3989
- void DumpCdsConfig(const EncodingContext& context,
3990
- const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3991
- envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3992
- upb_strview kCdsTypeUrlUpb = upb_strview_makez(XdsApi::kCdsTypeUrl);
3993
- auto* cluster_config_dump =
3994
- envoy_service_status_v3_PerXdsConfig_mutable_cluster_config(
3995
- per_xds_config, context.arena);
3996
- envoy_admin_v3_ClustersConfigDump_set_version_info(
3997
- cluster_config_dump,
3998
- StdStringToUpbString(resource_type_metadata.version));
3999
- for (auto& p : resource_type_metadata.resource_metadata_map) {
4000
- absl::string_view name = p.first;
4001
- const XdsApi::ResourceMetadata* meta = p.second;
4002
- const upb_strview name_upb = StdStringToUpbString(name);
4003
- auto* dynamic_cluster =
4004
- envoy_admin_v3_ClustersConfigDump_add_dynamic_active_clusters(
4005
- cluster_config_dump, context.arena);
4006
- envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_client_status(
4007
- dynamic_cluster, meta->client_status);
4008
- auto* cluster_any =
4009
- envoy_admin_v3_ClustersConfigDump_DynamicCluster_mutable_cluster(
4010
- dynamic_cluster, context.arena);
4011
- if (!meta->serialized_proto.empty()) {
4012
- // Set in-effective clusters
4013
- envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_version_info(
4014
- dynamic_cluster, StdStringToUpbString(meta->version));
4015
- envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_last_updated(
4016
- dynamic_cluster, GrpcMillisToTimestamp(context, meta->update_time));
4017
- google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
4018
- google_protobuf_Any_set_value(
4019
- cluster_any, StdStringToUpbString(meta->serialized_proto));
4020
- } else {
4021
- // If there isn't a working cluster, we still need to print the name.
4022
- auto* cluster = envoy_config_cluster_v3_Cluster_new(context.arena);
4023
- envoy_config_cluster_v3_Cluster_set_name(cluster, name_upb);
4024
- size_t length;
4025
- char* bytes = envoy_config_cluster_v3_Cluster_serialize(
4026
- cluster, context.arena, &length);
4027
- google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
4028
- google_protobuf_Any_set_value(cluster_any,
4029
- upb_strview_make(bytes, length));
4030
- }
4031
- if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
4032
- // Set error_state if NACKED
4033
- envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_error_state(
4034
- dynamic_cluster, CreateUpdateFailureStateUpb(context, meta));
4035
- }
4036
- }
4037
- }
4038
-
4039
- void DumpEdsConfig(const EncodingContext& context,
4040
- const XdsApi::ResourceTypeMetadata& resource_type_metadata,
4041
- envoy_service_status_v3_PerXdsConfig* per_xds_config) {
4042
- upb_strview kEdsTypeUrlUpb = upb_strview_makez(XdsApi::kEdsTypeUrl);
4043
- auto* endpoint_config_dump =
4044
- envoy_service_status_v3_PerXdsConfig_mutable_endpoint_config(
4045
- per_xds_config, context.arena);
4046
- for (auto& p : resource_type_metadata.resource_metadata_map) {
4047
- absl::string_view name = p.first;
4048
- const XdsApi::ResourceMetadata* meta = p.second;
4049
- const upb_strview name_upb = StdStringToUpbString(name);
4050
- auto* dynamic_endpoint =
4051
- envoy_admin_v3_EndpointsConfigDump_add_dynamic_endpoint_configs(
4052
- endpoint_config_dump, context.arena);
4053
- envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_client_status(
4054
- dynamic_endpoint, meta->client_status);
4055
- auto* endpoint_any =
4056
- envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_mutable_endpoint_config(
4057
- dynamic_endpoint, context.arena);
4058
- if (!meta->serialized_proto.empty()) {
4059
- // Set in-effective endpoints
4060
- envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_version_info(
4061
- dynamic_endpoint, StdStringToUpbString(meta->version));
4062
- envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_last_updated(
4063
- dynamic_endpoint, GrpcMillisToTimestamp(context, meta->update_time));
4064
- google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
4065
- google_protobuf_Any_set_value(
4066
- endpoint_any, StdStringToUpbString(meta->serialized_proto));
4067
- } else {
4068
- // If there isn't a working endpoint, we still need to print the name.
4069
- auto* cluster_load_assignment =
4070
- envoy_config_endpoint_v3_ClusterLoadAssignment_new(context.arena);
4071
- envoy_config_endpoint_v3_ClusterLoadAssignment_set_cluster_name(
4072
- cluster_load_assignment, name_upb);
4073
- size_t length;
4074
- char* bytes = envoy_config_endpoint_v3_ClusterLoadAssignment_serialize(
4075
- cluster_load_assignment, context.arena, &length);
4076
- google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
4077
- google_protobuf_Any_set_value(endpoint_any,
4078
- upb_strview_make(bytes, length));
4079
- }
4080
- if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
4081
- // Set error_state if NACKED
4082
- envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_error_state(
4083
- dynamic_endpoint, CreateUpdateFailureStateUpb(context, meta));
4084
- }
4085
- }
4086
- }
4087
-
4088
3897
  } // namespace
4089
3898
 
4090
3899
  std::string XdsApi::AssembleClientConfig(
@@ -4100,33 +3909,50 @@ std::string XdsApi::AssembleClientConfig(
4100
3909
  arena.ptr(), true, certificate_provider_definition_map_};
4101
3910
  PopulateNode(context, node_, build_version_, user_agent_name_,
4102
3911
  user_agent_version_, node);
4103
- // Dump each xDS-type config into PerXdsConfig
4104
- for (auto& p : resource_type_metadata_map) {
3912
+ // Dump each resource.
3913
+ for (const auto& p : resource_type_metadata_map) {
4105
3914
  absl::string_view type_url = p.first;
4106
- const ResourceTypeMetadata& resource_type_metadata = p.second;
4107
- if (type_url == kLdsTypeUrl) {
4108
- auto* per_xds_config =
4109
- envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
4110
- context.arena);
4111
- DumpLdsConfig(context, resource_type_metadata, per_xds_config);
4112
- } else if (type_url == kRdsTypeUrl) {
4113
- auto* per_xds_config =
4114
- envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
4115
- context.arena);
4116
- DumpRdsConfig(context, resource_type_metadata, per_xds_config);
4117
- } else if (type_url == kCdsTypeUrl) {
4118
- auto* per_xds_config =
4119
- envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
4120
- context.arena);
4121
- DumpCdsConfig(context, resource_type_metadata, per_xds_config);
4122
- } else if (type_url == kEdsTypeUrl) {
4123
- auto* per_xds_config =
4124
- envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
4125
- context.arena);
4126
- DumpEdsConfig(context, resource_type_metadata, per_xds_config);
4127
- } else {
4128
- gpr_log(GPR_ERROR, "invalid type_url %s", std::string(type_url).c_str());
4129
- return "";
3915
+ const ResourceMetadataMap& resource_metadata_map = p.second;
3916
+ for (const auto& q : resource_metadata_map) {
3917
+ absl::string_view resource_name = q.first;
3918
+ const ResourceMetadata& metadata = *q.second;
3919
+ auto* entry =
3920
+ envoy_service_status_v3_ClientConfig_add_generic_xds_configs(
3921
+ client_config, context.arena);
3922
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_type_url(
3923
+ entry, StdStringToUpbString(type_url));
3924
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_name(
3925
+ entry, StdStringToUpbString(resource_name));
3926
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_client_status(
3927
+ entry, metadata.client_status);
3928
+ if (!metadata.serialized_proto.empty()) {
3929
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_version_info(
3930
+ entry, StdStringToUpbString(metadata.version));
3931
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_last_updated(
3932
+ entry, GrpcMillisToTimestamp(context, metadata.update_time));
3933
+ auto* any_field =
3934
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_mutable_xds_config(
3935
+ entry, context.arena);
3936
+ google_protobuf_Any_set_type_url(any_field,
3937
+ StdStringToUpbString(type_url));
3938
+ google_protobuf_Any_set_value(
3939
+ any_field, StdStringToUpbString(metadata.serialized_proto));
3940
+ }
3941
+ if (metadata.client_status == XdsApi::ResourceMetadata::NACKED) {
3942
+ auto* update_failure_state =
3943
+ envoy_admin_v3_UpdateFailureState_new(context.arena);
3944
+ envoy_admin_v3_UpdateFailureState_set_details(
3945
+ update_failure_state,
3946
+ StdStringToUpbString(metadata.failed_details));
3947
+ envoy_admin_v3_UpdateFailureState_set_version_info(
3948
+ update_failure_state,
3949
+ StdStringToUpbString(metadata.failed_version));
3950
+ envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
3951
+ update_failure_state,
3952
+ GrpcMillisToTimestamp(context, metadata.failed_update_time));
3953
+ envoy_service_status_v3_ClientConfig_GenericXdsConfig_set_error_state(
3954
+ entry, update_failure_state);
3955
+ }
4130
3956
  }
4131
3957
  }
4132
3958
  // Serialize the upb message to bytes