grpc 1.33.0.pre1 → 1.37.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 (1106) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1075 -2814
  3. data/etc/roots.pem +257 -573
  4. data/include/grpc/compression.h +1 -1
  5. data/include/grpc/grpc.h +29 -2
  6. data/include/grpc/grpc_security.h +215 -175
  7. data/include/grpc/impl/codegen/atm_windows.h +4 -0
  8. data/include/grpc/impl/codegen/byte_buffer.h +1 -1
  9. data/include/grpc/impl/codegen/grpc_types.h +10 -3
  10. data/include/grpc/impl/codegen/log.h +0 -2
  11. data/include/grpc/impl/codegen/port_platform.h +24 -55
  12. data/include/grpc/impl/codegen/sync_windows.h +4 -0
  13. data/include/grpc/slice_buffer.h +3 -3
  14. data/include/grpc/support/sync.h +3 -3
  15. data/include/grpc/support/time.h +7 -7
  16. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -4
  17. data/src/core/ext/filters/client_channel/client_channel.cc +2829 -1588
  18. data/src/core/ext/filters/client_channel/client_channel.h +0 -6
  19. data/src/core/ext/filters/client_channel/client_channel_factory.h +2 -1
  20. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  21. data/src/core/ext/filters/client_channel/config_selector.h +15 -4
  22. data/src/core/ext/filters/client_channel/dynamic_filters.cc +191 -0
  23. data/src/core/ext/filters/client_channel/dynamic_filters.h +99 -0
  24. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +24 -142
  25. data/src/core/ext/filters/client_channel/global_subchannel_pool.h +15 -10
  26. data/src/core/ext/filters/client_channel/health/health_check_client.cc +10 -7
  27. data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -4
  28. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +7 -8
  29. data/src/core/ext/filters/client_channel/http_proxy.cc +21 -20
  30. data/src/core/ext/filters/client_channel/lb_policy.cc +9 -2
  31. data/src/core/ext/filters/client_channel/lb_policy.h +5 -6
  32. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +1 -1
  33. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +1 -1
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +115 -106
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +1 -2
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -2
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +3 -1
  38. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  39. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  40. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
  41. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +55 -23
  42. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +23 -0
  43. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +27 -0
  44. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +2 -2
  45. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -5
  46. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -3
  47. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +370 -109
  48. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +52 -24
  49. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +29 -0
  50. data/src/core/ext/filters/client_channel/lb_policy/xds/{eds_drop.cc → xds_cluster_impl.cc} +332 -108
  51. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +22 -27
  52. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +1384 -0
  53. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +27 -67
  54. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +10 -9
  55. data/src/core/ext/filters/client_channel/resolver.cc +7 -5
  56. data/src/core/ext/filters/client_channel/resolver.h +5 -13
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +42 -58
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -32
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +5 -5
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -1
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +444 -22
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -0
  63. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +22 -23
  64. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +21 -18
  65. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -1
  66. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +377 -0
  67. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +37 -30
  68. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +342 -133
  69. data/src/core/ext/filters/client_channel/resolver_factory.h +6 -6
  70. data/src/core/ext/filters/client_channel/resolver_registry.cc +40 -39
  71. data/src/core/ext/filters/client_channel/resolver_registry.h +2 -2
  72. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +24 -38
  73. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +8 -8
  74. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -3
  75. data/src/core/ext/filters/client_channel/retry_throttle.h +4 -2
  76. data/src/core/ext/filters/client_channel/server_address.cc +9 -0
  77. data/src/core/ext/filters/client_channel/server_address.h +31 -4
  78. data/src/core/ext/filters/client_channel/service_config.cc +3 -1
  79. data/src/core/ext/filters/client_channel/service_config.h +1 -1
  80. data/src/core/ext/filters/client_channel/service_config_call_data.h +19 -1
  81. data/src/core/ext/filters/client_channel/subchannel.cc +117 -207
  82. data/src/core/ext/filters/client_channel/subchannel.h +75 -113
  83. data/src/core/ext/filters/client_channel/subchannel_interface.h +7 -15
  84. data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +16 -2
  85. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +16 -10
  86. data/src/core/ext/filters/client_idle/client_idle_filter.cc +1 -1
  87. data/src/core/ext/filters/deadline/deadline_filter.cc +87 -79
  88. data/src/core/ext/filters/deadline/deadline_filter.h +7 -11
  89. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +495 -0
  90. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +39 -0
  91. data/src/core/ext/filters/fault_injection/service_config_parser.cc +189 -0
  92. data/src/core/ext/filters/fault_injection/service_config_parser.h +85 -0
  93. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -1
  94. data/src/core/ext/filters/http/client_authority_filter.cc +6 -6
  95. data/src/core/ext/filters/http/http_filters_plugin.cc +6 -3
  96. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -3
  97. data/src/core/ext/filters/max_age/max_age_filter.cc +36 -33
  98. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -1
  99. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +1 -1
  100. data/src/core/ext/filters/workarounds/workaround_utils.cc +1 -1
  101. data/src/core/ext/transport/chttp2/client/authority.cc +3 -3
  102. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -2
  103. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  104. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +23 -10
  105. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +21 -10
  106. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +29 -16
  107. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +629 -211
  108. data/src/core/ext/transport/chttp2/server/chttp2_server.h +11 -2
  109. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +11 -1
  110. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -5
  111. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +62 -18
  112. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -7
  113. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +50 -39
  114. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +12 -1
  115. data/src/core/ext/transport/chttp2/transport/flow_control.h +3 -3
  116. data/src/core/ext/transport/chttp2/transport/frame_data.cc +5 -1
  117. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
  118. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
  119. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +6 -6
  120. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +1 -1
  121. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +12 -8
  122. data/src/core/ext/transport/chttp2/transport/internal.h +1 -1
  123. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
  124. data/src/core/ext/transport/chttp2/transport/writing.cc +2 -3
  125. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -8
  126. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.c +406 -0
  127. data/src/core/ext/upb-generated/envoy/admin/v3/config_dump.upb.h +1459 -0
  128. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -0
  129. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
  130. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +7 -0
  131. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +27 -28
  132. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +139 -40
  133. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.c +350 -0
  134. data/src/core/ext/upb-generated/envoy/config/bootstrap/v3/bootstrap.upb.h +1348 -0
  135. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +13 -13
  136. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +44 -17
  137. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +119 -124
  138. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +450 -284
  139. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +3 -3
  140. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +13 -5
  141. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +24 -23
  142. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +62 -21
  143. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +21 -21
  144. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +88 -39
  145. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
  146. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +15 -6
  147. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +69 -45
  148. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +275 -78
  149. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +19 -19
  150. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +80 -43
  151. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +1 -1
  152. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +7 -0
  153. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +7 -7
  154. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +27 -11
  155. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +30 -30
  156. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +136 -49
  157. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +41 -41
  158. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +172 -89
  159. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +4 -4
  160. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +17 -9
  161. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +53 -47
  162. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +188 -78
  163. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +1 -2
  164. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +7 -0
  165. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +2 -2
  166. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +9 -2
  167. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +11 -5
  168. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +48 -7
  169. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +13 -14
  170. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +59 -36
  171. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +16 -16
  172. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +61 -29
  173. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +26 -26
  174. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +101 -66
  175. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +2 -2
  176. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -3
  177. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +34 -32
  178. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +151 -61
  179. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +33 -29
  180. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +138 -54
  181. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +2 -3
  182. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +13 -0
  183. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.c +144 -0
  184. data/src/core/ext/upb-generated/envoy/config/metrics/v3/stats.upb.h +488 -0
  185. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.c +141 -0
  186. data/src/core/ext/upb-generated/envoy/config/overload/v3/overload.upb.h +452 -0
  187. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +16 -16
  188. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +81 -35
  189. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +15 -13
  190. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +70 -37
  191. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +257 -216
  192. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +995 -495
  193. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +5 -5
  194. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +26 -6
  195. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +3 -4
  196. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +17 -3
  197. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.c +29 -0
  198. data/src/core/ext/upb-generated/envoy/extensions/clusters/aggregate/v3/cluster.upb.h +67 -0
  199. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.c +79 -0
  200. data/src/core/ext/upb-generated/envoy/extensions/filters/common/fault/v3/fault.upb.h +268 -0
  201. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.c +78 -0
  202. data/src/core/ext/upb-generated/envoy/extensions/filters/http/fault/v3/fault.upb.h +281 -0
  203. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.c +41 -0
  204. data/src/core/ext/upb-generated/envoy/extensions/filters/http/router/v3/router.upb.h +113 -0
  205. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +96 -98
  206. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +378 -226
  207. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +0 -1
  208. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -0
  209. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +28 -25
  210. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +124 -53
  211. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +9 -12
  212. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +29 -24
  213. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +32 -33
  214. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +118 -67
  215. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +1 -1
  216. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +7 -0
  217. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
  218. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +7 -0
  219. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +51 -44
  220. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +179 -129
  221. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +1 -4
  222. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +7 -0
  223. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +1 -4
  224. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +7 -0
  225. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +7 -8
  226. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +31 -16
  227. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +1 -3
  228. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +7 -0
  229. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +1 -1
  230. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +7 -0
  231. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.c +93 -0
  232. data/src/core/ext/upb-generated/envoy/service/status/v3/csds.upb.h +323 -0
  233. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +5 -5
  234. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -11
  235. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.c +36 -0
  236. data/src/core/ext/upb-generated/envoy/type/matcher/v3/node.upb.h +90 -0
  237. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +1 -1
  238. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +7 -0
  239. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +1 -1
  240. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +7 -0
  241. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +6 -6
  242. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +29 -8
  243. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +2 -3
  244. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +16 -3
  245. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.c +46 -0
  246. data/src/core/ext/upb-generated/envoy/type/matcher/v3/struct.upb.h +124 -0
  247. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +3 -3
  248. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +19 -0
  249. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +7 -7
  250. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +46 -3
  251. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +8 -8
  252. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +41 -8
  253. data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -0
  254. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +3 -3
  255. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +15 -2
  256. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +3 -3
  257. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +19 -0
  258. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +1 -1
  259. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +7 -0
  260. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -0
  261. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +34 -34
  262. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +149 -72
  263. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +54 -37
  264. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +171 -59
  265. data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
  266. data/src/core/ext/upb-generated/google/api/http.upb.h +25 -6
  267. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
  268. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +7 -0
  269. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +90 -90
  270. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +455 -292
  271. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
  272. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +7 -0
  273. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  274. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +7 -0
  275. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +4 -4
  276. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +22 -3
  277. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
  278. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +7 -0
  279. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +9 -9
  280. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +55 -0
  281. data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
  282. data/src/core/ext/upb-generated/google/rpc/status.upb.h +10 -3
  283. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +4 -4
  284. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -3
  285. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +41 -41
  286. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +149 -76
  287. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +5 -5
  288. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -6
  289. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
  290. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +13 -0
  291. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +17 -17
  292. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +82 -25
  293. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
  294. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +19 -0
  295. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +1 -1
  296. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +7 -0
  297. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -0
  298. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +2 -2
  299. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +9 -2
  300. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +1 -1
  301. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +7 -0
  302. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +3 -3
  303. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +7 -0
  304. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.c +33 -0
  305. data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +77 -0
  306. data/src/core/ext/upb-generated/validate/validate.upb.c +64 -64
  307. data/src/core/ext/upb-generated/validate/validate.upb.h +296 -157
  308. data/src/core/ext/upb-generated/{udpa/core/v1 → xds/core/v3}/authority.upb.c +6 -6
  309. data/src/core/ext/upb-generated/xds/core/v3/authority.upb.h +60 -0
  310. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +52 -0
  311. data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.h +143 -0
  312. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +42 -0
  313. data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.h +84 -0
  314. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +36 -0
  315. data/src/core/ext/upb-generated/xds/core/v3/resource.upb.h +94 -0
  316. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +54 -0
  317. data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.h +166 -0
  318. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +36 -0
  319. data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.h +85 -0
  320. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.c +354 -0
  321. data/src/core/ext/upbdefs-generated/envoy/admin/v3/config_dump.upbdefs.h +140 -0
  322. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +38 -0
  323. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.h +30 -0
  324. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +41 -0
  325. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.h +35 -0
  326. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +251 -0
  327. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +105 -0
  328. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.c +383 -0
  329. data/src/core/ext/upbdefs-generated/envoy/config/bootstrap/v3/bootstrap.upbdefs.h +115 -0
  330. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +100 -0
  331. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.h +45 -0
  332. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +543 -0
  333. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +145 -0
  334. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +53 -0
  335. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.h +35 -0
  336. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +136 -0
  337. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.h +35 -0
  338. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +127 -0
  339. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +65 -0
  340. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +56 -0
  341. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.h +35 -0
  342. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +272 -0
  343. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +135 -0
  344. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +143 -0
  345. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +55 -0
  346. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +56 -0
  347. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.h +35 -0
  348. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +66 -0
  349. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +40 -0
  350. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +263 -0
  351. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.h +100 -0
  352. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +233 -0
  353. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +70 -0
  354. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +56 -0
  355. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.h +35 -0
  356. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +231 -0
  357. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +85 -0
  358. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +43 -0
  359. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +35 -0
  360. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +59 -0
  361. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +35 -0
  362. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +68 -0
  363. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.h +35 -0
  364. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +107 -0
  365. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.h +50 -0
  366. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +113 -0
  367. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +50 -0
  368. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +146 -0
  369. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.h +55 -0
  370. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +50 -0
  371. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.h +35 -0
  372. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +195 -0
  373. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +55 -0
  374. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +193 -0
  375. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.h +65 -0
  376. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +59 -0
  377. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.h +40 -0
  378. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.c +141 -0
  379. data/src/core/ext/upbdefs-generated/envoy/config/metrics/v3/stats.upbdefs.h +70 -0
  380. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.c +141 -0
  381. data/src/core/ext/upbdefs-generated/envoy/config/overload/v3/overload.upbdefs.h +70 -0
  382. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +101 -0
  383. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +40 -0
  384. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +944 -0
  385. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +290 -0
  386. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +71 -0
  387. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.h +45 -0
  388. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +61 -0
  389. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.h +40 -0
  390. data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.c +51 -0
  391. data/src/core/ext/upbdefs-generated/envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h +35 -0
  392. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.c +102 -0
  393. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/common/fault/v3/fault.upbdefs.h +55 -0
  394. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.c +120 -0
  395. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/fault/v3/fault.upbdefs.h +45 -0
  396. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.c +76 -0
  397. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/http/router/v3/router.upbdefs.h +35 -0
  398. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +505 -0
  399. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +115 -0
  400. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +44 -0
  401. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.h +30 -0
  402. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +170 -0
  403. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +55 -0
  404. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +97 -0
  405. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.h +45 -0
  406. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +246 -0
  407. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +60 -0
  408. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +72 -0
  409. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.h +35 -0
  410. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +60 -0
  411. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.h +35 -0
  412. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +142 -0
  413. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +65 -0
  414. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +73 -0
  415. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.h +35 -0
  416. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +72 -0
  417. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.h +35 -0
  418. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +80 -0
  419. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.h +40 -0
  420. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +80 -0
  421. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.h +35 -0
  422. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +74 -0
  423. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.h +35 -0
  424. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.c +130 -0
  425. data/src/core/ext/upbdefs-generated/envoy/service/status/v3/csds.upbdefs.h +50 -0
  426. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +64 -0
  427. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.h +40 -0
  428. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.c +56 -0
  429. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/node.upbdefs.h +35 -0
  430. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +54 -0
  431. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.h +35 -0
  432. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +53 -0
  433. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.h +35 -0
  434. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +73 -0
  435. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.h +45 -0
  436. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +69 -0
  437. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.h +40 -0
  438. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.c +63 -0
  439. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/struct.upbdefs.h +40 -0
  440. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +81 -0
  441. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.h +45 -0
  442. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +92 -0
  443. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.h +65 -0
  444. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +95 -0
  445. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.h +55 -0
  446. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +34 -0
  447. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.h +30 -0
  448. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +59 -0
  449. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.h +40 -0
  450. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +54 -0
  451. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.h +45 -0
  452. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +47 -0
  453. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.h +35 -0
  454. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +40 -0
  455. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.h +30 -0
  456. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +61 -0
  457. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.h +45 -0
  458. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +39 -0
  459. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.h +35 -0
  460. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +386 -0
  461. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.h +165 -0
  462. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +40 -0
  463. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.h +35 -0
  464. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +37 -0
  465. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.h +35 -0
  466. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +65 -0
  467. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.h +50 -0
  468. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +40 -0
  469. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.h +35 -0
  470. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +66 -0
  471. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.h +75 -0
  472. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +42 -0
  473. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.h +35 -0
  474. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +70 -0
  475. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.h +45 -0
  476. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +56 -0
  477. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.h +35 -0
  478. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +33 -0
  479. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.h +30 -0
  480. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +49 -0
  481. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.h +35 -0
  482. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +43 -0
  483. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.h +35 -0
  484. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +44 -0
  485. data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +35 -0
  486. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +310 -0
  487. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.h +145 -0
  488. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +42 -0
  489. data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.h +35 -0
  490. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +62 -0
  491. data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.h +40 -0
  492. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +45 -0
  493. data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.h +40 -0
  494. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +49 -0
  495. data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.h +35 -0
  496. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +67 -0
  497. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.h +40 -0
  498. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +50 -0
  499. data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.h +35 -0
  500. data/src/core/ext/xds/certificate_provider_factory.h +7 -5
  501. data/src/core/ext/xds/certificate_provider_store.cc +87 -0
  502. data/src/core/ext/xds/certificate_provider_store.h +70 -8
  503. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +144 -0
  504. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +69 -0
  505. data/src/core/ext/xds/xds_api.cc +2378 -1183
  506. data/src/core/ext/xds/xds_api.h +373 -99
  507. data/src/core/ext/xds/xds_bootstrap.cc +250 -68
  508. data/src/core/ext/xds/xds_bootstrap.h +40 -13
  509. data/src/core/ext/xds/xds_certificate_provider.cc +405 -0
  510. data/src/core/ext/xds/xds_certificate_provider.h +151 -0
  511. data/src/core/ext/xds/xds_client.cc +364 -182
  512. data/src/core/ext/xds/xds_client.h +47 -12
  513. data/src/core/ext/xds/xds_client_stats.cc +43 -5
  514. data/src/core/ext/xds/xds_client_stats.h +4 -4
  515. data/src/core/ext/xds/xds_http_fault_filter.cc +226 -0
  516. data/src/core/ext/xds/xds_http_fault_filter.h +63 -0
  517. data/src/core/ext/xds/xds_http_filters.cc +114 -0
  518. data/src/core/ext/xds/xds_http_filters.h +130 -0
  519. data/src/core/ext/xds/xds_server_config_fetcher.cc +532 -0
  520. data/src/core/lib/channel/channel_args.cc +9 -8
  521. data/src/core/lib/channel/channel_stack.cc +12 -0
  522. data/src/core/lib/channel/channel_stack.h +7 -0
  523. data/src/core/lib/channel/channel_trace.cc +4 -2
  524. data/src/core/lib/channel/channel_trace.h +1 -1
  525. data/src/core/lib/channel/channelz.cc +105 -18
  526. data/src/core/lib/channel/channelz.h +32 -4
  527. data/src/core/lib/channel/channelz_registry.cc +14 -0
  528. data/src/core/lib/channel/channelz_registry.h +0 -1
  529. data/src/core/lib/channel/handshaker.cc +4 -46
  530. data/src/core/lib/channel/handshaker.h +3 -20
  531. data/src/core/lib/channel/status_util.cc +12 -2
  532. data/src/core/lib/channel/status_util.h +5 -0
  533. data/src/core/lib/compression/compression.cc +8 -4
  534. data/src/core/lib/compression/compression_args.cc +3 -2
  535. data/src/core/lib/compression/compression_internal.cc +10 -5
  536. data/src/core/lib/compression/compression_internal.h +2 -1
  537. data/src/core/lib/compression/stream_compression_identity.cc +1 -3
  538. data/src/core/lib/debug/stats.h +2 -2
  539. data/src/core/lib/debug/stats_data.cc +1 -0
  540. data/src/core/lib/debug/stats_data.h +13 -13
  541. data/src/core/lib/gpr/alloc.cc +3 -2
  542. data/src/core/lib/gpr/cpu_iphone.cc +10 -2
  543. data/src/core/lib/gpr/log.cc +59 -17
  544. data/src/core/lib/gpr/log_linux.cc +19 -3
  545. data/src/core/lib/gpr/log_posix.cc +15 -1
  546. data/src/core/lib/gpr/log_windows.cc +18 -4
  547. data/src/core/lib/gpr/murmur_hash.cc +1 -1
  548. data/src/core/lib/gpr/spinlock.h +10 -2
  549. data/src/core/lib/gpr/string.cc +23 -22
  550. data/src/core/lib/gpr/string.h +5 -6
  551. data/src/core/lib/gpr/sync.cc +4 -4
  552. data/src/core/lib/gpr/sync_abseil.cc +3 -6
  553. data/src/core/lib/gpr/sync_windows.cc +2 -2
  554. data/src/core/lib/gpr/time.cc +12 -12
  555. data/src/core/lib/gpr/time_precise.cc +3 -2
  556. data/src/core/lib/gpr/tls.h +4 -0
  557. data/src/core/lib/gpr/tls_msvc.h +2 -0
  558. data/src/core/lib/gpr/tls_stdcpp.h +48 -0
  559. data/src/core/lib/gpr/useful.h +5 -4
  560. data/src/core/lib/gprpp/arena.h +3 -2
  561. data/src/core/lib/gprpp/atomic.h +3 -3
  562. data/src/core/lib/gprpp/dual_ref_counted.h +46 -51
  563. data/src/core/lib/gprpp/examine_stack.cc +43 -0
  564. data/src/core/lib/gprpp/examine_stack.h +46 -0
  565. data/src/core/lib/gprpp/fork.cc +2 -2
  566. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  567. data/src/core/lib/gprpp/mpscq.cc +2 -2
  568. data/src/core/lib/gprpp/orphanable.h +4 -8
  569. data/src/core/lib/gprpp/ref_counted.h +42 -48
  570. data/src/core/lib/gprpp/ref_counted_ptr.h +20 -12
  571. data/src/core/lib/{security/authorization/mock_cel/statusor.h → gprpp/stat.h} +13 -25
  572. data/src/core/lib/gprpp/stat_posix.cc +49 -0
  573. data/src/core/lib/gprpp/stat_windows.cc +48 -0
  574. data/src/core/lib/gprpp/sync.h +129 -40
  575. data/src/core/lib/gprpp/thd.h +3 -3
  576. data/src/core/lib/gprpp/thd_posix.cc +42 -37
  577. data/src/core/lib/gprpp/thd_windows.cc +3 -1
  578. data/src/core/lib/gprpp/time_util.cc +77 -0
  579. data/src/core/lib/gprpp/time_util.h +42 -0
  580. data/src/core/lib/http/httpcli.cc +1 -1
  581. data/src/core/lib/http/httpcli.h +2 -3
  582. data/src/core/lib/http/httpcli_security_connector.cc +3 -3
  583. data/src/core/lib/http/parser.cc +47 -27
  584. data/src/core/lib/iomgr/buffer_list.h +1 -1
  585. data/src/core/lib/iomgr/call_combiner.cc +8 -5
  586. data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
  587. data/src/core/lib/iomgr/combiner.cc +2 -1
  588. data/src/core/lib/iomgr/endpoint.h +1 -1
  589. data/src/core/lib/iomgr/error.cc +17 -12
  590. data/src/core/lib/iomgr/error.h +1 -1
  591. data/src/core/lib/iomgr/error_internal.h +1 -1
  592. data/src/core/lib/iomgr/ev_apple.cc +11 -8
  593. data/src/core/lib/iomgr/ev_epoll1_linux.cc +23 -16
  594. data/src/core/lib/iomgr/ev_epollex_linux.cc +29 -21
  595. data/src/core/lib/iomgr/ev_poll_posix.cc +9 -7
  596. data/src/core/lib/iomgr/ev_posix.cc +3 -3
  597. data/src/core/lib/iomgr/exec_ctx.cc +7 -3
  598. data/src/core/lib/iomgr/exec_ctx.h +6 -4
  599. data/src/core/lib/iomgr/executor.cc +2 -1
  600. data/src/core/lib/iomgr/executor.h +1 -1
  601. data/src/core/lib/iomgr/executor/mpmcqueue.h +5 -5
  602. data/src/core/lib/iomgr/executor/threadpool.h +4 -4
  603. data/src/core/lib/iomgr/iomgr.cc +1 -1
  604. data/src/core/lib/iomgr/iomgr_posix.cc +0 -1
  605. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -1
  606. data/src/core/lib/iomgr/load_file.h +1 -1
  607. data/src/core/lib/iomgr/lockfree_event.cc +19 -14
  608. data/src/core/lib/iomgr/lockfree_event.h +2 -2
  609. data/src/core/lib/iomgr/parse_address.cc +127 -43
  610. data/src/core/lib/iomgr/parse_address.h +32 -8
  611. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +2 -1
  612. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +1 -1
  613. data/src/core/lib/iomgr/pollset_set_custom.cc +1 -1
  614. data/src/core/lib/iomgr/python_util.h +4 -4
  615. data/src/core/lib/iomgr/resolve_address.cc +4 -4
  616. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -5
  617. data/src/core/lib/iomgr/resource_quota.cc +5 -5
  618. data/src/core/lib/iomgr/sockaddr_utils.cc +131 -11
  619. data/src/core/lib/iomgr/sockaddr_utils.h +26 -1
  620. data/src/core/lib/iomgr/socket_factory_posix.cc +3 -2
  621. data/src/core/lib/iomgr/socket_mutator.cc +3 -2
  622. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -0
  623. data/src/core/lib/iomgr/tcp_client.cc +3 -3
  624. data/src/core/lib/iomgr/tcp_client_custom.cc +7 -6
  625. data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
  626. data/src/core/lib/iomgr/tcp_custom.cc +22 -17
  627. data/src/core/lib/iomgr/tcp_posix.cc +17 -16
  628. data/src/core/lib/iomgr/tcp_server_custom.cc +28 -22
  629. data/src/core/lib/iomgr/tcp_uv.cc +2 -2
  630. data/src/core/lib/iomgr/timer_custom.cc +5 -5
  631. data/src/core/lib/iomgr/timer_generic.cc +5 -5
  632. data/src/core/lib/iomgr/timer_manager.cc +3 -3
  633. data/src/core/lib/iomgr/udp_server.cc +1 -2
  634. data/src/core/lib/iomgr/udp_server.h +1 -2
  635. data/src/core/lib/iomgr/unix_sockets_posix.cc +32 -21
  636. data/src/core/lib/iomgr/unix_sockets_posix.h +5 -0
  637. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +7 -0
  638. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  639. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -2
  640. data/src/core/lib/json/json.h +12 -2
  641. data/src/core/lib/json/json_reader.cc +8 -4
  642. data/src/core/lib/json/json_util.h +167 -0
  643. data/src/core/lib/json/json_writer.cc +2 -1
  644. data/src/core/lib/matchers/matchers.cc +339 -0
  645. data/src/core/lib/matchers/matchers.h +160 -0
  646. data/src/core/lib/security/context/security_context.cc +4 -3
  647. data/src/core/lib/security/context/security_context.h +3 -1
  648. data/src/core/lib/security/credentials/alts/alts_credentials.cc +2 -1
  649. data/src/core/lib/security/credentials/alts/alts_credentials.h +1 -1
  650. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
  651. data/src/core/lib/security/credentials/credentials.cc +7 -7
  652. data/src/core/lib/security/credentials/credentials.h +5 -4
  653. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +413 -0
  654. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +80 -0
  655. data/src/core/lib/security/credentials/external/aws_request_signer.cc +213 -0
  656. data/src/core/lib/security/credentials/external/aws_request_signer.h +72 -0
  657. data/src/core/lib/security/credentials/external/external_account_credentials.cc +497 -0
  658. data/src/core/lib/security/credentials/external/external_account_credentials.h +120 -0
  659. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +135 -0
  660. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +48 -0
  661. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +213 -0
  662. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +58 -0
  663. data/src/core/lib/security/credentials/fake/fake_credentials.cc +3 -2
  664. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +25 -18
  665. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +64 -0
  666. data/src/core/lib/security/credentials/jwt/json_token.cc +3 -3
  667. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +4 -3
  668. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +5 -4
  669. data/src/core/lib/security/credentials/local/local_credentials.cc +2 -1
  670. data/src/core/lib/security/credentials/local/local_credentials.h +1 -1
  671. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +39 -46
  672. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -4
  673. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -1
  674. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +7 -6
  675. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +2 -2
  676. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +30 -5
  677. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +13 -14
  678. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +399 -0
  679. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +138 -0
  680. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +78 -150
  681. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +57 -187
  682. data/src/core/lib/security/credentials/tls/tls_credentials.cc +18 -13
  683. data/src/core/lib/security/credentials/tls/tls_credentials.h +3 -3
  684. data/src/core/lib/security/credentials/tls/tls_utils.cc +91 -0
  685. data/src/core/lib/security/credentials/tls/tls_utils.h +38 -0
  686. data/src/core/lib/security/credentials/xds/xds_credentials.cc +209 -10
  687. data/src/core/lib/security/credentials/xds/xds_credentials.h +27 -9
  688. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -1
  689. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +3 -3
  690. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +121 -0
  691. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +87 -0
  692. data/src/core/lib/security/security_connector/load_system_roots.h +4 -0
  693. data/src/core/lib/security/security_connector/load_system_roots_linux.h +2 -0
  694. data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -3
  695. data/src/core/lib/security/security_connector/security_connector.cc +4 -3
  696. data/src/core/lib/security/security_connector/security_connector.h +4 -2
  697. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -4
  698. data/src/core/lib/security/security_connector/ssl_utils.cc +11 -6
  699. data/src/core/lib/security/security_connector/ssl_utils.h +16 -21
  700. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +360 -279
  701. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +105 -61
  702. data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
  703. data/src/core/lib/security/transport/security_handshaker.cc +36 -8
  704. data/src/core/lib/security/transport/server_auth_filter.cc +2 -1
  705. data/src/core/lib/security/util/json_util.h +1 -0
  706. data/src/core/lib/slice/slice.cc +7 -4
  707. data/src/core/lib/slice/slice_buffer.cc +2 -1
  708. data/src/core/lib/slice/slice_intern.cc +11 -13
  709. data/src/core/lib/slice/slice_internal.h +2 -2
  710. data/src/core/lib/surface/call.cc +41 -32
  711. data/src/core/lib/surface/call_details.cc +8 -8
  712. data/src/core/lib/surface/channel.cc +16 -10
  713. data/src/core/lib/surface/channel.h +6 -5
  714. data/src/core/lib/surface/channel_init.cc +1 -1
  715. data/src/core/lib/surface/completion_queue.cc +31 -25
  716. data/src/core/lib/surface/completion_queue.h +16 -16
  717. data/src/core/lib/surface/init.cc +19 -20
  718. data/src/core/lib/surface/lame_client.cc +47 -54
  719. data/src/core/lib/surface/lame_client.h +5 -0
  720. data/src/core/lib/surface/server.cc +106 -53
  721. data/src/core/lib/surface/server.h +114 -20
  722. data/src/core/lib/surface/validate_metadata.h +3 -0
  723. data/src/core/lib/surface/version.cc +2 -2
  724. data/src/core/lib/transport/authority_override.cc +6 -4
  725. data/src/core/lib/transport/authority_override.h +7 -2
  726. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  727. data/src/core/lib/transport/byte_stream.h +3 -3
  728. data/src/core/lib/transport/connectivity_state.h +9 -7
  729. data/src/core/lib/transport/error_utils.h +1 -1
  730. data/src/core/lib/transport/metadata.cc +6 -2
  731. data/src/core/lib/transport/metadata.h +2 -2
  732. data/src/core/lib/transport/metadata_batch.cc +27 -0
  733. data/src/core/lib/transport/metadata_batch.h +18 -4
  734. data/src/core/lib/transport/static_metadata.cc +1 -1
  735. data/src/core/lib/transport/status_metadata.cc +4 -3
  736. data/src/core/lib/transport/timeout_encoding.cc +4 -4
  737. data/src/core/lib/transport/transport.cc +5 -3
  738. data/src/core/lib/transport/transport.h +8 -8
  739. data/src/core/lib/uri/uri_parser.cc +131 -249
  740. data/src/core/lib/uri/uri_parser.h +57 -21
  741. data/src/core/plugin_registry/grpc_plugin_registry.cc +26 -8
  742. data/src/core/tsi/alts/crypt/gsec.cc +5 -4
  743. data/src/core/tsi/alts/frame_protector/frame_handler.cc +8 -6
  744. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +19 -25
  745. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +43 -47
  746. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
  747. data/src/core/tsi/alts/handshaker/transport_security_common_api.cc +1 -3
  748. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +8 -6
  749. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +4 -4
  750. data/src/core/tsi/fake_transport_security.cc +17 -5
  751. data/src/core/tsi/local_transport_security.cc +5 -1
  752. data/src/core/tsi/local_transport_security.h +6 -7
  753. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  754. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +0 -2
  755. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +3 -2
  756. data/src/core/tsi/ssl_transport_security.cc +73 -56
  757. data/src/core/tsi/ssl_transport_security.h +6 -6
  758. data/src/core/tsi/transport_security.cc +10 -8
  759. data/src/core/tsi/transport_security_interface.h +1 -1
  760. data/src/ruby/ext/grpc/extconf.rb +10 -2
  761. data/src/ruby/ext/grpc/rb_channel.c +10 -1
  762. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -1
  763. data/src/ruby/ext/grpc/rb_channel_credentials.h +4 -0
  764. data/src/ruby/ext/grpc/rb_compression_options.c +1 -1
  765. data/src/ruby/ext/grpc/rb_enable_cpp.cc +1 -1
  766. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  767. data/src/ruby/ext/grpc/rb_grpc.c +4 -0
  768. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -14
  769. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +70 -37
  770. data/src/ruby/ext/grpc/rb_server.c +13 -1
  771. data/src/ruby/ext/grpc/rb_server_credentials.c +19 -3
  772. data/src/ruby/ext/grpc/rb_server_credentials.h +4 -0
  773. data/src/ruby/ext/grpc/rb_xds_channel_credentials.c +215 -0
  774. data/src/ruby/ext/grpc/rb_xds_channel_credentials.h +35 -0
  775. data/src/ruby/ext/grpc/rb_xds_server_credentials.c +169 -0
  776. data/src/ruby/ext/grpc/rb_xds_server_credentials.h +35 -0
  777. data/src/ruby/lib/grpc/generic/client_stub.rb +4 -2
  778. data/src/ruby/lib/grpc/version.rb +1 -1
  779. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +35 -0
  780. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +18 -0
  781. data/src/ruby/spec/call_spec.rb +1 -1
  782. data/src/ruby/spec/channel_credentials_spec.rb +32 -0
  783. data/src/ruby/spec/channel_spec.rb +17 -6
  784. data/src/ruby/spec/client_auth_spec.rb +27 -1
  785. data/src/ruby/spec/errors_spec.rb +1 -1
  786. data/src/ruby/spec/generic/active_call_spec.rb +2 -2
  787. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  788. data/src/ruby/spec/generic/rpc_server_spec.rb +1 -1
  789. data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -6
  790. data/src/ruby/spec/server_credentials_spec.rb +25 -0
  791. data/src/ruby/spec/server_spec.rb +22 -0
  792. data/third_party/abseil-cpp/absl/algorithm/container.h +59 -22
  793. data/third_party/abseil-cpp/absl/base/attributes.h +99 -38
  794. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  795. data/third_party/abseil-cpp/absl/base/casts.h +9 -6
  796. data/third_party/abseil-cpp/absl/base/config.h +60 -17
  797. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +428 -335
  798. data/third_party/abseil-cpp/absl/base/internal/bits.h +17 -16
  799. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +5 -0
  800. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +398 -0
  801. data/third_party/abseil-cpp/absl/base/internal/invoke.h +4 -4
  802. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +1 -1
  803. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +29 -1
  804. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +2 -2
  805. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +7 -5
  806. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +25 -38
  807. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +19 -25
  808. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +8 -0
  809. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +28 -5
  810. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +8 -0
  811. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +3 -1
  812. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +2 -2
  813. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -3
  814. data/third_party/abseil-cpp/absl/base/macros.h +36 -109
  815. data/third_party/abseil-cpp/absl/base/optimization.h +61 -1
  816. data/third_party/abseil-cpp/absl/base/options.h +31 -4
  817. data/third_party/abseil-cpp/absl/base/policy_checks.h +1 -1
  818. data/third_party/abseil-cpp/absl/base/thread_annotations.h +94 -39
  819. data/third_party/abseil-cpp/absl/container/fixed_array.h +42 -25
  820. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +606 -0
  821. data/third_party/abseil-cpp/absl/container/inlined_vector.h +33 -36
  822. data/third_party/abseil-cpp/absl/container/internal/common.h +6 -2
  823. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +33 -8
  824. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +49 -29
  825. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +15 -0
  826. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +24 -7
  827. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -1
  828. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +35 -11
  829. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +10 -9
  830. data/third_party/abseil-cpp/absl/container/internal/layout.h +7 -5
  831. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +197 -0
  832. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +55 -34
  833. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +5 -4
  834. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +66 -16
  835. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +4 -0
  836. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +13 -4
  837. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +43 -24
  838. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +12 -3
  839. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +10 -2
  840. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +22 -1
  841. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +0 -21
  842. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +12 -1
  843. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +101 -0
  844. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +100 -20
  845. data/third_party/abseil-cpp/absl/functional/bind_front.h +184 -0
  846. data/third_party/abseil-cpp/absl/functional/function_ref.h +1 -1
  847. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +95 -0
  848. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -2
  849. data/third_party/abseil-cpp/absl/hash/hash.h +6 -5
  850. data/third_party/abseil-cpp/absl/hash/internal/hash.h +73 -65
  851. data/third_party/abseil-cpp/absl/memory/memory.h +4 -0
  852. data/third_party/abseil-cpp/absl/meta/type_traits.h +2 -8
  853. data/third_party/abseil-cpp/absl/numeric/int128.cc +13 -27
  854. data/third_party/abseil-cpp/absl/numeric/int128.h +16 -15
  855. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +51 -0
  856. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +399 -0
  857. data/third_party/abseil-cpp/absl/status/status.cc +4 -6
  858. data/third_party/abseil-cpp/absl/status/status.h +502 -113
  859. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +5 -10
  860. data/third_party/abseil-cpp/absl/status/statusor.cc +71 -0
  861. data/third_party/abseil-cpp/absl/status/statusor.h +760 -0
  862. data/third_party/abseil-cpp/absl/strings/charconv.cc +2 -2
  863. data/third_party/abseil-cpp/absl/strings/cord.cc +91 -112
  864. data/third_party/abseil-cpp/absl/strings/cord.h +360 -205
  865. data/third_party/abseil-cpp/absl/strings/escaping.cc +9 -9
  866. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +1 -1
  867. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
  868. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +2 -2
  869. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  870. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +45 -23
  871. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +222 -136
  872. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +136 -64
  873. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +1 -1
  874. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +14 -21
  875. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +7 -14
  876. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +31 -7
  877. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +147 -135
  878. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +999 -87
  879. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +3 -3
  880. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +4 -12
  881. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +8 -6
  882. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +13 -11
  883. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -2
  884. data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
  885. data/third_party/abseil-cpp/absl/strings/str_cat.h +1 -1
  886. data/third_party/abseil-cpp/absl/strings/str_format.h +289 -13
  887. data/third_party/abseil-cpp/absl/strings/str_split.cc +2 -2
  888. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -0
  889. data/third_party/abseil-cpp/absl/strings/string_view.h +26 -19
  890. data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -5
  891. data/third_party/abseil-cpp/absl/strings/substitute.h +32 -29
  892. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +3 -3
  893. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +4 -3
  894. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +28 -28
  895. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +4 -16
  896. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +1 -1
  897. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +8 -0
  898. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -2
  899. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +75 -64
  900. data/third_party/abseil-cpp/absl/synchronization/mutex.h +15 -6
  901. data/third_party/abseil-cpp/absl/time/civil_time.cc +9 -9
  902. data/third_party/abseil-cpp/absl/time/clock.cc +3 -3
  903. data/third_party/abseil-cpp/absl/time/duration.cc +90 -59
  904. data/third_party/abseil-cpp/absl/time/format.cc +43 -36
  905. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +26 -16
  906. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +4 -2
  907. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +1 -1
  908. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +136 -29
  909. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +13 -21
  910. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +1 -1
  911. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +136 -129
  912. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +4 -5
  913. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +8 -7
  914. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +6 -6
  915. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +2 -1
  916. data/third_party/abseil-cpp/absl/time/time.h +15 -16
  917. data/third_party/abseil-cpp/absl/types/internal/variant.h +4 -4
  918. data/third_party/abseil-cpp/absl/types/optional.h +9 -9
  919. data/third_party/abseil-cpp/absl/types/span.h +49 -36
  920. data/third_party/abseil-cpp/absl/utility/utility.h +2 -2
  921. data/third_party/address_sorting/include/address_sorting/address_sorting.h +2 -0
  922. data/third_party/boringssl-with-bazel/err_data.c +728 -722
  923. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bitstr.c +3 -3
  924. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_enum.c +2 -2
  925. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_int.c +5 -5
  926. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_object.c +3 -10
  927. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_octet.c +3 -3
  928. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_type.c +4 -2
  929. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +2 -2
  930. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +15 -14
  931. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_locl.h +30 -0
  932. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_dec.c +28 -79
  933. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_enc.c +39 -85
  934. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_fre.c +5 -16
  935. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_new.c +10 -61
  936. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_typ.c +0 -2
  937. data/third_party/boringssl-with-bazel/src/crypto/asn1/tasn_utl.c +2 -2
  938. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +2 -0
  939. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +4 -0
  940. data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +158 -0
  941. data/third_party/boringssl-with-bazel/src/crypto/bn_extra/bn_asn1.c +3 -10
  942. data/third_party/boringssl-with-bazel/src/crypto/bytestring/ber.c +8 -9
  943. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +60 -45
  944. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/e_chacha20poly1305.c +6 -81
  945. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/internal.h +87 -0
  946. data/third_party/boringssl-with-bazel/src/crypto/cpu-aarch64-win.c +41 -0
  947. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +11 -2
  948. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm.c +3 -3
  949. data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/dh_asn1.c +0 -0
  950. data/third_party/boringssl-with-bazel/src/crypto/{dh → dh_extra}/params.c +179 -0
  951. data/third_party/boringssl-with-bazel/src/crypto/digest_extra/digest_extra.c +25 -0
  952. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/ec_asn1.c +2 -17
  953. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +3 -1
  954. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/bn.c +13 -20
  955. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/div.c +2 -3
  956. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +9 -1
  957. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/cipher.c +21 -13
  958. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +173 -35
  959. data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/check.c +0 -0
  960. data/third_party/boringssl-with-bazel/src/crypto/{dh → fipsmodule/dh}/dh.c +136 -213
  961. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +12 -0
  962. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +9 -1
  963. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +28 -0
  964. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +135 -43
  965. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +0 -7
  966. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +97 -39
  967. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +155 -2
  968. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +18 -29
  969. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +13 -4
  970. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305.c +10 -7
  971. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_arm.c +13 -11
  972. data/third_party/boringssl-with-bazel/src/crypto/poly1305/poly1305_vec.c +4 -0
  973. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/passive.c +34 -0
  974. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/rand_extra.c +4 -0
  975. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +7 -13
  976. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +90 -63
  977. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +60 -60
  978. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +179 -47
  979. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +766 -0
  980. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +10 -0
  981. data/third_party/boringssl-with-bazel/src/crypto/x509/rsa_pss.c +5 -1
  982. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +1 -29
  983. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +10 -7
  984. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_r2x.c +1 -1
  985. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +8 -8
  986. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +1 -1
  987. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +29 -23
  988. data/third_party/boringssl-with-bazel/src/crypto/x509/x_attrib.c +22 -17
  989. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +1 -2
  990. data/third_party/boringssl-with-bazel/src/crypto/x509/x_pkey.c +2 -2
  991. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +39 -4
  992. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509a.c +2 -2
  993. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +5 -3
  994. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_akey.c +3 -3
  995. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +25 -24
  996. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_bitst.c +3 -3
  997. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +25 -25
  998. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_cpols.c +2 -2
  999. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_enum.c +2 -1
  1000. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +40 -20
  1001. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_ia5.c +3 -4
  1002. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_lib.c +25 -36
  1003. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +2 -2
  1004. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +6 -6
  1005. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_utl.c +6 -6
  1006. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +24 -0
  1007. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +10 -8
  1008. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +652 -545
  1009. data/third_party/boringssl-with-bazel/src/include/openssl/asn1t.h +0 -167
  1010. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +14 -6
  1011. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +4 -0
  1012. data/third_party/boringssl-with-bazel/src/include/openssl/blake2.h +62 -0
  1013. data/third_party/boringssl-with-bazel/src/include/openssl/bytestring.h +22 -7
  1014. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +19 -0
  1015. data/third_party/boringssl-with-bazel/src/include/openssl/cpu.h +22 -32
  1016. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +6 -0
  1017. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +56 -26
  1018. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +1 -0
  1019. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +15 -0
  1020. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +12 -2
  1021. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +3 -0
  1022. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +202 -134
  1023. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +3 -0
  1024. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +2 -1
  1025. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +122 -34
  1026. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +31 -8
  1027. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +31 -23
  1028. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +287 -99
  1029. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +546 -402
  1030. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +18 -5
  1031. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +35 -0
  1032. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +4 -3
  1033. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +11 -20
  1034. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +10 -5
  1035. data/third_party/boringssl-with-bazel/src/ssl/internal.h +73 -17
  1036. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +0 -1
  1037. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +49 -9
  1038. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +87 -14
  1039. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +18 -22
  1040. data/third_party/boringssl-with-bazel/src/ssl/ssl_transcript.cc +2 -2
  1041. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +5 -7
  1042. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +570 -53
  1043. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +55 -13
  1044. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +48 -15
  1045. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +192 -56
  1046. data/third_party/upb/third_party/wyhash/wyhash.h +145 -0
  1047. data/third_party/upb/upb/decode.c +248 -167
  1048. data/third_party/upb/upb/decode.h +20 -1
  1049. data/third_party/upb/upb/decode.int.h +163 -0
  1050. data/third_party/upb/upb/decode_fast.c +1040 -0
  1051. data/third_party/upb/upb/decode_fast.h +126 -0
  1052. data/third_party/upb/upb/def.c +2178 -0
  1053. data/third_party/upb/upb/def.h +315 -0
  1054. data/third_party/upb/upb/def.hpp +439 -0
  1055. data/third_party/upb/upb/encode.c +227 -169
  1056. data/third_party/upb/upb/encode.h +27 -2
  1057. data/third_party/upb/upb/msg.c +167 -88
  1058. data/third_party/upb/upb/msg.h +174 -34
  1059. data/third_party/upb/upb/port_def.inc +74 -61
  1060. data/third_party/upb/upb/port_undef.inc +3 -7
  1061. data/third_party/upb/upb/reflection.c +408 -0
  1062. data/third_party/upb/upb/reflection.h +168 -0
  1063. data/third_party/upb/upb/table.c +34 -197
  1064. data/third_party/upb/upb/table.int.h +14 -5
  1065. data/third_party/upb/upb/text_encode.c +421 -0
  1066. data/third_party/upb/upb/text_encode.h +38 -0
  1067. data/third_party/upb/upb/upb.c +18 -41
  1068. data/third_party/upb/upb/upb.h +36 -7
  1069. data/third_party/upb/upb/upb.hpp +4 -4
  1070. data/third_party/upb/upb/upb.int.h +29 -0
  1071. data/third_party/xxhash/xxhash.h +5443 -0
  1072. metadata +335 -75
  1073. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +0 -1136
  1074. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +0 -485
  1075. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +0 -68
  1076. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +0 -355
  1077. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +0 -138
  1078. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +0 -53
  1079. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +0 -52
  1080. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +0 -129
  1081. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +0 -42
  1082. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +0 -77
  1083. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +0 -36
  1084. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +0 -85
  1085. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +0 -54
  1086. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +0 -160
  1087. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +0 -36
  1088. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +0 -84
  1089. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +0 -377
  1090. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +0 -102
  1091. data/src/core/lib/gprpp/map.h +0 -53
  1092. data/src/core/lib/iomgr/iomgr_posix.h +0 -26
  1093. data/src/core/lib/security/authorization/authorization_engine.cc +0 -177
  1094. data/src/core/lib/security/authorization/authorization_engine.h +0 -84
  1095. data/src/core/lib/security/authorization/evaluate_args.cc +0 -153
  1096. data/src/core/lib/security/authorization/evaluate_args.h +0 -59
  1097. data/src/core/lib/security/authorization/mock_cel/activation.h +0 -57
  1098. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +0 -42
  1099. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +0 -68
  1100. data/src/core/lib/security/authorization/mock_cel/cel_value.h +0 -93
  1101. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +0 -67
  1102. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +0 -56
  1103. data/src/core/lib/security/certificate_provider.h +0 -60
  1104. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +0 -129
  1105. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +0 -503
  1106. data/third_party/upb/upb/port.c +0 -26
@@ -0,0 +1,144 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/ext/xds/file_watcher_certificate_provider_factory.h"
22
+
23
+ #include "absl/strings/str_format.h"
24
+ #include "absl/strings/str_join.h"
25
+
26
+ #include "src/core/ext/xds/certificate_provider_registry.h"
27
+ #include "src/core/lib/json/json_util.h"
28
+
29
+ namespace grpc_core {
30
+
31
+ namespace {
32
+
33
+ const char* kFileWatcherPlugin = "file_watcher";
34
+
35
+ } // namespace
36
+
37
+ //
38
+ // FileWatcherCertificateProviderFactory::Config
39
+ //
40
+
41
+ const char* FileWatcherCertificateProviderFactory::Config::name() const {
42
+ return kFileWatcherPlugin;
43
+ }
44
+
45
+ std::string FileWatcherCertificateProviderFactory::Config::ToString() const {
46
+ std::vector<std::string> parts;
47
+ parts.push_back("{");
48
+ if (!identity_cert_file_.empty()) {
49
+ parts.push_back(
50
+ absl::StrFormat("certificate_file=\"%s\", ", identity_cert_file_));
51
+ }
52
+ if (!identity_cert_file_.empty()) {
53
+ parts.push_back(
54
+ absl::StrFormat("private_key_file=\"%s\", ", private_key_file_));
55
+ }
56
+ if (!identity_cert_file_.empty()) {
57
+ parts.push_back(
58
+ absl::StrFormat("ca_certificate_file=\"%s\", ", root_cert_file_));
59
+ }
60
+ parts.push_back(
61
+ absl::StrFormat("refresh_interval=%ldms}", refresh_interval_ms_));
62
+ return absl::StrJoin(parts, "");
63
+ }
64
+
65
+ RefCountedPtr<FileWatcherCertificateProviderFactory::Config>
66
+ FileWatcherCertificateProviderFactory::Config::Parse(const Json& config_json,
67
+ grpc_error** error) {
68
+ auto config = MakeRefCounted<FileWatcherCertificateProviderFactory::Config>();
69
+ if (config_json.type() != Json::Type::OBJECT) {
70
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
71
+ "error:config type should be OBJECT.");
72
+ return nullptr;
73
+ }
74
+ std::vector<grpc_error*> error_list;
75
+ ParseJsonObjectField(config_json.object_value(), "certificate_file",
76
+ &config->identity_cert_file_, &error_list, false);
77
+ ParseJsonObjectField(config_json.object_value(), "private_key_file",
78
+ &config->private_key_file_, &error_list, false);
79
+ if (config->identity_cert_file_.empty() !=
80
+ config->private_key_file_.empty()) {
81
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
82
+ "fields \"certificate_file\" and \"private_key_file\" must be both set "
83
+ "or both unset."));
84
+ }
85
+ ParseJsonObjectField(config_json.object_value(), "ca_certificate_file",
86
+ &config->root_cert_file_, &error_list, false);
87
+ if (config->identity_cert_file_.empty() && config->root_cert_file_.empty()) {
88
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
89
+ "At least one of \"certificate_file\" and \"ca_certificate_file\" must "
90
+ "be specified."));
91
+ }
92
+ if (!ParseJsonObjectFieldAsDuration(
93
+ config_json.object_value(), "refresh_interval",
94
+ &config->refresh_interval_ms_, &error_list, false)) {
95
+ config->refresh_interval_ms_ = 10 * 60 * 1000; // 10 minutes default
96
+ }
97
+ if (!error_list.empty()) {
98
+ *error = GRPC_ERROR_CREATE_FROM_VECTOR(
99
+ "Error parsing file watcher certificate provider config", &error_list);
100
+ return nullptr;
101
+ }
102
+ return config;
103
+ }
104
+
105
+ //
106
+ // FileWatcherCertificateProviderFactory
107
+ //
108
+
109
+ const char* FileWatcherCertificateProviderFactory::name() const {
110
+ return kFileWatcherPlugin;
111
+ }
112
+
113
+ RefCountedPtr<CertificateProviderFactory::Config>
114
+ FileWatcherCertificateProviderFactory::CreateCertificateProviderConfig(
115
+ const Json& config_json, grpc_error** error) {
116
+ return FileWatcherCertificateProviderFactory::Config::Parse(config_json,
117
+ error);
118
+ }
119
+
120
+ RefCountedPtr<grpc_tls_certificate_provider>
121
+ FileWatcherCertificateProviderFactory::CreateCertificateProvider(
122
+ RefCountedPtr<CertificateProviderFactory::Config> config) {
123
+ if (config->name() != name()) {
124
+ gpr_log(GPR_ERROR, "Wrong config type Actual:%s vs Expected:%s",
125
+ config->name(), name());
126
+ return nullptr;
127
+ }
128
+ auto* file_watcher_config =
129
+ static_cast<FileWatcherCertificateProviderFactory::Config*>(config.get());
130
+ return MakeRefCounted<FileWatcherCertificateProvider>(
131
+ file_watcher_config->private_key_file(),
132
+ file_watcher_config->identity_cert_file(),
133
+ file_watcher_config->root_cert_file(),
134
+ file_watcher_config->refresh_interval_ms() / GPR_MS_PER_SEC);
135
+ }
136
+
137
+ void FileWatcherCertificateProviderInit() {
138
+ CertificateProviderRegistry::RegisterCertificateProviderFactory(
139
+ absl::make_unique<FileWatcherCertificateProviderFactory>());
140
+ }
141
+
142
+ void FileWatcherCertificateProviderShutdown() {}
143
+
144
+ } // namespace grpc_core
@@ -0,0 +1,69 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #ifndef GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
20
+ #define GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ #include "src/core/ext/xds/certificate_provider_factory.h"
25
+
26
+ namespace grpc_core {
27
+
28
+ class FileWatcherCertificateProviderFactory
29
+ : public CertificateProviderFactory {
30
+ public:
31
+ class Config : public CertificateProviderFactory::Config {
32
+ public:
33
+ static RefCountedPtr<Config> Parse(const Json& config_json,
34
+ grpc_error** error);
35
+
36
+ const char* name() const override;
37
+
38
+ std::string ToString() const override;
39
+
40
+ const std::string& identity_cert_file() const {
41
+ return identity_cert_file_;
42
+ }
43
+
44
+ const std::string& private_key_file() const { return private_key_file_; }
45
+
46
+ const std::string& root_cert_file() const { return root_cert_file_; }
47
+
48
+ grpc_millis refresh_interval_ms() const { return refresh_interval_ms_; }
49
+
50
+ private:
51
+ std::string identity_cert_file_;
52
+ std::string private_key_file_;
53
+ std::string root_cert_file_;
54
+ grpc_millis refresh_interval_ms_;
55
+ };
56
+
57
+ const char* name() const override;
58
+
59
+ RefCountedPtr<CertificateProviderFactory::Config>
60
+ CreateCertificateProviderConfig(const Json& config_json,
61
+ grpc_error** error) override;
62
+
63
+ RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
64
+ RefCountedPtr<CertificateProviderFactory::Config> config) override;
65
+ };
66
+
67
+ } // namespace grpc_core
68
+
69
+ #endif // GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
@@ -28,42 +28,48 @@
28
28
  #include "absl/strings/str_format.h"
29
29
  #include "absl/strings/str_join.h"
30
30
  #include "absl/strings/str_split.h"
31
-
32
- #include "upb/upb.hpp"
33
-
34
- #include <grpc/impl/codegen/log.h>
35
- #include <grpc/support/alloc.h>
36
- #include <grpc/support/string_util.h>
37
-
38
- #include "src/core/ext/xds/xds_api.h"
39
- #include "src/core/lib/gpr/env.h"
40
- #include "src/core/lib/gpr/string.h"
41
- #include "src/core/lib/gpr/useful.h"
42
- #include "src/core/lib/iomgr/error.h"
43
- #include "src/core/lib/iomgr/sockaddr_utils.h"
44
-
31
+ #include "envoy/admin/v3/config_dump.upb.h"
45
32
  #include "envoy/config/cluster/v3/circuit_breaker.upb.h"
46
33
  #include "envoy/config/cluster/v3/cluster.upb.h"
34
+ #include "envoy/config/cluster/v3/cluster.upbdefs.h"
47
35
  #include "envoy/config/core/v3/address.upb.h"
48
36
  #include "envoy/config/core/v3/base.upb.h"
37
+ #include "envoy/config/core/v3/base.upbdefs.h"
49
38
  #include "envoy/config/core/v3/config_source.upb.h"
50
39
  #include "envoy/config/core/v3/health_check.upb.h"
40
+ #include "envoy/config/core/v3/protocol.upb.h"
51
41
  #include "envoy/config/endpoint/v3/endpoint.upb.h"
42
+ #include "envoy/config/endpoint/v3/endpoint.upbdefs.h"
52
43
  #include "envoy/config/endpoint/v3/endpoint_components.upb.h"
53
44
  #include "envoy/config/endpoint/v3/load_report.upb.h"
54
45
  #include "envoy/config/listener/v3/api_listener.upb.h"
55
46
  #include "envoy/config/listener/v3/listener.upb.h"
47
+ #include "envoy/config/listener/v3/listener.upbdefs.h"
48
+ #include "envoy/config/listener/v3/listener_components.upb.h"
56
49
  #include "envoy/config/route/v3/route.upb.h"
50
+ #include "envoy/config/route/v3/route.upbdefs.h"
57
51
  #include "envoy/config/route/v3/route_components.upb.h"
52
+ #include "envoy/config/route/v3/route_components.upbdefs.h"
53
+ #include "envoy/extensions/clusters/aggregate/v3/cluster.upb.h"
54
+ #include "envoy/extensions/clusters/aggregate/v3/cluster.upbdefs.h"
58
55
  #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
56
+ #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h"
59
57
  #include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
60
58
  #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
59
+ #include "envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h"
61
60
  #include "envoy/service/cluster/v3/cds.upb.h"
61
+ #include "envoy/service/cluster/v3/cds.upbdefs.h"
62
62
  #include "envoy/service/discovery/v3/discovery.upb.h"
63
+ #include "envoy/service/discovery/v3/discovery.upbdefs.h"
63
64
  #include "envoy/service/endpoint/v3/eds.upb.h"
65
+ #include "envoy/service/endpoint/v3/eds.upbdefs.h"
64
66
  #include "envoy/service/listener/v3/lds.upb.h"
65
67
  #include "envoy/service/load_stats/v3/lrs.upb.h"
68
+ #include "envoy/service/load_stats/v3/lrs.upbdefs.h"
66
69
  #include "envoy/service/route/v3/rds.upb.h"
70
+ #include "envoy/service/route/v3/rds.upbdefs.h"
71
+ #include "envoy/service/status/v3/csds.upb.h"
72
+ #include "envoy/service/status/v3/csds.upbdefs.h"
67
73
  #include "envoy/type/matcher/v3/regex.upb.h"
68
74
  #include "envoy/type/matcher/v3/string.upb.h"
69
75
  #include "envoy/type/v3/percent.upb.h"
@@ -71,158 +77,141 @@
71
77
  #include "google/protobuf/any.upb.h"
72
78
  #include "google/protobuf/duration.upb.h"
73
79
  #include "google/protobuf/struct.upb.h"
80
+ #include "google/protobuf/timestamp.upb.h"
74
81
  #include "google/protobuf/wrappers.upb.h"
75
82
  #include "google/rpc/status.upb.h"
83
+ #include "udpa/type/v1/typed_struct.upb.h"
84
+ #include "upb/text_encode.h"
76
85
  #include "upb/upb.h"
86
+ #include "upb/upb.hpp"
87
+
88
+ #include <grpc/impl/codegen/log.h>
89
+ #include <grpc/support/alloc.h>
90
+ #include <grpc/support/string_util.h>
91
+
92
+ #include "src/core/ext/xds/xds_api.h"
93
+ #include "src/core/lib/gpr/env.h"
94
+ #include "src/core/lib/gpr/string.h"
95
+ #include "src/core/lib/gpr/useful.h"
96
+ #include "src/core/lib/gprpp/host_port.h"
97
+ #include "src/core/lib/iomgr/error.h"
98
+ #include "src/core/lib/iomgr/sockaddr.h"
99
+ #include "src/core/lib/iomgr/sockaddr_utils.h"
100
+ #include "src/core/lib/iomgr/socket_utils.h"
101
+ #include "src/core/lib/slice/slice_utils.h"
77
102
 
78
103
  namespace grpc_core {
79
104
 
105
+ // TODO(donnadionne): Check to see if cluster types aggregate_cluster and
106
+ // logical_dns are enabled, this will be
107
+ // removed once the cluster types are fully integration-tested and enabled by
108
+ // default.
109
+ bool XdsAggregateAndLogicalDnsClusterEnabled() {
110
+ char* value = gpr_getenv(
111
+ "GRPC_XDS_EXPERIMENTAL_ENABLE_AGGREGATE_AND_LOGICAL_DNS_CLUSTER");
112
+ bool parsed_value;
113
+ bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
114
+ gpr_free(value);
115
+ return parse_succeeded && parsed_value;
116
+ }
117
+
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");
123
+ bool parsed_value;
124
+ bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
125
+ gpr_free(value);
126
+ return parse_succeeded && parsed_value;
127
+ }
128
+
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;
138
+ }
139
+
80
140
  //
81
- // XdsApi::Route::Matchers::PathMatcher
141
+ // XdsApi::Route::HashPolicy
82
142
  //
83
143
 
84
- XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
85
- : type(other.type) {
86
- if (type == PathMatcherType::REGEX) {
87
- regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
88
- } else {
89
- string_matcher = other.string_matcher;
144
+ XdsApi::Route::HashPolicy::HashPolicy(const HashPolicy& other)
145
+ : type(other.type),
146
+ header_name(other.header_name),
147
+ regex_substitution(other.regex_substitution) {
148
+ if (other.regex != nullptr) {
149
+ regex =
150
+ absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
90
151
  }
91
152
  }
92
153
 
93
- XdsApi::Route::Matchers::PathMatcher& XdsApi::Route::Matchers::PathMatcher::
94
- operator=(const PathMatcher& other) {
154
+ XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
155
+ const HashPolicy& other) {
95
156
  type = other.type;
96
- if (type == PathMatcherType::REGEX) {
97
- regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
98
- } else {
99
- string_matcher = other.string_matcher;
157
+ header_name = other.header_name;
158
+ if (other.regex != nullptr) {
159
+ regex =
160
+ absl::make_unique<RE2>(other.regex->pattern(), other.regex->options());
100
161
  }
162
+ regex_substitution = other.regex_substitution;
101
163
  return *this;
102
164
  }
103
165
 
104
- bool XdsApi::Route::Matchers::PathMatcher::operator==(
105
- const PathMatcher& other) const {
106
- if (type != other.type) return false;
107
- if (type == PathMatcherType::REGEX) {
108
- // Should never be null.
109
- if (regex_matcher == nullptr || other.regex_matcher == nullptr) {
110
- return false;
111
- }
112
- return regex_matcher->pattern() == other.regex_matcher->pattern();
113
- }
114
- return string_matcher == other.string_matcher;
115
- }
116
-
117
- std::string XdsApi::Route::Matchers::PathMatcher::ToString() const {
118
- std::string path_type_string;
119
- switch (type) {
120
- case PathMatcherType::PATH:
121
- path_type_string = "path match";
122
- break;
123
- case PathMatcherType::PREFIX:
124
- path_type_string = "prefix match";
125
- break;
126
- case PathMatcherType::REGEX:
127
- path_type_string = "regex match";
128
- break;
129
- default:
130
- break;
131
- }
132
- return absl::StrFormat("Path %s:%s", path_type_string,
133
- type == PathMatcherType::REGEX
134
- ? regex_matcher->pattern()
135
- : string_matcher);
136
- }
137
-
138
- //
139
- // XdsApi::Route::Matchers::HeaderMatcher
140
- //
141
-
142
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcher(
143
- const HeaderMatcher& other)
144
- : name(other.name), type(other.type), invert_match(other.invert_match) {
145
- switch (type) {
146
- case HeaderMatcherType::REGEX:
147
- regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
148
- break;
149
- case HeaderMatcherType::RANGE:
150
- range_start = other.range_start;
151
- range_end = other.range_end;
152
- break;
153
- case HeaderMatcherType::PRESENT:
154
- present_match = other.present_match;
155
- break;
156
- default:
157
- string_matcher = other.string_matcher;
158
- }
159
- }
166
+ XdsApi::Route::HashPolicy::HashPolicy(HashPolicy&& other) noexcept
167
+ : type(other.type),
168
+ header_name(std::move(other.header_name)),
169
+ regex(std::move(other.regex)),
170
+ regex_substitution(std::move(other.regex_substitution)) {}
160
171
 
161
- XdsApi::Route::Matchers::HeaderMatcher& XdsApi::Route::Matchers::HeaderMatcher::
162
- operator=(const HeaderMatcher& other) {
163
- name = other.name;
172
+ XdsApi::Route::HashPolicy& XdsApi::Route::HashPolicy::operator=(
173
+ HashPolicy&& other) noexcept {
164
174
  type = other.type;
165
- invert_match = other.invert_match;
166
- switch (type) {
167
- case HeaderMatcherType::REGEX:
168
- regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
169
- break;
170
- case HeaderMatcherType::RANGE:
171
- range_start = other.range_start;
172
- range_end = other.range_end;
173
- break;
174
- case HeaderMatcherType::PRESENT:
175
- present_match = other.present_match;
176
- break;
177
- default:
178
- string_matcher = other.string_matcher;
179
- }
175
+ header_name = std::move(other.header_name);
176
+ regex = std::move(other.regex);
177
+ regex_substitution = std::move(other.regex_substitution);
180
178
  return *this;
181
179
  }
182
180
 
183
- bool XdsApi::Route::Matchers::HeaderMatcher::operator==(
184
- const HeaderMatcher& other) const {
185
- if (name != other.name) return false;
181
+ bool XdsApi::Route::HashPolicy::HashPolicy::operator==(
182
+ const HashPolicy& other) const {
186
183
  if (type != other.type) return false;
187
- if (invert_match != other.invert_match) return false;
188
- switch (type) {
189
- case HeaderMatcherType::REGEX:
190
- return regex_match->pattern() != other.regex_match->pattern();
191
- case HeaderMatcherType::RANGE:
192
- return range_start != other.range_start && range_end != other.range_end;
193
- case HeaderMatcherType::PRESENT:
194
- return present_match != other.present_match;
195
- default:
196
- return string_matcher != other.string_matcher;
184
+ if (type == Type::HEADER) {
185
+ if (regex == nullptr) {
186
+ if (other.regex != nullptr) return false;
187
+ } else {
188
+ if (other.regex == nullptr) return false;
189
+ return header_name == other.header_name &&
190
+ regex->pattern() == other.regex->pattern() &&
191
+ regex_substitution == other.regex_substitution;
192
+ }
197
193
  }
194
+ return true;
198
195
  }
199
196
 
200
- std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const {
197
+ std::string XdsApi::Route::HashPolicy::ToString() const {
198
+ std::vector<std::string> contents;
201
199
  switch (type) {
202
- case HeaderMatcherType::EXACT:
203
- return absl::StrFormat("Header exact match:%s %s:%s",
204
- invert_match ? " not" : "", name, string_matcher);
205
- case HeaderMatcherType::REGEX:
206
- return absl::StrFormat("Header regex match:%s %s:%s",
207
- invert_match ? " not" : "", name,
208
- regex_match->pattern());
209
- case HeaderMatcherType::RANGE:
210
- return absl::StrFormat("Header range match:%s %s:[%d, %d)",
211
- invert_match ? " not" : "", name, range_start,
212
- range_end);
213
- case HeaderMatcherType::PRESENT:
214
- return absl::StrFormat("Header present match:%s %s:%s",
215
- invert_match ? " not" : "", name,
216
- present_match ? "true" : "false");
217
- case HeaderMatcherType::PREFIX:
218
- return absl::StrFormat("Header prefix match:%s %s:%s",
219
- invert_match ? " not" : "", name, string_matcher);
220
- case HeaderMatcherType::SUFFIX:
221
- return absl::StrFormat("Header suffix match:%s %s:%s",
222
- invert_match ? " not" : "", name, string_matcher);
223
- default:
224
- return "";
200
+ case Type::HEADER:
201
+ contents.push_back("type=HEADER");
202
+ break;
203
+ case Type::CHANNEL_ID:
204
+ contents.push_back("type=CHANNEL_ID");
205
+ break;
225
206
  }
207
+ contents.push_back(
208
+ absl::StrFormat("terminal=%s", terminal ? "true" : "false"));
209
+ if (type == Type::HEADER) {
210
+ contents.push_back(absl::StrFormat(
211
+ "Header %s:/%s/%s", header_name,
212
+ (regex == nullptr) ? "" : regex->pattern(), regex_substitution));
213
+ }
214
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
226
215
  }
227
216
 
228
217
  //
@@ -231,7 +220,8 @@ std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const {
231
220
 
232
221
  std::string XdsApi::Route::Matchers::ToString() const {
233
222
  std::vector<std::string> contents;
234
- contents.push_back(path_matcher.ToString());
223
+ contents.push_back(
224
+ absl::StrFormat("PathMatcher{%s}", path_matcher.ToString()));
235
225
  for (const HeaderMatcher& header_matcher : header_matchers) {
236
226
  contents.push_back(header_matcher.ToString());
237
227
  }
@@ -243,18 +233,46 @@ std::string XdsApi::Route::Matchers::ToString() const {
243
233
  }
244
234
 
245
235
  std::string XdsApi::Route::ClusterWeight::ToString() const {
246
- return absl::StrFormat("{cluster=%s, weight=%d}", name, weight);
236
+ std::vector<std::string> contents;
237
+ contents.push_back(absl::StrCat("cluster=", name));
238
+ contents.push_back(absl::StrCat("weight=", weight));
239
+ if (!typed_per_filter_config.empty()) {
240
+ std::vector<std::string> parts;
241
+ for (const auto& p : typed_per_filter_config) {
242
+ const std::string& key = p.first;
243
+ const auto& config = p.second;
244
+ parts.push_back(absl::StrCat(key, "=", config.ToString()));
245
+ }
246
+ contents.push_back(absl::StrCat("typed_per_filter_config={",
247
+ absl::StrJoin(parts, ", "), "}"));
248
+ }
249
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
247
250
  }
248
251
 
249
252
  std::string XdsApi::Route::ToString() const {
250
253
  std::vector<std::string> contents;
251
254
  contents.push_back(matchers.ToString());
255
+ for (const HashPolicy& hash_policy : hash_policies) {
256
+ contents.push_back(absl::StrCat("hash_policy=", hash_policy.ToString()));
257
+ }
252
258
  if (!cluster_name.empty()) {
253
259
  contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
254
260
  }
255
261
  for (const ClusterWeight& cluster_weight : weighted_clusters) {
256
262
  contents.push_back(cluster_weight.ToString());
257
263
  }
264
+ if (max_stream_duration.has_value()) {
265
+ contents.push_back(max_stream_duration->ToString());
266
+ }
267
+ if (!typed_per_filter_config.empty()) {
268
+ contents.push_back("typed_per_filter_config={");
269
+ for (const auto& p : typed_per_filter_config) {
270
+ const std::string& name = p.first;
271
+ const auto& config = p.second;
272
+ contents.push_back(absl::StrCat(" ", name, "=", config.ToString()));
273
+ }
274
+ contents.push_back("}");
275
+ }
258
276
  return absl::StrJoin(contents, "\n");
259
277
  }
260
278
 
@@ -277,6 +295,14 @@ std::string XdsApi::RdsUpdate::ToString() const {
277
295
  vhosts.push_back("\n }\n");
278
296
  }
279
297
  vhosts.push_back(" ]\n");
298
+ vhosts.push_back(" typed_per_filter_config={\n");
299
+ for (const auto& p : vhost.typed_per_filter_config) {
300
+ const std::string& name = p.first;
301
+ const auto& config = p.second;
302
+ vhosts.push_back(
303
+ absl::StrCat(" ", name, "=", config.ToString(), "\n"));
304
+ }
305
+ vhosts.push_back(" }\n");
280
306
  vhosts.push_back("]\n");
281
307
  }
282
308
  return absl::StrJoin(vhosts, "");
@@ -294,9 +320,11 @@ enum MatchType {
294
320
  };
295
321
 
296
322
  // Returns true if match succeeds.
297
- bool DomainMatch(MatchType match_type, std::string domain_pattern,
298
- std::string expected_host_name) {
323
+ bool DomainMatch(MatchType match_type, const std::string& domain_pattern_in,
324
+ const std::string& expected_host_name_in) {
299
325
  // Normalize the args to lower-case. Domain matching is case-insensitive.
326
+ std::string domain_pattern = domain_pattern_in;
327
+ std::string expected_host_name = expected_host_name_in;
300
328
  std::transform(domain_pattern.begin(), domain_pattern.end(),
301
329
  domain_pattern.begin(),
302
330
  [](unsigned char c) { return std::tolower(c); });
@@ -379,41 +407,312 @@ XdsApi::RdsUpdate::VirtualHost* XdsApi::RdsUpdate::FindVirtualHostForDomain(
379
407
  }
380
408
 
381
409
  //
382
- // XdsApi::StringMatcher
410
+ // XdsApi::CommonTlsContext::CertificateValidationContext
383
411
  //
384
412
 
385
- XdsApi::StringMatcher::StringMatcher(const StringMatcher& other)
386
- : type(other.type) {
387
- switch (type) {
388
- case StringMatcherType::SAFE_REGEX:
389
- regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
390
- break;
391
- default:
392
- string_matcher = other.string_matcher;
413
+ std::string XdsApi::CommonTlsContext::CertificateValidationContext::ToString()
414
+ const {
415
+ std::vector<std::string> contents;
416
+ for (const auto& match : match_subject_alt_names) {
417
+ contents.push_back(match.ToString());
393
418
  }
419
+ return absl::StrFormat("{match_subject_alt_names=[%s]}",
420
+ absl::StrJoin(contents, ", "));
394
421
  }
395
422
 
396
- XdsApi::StringMatcher& XdsApi::StringMatcher::operator=(
397
- const StringMatcher& other) {
398
- type = other.type;
399
- switch (type) {
400
- case StringMatcherType::SAFE_REGEX:
401
- regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
402
- break;
403
- default:
404
- string_matcher = other.string_matcher;
423
+ bool XdsApi::CommonTlsContext::CertificateValidationContext::Empty() const {
424
+ return match_subject_alt_names.empty();
425
+ }
426
+
427
+ //
428
+ // XdsApi::CommonTlsContext::CertificateValidationContext
429
+ //
430
+
431
+ std::string XdsApi::CommonTlsContext::CertificateProviderInstance::ToString()
432
+ const {
433
+ absl::InlinedVector<std::string, 2> contents;
434
+ if (!instance_name.empty()) {
435
+ contents.push_back(absl::StrFormat("instance_name=%s", instance_name));
405
436
  }
406
- return *this;
437
+ if (!certificate_name.empty()) {
438
+ contents.push_back(
439
+ absl::StrFormat("certificate_name=%s", certificate_name));
440
+ }
441
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
407
442
  }
408
443
 
409
- bool XdsApi::StringMatcher::operator==(const StringMatcher& other) const {
410
- if (type != other.type) return false;
411
- switch (type) {
412
- case StringMatcherType::SAFE_REGEX:
413
- return regex_match->pattern() != other.regex_match->pattern();
414
- default:
415
- return string_matcher != other.string_matcher;
444
+ bool XdsApi::CommonTlsContext::CertificateProviderInstance::Empty() const {
445
+ return instance_name.empty() && certificate_name.empty();
446
+ }
447
+
448
+ //
449
+ // XdsApi::CommonTlsContext::CombinedCertificateValidationContext
450
+ //
451
+
452
+ std::string
453
+ XdsApi::CommonTlsContext::CombinedCertificateValidationContext::ToString()
454
+ const {
455
+ absl::InlinedVector<std::string, 2> contents;
456
+ if (!default_validation_context.Empty()) {
457
+ contents.push_back(absl::StrFormat("default_validation_context=%s",
458
+ default_validation_context.ToString()));
459
+ }
460
+ if (!validation_context_certificate_provider_instance.Empty()) {
461
+ contents.push_back(absl::StrFormat(
462
+ "validation_context_certificate_provider_instance=%s",
463
+ validation_context_certificate_provider_instance.ToString()));
464
+ }
465
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
466
+ }
467
+
468
+ bool XdsApi::CommonTlsContext::CombinedCertificateValidationContext::Empty()
469
+ const {
470
+ return default_validation_context.Empty() &&
471
+ validation_context_certificate_provider_instance.Empty();
472
+ }
473
+
474
+ //
475
+ // XdsApi::CommonTlsContext
476
+ //
477
+
478
+ std::string XdsApi::CommonTlsContext::ToString() const {
479
+ absl::InlinedVector<std::string, 2> contents;
480
+ if (!tls_certificate_certificate_provider_instance.Empty()) {
481
+ contents.push_back(absl::StrFormat(
482
+ "tls_certificate_certificate_provider_instance=%s",
483
+ tls_certificate_certificate_provider_instance.ToString()));
484
+ }
485
+ if (!combined_validation_context.Empty()) {
486
+ contents.push_back(absl::StrFormat("combined_validation_context=%s",
487
+ combined_validation_context.ToString()));
488
+ }
489
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
490
+ }
491
+
492
+ bool XdsApi::CommonTlsContext::Empty() const {
493
+ return tls_certificate_certificate_provider_instance.Empty() &&
494
+ combined_validation_context.Empty();
495
+ }
496
+
497
+ //
498
+ // XdsApi::DownstreamTlsContext
499
+ //
500
+
501
+ std::string XdsApi::DownstreamTlsContext::ToString() const {
502
+ return absl::StrFormat("common_tls_context=%s, require_client_certificate=%s",
503
+ common_tls_context.ToString(),
504
+ require_client_certificate ? "true" : "false");
505
+ }
506
+
507
+ bool XdsApi::DownstreamTlsContext::Empty() const {
508
+ return common_tls_context.Empty();
509
+ }
510
+
511
+ //
512
+ // XdsApi::LdsUpdate::HttpConnectionManager
513
+ //
514
+
515
+ std::string XdsApi::LdsUpdate::HttpConnectionManager::ToString() const {
516
+ absl::InlinedVector<std::string, 4> contents;
517
+ contents.push_back(absl::StrFormat(
518
+ "route_config_name=%s",
519
+ !route_config_name.empty() ? route_config_name.c_str() : "<inlined>"));
520
+ contents.push_back(absl::StrFormat("http_max_stream_duration=%s",
521
+ http_max_stream_duration.ToString()));
522
+ if (rds_update.has_value()) {
523
+ contents.push_back(
524
+ absl::StrFormat("rds_update=%s", rds_update->ToString()));
525
+ }
526
+ if (!http_filters.empty()) {
527
+ std::vector<std::string> filter_strings;
528
+ for (const auto& http_filter : http_filters) {
529
+ filter_strings.push_back(http_filter.ToString());
530
+ }
531
+ contents.push_back(absl::StrCat("http_filters=[",
532
+ absl::StrJoin(filter_strings, ", "), "]"));
416
533
  }
534
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
535
+ }
536
+
537
+ //
538
+ // XdsApi::LdsUpdate::HttpFilter
539
+ //
540
+
541
+ std::string XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter::ToString()
542
+ const {
543
+ return absl::StrCat("{name=", name, ", config=", config.ToString(), "}");
544
+ }
545
+
546
+ //
547
+ // XdsApi::LdsUpdate::FilterChainData
548
+ //
549
+
550
+ std::string XdsApi::LdsUpdate::FilterChainData::ToString() const {
551
+ return absl::StrCat(
552
+ "{downstream_tls_context=", downstream_tls_context.ToString(),
553
+ " http_connection_manager=", http_connection_manager.ToString(), "}");
554
+ }
555
+
556
+ //
557
+ // XdsApi::LdsUpdate::FilterChainMap::CidrRange
558
+ //
559
+
560
+ std::string XdsApi::LdsUpdate::FilterChainMap::CidrRange::ToString() const {
561
+ return absl::StrCat(
562
+ "{address_prefix=", grpc_sockaddr_to_string(&address, false),
563
+ ", prefix_len=", prefix_len, "}");
564
+ }
565
+
566
+ //
567
+ // FilterChain
568
+ //
569
+
570
+ struct FilterChain {
571
+ struct FilterChainMatch {
572
+ uint32_t destination_port = 0;
573
+ std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_ranges;
574
+ XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType source_type =
575
+ XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::kAny;
576
+ std::vector<XdsApi::LdsUpdate::FilterChainMap::CidrRange>
577
+ source_prefix_ranges;
578
+ std::vector<uint32_t> source_ports;
579
+ std::vector<std::string> server_names;
580
+ std::string transport_protocol;
581
+ std::vector<std::string> application_protocols;
582
+
583
+ std::string ToString() const;
584
+ } filter_chain_match;
585
+
586
+ std::shared_ptr<XdsApi::LdsUpdate::FilterChainData> filter_chain_data;
587
+ };
588
+
589
+ std::string FilterChain::FilterChainMatch::ToString() const {
590
+ absl::InlinedVector<std::string, 8> contents;
591
+ if (destination_port != 0) {
592
+ contents.push_back(absl::StrCat("destination_port=", destination_port));
593
+ }
594
+ if (!prefix_ranges.empty()) {
595
+ std::vector<std::string> prefix_ranges_content;
596
+ for (const auto& range : prefix_ranges) {
597
+ prefix_ranges_content.push_back(range.ToString());
598
+ }
599
+ contents.push_back(absl::StrCat(
600
+ "prefix_ranges={", absl::StrJoin(prefix_ranges_content, ", "), "}"));
601
+ }
602
+ if (source_type == XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType::
603
+ kSameIpOrLoopback) {
604
+ contents.push_back("source_type=SAME_IP_OR_LOOPBACK");
605
+ } else if (source_type == XdsApi::LdsUpdate::FilterChainMap::
606
+ ConnectionSourceType::kExternal) {
607
+ contents.push_back("source_type=EXTERNAL");
608
+ }
609
+ if (!source_prefix_ranges.empty()) {
610
+ std::vector<std::string> source_prefix_ranges_content;
611
+ for (const auto& range : source_prefix_ranges) {
612
+ source_prefix_ranges_content.push_back(range.ToString());
613
+ }
614
+ contents.push_back(
615
+ absl::StrCat("source_prefix_ranges={",
616
+ absl::StrJoin(source_prefix_ranges_content, ", "), "}"));
617
+ }
618
+ if (!source_ports.empty()) {
619
+ contents.push_back(
620
+ absl::StrCat("source_ports={", absl::StrJoin(source_ports, ", "), "}"));
621
+ }
622
+ if (!server_names.empty()) {
623
+ contents.push_back(
624
+ absl::StrCat("server_names={", absl::StrJoin(server_names, ", "), "}"));
625
+ }
626
+ if (!transport_protocol.empty()) {
627
+ contents.push_back(absl::StrCat("transport_protocol=", transport_protocol));
628
+ }
629
+ if (!application_protocols.empty()) {
630
+ contents.push_back(absl::StrCat("application_protocols={",
631
+ absl::StrJoin(application_protocols, ", "),
632
+ "}"));
633
+ }
634
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
635
+ }
636
+
637
+ //
638
+ // XdsApi::LdsUpdate::FilterChainMap
639
+ //
640
+
641
+ std::string XdsApi::LdsUpdate::FilterChainMap::ToString() const {
642
+ std::vector<std::string> contents;
643
+ for (const auto& destination_ip : destination_ip_vector) {
644
+ for (int source_type = 0; source_type < 3; ++source_type) {
645
+ for (const auto& source_ip :
646
+ destination_ip.source_types_array[source_type]) {
647
+ for (const auto& source_port_pair : source_ip.ports_map) {
648
+ FilterChain::FilterChainMatch filter_chain_match;
649
+ if (destination_ip.prefix_range.has_value()) {
650
+ filter_chain_match.prefix_ranges.push_back(
651
+ *destination_ip.prefix_range);
652
+ }
653
+ filter_chain_match.source_type = static_cast<
654
+ XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
655
+ source_type);
656
+ if (source_ip.prefix_range.has_value()) {
657
+ filter_chain_match.source_prefix_ranges.push_back(
658
+ *source_ip.prefix_range);
659
+ }
660
+ if (source_port_pair.first != 0) {
661
+ filter_chain_match.source_ports.push_back(source_port_pair.first);
662
+ }
663
+ contents.push_back(absl::StrCat(
664
+ "{filter_chain_match=", filter_chain_match.ToString(),
665
+ ", filter_chain=", source_port_pair.second.data->ToString(),
666
+ "}"));
667
+ }
668
+ }
669
+ }
670
+ }
671
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
672
+ }
673
+
674
+ //
675
+ // XdsApi::LdsUpdate
676
+ //
677
+
678
+ std::string XdsApi::LdsUpdate::ToString() const {
679
+ absl::InlinedVector<std::string, 4> contents;
680
+ if (type == ListenerType::kTcpListener) {
681
+ contents.push_back(absl::StrCat("address=", address));
682
+ contents.push_back(
683
+ absl::StrCat("filter_chain_map=", filter_chain_map.ToString()));
684
+ if (default_filter_chain.has_value()) {
685
+ contents.push_back(absl::StrCat("default_filter_chain=",
686
+ default_filter_chain->ToString()));
687
+ }
688
+ } else if (type == ListenerType::kHttpApiListener) {
689
+ contents.push_back(absl::StrFormat("http_connection_manager=%s",
690
+ http_connection_manager.ToString()));
691
+ }
692
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
693
+ }
694
+
695
+ //
696
+ // XdsApi::CdsUpdate
697
+ //
698
+
699
+ std::string XdsApi::CdsUpdate::ToString() const {
700
+ absl::InlinedVector<std::string, 4> contents;
701
+ if (!eds_service_name.empty()) {
702
+ contents.push_back(
703
+ absl::StrFormat("eds_service_name=%s", eds_service_name));
704
+ }
705
+ if (!common_tls_context.Empty()) {
706
+ contents.push_back(absl::StrFormat("common_tls_context=%s",
707
+ common_tls_context.ToString()));
708
+ }
709
+ if (lrs_load_reporting_server_name.has_value()) {
710
+ contents.push_back(absl::StrFormat("lrs_load_reporting_server_name=%s",
711
+ lrs_load_reporting_server_name.value()));
712
+ }
713
+ contents.push_back(
714
+ absl::StrFormat("max_concurrent_requests=%d", max_concurrent_requests));
715
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
417
716
  }
418
717
 
419
718
  //
@@ -508,8 +807,13 @@ const char* kCdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
508
807
  const char* kEdsV2TypeUrl =
509
808
  "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
510
809
 
511
- bool IsLds(absl::string_view type_url) {
512
- return type_url == XdsApi::kLdsTypeUrl || type_url == kLdsV2TypeUrl;
810
+ bool IsLds(absl::string_view type_url, bool* is_v2 = nullptr) {
811
+ if (type_url == XdsApi::kLdsTypeUrl) return true;
812
+ if (type_url == kLdsV2TypeUrl) {
813
+ if (is_v2 != nullptr) *is_v2 = true;
814
+ return true;
815
+ }
816
+ return false;
513
817
  }
514
818
 
515
819
  bool IsRds(absl::string_view type_url) {
@@ -527,46 +831,73 @@ bool IsEds(absl::string_view type_url) {
527
831
  } // namespace
528
832
 
529
833
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
530
- const XdsBootstrap* bootstrap)
834
+ const XdsBootstrap::Node* node)
531
835
  : client_(client),
532
836
  tracer_(tracer),
533
- use_v3_(bootstrap != nullptr && bootstrap->server().ShouldUseV3()),
534
- bootstrap_(bootstrap),
837
+ node_(node),
535
838
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
536
839
  grpc_version_string())),
537
- user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {}
840
+ user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {
841
+ // Populate upb symtab with xDS proto messages that we want to print
842
+ // properly in logs.
843
+ // Note: This won't actually work properly until upb adds support for
844
+ // Any fields in textproto printing (internal b/178821188).
845
+ envoy_config_listener_v3_Listener_getmsgdef(symtab_.ptr());
846
+ envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab_.ptr());
847
+ envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
848
+ envoy_extensions_clusters_aggregate_v3_ClusterConfig_getmsgdef(symtab_.ptr());
849
+ envoy_config_cluster_v3_Cluster_getmsgdef(symtab_.ptr());
850
+ envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab_.ptr());
851
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_getmsgdef(
852
+ symtab_.ptr());
853
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(
854
+ symtab_.ptr());
855
+ // Load HTTP filter proto messages into the upb symtab.
856
+ XdsHttpFilterRegistry::PopulateSymtab(symtab_.ptr());
857
+ }
538
858
 
539
859
  namespace {
540
860
 
861
+ struct EncodingContext {
862
+ XdsClient* client;
863
+ TraceFlag* tracer;
864
+ upb_symtab* symtab;
865
+ upb_arena* arena;
866
+ bool use_v3;
867
+ };
868
+
541
869
  // Works for both std::string and absl::string_view.
542
870
  template <typename T>
543
871
  inline upb_strview StdStringToUpbString(const T& str) {
544
872
  return upb_strview_make(str.data(), str.size());
545
873
  }
546
874
 
547
- void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
548
- const Json& value);
875
+ void PopulateMetadataValue(const EncodingContext& context,
876
+ google_protobuf_Value* value_pb, const Json& value);
549
877
 
550
- void PopulateListValue(upb_arena* arena, google_protobuf_ListValue* list_value,
878
+ void PopulateListValue(const EncodingContext& context,
879
+ google_protobuf_ListValue* list_value,
551
880
  const Json::Array& values) {
552
881
  for (const auto& value : values) {
553
- auto* value_pb = google_protobuf_ListValue_add_values(list_value, arena);
554
- PopulateMetadataValue(arena, value_pb, value);
882
+ auto* value_pb =
883
+ google_protobuf_ListValue_add_values(list_value, context.arena);
884
+ PopulateMetadataValue(context, value_pb, value);
555
885
  }
556
886
  }
557
887
 
558
- void PopulateMetadata(upb_arena* arena, google_protobuf_Struct* metadata_pb,
888
+ void PopulateMetadata(const EncodingContext& context,
889
+ google_protobuf_Struct* metadata_pb,
559
890
  const Json::Object& metadata) {
560
891
  for (const auto& p : metadata) {
561
- google_protobuf_Value* value = google_protobuf_Value_new(arena);
562
- PopulateMetadataValue(arena, value, p.second);
892
+ google_protobuf_Value* value = google_protobuf_Value_new(context.arena);
893
+ PopulateMetadataValue(context, value, p.second);
563
894
  google_protobuf_Struct_fields_set(
564
- metadata_pb, StdStringToUpbString(p.first), value, arena);
895
+ metadata_pb, StdStringToUpbString(p.first), value, context.arena);
565
896
  }
566
897
  }
567
898
 
568
- void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
569
- const Json& value) {
899
+ void PopulateMetadataValue(const EncodingContext& context,
900
+ google_protobuf_Value* value_pb, const Json& value) {
570
901
  switch (value.type()) {
571
902
  case Json::Type::JSON_NULL:
572
903
  google_protobuf_Value_set_null_value(value_pb, 0);
@@ -587,14 +918,14 @@ void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
587
918
  break;
588
919
  case Json::Type::OBJECT: {
589
920
  google_protobuf_Struct* struct_value =
590
- google_protobuf_Value_mutable_struct_value(value_pb, arena);
591
- PopulateMetadata(arena, struct_value, value.object_value());
921
+ google_protobuf_Value_mutable_struct_value(value_pb, context.arena);
922
+ PopulateMetadata(context, struct_value, value.object_value());
592
923
  break;
593
924
  }
594
925
  case Json::Type::ARRAY: {
595
926
  google_protobuf_ListValue* list_value =
596
- google_protobuf_Value_mutable_list_value(value_pb, arena);
597
- PopulateListValue(arena, list_value, value.array_value());
927
+ google_protobuf_Value_mutable_list_value(value_pb, context.arena);
928
+ PopulateListValue(context, list_value, value.array_value());
598
929
  break;
599
930
  }
600
931
  }
@@ -621,7 +952,8 @@ std::string EncodeStringField(uint32_t field_number, const std::string& str) {
621
952
  EncodeVarint(str.size()) + str;
622
953
  }
623
954
 
624
- void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
955
+ void PopulateBuildVersion(const EncodingContext& context,
956
+ envoy_config_core_v3_Node* node_msg,
625
957
  const std::string& build_version) {
626
958
  std::string encoded_build_version = EncodeStringField(5, build_version);
627
959
  // TODO(roth): This should use upb_msg_addunknown(), but that API is
@@ -629,14 +961,14 @@ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
629
961
  // API for now. Change this once we upgrade to a version of upb that
630
962
  // fixes this bug.
631
963
  _upb_msg_addunknown(node_msg, encoded_build_version.data(),
632
- encoded_build_version.size(), arena);
964
+ encoded_build_version.size(), context.arena);
633
965
  }
634
966
 
635
- void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
967
+ void PopulateNode(const EncodingContext& context,
968
+ const XdsBootstrap::Node* node,
636
969
  const std::string& build_version,
637
970
  const std::string& user_agent_name,
638
971
  envoy_config_core_v3_Node* node_msg) {
639
- const XdsBootstrap::Node* node = bootstrap->node();
640
972
  if (node != nullptr) {
641
973
  if (!node->id.empty()) {
642
974
  envoy_config_core_v3_Node_set_id(node_msg,
@@ -648,13 +980,13 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
648
980
  }
649
981
  if (!node->metadata.object_value().empty()) {
650
982
  google_protobuf_Struct* metadata =
651
- envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
652
- PopulateMetadata(arena, metadata, node->metadata.object_value());
983
+ envoy_config_core_v3_Node_mutable_metadata(node_msg, context.arena);
984
+ PopulateMetadata(context, metadata, node->metadata.object_value());
653
985
  }
654
986
  if (!node->locality_region.empty() || !node->locality_zone.empty() ||
655
- !node->locality_subzone.empty()) {
987
+ !node->locality_sub_zone.empty()) {
656
988
  envoy_config_core_v3_Locality* locality =
657
- envoy_config_core_v3_Node_mutable_locality(node_msg, arena);
989
+ envoy_config_core_v3_Node_mutable_locality(node_msg, context.arena);
658
990
  if (!node->locality_region.empty()) {
659
991
  envoy_config_core_v3_Locality_set_region(
660
992
  locality, StdStringToUpbString(node->locality_region));
@@ -663,14 +995,14 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
663
995
  envoy_config_core_v3_Locality_set_zone(
664
996
  locality, StdStringToUpbString(node->locality_zone));
665
997
  }
666
- if (!node->locality_subzone.empty()) {
998
+ if (!node->locality_sub_zone.empty()) {
667
999
  envoy_config_core_v3_Locality_set_sub_zone(
668
- locality, StdStringToUpbString(node->locality_subzone));
1000
+ locality, StdStringToUpbString(node->locality_sub_zone));
669
1001
  }
670
1002
  }
671
1003
  }
672
- if (!bootstrap->server().ShouldUseV3()) {
673
- PopulateBuildVersion(arena, node_msg, build_version);
1004
+ if (!context.use_v3) {
1005
+ PopulateBuildVersion(context, node_msg, build_version);
674
1006
  }
675
1007
  envoy_config_core_v3_Node_set_user_agent_name(
676
1008
  node_msg, StdStringToUpbString(user_agent_name));
@@ -678,7 +1010,7 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
678
1010
  node_msg, upb_strview_makez(grpc_version_string()));
679
1011
  envoy_config_core_v3_Node_add_client_features(
680
1012
  node_msg, upb_strview_makez("envoy.lb.does_not_support_overprovisioning"),
681
- arena);
1013
+ context.arena);
682
1014
  }
683
1015
 
684
1016
  inline absl::string_view UpbStringToAbsl(const upb_strview& str) {
@@ -689,180 +1021,26 @@ inline std::string UpbStringToStdString(const upb_strview& str) {
689
1021
  return std::string(str.data, str.size);
690
1022
  }
691
1023
 
692
- inline void AddStringField(const char* name, const upb_strview& value,
693
- std::vector<std::string>* fields,
694
- bool add_if_empty = false) {
695
- if (value.size > 0 || add_if_empty) {
696
- fields->emplace_back(
697
- absl::StrCat(name, ": \"", UpbStringToAbsl(value), "\""));
698
- }
699
- }
700
-
701
- inline void AddUInt32ValueField(const char* name,
702
- const google_protobuf_UInt32Value* value,
703
- std::vector<std::string>* fields) {
704
- if (value != nullptr) {
705
- fields->emplace_back(absl::StrCat(
706
- name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
707
- }
708
- }
709
-
710
- inline void AddLocalityField(int indent_level,
711
- const envoy_config_core_v3_Locality* locality,
712
- std::vector<std::string>* fields) {
713
- std::string indent =
714
- absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
715
- // region
716
- std::string field = absl::StrCat(indent, "region");
717
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_region(locality),
718
- fields);
719
- // zone
720
- field = absl::StrCat(indent, "zone");
721
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_zone(locality),
722
- fields);
723
- // sub_zone
724
- field = absl::StrCat(indent, "sub_zone");
725
- AddStringField(field.c_str(),
726
- envoy_config_core_v3_Locality_sub_zone(locality), fields);
727
- }
728
-
729
- void AddNodeLogFields(const envoy_config_core_v3_Node* node,
730
- const std::string& build_version,
731
- std::vector<std::string>* fields) {
732
- fields->emplace_back("node {");
733
- // id
734
- AddStringField(" id", envoy_config_core_v3_Node_id(node), fields);
735
- // metadata
736
- const google_protobuf_Struct* metadata =
737
- envoy_config_core_v3_Node_metadata(node);
738
- if (metadata != nullptr) {
739
- fields->emplace_back(" metadata {");
740
- size_t entry_idx = UPB_MAP_BEGIN;
741
- while (true) {
742
- const google_protobuf_Struct_FieldsEntry* entry =
743
- google_protobuf_Struct_fields_next(metadata, &entry_idx);
744
- if (entry == nullptr) break;
745
- fields->emplace_back(" field {");
746
- // key
747
- AddStringField(" key", google_protobuf_Struct_FieldsEntry_key(entry),
748
- fields);
749
- // value
750
- const google_protobuf_Value* value =
751
- google_protobuf_Struct_FieldsEntry_value(entry);
752
- if (value != nullptr) {
753
- std::string value_str;
754
- if (google_protobuf_Value_has_string_value(value)) {
755
- value_str = absl::StrCat(
756
- "string_value: \"",
757
- UpbStringToAbsl(google_protobuf_Value_string_value(value)), "\"");
758
- } else if (google_protobuf_Value_has_null_value(value)) {
759
- value_str = "null_value: NULL_VALUE";
760
- } else if (google_protobuf_Value_has_number_value(value)) {
761
- value_str = absl::StrCat("double_value: ",
762
- google_protobuf_Value_number_value(value));
763
- } else if (google_protobuf_Value_has_bool_value(value)) {
764
- value_str = absl::StrCat("bool_value: ",
765
- google_protobuf_Value_bool_value(value));
766
- } else if (google_protobuf_Value_has_struct_value(value)) {
767
- value_str = "struct_value: <not printed>";
768
- } else if (google_protobuf_Value_has_list_value(value)) {
769
- value_str = "list_value: <not printed>";
770
- } else {
771
- value_str = "<unknown>";
772
- }
773
- fields->emplace_back(absl::StrCat(" value { ", value_str, " }"));
774
- }
775
- fields->emplace_back(" }");
776
- }
777
- fields->emplace_back(" }");
778
- }
779
- // locality
780
- const envoy_config_core_v3_Locality* locality =
781
- envoy_config_core_v3_Node_locality(node);
782
- if (locality != nullptr) {
783
- fields->emplace_back(" locality {");
784
- AddLocalityField(2, locality, fields);
785
- fields->emplace_back(" }");
786
- }
787
- // build_version (doesn't exist in v3 proto; this is a horrible hack)
788
- if (!build_version.empty()) {
789
- fields->emplace_back(
790
- absl::StrCat(" build_version: \"", build_version, "\""));
791
- }
792
- // user_agent_name
793
- AddStringField(" user_agent_name",
794
- envoy_config_core_v3_Node_user_agent_name(node), fields);
795
- // user_agent_version
796
- AddStringField(" user_agent_version",
797
- envoy_config_core_v3_Node_user_agent_version(node), fields);
798
- // client_features
799
- size_t num_client_features;
800
- const upb_strview* client_features =
801
- envoy_config_core_v3_Node_client_features(node, &num_client_features);
802
- for (size_t i = 0; i < num_client_features; ++i) {
803
- AddStringField(" client_features", client_features[i], fields);
804
- }
805
- fields->emplace_back("}");
806
- }
807
-
808
1024
  void MaybeLogDiscoveryRequest(
809
- XdsClient* client, TraceFlag* tracer,
810
- const envoy_service_discovery_v3_DiscoveryRequest* request,
811
- const std::string& build_version) {
812
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1025
+ const EncodingContext& context,
1026
+ const envoy_service_discovery_v3_DiscoveryRequest* request) {
1027
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
813
1028
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
814
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
815
- // the raw proto instead of doing this manually.
816
- std::vector<std::string> fields;
817
- // version_info
818
- AddStringField(
819
- "version_info",
820
- envoy_service_discovery_v3_DiscoveryRequest_version_info(request),
821
- &fields);
822
- // node
823
- const envoy_config_core_v3_Node* node =
824
- envoy_service_discovery_v3_DiscoveryRequest_node(request);
825
- if (node != nullptr) AddNodeLogFields(node, build_version, &fields);
826
- // resource_names
827
- size_t num_resource_names;
828
- const upb_strview* resource_names =
829
- envoy_service_discovery_v3_DiscoveryRequest_resource_names(
830
- request, &num_resource_names);
831
- for (size_t i = 0; i < num_resource_names; ++i) {
832
- AddStringField("resource_names", resource_names[i], &fields);
833
- }
834
- // type_url
835
- AddStringField(
836
- "type_url",
837
- envoy_service_discovery_v3_DiscoveryRequest_type_url(request), &fields);
838
- // response_nonce
839
- AddStringField(
840
- "response_nonce",
841
- envoy_service_discovery_v3_DiscoveryRequest_response_nonce(request),
842
- &fields);
843
- // error_detail
844
- const struct google_rpc_Status* error_detail =
845
- envoy_service_discovery_v3_DiscoveryRequest_error_detail(request);
846
- if (error_detail != nullptr) {
847
- fields.emplace_back("error_detail {");
848
- // code
849
- int32_t code = google_rpc_Status_code(error_detail);
850
- if (code != 0) fields.emplace_back(absl::StrCat(" code: ", code));
851
- // message
852
- AddStringField(" message", google_rpc_Status_message(error_detail),
853
- &fields);
854
- fields.emplace_back("}");
855
- }
856
- gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s", client,
857
- absl::StrJoin(fields, "\n").c_str());
1029
+ const upb_msgdef* msg_type =
1030
+ envoy_service_discovery_v3_DiscoveryRequest_getmsgdef(context.symtab);
1031
+ char buf[10240];
1032
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
1033
+ gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s",
1034
+ context.client, buf);
858
1035
  }
859
1036
  }
860
1037
 
861
1038
  grpc_slice SerializeDiscoveryRequest(
862
- upb_arena* arena, envoy_service_discovery_v3_DiscoveryRequest* request) {
1039
+ const EncodingContext& context,
1040
+ envoy_service_discovery_v3_DiscoveryRequest* request) {
863
1041
  size_t output_length;
864
1042
  char* output = envoy_service_discovery_v3_DiscoveryRequest_serialize(
865
- request, arena, &output_length);
1043
+ request, context.arena, &output_length);
866
1044
  return grpc_slice_from_copied_buffer(output, output_length);
867
1045
  }
868
1046
 
@@ -888,17 +1066,19 @@ absl::string_view TypeUrlExternalToInternal(bool use_v3,
888
1066
  } // namespace
889
1067
 
890
1068
  grpc_slice XdsApi::CreateAdsRequest(
891
- const std::string& type_url,
1069
+ const XdsBootstrap::XdsServer& server, const std::string& type_url,
892
1070
  const std::set<absl::string_view>& resource_names,
893
1071
  const std::string& version, const std::string& nonce, grpc_error* error,
894
1072
  bool populate_node) {
895
1073
  upb::Arena arena;
1074
+ const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
1075
+ server.ShouldUseV3()};
896
1076
  // Create a request.
897
1077
  envoy_service_discovery_v3_DiscoveryRequest* request =
898
1078
  envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
899
1079
  // Set type_url.
900
1080
  absl::string_view real_type_url =
901
- TypeUrlExternalToInternal(use_v3_, type_url);
1081
+ TypeUrlExternalToInternal(server.ShouldUseV3(), type_url);
902
1082
  envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
903
1083
  request, StdStringToUpbString(real_type_url));
904
1084
  // Set version_info.
@@ -913,17 +1093,18 @@ grpc_slice XdsApi::CreateAdsRequest(
913
1093
  }
914
1094
  // Set error_detail if it's a NACK.
915
1095
  if (error != GRPC_ERROR_NONE) {
916
- grpc_slice error_description_slice;
917
- GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
918
- &error_description_slice));
919
- upb_strview error_description_strview =
920
- upb_strview_make(reinterpret_cast<const char*>(
921
- GPR_SLICE_START_PTR(error_description_slice)),
922
- GPR_SLICE_LENGTH(error_description_slice));
923
1096
  google_rpc_Status* error_detail =
924
1097
  envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
925
1098
  request, arena.ptr());
926
- google_rpc_Status_set_message(error_detail, error_description_strview);
1099
+ // Hard-code INVALID_ARGUMENT as the status code.
1100
+ // TODO(roth): If at some point we decide we care about this value,
1101
+ // we could attach a status code to the individual errors where we
1102
+ // generate them in the parsing code, and then use that here.
1103
+ google_rpc_Status_set_code(error_detail, GRPC_STATUS_INVALID_ARGUMENT);
1104
+ // Error description comes from the error that was passed in.
1105
+ upb_strview error_description =
1106
+ StdStringToUpbString(absl::string_view(grpc_error_string(error)));
1107
+ google_rpc_Status_set_message(error_detail, error_description);
927
1108
  GRPC_ERROR_UNREF(error);
928
1109
  }
929
1110
  // Populate node.
@@ -931,401 +1112,106 @@ grpc_slice XdsApi::CreateAdsRequest(
931
1112
  envoy_config_core_v3_Node* node_msg =
932
1113
  envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
933
1114
  arena.ptr());
934
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
935
- node_msg);
1115
+ PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
936
1116
  }
937
1117
  // Add resource_names.
938
1118
  for (const auto& resource_name : resource_names) {
939
1119
  envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
940
1120
  request, StdStringToUpbString(resource_name), arena.ptr());
941
1121
  }
942
- MaybeLogDiscoveryRequest(client_, tracer_, request, build_version_);
943
- return SerializeDiscoveryRequest(arena.ptr(), request);
1122
+ MaybeLogDiscoveryRequest(context, request);
1123
+ return SerializeDiscoveryRequest(context, request);
944
1124
  }
945
1125
 
946
1126
  namespace {
947
1127
 
948
1128
  void MaybeLogDiscoveryResponse(
949
- XdsClient* client, TraceFlag* tracer,
1129
+ const EncodingContext& context,
950
1130
  const envoy_service_discovery_v3_DiscoveryResponse* response) {
951
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1131
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
1132
+ gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1133
+ const upb_msgdef* msg_type =
1134
+ envoy_service_discovery_v3_DiscoveryResponse_getmsgdef(context.symtab);
1135
+ char buf[10240];
1136
+ upb_text_encode(response, msg_type, nullptr, 0, buf, sizeof(buf));
1137
+ gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", context.client,
1138
+ buf);
1139
+ }
1140
+ }
1141
+
1142
+ void MaybeLogHttpConnectionManager(
1143
+ const EncodingContext& context,
1144
+ const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
1145
+ http_connection_manager_config) {
1146
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
952
1147
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
953
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
954
- // the raw proto instead of doing this manually.
955
- std::vector<std::string> fields;
956
- // version_info
957
- AddStringField(
958
- "version_info",
959
- envoy_service_discovery_v3_DiscoveryResponse_version_info(response),
960
- &fields);
961
- // resources
962
- size_t num_resources;
963
- envoy_service_discovery_v3_DiscoveryResponse_resources(response,
964
- &num_resources);
965
- fields.emplace_back(
966
- absl::StrCat("resources: <", num_resources, " element(s)>"));
967
- // type_url
968
- AddStringField(
969
- "type_url",
970
- envoy_service_discovery_v3_DiscoveryResponse_type_url(response),
971
- &fields);
972
- // nonce
973
- AddStringField("nonce",
974
- envoy_service_discovery_v3_DiscoveryResponse_nonce(response),
975
- &fields);
976
- gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
977
- absl::StrJoin(fields, "\n").c_str());
1148
+ const upb_msgdef* msg_type =
1149
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_getmsgdef(
1150
+ context.symtab);
1151
+ char buf[10240];
1152
+ upb_text_encode(http_connection_manager_config, msg_type, nullptr, 0, buf,
1153
+ sizeof(buf));
1154
+ gpr_log(GPR_DEBUG, "[xds_client %p] HttpConnectionManager: %s",
1155
+ context.client, buf);
978
1156
  }
979
1157
  }
980
1158
 
981
1159
  void MaybeLogRouteConfiguration(
982
- XdsClient* client, TraceFlag* tracer,
1160
+ const EncodingContext& context,
983
1161
  const envoy_config_route_v3_RouteConfiguration* route_config) {
984
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1162
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
985
1163
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
986
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
987
- // the raw proto instead of doing this manually.
988
- std::vector<std::string> fields;
989
- // name
990
- AddStringField("name",
991
- envoy_config_route_v3_RouteConfiguration_name(route_config),
992
- &fields);
993
- // virtual_hosts
994
- size_t num_virtual_hosts;
995
- const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
996
- envoy_config_route_v3_RouteConfiguration_virtual_hosts(
997
- route_config, &num_virtual_hosts);
998
- for (size_t i = 0; i < num_virtual_hosts; ++i) {
999
- const auto* virtual_host = virtual_hosts[i];
1000
- fields.push_back("virtual_hosts {");
1001
- // name
1002
- AddStringField(" name",
1003
- envoy_config_route_v3_VirtualHost_name(virtual_host),
1004
- &fields);
1005
- // domains
1006
- size_t num_domains;
1007
- const upb_strview* const domains =
1008
- envoy_config_route_v3_VirtualHost_domains(virtual_host, &num_domains);
1009
- for (size_t j = 0; j < num_domains; ++j) {
1010
- AddStringField(" domains", domains[j], &fields);
1011
- }
1012
- // routes
1013
- size_t num_routes;
1014
- const envoy_config_route_v3_Route* const* routes =
1015
- envoy_config_route_v3_VirtualHost_routes(virtual_host, &num_routes);
1016
- for (size_t j = 0; j < num_routes; ++j) {
1017
- const auto* route = routes[j];
1018
- fields.push_back(" route {");
1019
- // name
1020
- AddStringField(" name", envoy_config_route_v3_Route_name(route),
1021
- &fields);
1022
- // match
1023
- const envoy_config_route_v3_RouteMatch* match =
1024
- envoy_config_route_v3_Route_match(route);
1025
- if (match != nullptr) {
1026
- fields.emplace_back(" match {");
1027
- // path matching
1028
- if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1029
- AddStringField(" prefix",
1030
- envoy_config_route_v3_RouteMatch_prefix(match),
1031
- &fields,
1032
- /*add_if_empty=*/true);
1033
- } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1034
- AddStringField(" path",
1035
- envoy_config_route_v3_RouteMatch_path(match),
1036
- &fields,
1037
- /*add_if_empty=*/true);
1038
- } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
1039
- fields.emplace_back(" safe_regex: <not printed>");
1040
- } else {
1041
- fields.emplace_back(" <unknown path matching type>");
1042
- }
1043
- // header matching
1044
- size_t num_headers;
1045
- envoy_config_route_v3_RouteMatch_headers(match, &num_headers);
1046
- if (num_headers > 0) {
1047
- fields.emplace_back(
1048
- absl::StrCat(" headers: <", num_headers, " element(s)>"));
1049
- }
1050
- fields.emplace_back(" }");
1051
- }
1052
- // action
1053
- if (envoy_config_route_v3_Route_has_route(route)) {
1054
- const envoy_config_route_v3_RouteAction* action =
1055
- envoy_config_route_v3_Route_route(route);
1056
- fields.emplace_back(" route {");
1057
- if (envoy_config_route_v3_RouteAction_has_cluster(action)) {
1058
- AddStringField(" cluster",
1059
- envoy_config_route_v3_RouteAction_cluster(action),
1060
- &fields);
1061
- } else if (envoy_config_route_v3_RouteAction_has_cluster_header(
1062
- action)) {
1063
- AddStringField(
1064
- " cluster_header",
1065
- envoy_config_route_v3_RouteAction_cluster_header(action),
1066
- &fields);
1067
- } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
1068
- action)) {
1069
- const envoy_config_route_v3_WeightedCluster* weighted_clusters =
1070
- envoy_config_route_v3_RouteAction_weighted_clusters(action);
1071
- fields.emplace_back(" weighted_clusters {");
1072
- size_t num_cluster_weights;
1073
- const envoy_config_route_v3_WeightedCluster_ClusterWeight* const*
1074
- cluster_weights =
1075
- envoy_config_route_v3_WeightedCluster_clusters(
1076
- weighted_clusters, &num_cluster_weights);
1077
- for (size_t i = 0; i < num_cluster_weights; ++i) {
1078
- const envoy_config_route_v3_WeightedCluster_ClusterWeight*
1079
- cluster_weight = cluster_weights[i];
1080
- fields.emplace_back(" clusters {");
1081
- AddStringField(
1082
- " name",
1083
- envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
1084
- cluster_weight),
1085
- &fields);
1086
- AddUInt32ValueField(
1087
- " weight",
1088
- envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
1089
- cluster_weight),
1090
- &fields);
1091
- fields.emplace_back(" }");
1092
- }
1093
- AddUInt32ValueField(
1094
- " total_weight",
1095
- envoy_config_route_v3_WeightedCluster_total_weight(
1096
- weighted_clusters),
1097
- &fields);
1098
- fields.emplace_back(" }");
1099
- }
1100
- fields.emplace_back(" }");
1101
- } else if (envoy_config_route_v3_Route_has_redirect(route)) {
1102
- fields.emplace_back(" redirect: <not printed>");
1103
- } else if (envoy_config_route_v3_Route_has_direct_response(route)) {
1104
- fields.emplace_back(" direct_response: <not printed>");
1105
- } else if (envoy_config_route_v3_Route_has_filter_action(route)) {
1106
- fields.emplace_back(" filter_action: <not printed>");
1107
- }
1108
- fields.push_back(" }");
1109
- }
1110
- fields.push_back("}");
1111
- }
1112
- gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client,
1113
- absl::StrJoin(fields, "\n").c_str());
1164
+ const upb_msgdef* msg_type =
1165
+ envoy_config_route_v3_RouteConfiguration_getmsgdef(context.symtab);
1166
+ char buf[10240];
1167
+ upb_text_encode(route_config, msg_type, nullptr, 0, buf, sizeof(buf));
1168
+ gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", context.client,
1169
+ buf);
1114
1170
  }
1115
1171
  }
1116
1172
 
1117
- void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
1173
+ void MaybeLogCluster(const EncodingContext& context,
1118
1174
  const envoy_config_cluster_v3_Cluster* cluster) {
1119
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1175
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
1120
1176
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1121
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1122
- // the raw proto instead of doing this manually.
1123
- std::vector<std::string> fields;
1124
- // name
1125
- AddStringField("name", envoy_config_cluster_v3_Cluster_name(cluster),
1126
- &fields);
1127
- // type
1128
- if (envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1129
- fields.emplace_back(absl::StrCat(
1130
- "type: ", envoy_config_cluster_v3_Cluster_type(cluster)));
1131
- } else if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
1132
- fields.emplace_back("cluster_type: <not printed>");
1133
- } else {
1134
- fields.emplace_back("<unknown type>");
1135
- }
1136
- // eds_cluster_config
1137
- const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1138
- envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
1139
- if (eds_cluster_config != nullptr) {
1140
- fields.emplace_back("eds_cluster_config {");
1141
- // eds_config
1142
- const struct envoy_config_core_v3_ConfigSource* eds_config =
1143
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1144
- eds_cluster_config);
1145
- if (eds_config != nullptr) {
1146
- if (envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
1147
- fields.emplace_back(" eds_config { ads {} }");
1148
- } else {
1149
- fields.emplace_back(" eds_config: <non-ADS type>");
1150
- }
1151
- }
1152
- // service_name
1153
- AddStringField(
1154
- " service_name",
1155
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1156
- eds_cluster_config),
1157
- &fields);
1158
- fields.emplace_back("}");
1159
- }
1160
- // lb_policy
1161
- fields.emplace_back(absl::StrCat(
1162
- "lb_policy: ", envoy_config_cluster_v3_Cluster_lb_policy(cluster)));
1163
- // lrs_server
1164
- const envoy_config_core_v3_ConfigSource* lrs_server =
1165
- envoy_config_cluster_v3_Cluster_lrs_server(cluster);
1166
- if (lrs_server != nullptr) {
1167
- if (envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
1168
- fields.emplace_back("lrs_server { self {} }");
1169
- } else {
1170
- fields.emplace_back("lrs_server: <non-self type>");
1171
- }
1172
- }
1173
- gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client,
1174
- absl::StrJoin(fields, "\n").c_str());
1177
+ const upb_msgdef* msg_type =
1178
+ envoy_config_cluster_v3_Cluster_getmsgdef(context.symtab);
1179
+ char buf[10240];
1180
+ upb_text_encode(cluster, msg_type, nullptr, 0, buf, sizeof(buf));
1181
+ gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", context.client, buf);
1175
1182
  }
1176
1183
  }
1177
1184
 
1178
1185
  void MaybeLogClusterLoadAssignment(
1179
- XdsClient* client, TraceFlag* tracer,
1186
+ const EncodingContext& context,
1180
1187
  const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
1181
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1188
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
1182
1189
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1183
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1184
- // the raw proto instead of doing this manually.
1185
- std::vector<std::string> fields;
1186
- // cluster_name
1187
- AddStringField(
1188
- "cluster_name",
1189
- envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(cla),
1190
- &fields);
1191
- // endpoints
1192
- size_t num_localities;
1193
- const struct envoy_config_endpoint_v3_LocalityLbEndpoints* const*
1194
- locality_endpoints =
1195
- envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1196
- cla, &num_localities);
1197
- for (size_t i = 0; i < num_localities; ++i) {
1198
- const auto* locality_endpoint = locality_endpoints[i];
1199
- fields.emplace_back("endpoints {");
1200
- // locality
1201
- const auto* locality =
1202
- envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
1203
- locality_endpoint);
1204
- if (locality != nullptr) {
1205
- fields.emplace_back(" locality {");
1206
- AddLocalityField(2, locality, &fields);
1207
- fields.emplace_back(" }");
1208
- }
1209
- // lb_endpoints
1210
- size_t num_lb_endpoints;
1211
- const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
1212
- envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
1213
- locality_endpoint, &num_lb_endpoints);
1214
- for (size_t j = 0; j < num_lb_endpoints; ++j) {
1215
- const auto* lb_endpoint = lb_endpoints[j];
1216
- fields.emplace_back(" lb_endpoints {");
1217
- // health_status
1218
- uint32_t health_status =
1219
- envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
1220
- if (health_status > 0) {
1221
- fields.emplace_back(
1222
- absl::StrCat(" health_status: ", health_status));
1223
- }
1224
- // endpoint
1225
- const envoy_config_endpoint_v3_Endpoint* endpoint =
1226
- envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
1227
- if (endpoint != nullptr) {
1228
- fields.emplace_back(" endpoint {");
1229
- // address
1230
- const auto* address =
1231
- envoy_config_endpoint_v3_Endpoint_address(endpoint);
1232
- if (address != nullptr) {
1233
- fields.emplace_back(" address {");
1234
- // socket_address
1235
- const auto* socket_address =
1236
- envoy_config_core_v3_Address_socket_address(address);
1237
- if (socket_address != nullptr) {
1238
- fields.emplace_back(" socket_address {");
1239
- // address
1240
- AddStringField(
1241
- " address",
1242
- envoy_config_core_v3_SocketAddress_address(socket_address),
1243
- &fields);
1244
- // port_value
1245
- if (envoy_config_core_v3_SocketAddress_has_port_value(
1246
- socket_address)) {
1247
- fields.emplace_back(
1248
- absl::StrCat(" port_value: ",
1249
- envoy_config_core_v3_SocketAddress_port_value(
1250
- socket_address)));
1251
- } else {
1252
- fields.emplace_back(" <non-numeric port>");
1253
- }
1254
- fields.emplace_back(" }");
1255
- } else {
1256
- fields.emplace_back(" <non-socket address>");
1257
- }
1258
- fields.emplace_back(" }");
1259
- }
1260
- fields.emplace_back(" }");
1261
- }
1262
- fields.emplace_back(" }");
1263
- }
1264
- // load_balancing_weight
1265
- AddUInt32ValueField(
1266
- " load_balancing_weight",
1267
- envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
1268
- locality_endpoint),
1269
- &fields);
1270
- // priority
1271
- uint32_t priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1272
- locality_endpoint);
1273
- if (priority > 0) {
1274
- fields.emplace_back(absl::StrCat(" priority: ", priority));
1275
- }
1276
- fields.emplace_back("}");
1277
- }
1278
- // policy
1279
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
1280
- envoy_config_endpoint_v3_ClusterLoadAssignment_policy(cla);
1281
- if (policy != nullptr) {
1282
- fields.emplace_back("policy {");
1283
- // drop_overloads
1284
- size_t num_drop_overloads;
1285
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
1286
- drop_overloads =
1287
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
1288
- policy, &num_drop_overloads);
1289
- for (size_t i = 0; i < num_drop_overloads; ++i) {
1290
- auto* drop_overload = drop_overloads[i];
1291
- fields.emplace_back(" drop_overloads {");
1292
- // category
1293
- AddStringField(
1294
- " category",
1295
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
1296
- drop_overload),
1297
- &fields);
1298
- // drop_percentage
1299
- const auto* drop_percentage =
1300
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1301
- drop_overload);
1302
- if (drop_percentage != nullptr) {
1303
- fields.emplace_back(" drop_percentage {");
1304
- fields.emplace_back(absl::StrCat(
1305
- " numerator: ",
1306
- envoy_type_v3_FractionalPercent_numerator(drop_percentage)));
1307
- fields.emplace_back(absl::StrCat(
1308
- " denominator: ",
1309
- envoy_type_v3_FractionalPercent_denominator(drop_percentage)));
1310
- fields.emplace_back(" }");
1311
- }
1312
- fields.emplace_back(" }");
1313
- }
1314
- // overprovisioning_factor
1315
- fields.emplace_back("}");
1316
- }
1317
- gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s", client,
1318
- absl::StrJoin(fields, "\n").c_str());
1190
+ const upb_msgdef* msg_type =
1191
+ envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(
1192
+ context.symtab);
1193
+ char buf[10240];
1194
+ upb_text_encode(cla, msg_type, nullptr, 0, buf, sizeof(buf));
1195
+ gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s",
1196
+ context.client, buf);
1319
1197
  }
1320
1198
  }
1321
1199
 
1322
1200
  grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1323
1201
  XdsApi::Route* route, bool* ignore_route) {
1202
+ auto* case_sensitive_ptr =
1203
+ envoy_config_route_v3_RouteMatch_case_sensitive(match);
1204
+ bool case_sensitive = true;
1205
+ if (case_sensitive_ptr != nullptr) {
1206
+ case_sensitive = google_protobuf_BoolValue_value(case_sensitive_ptr);
1207
+ }
1208
+ StringMatcher::Type type;
1209
+ std::string match_string;
1324
1210
  if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1325
1211
  absl::string_view prefix =
1326
1212
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
1327
1213
  // Empty prefix "" is accepted.
1328
- if (prefix.size() > 0) {
1214
+ if (!prefix.empty()) {
1329
1215
  // Prefix "/" is accepted.
1330
1216
  if (prefix[0] != '/') {
1331
1217
  // Prefix which does not start with a / will never match anything, so
@@ -1345,13 +1231,12 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1345
1231
  return GRPC_ERROR_NONE;
1346
1232
  }
1347
1233
  }
1348
- route->matchers.path_matcher.type =
1349
- XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX;
1350
- route->matchers.path_matcher.string_matcher = std::string(prefix);
1234
+ type = StringMatcher::Type::PREFIX;
1235
+ match_string = std::string(prefix);
1351
1236
  } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1352
1237
  absl::string_view path =
1353
1238
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
1354
- if (path.size() == 0) {
1239
+ if (path.empty()) {
1355
1240
  // Path that is empty will never match anything, so ignore this route.
1356
1241
  *ignore_route = true;
1357
1242
  return GRPC_ERROR_NONE;
@@ -1380,27 +1265,28 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1380
1265
  *ignore_route = true;
1381
1266
  return GRPC_ERROR_NONE;
1382
1267
  }
1383
- route->matchers.path_matcher.type =
1384
- XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH;
1385
- route->matchers.path_matcher.string_matcher = std::string(path);
1268
+ type = StringMatcher::Type::EXACT;
1269
+ match_string = std::string(path);
1386
1270
  } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
1387
1271
  const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1388
1272
  envoy_config_route_v3_RouteMatch_safe_regex(match);
1389
1273
  GPR_ASSERT(regex_matcher != nullptr);
1390
- std::string matcher = UpbStringToStdString(
1274
+ type = StringMatcher::Type::SAFE_REGEX;
1275
+ match_string = UpbStringToStdString(
1391
1276
  envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1392
- std::unique_ptr<RE2> regex = absl::make_unique<RE2>(std::move(matcher));
1393
- if (!regex->ok()) {
1394
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1395
- "Invalid regex string specified in path matcher.");
1396
- }
1397
- route->matchers.path_matcher.type =
1398
- XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX;
1399
- route->matchers.path_matcher.regex_matcher = std::move(regex);
1400
1277
  } else {
1401
1278
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1402
1279
  "Invalid route path specifier specified.");
1403
1280
  }
1281
+ absl::StatusOr<StringMatcher> string_matcher =
1282
+ StringMatcher::Create(type, match_string, case_sensitive);
1283
+ if (!string_matcher.ok()) {
1284
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1285
+ absl::StrCat("path matcher: ", string_matcher.status().message())
1286
+ .c_str());
1287
+ ;
1288
+ }
1289
+ route->matchers.path_matcher = std::move(string_matcher.value());
1404
1290
  return GRPC_ERROR_NONE;
1405
1291
  }
1406
1292
 
@@ -1411,64 +1297,62 @@ grpc_error* RouteHeaderMatchersParse(
1411
1297
  envoy_config_route_v3_RouteMatch_headers(match, &size);
1412
1298
  for (size_t i = 0; i < size; ++i) {
1413
1299
  const envoy_config_route_v3_HeaderMatcher* header = headers[i];
1414
- XdsApi::Route::Matchers::HeaderMatcher header_matcher;
1415
- header_matcher.name =
1300
+ const std::string name =
1416
1301
  UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
1302
+ HeaderMatcher::Type type;
1303
+ std::string match_string;
1304
+ int64_t range_start = 0;
1305
+ int64_t range_end = 0;
1306
+ bool present_match = false;
1417
1307
  if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) {
1418
- header_matcher.type =
1419
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::EXACT;
1420
- header_matcher.string_matcher = UpbStringToStdString(
1308
+ type = HeaderMatcher::Type::EXACT;
1309
+ match_string = UpbStringToStdString(
1421
1310
  envoy_config_route_v3_HeaderMatcher_exact_match(header));
1422
1311
  } else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match(
1423
1312
  header)) {
1424
1313
  const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1425
1314
  envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
1426
1315
  GPR_ASSERT(regex_matcher != nullptr);
1427
- const std::string matcher = UpbStringToStdString(
1316
+ type = HeaderMatcher::Type::SAFE_REGEX;
1317
+ match_string = UpbStringToStdString(
1428
1318
  envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1429
- std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
1430
- if (!regex->ok()) {
1431
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1432
- "Invalid regex string specified in header matcher.");
1433
- }
1434
- header_matcher.type =
1435
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX;
1436
- header_matcher.regex_match = std::move(regex);
1437
1319
  } else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) {
1438
- header_matcher.type =
1439
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE;
1320
+ type = HeaderMatcher::Type::RANGE;
1440
1321
  const envoy_type_v3_Int64Range* range_matcher =
1441
1322
  envoy_config_route_v3_HeaderMatcher_range_match(header);
1442
- header_matcher.range_start =
1443
- envoy_type_v3_Int64Range_start(range_matcher);
1444
- header_matcher.range_end = envoy_type_v3_Int64Range_end(range_matcher);
1445
- if (header_matcher.range_end < header_matcher.range_start) {
1446
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1447
- "Invalid range header matcher specifier specified: end "
1448
- "cannot be smaller than start.");
1449
- }
1323
+ range_start = envoy_type_v3_Int64Range_start(range_matcher);
1324
+ range_end = envoy_type_v3_Int64Range_end(range_matcher);
1450
1325
  } else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
1451
- header_matcher.type =
1452
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PRESENT;
1453
- header_matcher.present_match =
1454
- envoy_config_route_v3_HeaderMatcher_present_match(header);
1326
+ type = HeaderMatcher::Type::PRESENT;
1327
+ present_match = envoy_config_route_v3_HeaderMatcher_present_match(header);
1455
1328
  } else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) {
1456
- header_matcher.type =
1457
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PREFIX;
1458
- header_matcher.string_matcher = UpbStringToStdString(
1329
+ type = HeaderMatcher::Type::PREFIX;
1330
+ match_string = UpbStringToStdString(
1459
1331
  envoy_config_route_v3_HeaderMatcher_prefix_match(header));
1460
1332
  } else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) {
1461
- header_matcher.type =
1462
- XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::SUFFIX;
1463
- header_matcher.string_matcher = UpbStringToStdString(
1333
+ type = HeaderMatcher::Type::SUFFIX;
1334
+ match_string = UpbStringToStdString(
1464
1335
  envoy_config_route_v3_HeaderMatcher_suffix_match(header));
1336
+ } else if (envoy_config_route_v3_HeaderMatcher_has_contains_match(header)) {
1337
+ type = HeaderMatcher::Type::CONTAINS;
1338
+ match_string = UpbStringToStdString(
1339
+ envoy_config_route_v3_HeaderMatcher_contains_match(header));
1465
1340
  } else {
1466
1341
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1467
1342
  "Invalid route header matcher specified.");
1468
1343
  }
1469
- header_matcher.invert_match =
1344
+ bool invert_match =
1470
1345
  envoy_config_route_v3_HeaderMatcher_invert_match(header);
1471
- route->matchers.header_matchers.emplace_back(std::move(header_matcher));
1346
+ absl::StatusOr<HeaderMatcher> header_matcher =
1347
+ HeaderMatcher::Create(name, type, match_string, range_start, range_end,
1348
+ present_match, invert_match);
1349
+ if (!header_matcher.ok()) {
1350
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1351
+ absl::StrCat("header matcher: ", header_matcher.status().message())
1352
+ .c_str());
1353
+ }
1354
+ route->matchers.header_matchers.emplace_back(
1355
+ std::move(header_matcher.value()));
1472
1356
  }
1473
1357
  return GRPC_ERROR_NONE;
1474
1358
  }
@@ -1506,8 +1390,97 @@ grpc_error* RouteRuntimeFractionParse(
1506
1390
  return GRPC_ERROR_NONE;
1507
1391
  }
1508
1392
 
1509
- grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1510
- XdsApi::Route* route, bool* ignore_route) {
1393
+ grpc_error* ExtractHttpFilterTypeName(const EncodingContext& context,
1394
+ const google_protobuf_Any* any,
1395
+ absl::string_view* filter_type) {
1396
+ *filter_type = UpbStringToAbsl(google_protobuf_Any_type_url(any));
1397
+ if (*filter_type == "type.googleapis.com/udpa.type.v1.TypedStruct") {
1398
+ upb_strview any_value = google_protobuf_Any_value(any);
1399
+ const auto* typed_struct = udpa_type_v1_TypedStruct_parse(
1400
+ any_value.data, any_value.size, context.arena);
1401
+ if (typed_struct == nullptr) {
1402
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1403
+ "could not parse TypedStruct from filter config");
1404
+ }
1405
+ *filter_type =
1406
+ UpbStringToAbsl(udpa_type_v1_TypedStruct_type_url(typed_struct));
1407
+ }
1408
+ *filter_type = absl::StripPrefix(*filter_type, "type.googleapis.com/");
1409
+ return GRPC_ERROR_NONE;
1410
+ }
1411
+
1412
+ template <typename ParentType, typename EntryType>
1413
+ grpc_error* ParseTypedPerFilterConfig(
1414
+ const EncodingContext& context, const ParentType* parent,
1415
+ const EntryType* (*entry_func)(const ParentType*, size_t*),
1416
+ upb_strview (*key_func)(const EntryType*),
1417
+ const google_protobuf_Any* (*value_func)(const EntryType*),
1418
+ XdsApi::TypedPerFilterConfig* typed_per_filter_config) {
1419
+ size_t filter_it = UPB_MAP_BEGIN;
1420
+ while (true) {
1421
+ const auto* filter_entry = entry_func(parent, &filter_it);
1422
+ if (filter_entry == nullptr) break;
1423
+ absl::string_view key = UpbStringToAbsl(key_func(filter_entry));
1424
+ if (key.empty()) {
1425
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("empty filter name in map");
1426
+ }
1427
+ const google_protobuf_Any* any = value_func(filter_entry);
1428
+ GPR_ASSERT(any != nullptr);
1429
+ absl::string_view filter_type =
1430
+ UpbStringToAbsl(google_protobuf_Any_type_url(any));
1431
+ if (filter_type.empty()) {
1432
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1433
+ absl::StrCat("no filter config specified for filter name ", key)
1434
+ .c_str());
1435
+ }
1436
+ bool is_optional = false;
1437
+ if (filter_type ==
1438
+ "type.googleapis.com/envoy.config.route.v3.FilterConfig") {
1439
+ upb_strview any_value = google_protobuf_Any_value(any);
1440
+ const auto* filter_config = envoy_config_route_v3_FilterConfig_parse(
1441
+ any_value.data, any_value.size, context.arena);
1442
+ if (filter_config == nullptr) {
1443
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1444
+ absl::StrCat("could not parse FilterConfig wrapper for ", key)
1445
+ .c_str());
1446
+ }
1447
+ is_optional =
1448
+ envoy_config_route_v3_FilterConfig_is_optional(filter_config);
1449
+ any = envoy_config_route_v3_FilterConfig_config(filter_config);
1450
+ if (any == nullptr) {
1451
+ if (is_optional) continue;
1452
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1453
+ absl::StrCat("no filter config specified for filter name ", key)
1454
+ .c_str());
1455
+ }
1456
+ }
1457
+ grpc_error* error = ExtractHttpFilterTypeName(context, any, &filter_type);
1458
+ if (error != GRPC_ERROR_NONE) return error;
1459
+ const XdsHttpFilterImpl* filter_impl =
1460
+ XdsHttpFilterRegistry::GetFilterForType(filter_type);
1461
+ if (filter_impl == nullptr) {
1462
+ if (is_optional) continue;
1463
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1464
+ absl::StrCat("no filter registered for config type ", filter_type)
1465
+ .c_str());
1466
+ }
1467
+ absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
1468
+ filter_impl->GenerateFilterConfigOverride(
1469
+ google_protobuf_Any_value(any), context.arena);
1470
+ if (!filter_config.ok()) {
1471
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1472
+ absl::StrCat("filter config for type ", filter_type,
1473
+ " failed to parse: ", filter_config.status().ToString())
1474
+ .c_str());
1475
+ }
1476
+ (*typed_per_filter_config)[std::string(key)] = std::move(*filter_config);
1477
+ }
1478
+ return GRPC_ERROR_NONE;
1479
+ }
1480
+
1481
+ grpc_error* RouteActionParse(const EncodingContext& context,
1482
+ const envoy_config_route_v3_Route* route_msg,
1483
+ XdsApi::Route* route, bool* ignore_route) {
1511
1484
  if (!envoy_config_route_v3_Route_has_route(route_msg)) {
1512
1485
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1513
1486
  "No RouteAction found in route.");
@@ -1518,7 +1491,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1518
1491
  if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
1519
1492
  route->cluster_name = UpbStringToStdString(
1520
1493
  envoy_config_route_v3_RouteAction_cluster(route_action));
1521
- if (route->cluster_name.size() == 0) {
1494
+ if (route->cluster_name.empty()) {
1522
1495
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1523
1496
  "RouteAction cluster contains empty cluster name.");
1524
1497
  }
@@ -1557,7 +1530,19 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1557
1530
  "RouteAction weighted_cluster cluster missing weight");
1558
1531
  }
1559
1532
  cluster.weight = google_protobuf_UInt32Value_value(weight);
1533
+ if (cluster.weight == 0) continue;
1560
1534
  sum_of_weights += cluster.weight;
1535
+ if (context.use_v3) {
1536
+ grpc_error* error = ParseTypedPerFilterConfig<
1537
+ envoy_config_route_v3_WeightedCluster_ClusterWeight,
1538
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry>(
1539
+ context, cluster_weight,
1540
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_typed_per_filter_config_next,
1541
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_key,
1542
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_TypedPerFilterConfigEntry_value,
1543
+ &cluster.typed_per_filter_config);
1544
+ if (error != GRPC_ERROR_NONE) return error;
1545
+ }
1561
1546
  route->weighted_clusters.emplace_back(std::move(cluster));
1562
1547
  }
1563
1548
  if (total_weight != sum_of_weights) {
@@ -1571,22 +1556,124 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1571
1556
  } else {
1572
1557
  // No cluster or weighted_clusters found in RouteAction, ignore this route.
1573
1558
  *ignore_route = true;
1574
- return GRPC_ERROR_NONE;
1559
+ }
1560
+ if (!*ignore_route) {
1561
+ const envoy_config_route_v3_RouteAction_MaxStreamDuration*
1562
+ max_stream_duration =
1563
+ envoy_config_route_v3_RouteAction_max_stream_duration(route_action);
1564
+ if (max_stream_duration != nullptr) {
1565
+ const google_protobuf_Duration* duration =
1566
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_grpc_timeout_header_max(
1567
+ max_stream_duration);
1568
+ if (duration == nullptr) {
1569
+ duration =
1570
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_max_stream_duration(
1571
+ max_stream_duration);
1572
+ }
1573
+ if (duration != nullptr) {
1574
+ XdsApi::Duration duration_in_route;
1575
+ duration_in_route.seconds = google_protobuf_Duration_seconds(duration);
1576
+ duration_in_route.nanos = google_protobuf_Duration_nanos(duration);
1577
+ route->max_stream_duration = duration_in_route;
1578
+ }
1579
+ }
1580
+ }
1581
+ // Get HashPolicy from RouteAction
1582
+ if (XdsRingHashEnabled()) {
1583
+ size_t size = 0;
1584
+ const envoy_config_route_v3_RouteAction_HashPolicy* const* hash_policies =
1585
+ envoy_config_route_v3_RouteAction_hash_policy(route_action, &size);
1586
+ for (size_t i = 0; i < size; ++i) {
1587
+ const envoy_config_route_v3_RouteAction_HashPolicy* hash_policy =
1588
+ hash_policies[i];
1589
+ XdsApi::Route::HashPolicy policy;
1590
+ policy.terminal =
1591
+ envoy_config_route_v3_RouteAction_HashPolicy_terminal(hash_policy);
1592
+ const envoy_config_route_v3_RouteAction_HashPolicy_Header* header;
1593
+ const envoy_config_route_v3_RouteAction_HashPolicy_FilterState*
1594
+ filter_state;
1595
+ if ((header = envoy_config_route_v3_RouteAction_HashPolicy_header(
1596
+ hash_policy)) != nullptr) {
1597
+ policy.type = XdsApi::Route::HashPolicy::Type::HEADER;
1598
+ policy.header_name = UpbStringToStdString(
1599
+ envoy_config_route_v3_RouteAction_HashPolicy_Header_header_name(
1600
+ header));
1601
+ const struct envoy_type_matcher_v3_RegexMatchAndSubstitute*
1602
+ regex_rewrite =
1603
+ envoy_config_route_v3_RouteAction_HashPolicy_Header_regex_rewrite(
1604
+ header);
1605
+ if (regex_rewrite == nullptr) {
1606
+ gpr_log(
1607
+ GPR_DEBUG,
1608
+ "RouteAction HashPolicy contains policy specifier Header with "
1609
+ "RegexMatchAndSubstitution but Regex is missing");
1610
+ continue;
1611
+ }
1612
+ const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1613
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_pattern(
1614
+ regex_rewrite);
1615
+ if (regex_matcher == nullptr) {
1616
+ gpr_log(
1617
+ GPR_DEBUG,
1618
+ "RouteAction HashPolicy contains policy specifier Header with "
1619
+ "RegexMatchAndSubstitution but RegexMatcher pattern is "
1620
+ "missing");
1621
+ continue;
1622
+ }
1623
+ RE2::Options options;
1624
+ policy.regex = absl::make_unique<RE2>(
1625
+ UpbStringToStdString(
1626
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)),
1627
+ options);
1628
+ if (!policy.regex->ok()) {
1629
+ gpr_log(
1630
+ GPR_DEBUG,
1631
+ "RouteAction HashPolicy contains policy specifier Header with "
1632
+ "RegexMatchAndSubstitution but RegexMatcher pattern does not "
1633
+ "compile");
1634
+ continue;
1635
+ }
1636
+ policy.regex_substitution = UpbStringToStdString(
1637
+ envoy_type_matcher_v3_RegexMatchAndSubstitute_substitution(
1638
+ regex_rewrite));
1639
+ } else if ((filter_state =
1640
+ envoy_config_route_v3_RouteAction_HashPolicy_filter_state(
1641
+ hash_policy)) != nullptr) {
1642
+ std::string key = UpbStringToStdString(
1643
+ envoy_config_route_v3_RouteAction_HashPolicy_FilterState_key(
1644
+ filter_state));
1645
+ if (key == "io.grpc.channel_id") {
1646
+ policy.type = XdsApi::Route::HashPolicy::Type::CHANNEL_ID;
1647
+ } else {
1648
+ gpr_log(GPR_DEBUG,
1649
+ "RouteAction HashPolicy contains policy specifier "
1650
+ "FilterState but "
1651
+ "key is not io.grpc.channel_id.");
1652
+ continue;
1653
+ }
1654
+ } else {
1655
+ gpr_log(
1656
+ GPR_DEBUG,
1657
+ "RouteAction HashPolicy contains unsupported policy specifier.");
1658
+ continue;
1659
+ }
1660
+ route->hash_policies.emplace_back(std::move(policy));
1661
+ }
1575
1662
  }
1576
1663
  return GRPC_ERROR_NONE;
1577
1664
  }
1578
1665
 
1579
1666
  grpc_error* RouteConfigParse(
1580
- XdsClient* client, TraceFlag* tracer,
1667
+ const EncodingContext& context,
1581
1668
  const envoy_config_route_v3_RouteConfiguration* route_config,
1582
1669
  XdsApi::RdsUpdate* rds_update) {
1583
- MaybeLogRouteConfiguration(client, tracer, route_config);
1670
+ MaybeLogRouteConfiguration(context, route_config);
1584
1671
  // Get the virtual hosts.
1585
- size_t size;
1672
+ size_t num_virtual_hosts;
1586
1673
  const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
1587
- envoy_config_route_v3_RouteConfiguration_virtual_hosts(route_config,
1588
- &size);
1589
- for (size_t i = 0; i < size; ++i) {
1674
+ envoy_config_route_v3_RouteConfiguration_virtual_hosts(
1675
+ route_config, &num_virtual_hosts);
1676
+ for (size_t i = 0; i < num_virtual_hosts; ++i) {
1590
1677
  rds_update->virtual_hosts.emplace_back();
1591
1678
  XdsApi::RdsUpdate::VirtualHost& vhost = rds_update->virtual_hosts.back();
1592
1679
  // Parse domains.
@@ -1606,6 +1693,18 @@ grpc_error* RouteConfigParse(
1606
1693
  if (vhost.domains.empty()) {
1607
1694
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("VirtualHost has no domains");
1608
1695
  }
1696
+ // Parse typed_per_filter_config.
1697
+ if (context.use_v3) {
1698
+ grpc_error* error = ParseTypedPerFilterConfig<
1699
+ envoy_config_route_v3_VirtualHost,
1700
+ envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry>(
1701
+ context, virtual_hosts[i],
1702
+ envoy_config_route_v3_VirtualHost_typed_per_filter_config_next,
1703
+ envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_key,
1704
+ envoy_config_route_v3_VirtualHost_TypedPerFilterConfigEntry_value,
1705
+ &vhost.typed_per_filter_config);
1706
+ if (error != GRPC_ERROR_NONE) return error;
1707
+ }
1609
1708
  // Parse routes.
1610
1709
  size_t num_routes;
1611
1710
  const envoy_config_route_v3_Route* const* routes =
@@ -1618,6 +1717,9 @@ grpc_error* RouteConfigParse(
1618
1717
  for (size_t j = 0; j < num_routes; ++j) {
1619
1718
  const envoy_config_route_v3_RouteMatch* match =
1620
1719
  envoy_config_route_v3_Route_match(routes[j]);
1720
+ if (match == nullptr) {
1721
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Match can't be null.");
1722
+ }
1621
1723
  size_t query_parameters_size;
1622
1724
  static_cast<void>(envoy_config_route_v3_RouteMatch_query_parameters(
1623
1725
  match, &query_parameters_size));
@@ -1633,15 +1735,19 @@ grpc_error* RouteConfigParse(
1633
1735
  if (error != GRPC_ERROR_NONE) return error;
1634
1736
  error = RouteRuntimeFractionParse(match, &route);
1635
1737
  if (error != GRPC_ERROR_NONE) return error;
1636
- error = RouteActionParse(routes[j], &route, &ignore_route);
1738
+ error = RouteActionParse(context, routes[j], &route, &ignore_route);
1637
1739
  if (error != GRPC_ERROR_NONE) return error;
1638
1740
  if (ignore_route) continue;
1639
- const google_protobuf_BoolValue* case_sensitive =
1640
- envoy_config_route_v3_RouteMatch_case_sensitive(match);
1641
- if (case_sensitive != nullptr &&
1642
- !google_protobuf_BoolValue_value(case_sensitive)) {
1643
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1644
- "case_sensitive if set must be set to true.");
1741
+ if (context.use_v3) {
1742
+ grpc_error* error = ParseTypedPerFilterConfig<
1743
+ envoy_config_route_v3_Route,
1744
+ envoy_config_route_v3_Route_TypedPerFilterConfigEntry>(
1745
+ context, routes[j],
1746
+ envoy_config_route_v3_Route_typed_per_filter_config_next,
1747
+ envoy_config_route_v3_Route_TypedPerFilterConfigEntry_key,
1748
+ envoy_config_route_v3_Route_TypedPerFilterConfigEntry_value,
1749
+ &route.typed_per_filter_config);
1750
+ if (error != GRPC_ERROR_NONE) return error;
1645
1751
  }
1646
1752
  vhost.routes.emplace_back(std::move(route));
1647
1753
  }
@@ -1652,11 +1758,744 @@ grpc_error* RouteConfigParse(
1652
1758
  return GRPC_ERROR_NONE;
1653
1759
  }
1654
1760
 
1761
+ XdsApi::CommonTlsContext::CertificateProviderInstance
1762
+ CertificateProviderInstanceParse(
1763
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
1764
+ certificate_provider_instance_proto) {
1765
+ return {
1766
+ UpbStringToStdString(
1767
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1768
+ certificate_provider_instance_proto)),
1769
+ UpbStringToStdString(
1770
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
1771
+ certificate_provider_instance_proto))};
1772
+ }
1773
+
1774
+ grpc_error* CommonTlsContextParse(
1775
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1776
+ common_tls_context_proto,
1777
+ XdsApi::CommonTlsContext* common_tls_context) GRPC_MUST_USE_RESULT;
1778
+ grpc_error* CommonTlsContextParse(
1779
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1780
+ common_tls_context_proto,
1781
+ XdsApi::CommonTlsContext* common_tls_context) {
1782
+ auto* combined_validation_context =
1783
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
1784
+ common_tls_context_proto);
1785
+ if (combined_validation_context != nullptr) {
1786
+ auto* default_validation_context =
1787
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
1788
+ combined_validation_context);
1789
+ if (default_validation_context != nullptr) {
1790
+ size_t len = 0;
1791
+ auto* subject_alt_names_matchers =
1792
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
1793
+ default_validation_context, &len);
1794
+ for (size_t i = 0; i < len; ++i) {
1795
+ StringMatcher::Type type;
1796
+ std::string matcher;
1797
+ if (envoy_type_matcher_v3_StringMatcher_has_exact(
1798
+ subject_alt_names_matchers[i])) {
1799
+ type = StringMatcher::Type::EXACT;
1800
+ matcher =
1801
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
1802
+ subject_alt_names_matchers[i]));
1803
+ } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
1804
+ subject_alt_names_matchers[i])) {
1805
+ type = StringMatcher::Type::PREFIX;
1806
+ matcher =
1807
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
1808
+ subject_alt_names_matchers[i]));
1809
+ } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
1810
+ subject_alt_names_matchers[i])) {
1811
+ type = StringMatcher::Type::SUFFIX;
1812
+ matcher =
1813
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
1814
+ subject_alt_names_matchers[i]));
1815
+ } else if (envoy_type_matcher_v3_StringMatcher_has_contains(
1816
+ subject_alt_names_matchers[i])) {
1817
+ type = StringMatcher::Type::CONTAINS;
1818
+ matcher =
1819
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
1820
+ subject_alt_names_matchers[i]));
1821
+ } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
1822
+ subject_alt_names_matchers[i])) {
1823
+ type = StringMatcher::Type::SAFE_REGEX;
1824
+ auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
1825
+ subject_alt_names_matchers[i]);
1826
+ matcher = UpbStringToStdString(
1827
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1828
+ } else {
1829
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1830
+ "Invalid StringMatcher specified");
1831
+ }
1832
+ bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
1833
+ subject_alt_names_matchers[i]);
1834
+ absl::StatusOr<StringMatcher> string_matcher =
1835
+ StringMatcher::Create(type, matcher,
1836
+ /*case_sensitive=*/!ignore_case);
1837
+ if (!string_matcher.ok()) {
1838
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1839
+ absl::StrCat("string matcher: ",
1840
+ string_matcher.status().message())
1841
+ .c_str());
1842
+ }
1843
+ if (type == StringMatcher::Type::SAFE_REGEX && ignore_case) {
1844
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1845
+ "StringMatcher: ignore_case has no effect for SAFE_REGEX.");
1846
+ }
1847
+ common_tls_context->combined_validation_context
1848
+ .default_validation_context.match_subject_alt_names.push_back(
1849
+ std::move(string_matcher.value()));
1850
+ }
1851
+ }
1852
+ auto* validation_context_certificate_provider_instance =
1853
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
1854
+ combined_validation_context);
1855
+ if (validation_context_certificate_provider_instance != nullptr) {
1856
+ common_tls_context->combined_validation_context
1857
+ .validation_context_certificate_provider_instance =
1858
+ CertificateProviderInstanceParse(
1859
+ validation_context_certificate_provider_instance);
1860
+ }
1861
+ }
1862
+ auto* tls_certificate_certificate_provider_instance =
1863
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
1864
+ common_tls_context_proto);
1865
+ if (tls_certificate_certificate_provider_instance != nullptr) {
1866
+ common_tls_context->tls_certificate_certificate_provider_instance =
1867
+ CertificateProviderInstanceParse(
1868
+ tls_certificate_certificate_provider_instance);
1869
+ }
1870
+ return GRPC_ERROR_NONE;
1871
+ }
1872
+
1873
+ grpc_error* HttpConnectionManagerParse(
1874
+ bool is_client, const EncodingContext& context,
1875
+ const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
1876
+ http_connection_manager_proto,
1877
+ bool is_v2,
1878
+ XdsApi::LdsUpdate::HttpConnectionManager* http_connection_manager) {
1879
+ MaybeLogHttpConnectionManager(context, http_connection_manager_proto);
1880
+ // Obtain max_stream_duration from Http Protocol Options.
1881
+ const envoy_config_core_v3_HttpProtocolOptions* options =
1882
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
1883
+ http_connection_manager_proto);
1884
+ if (options != nullptr) {
1885
+ const google_protobuf_Duration* duration =
1886
+ envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(options);
1887
+ if (duration != nullptr) {
1888
+ http_connection_manager->http_max_stream_duration.seconds =
1889
+ google_protobuf_Duration_seconds(duration);
1890
+ http_connection_manager->http_max_stream_duration.nanos =
1891
+ google_protobuf_Duration_nanos(duration);
1892
+ }
1893
+ }
1894
+ // Parse filters.
1895
+ if (!is_v2) {
1896
+ size_t num_filters = 0;
1897
+ const auto* http_filters =
1898
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_http_filters(
1899
+ http_connection_manager_proto, &num_filters);
1900
+ std::set<absl::string_view> names_seen;
1901
+ for (size_t i = 0; i < num_filters; ++i) {
1902
+ const auto* http_filter = http_filters[i];
1903
+ absl::string_view name = UpbStringToAbsl(
1904
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_name(
1905
+ http_filter));
1906
+ if (name.empty()) {
1907
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1908
+ absl::StrCat("empty filter name at index ", i).c_str());
1909
+ }
1910
+ if (names_seen.find(name) != names_seen.end()) {
1911
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1912
+ absl::StrCat("duplicate HTTP filter name: ", name).c_str());
1913
+ }
1914
+ names_seen.insert(name);
1915
+ const bool is_optional =
1916
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_is_optional(
1917
+ http_filter);
1918
+ const google_protobuf_Any* any =
1919
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpFilter_typed_config(
1920
+ http_filter);
1921
+ if (any == nullptr) {
1922
+ if (is_optional) continue;
1923
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1924
+ absl::StrCat("no filter config specified for filter name ", name)
1925
+ .c_str());
1926
+ }
1927
+ absl::string_view filter_type;
1928
+ grpc_error* error = ExtractHttpFilterTypeName(context, any, &filter_type);
1929
+ if (error != GRPC_ERROR_NONE) return error;
1930
+ const XdsHttpFilterImpl* filter_impl =
1931
+ XdsHttpFilterRegistry::GetFilterForType(filter_type);
1932
+ if (filter_impl == nullptr) {
1933
+ if (is_optional) continue;
1934
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1935
+ absl::StrCat("no filter registered for config type ", filter_type)
1936
+ .c_str());
1937
+ }
1938
+ if ((is_client && !filter_impl->IsSupportedOnClients()) ||
1939
+ (!is_client && !filter_impl->IsSupportedOnServers())) {
1940
+ if (is_optional) continue;
1941
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1942
+ absl::StrFormat("Filter %s is not supported on %s", filter_type,
1943
+ is_client ? "clients" : "servers")
1944
+ .c_str());
1945
+ }
1946
+ absl::StatusOr<XdsHttpFilterImpl::FilterConfig> filter_config =
1947
+ filter_impl->GenerateFilterConfig(google_protobuf_Any_value(any),
1948
+ context.arena);
1949
+ if (!filter_config.ok()) {
1950
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1951
+ absl::StrCat(
1952
+ "filter config for type ", filter_type,
1953
+ " failed to parse: ", filter_config.status().ToString())
1954
+ .c_str());
1955
+ }
1956
+ http_connection_manager->http_filters.emplace_back(
1957
+ XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
1958
+ std::string(name), std::move(*filter_config)});
1959
+ }
1960
+ } else {
1961
+ // If using a v2 config, we just hard-code a list containing only the
1962
+ // router filter without actually looking at the config. This ensures
1963
+ // that the right thing happens in the xds resolver without having
1964
+ // to expose whether the resource we received was v2 or v3.
1965
+ http_connection_manager->http_filters.emplace_back(
1966
+ XdsApi::LdsUpdate::HttpConnectionManager::HttpFilter{
1967
+ "router", {kXdsHttpRouterFilterConfigName, Json()}});
1968
+ }
1969
+ if (is_client) {
1970
+ // Found inlined route_config. Parse it to find the cluster_name.
1971
+ if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
1972
+ http_connection_manager_proto)) {
1973
+ const envoy_config_route_v3_RouteConfiguration* route_config =
1974
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
1975
+ http_connection_manager_proto);
1976
+ XdsApi::RdsUpdate rds_update;
1977
+ grpc_error* error = RouteConfigParse(context, route_config, &rds_update);
1978
+ if (error != GRPC_ERROR_NONE) return error;
1979
+ http_connection_manager->rds_update = std::move(rds_update);
1980
+ return GRPC_ERROR_NONE;
1981
+ }
1982
+ // Validate that RDS must be used to get the route_config dynamically.
1983
+ const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
1984
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
1985
+ http_connection_manager_proto);
1986
+ if (rds == nullptr) {
1987
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1988
+ "HttpConnectionManager neither has inlined route_config nor RDS.");
1989
+ }
1990
+ // Check that the ConfigSource specifies ADS.
1991
+ const envoy_config_core_v3_ConfigSource* config_source =
1992
+ envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
1993
+ rds);
1994
+ if (config_source == nullptr) {
1995
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1996
+ "HttpConnectionManager missing config_source for RDS.");
1997
+ }
1998
+ if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
1999
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2000
+ "HttpConnectionManager ConfigSource for RDS does not specify ADS.");
2001
+ }
2002
+ // Get the route_config_name.
2003
+ http_connection_manager->route_config_name = UpbStringToStdString(
2004
+ envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
2005
+ rds));
2006
+ }
2007
+ return GRPC_ERROR_NONE;
2008
+ }
2009
+
2010
+ grpc_error* LdsResponseParseClient(
2011
+ const EncodingContext& context,
2012
+ const envoy_config_listener_v3_ApiListener* api_listener, bool is_v2,
2013
+ XdsApi::LdsUpdate* lds_update) {
2014
+ lds_update->type = XdsApi::LdsUpdate::ListenerType::kHttpApiListener;
2015
+ const upb_strview encoded_api_listener = google_protobuf_Any_value(
2016
+ envoy_config_listener_v3_ApiListener_api_listener(api_listener));
2017
+ const auto* http_connection_manager =
2018
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
2019
+ encoded_api_listener.data, encoded_api_listener.size, context.arena);
2020
+ if (http_connection_manager == nullptr) {
2021
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2022
+ "Could not parse HttpConnectionManager config from ApiListener");
2023
+ }
2024
+ return HttpConnectionManagerParse(true /* is_client */, context,
2025
+ http_connection_manager, is_v2,
2026
+ &lds_update->http_connection_manager);
2027
+ }
2028
+
2029
+ grpc_error* DownstreamTlsContextParse(
2030
+ const EncodingContext& context,
2031
+ const envoy_config_core_v3_TransportSocket* transport_socket,
2032
+ XdsApi::DownstreamTlsContext* downstream_tls_context) {
2033
+ absl::string_view name = UpbStringToAbsl(
2034
+ envoy_config_core_v3_TransportSocket_name(transport_socket));
2035
+ if (name == "envoy.transport_sockets.tls") {
2036
+ auto* typed_config =
2037
+ envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
2038
+ if (typed_config != nullptr) {
2039
+ const upb_strview encoded_downstream_tls_context =
2040
+ google_protobuf_Any_value(typed_config);
2041
+ auto* downstream_tls_context_proto =
2042
+ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_parse(
2043
+ encoded_downstream_tls_context.data,
2044
+ encoded_downstream_tls_context.size, context.arena);
2045
+ if (downstream_tls_context_proto == nullptr) {
2046
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2047
+ "Can't decode downstream tls context.");
2048
+ }
2049
+ auto* common_tls_context =
2050
+ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_common_tls_context(
2051
+ downstream_tls_context_proto);
2052
+ if (common_tls_context != nullptr) {
2053
+ grpc_error* error = CommonTlsContextParse(
2054
+ common_tls_context, &downstream_tls_context->common_tls_context);
2055
+ if (error != GRPC_ERROR_NONE) return error;
2056
+ }
2057
+ auto* require_client_certificate =
2058
+ envoy_extensions_transport_sockets_tls_v3_DownstreamTlsContext_require_client_certificate(
2059
+ downstream_tls_context_proto);
2060
+ if (require_client_certificate != nullptr) {
2061
+ downstream_tls_context->require_client_certificate =
2062
+ google_protobuf_BoolValue_value(require_client_certificate);
2063
+ }
2064
+ }
2065
+ if (downstream_tls_context->common_tls_context
2066
+ .tls_certificate_certificate_provider_instance.instance_name
2067
+ .empty()) {
2068
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2069
+ "TLS configuration provided but no "
2070
+ "tls_certificate_certificate_provider_instance found.");
2071
+ }
2072
+ }
2073
+ return GRPC_ERROR_NONE;
2074
+ }
2075
+
2076
+ grpc_error* CidrRangeParse(
2077
+ const envoy_config_core_v3_CidrRange* cidr_range_proto,
2078
+ XdsApi::LdsUpdate::FilterChainMap::CidrRange* cidr_range) {
2079
+ std::string address_prefix = UpbStringToStdString(
2080
+ envoy_config_core_v3_CidrRange_address_prefix(cidr_range_proto));
2081
+ grpc_error* error = grpc_string_to_sockaddr_new(&cidr_range->address,
2082
+ address_prefix.c_str(), 0);
2083
+ if (error != GRPC_ERROR_NONE) return error;
2084
+ cidr_range->prefix_len = 0;
2085
+ auto* prefix_len_proto =
2086
+ envoy_config_core_v3_CidrRange_prefix_len(cidr_range_proto);
2087
+ if (prefix_len_proto != nullptr) {
2088
+ cidr_range->prefix_len = std::min(
2089
+ google_protobuf_UInt32Value_value(prefix_len_proto),
2090
+ (reinterpret_cast<const grpc_sockaddr*>(cidr_range->address.addr))
2091
+ ->sa_family == GRPC_AF_INET
2092
+ ? uint32_t(32)
2093
+ : uint32_t(128));
2094
+ }
2095
+ // Normalize the network address by masking it with prefix_len
2096
+ grpc_sockaddr_mask_bits(&cidr_range->address, cidr_range->prefix_len);
2097
+ return GRPC_ERROR_NONE;
2098
+ }
2099
+
2100
+ grpc_error* FilterChainMatchParse(
2101
+ const envoy_config_listener_v3_FilterChainMatch* filter_chain_match_proto,
2102
+ FilterChain::FilterChainMatch* filter_chain_match) {
2103
+ auto* destination_port =
2104
+ envoy_config_listener_v3_FilterChainMatch_destination_port(
2105
+ filter_chain_match_proto);
2106
+ if (destination_port != nullptr) {
2107
+ filter_chain_match->destination_port =
2108
+ google_protobuf_UInt32Value_value(destination_port);
2109
+ }
2110
+ size_t size = 0;
2111
+ auto* prefix_ranges = envoy_config_listener_v3_FilterChainMatch_prefix_ranges(
2112
+ filter_chain_match_proto, &size);
2113
+ filter_chain_match->prefix_ranges.reserve(size);
2114
+ for (size_t i = 0; i < size; i++) {
2115
+ XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
2116
+ grpc_error* error = CidrRangeParse(prefix_ranges[i], &cidr_range);
2117
+ if (error != GRPC_ERROR_NONE) return error;
2118
+ filter_chain_match->prefix_ranges.push_back(cidr_range);
2119
+ }
2120
+ filter_chain_match->source_type =
2121
+ static_cast<XdsApi::LdsUpdate::FilterChainMap::ConnectionSourceType>(
2122
+ envoy_config_listener_v3_FilterChainMatch_source_type(
2123
+ filter_chain_match_proto));
2124
+ auto* source_prefix_ranges =
2125
+ envoy_config_listener_v3_FilterChainMatch_source_prefix_ranges(
2126
+ filter_chain_match_proto, &size);
2127
+ filter_chain_match->source_prefix_ranges.reserve(size);
2128
+ for (size_t i = 0; i < size; i++) {
2129
+ XdsApi::LdsUpdate::FilterChainMap::CidrRange cidr_range;
2130
+ grpc_error* error = CidrRangeParse(source_prefix_ranges[i], &cidr_range);
2131
+ if (error != GRPC_ERROR_NONE) return error;
2132
+ filter_chain_match->source_prefix_ranges.push_back(cidr_range);
2133
+ }
2134
+ auto* source_ports = envoy_config_listener_v3_FilterChainMatch_source_ports(
2135
+ filter_chain_match_proto, &size);
2136
+ filter_chain_match->source_ports.reserve(size);
2137
+ for (size_t i = 0; i < size; i++) {
2138
+ filter_chain_match->source_ports.push_back(source_ports[i]);
2139
+ }
2140
+ auto* server_names = envoy_config_listener_v3_FilterChainMatch_server_names(
2141
+ filter_chain_match_proto, &size);
2142
+ for (size_t i = 0; i < size; i++) {
2143
+ filter_chain_match->server_names.push_back(
2144
+ UpbStringToStdString(server_names[i]));
2145
+ }
2146
+ filter_chain_match->transport_protocol = UpbStringToStdString(
2147
+ envoy_config_listener_v3_FilterChainMatch_transport_protocol(
2148
+ filter_chain_match_proto));
2149
+ auto* application_protocols =
2150
+ envoy_config_listener_v3_FilterChainMatch_application_protocols(
2151
+ filter_chain_match_proto, &size);
2152
+ for (size_t i = 0; i < size; i++) {
2153
+ filter_chain_match->application_protocols.push_back(
2154
+ UpbStringToStdString(application_protocols[i]));
2155
+ }
2156
+ return GRPC_ERROR_NONE;
2157
+ }
2158
+
2159
+ grpc_error* FilterChainParse(
2160
+ const EncodingContext& context,
2161
+ const envoy_config_listener_v3_FilterChain* filter_chain_proto, bool is_v2,
2162
+ FilterChain* filter_chain) {
2163
+ grpc_error* error = GRPC_ERROR_NONE;
2164
+ auto* filter_chain_match =
2165
+ envoy_config_listener_v3_FilterChain_filter_chain_match(
2166
+ filter_chain_proto);
2167
+ if (filter_chain_match != nullptr) {
2168
+ error = FilterChainMatchParse(filter_chain_match,
2169
+ &filter_chain->filter_chain_match);
2170
+ if (error != GRPC_ERROR_NONE) return error;
2171
+ }
2172
+ // Parse the filters list. Currently we only support HttpConnectionManager.
2173
+ size_t size = 0;
2174
+ auto* filters =
2175
+ envoy_config_listener_v3_FilterChain_filters(filter_chain_proto, &size);
2176
+ if (size != 1) {
2177
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2178
+ "FilterChain should have exactly one filter: HttpConnectionManager; no "
2179
+ "other filter is supported at the moment");
2180
+ }
2181
+ auto* typed_config = envoy_config_listener_v3_Filter_typed_config(filters[0]);
2182
+ if (typed_config == nullptr) {
2183
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2184
+ "No typed_config found in filter.");
2185
+ }
2186
+ absl::string_view type_url =
2187
+ UpbStringToAbsl(google_protobuf_Any_type_url(typed_config));
2188
+ if (type_url !=
2189
+ "type.googleapis.com/"
2190
+ "envoy.extensions.filters.network.http_connection_manager.v3."
2191
+ "HttpConnectionManager") {
2192
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2193
+ absl::StrCat("Unsupported filter type ", type_url).c_str());
2194
+ }
2195
+ const upb_strview encoded_http_connection_manager =
2196
+ google_protobuf_Any_value(typed_config);
2197
+ const auto* http_connection_manager =
2198
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
2199
+ encoded_http_connection_manager.data,
2200
+ encoded_http_connection_manager.size, context.arena);
2201
+ if (http_connection_manager == nullptr) {
2202
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2203
+ "Could not parse HttpConnectionManager config from filter "
2204
+ "typed_config");
2205
+ }
2206
+ filter_chain->filter_chain_data =
2207
+ std::make_shared<XdsApi::LdsUpdate::FilterChainData>();
2208
+ error = HttpConnectionManagerParse(
2209
+ false /* is_client */, context, http_connection_manager, is_v2,
2210
+ &filter_chain->filter_chain_data->http_connection_manager);
2211
+ if (error != GRPC_ERROR_NONE) return error;
2212
+ // Get the DownstreamTlsContext for the filter chain
2213
+ if (XdsSecurityEnabled()) {
2214
+ auto* transport_socket =
2215
+ envoy_config_listener_v3_FilterChain_transport_socket(
2216
+ filter_chain_proto);
2217
+ if (transport_socket != nullptr) {
2218
+ error = DownstreamTlsContextParse(
2219
+ context, transport_socket,
2220
+ &filter_chain->filter_chain_data->downstream_tls_context);
2221
+ }
2222
+ }
2223
+ return error;
2224
+ }
2225
+
2226
+ grpc_error* AddressParse(const envoy_config_core_v3_Address* address_proto,
2227
+ std::string* address) {
2228
+ const auto* socket_address =
2229
+ envoy_config_core_v3_Address_socket_address(address_proto);
2230
+ if (socket_address == nullptr) {
2231
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2232
+ "Address does not have socket_address");
2233
+ }
2234
+ if (envoy_config_core_v3_SocketAddress_protocol(socket_address) !=
2235
+ envoy_config_core_v3_SocketAddress_TCP) {
2236
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2237
+ "SocketAddress protocol is not TCP");
2238
+ }
2239
+ uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
2240
+ if (port > 65535) {
2241
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port");
2242
+ }
2243
+ *address = JoinHostPort(
2244
+ UpbStringToAbsl(
2245
+ envoy_config_core_v3_SocketAddress_address(socket_address)),
2246
+ port);
2247
+ return GRPC_ERROR_NONE;
2248
+ }
2249
+
2250
+ // An intermediate map for filter chains that we create to validate the list of
2251
+ // filter chains received from the control plane and to finally create
2252
+ // XdsApi::LdsUpdate::FilterChainMap
2253
+ struct InternalFilterChainMap {
2254
+ using SourceIpMap =
2255
+ std::map<std::string, XdsApi::LdsUpdate::FilterChainMap::SourceIp>;
2256
+ using ConnectionSourceTypesArray = std::array<SourceIpMap, 3>;
2257
+ struct DestinationIp {
2258
+ absl::optional<XdsApi::LdsUpdate::FilterChainMap::CidrRange> prefix_range;
2259
+ bool transport_protocol_raw_buffer_provided = false;
2260
+ ConnectionSourceTypesArray source_types_array;
2261
+ };
2262
+ using DestinationIpMap = std::map<std::string, DestinationIp>;
2263
+ DestinationIpMap destination_ip_map;
2264
+ };
2265
+
2266
+ grpc_error* AddFilterChainDataForSourcePort(
2267
+ const FilterChain& filter_chain,
2268
+ XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map,
2269
+ uint32_t port) {
2270
+ auto insert_result = ports_map->emplace(
2271
+ port, XdsApi::LdsUpdate::FilterChainMap::FilterChainDataSharedPtr{
2272
+ filter_chain.filter_chain_data});
2273
+ if (!insert_result.second) {
2274
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2275
+ absl::StrCat(
2276
+ "Duplicate matching rules detected when adding filter chain: ",
2277
+ filter_chain.filter_chain_match.ToString())
2278
+ .c_str());
2279
+ }
2280
+ return GRPC_ERROR_NONE;
2281
+ }
2282
+
2283
+ grpc_error* AddFilterChainDataForSourcePorts(
2284
+ const FilterChain& filter_chain,
2285
+ XdsApi::LdsUpdate::FilterChainMap::SourcePortsMap* ports_map) {
2286
+ if (filter_chain.filter_chain_match.source_ports.empty()) {
2287
+ return AddFilterChainDataForSourcePort(filter_chain, ports_map, 0);
2288
+ } else {
2289
+ for (uint32_t port : filter_chain.filter_chain_match.source_ports) {
2290
+ grpc_error* error =
2291
+ AddFilterChainDataForSourcePort(filter_chain, ports_map, port);
2292
+ if (error != GRPC_ERROR_NONE) return error;
2293
+ }
2294
+ }
2295
+ return GRPC_ERROR_NONE;
2296
+ }
2297
+
2298
+ grpc_error* AddFilterChainDataForSourceIpRange(
2299
+ const FilterChain& filter_chain,
2300
+ InternalFilterChainMap::SourceIpMap* source_ip_map) {
2301
+ if (filter_chain.filter_chain_match.source_prefix_ranges.empty()) {
2302
+ auto insert_result = source_ip_map->emplace(
2303
+ "", XdsApi::LdsUpdate::FilterChainMap::SourceIp());
2304
+ return AddFilterChainDataForSourcePorts(
2305
+ filter_chain, &insert_result.first->second.ports_map);
2306
+ } else {
2307
+ for (const auto& prefix_range :
2308
+ filter_chain.filter_chain_match.source_prefix_ranges) {
2309
+ auto insert_result = source_ip_map->emplace(
2310
+ absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
2311
+ "/", prefix_range.prefix_len),
2312
+ XdsApi::LdsUpdate::FilterChainMap::SourceIp());
2313
+ if (insert_result.second) {
2314
+ insert_result.first->second.prefix_range.emplace(prefix_range);
2315
+ }
2316
+ grpc_error* error = AddFilterChainDataForSourcePorts(
2317
+ filter_chain, &insert_result.first->second.ports_map);
2318
+ if (error != GRPC_ERROR_NONE) return error;
2319
+ }
2320
+ }
2321
+ return GRPC_ERROR_NONE;
2322
+ }
2323
+
2324
+ grpc_error* AddFilterChainDataForSourceType(
2325
+ const FilterChain& filter_chain,
2326
+ InternalFilterChainMap::DestinationIp* destination_ip) {
2327
+ GPR_ASSERT(static_cast<unsigned int>(
2328
+ filter_chain.filter_chain_match.source_type) < 3);
2329
+ return AddFilterChainDataForSourceIpRange(
2330
+ filter_chain, &destination_ip->source_types_array[static_cast<int>(
2331
+ filter_chain.filter_chain_match.source_type)]);
2332
+ }
2333
+
2334
+ grpc_error* AddFilterChainDataForApplicationProtocols(
2335
+ const FilterChain& filter_chain,
2336
+ InternalFilterChainMap::DestinationIp* destination_ip) {
2337
+ // Only allow filter chains that do not mention application protocols
2338
+ if (!filter_chain.filter_chain_match.application_protocols.empty()) {
2339
+ return GRPC_ERROR_NONE;
2340
+ }
2341
+ return AddFilterChainDataForSourceType(filter_chain, destination_ip);
2342
+ }
2343
+
2344
+ grpc_error* AddFilterChainDataForTransportProtocol(
2345
+ const FilterChain& filter_chain,
2346
+ InternalFilterChainMap::DestinationIp* destination_ip) {
2347
+ const std::string& transport_protocol =
2348
+ filter_chain.filter_chain_match.transport_protocol;
2349
+ // Only allow filter chains with no transport protocol or "raw_buffer"
2350
+ if (!transport_protocol.empty() && transport_protocol != "raw_buffer") {
2351
+ return GRPC_ERROR_NONE;
2352
+ }
2353
+ // If for this configuration, we've already seen filter chains that mention
2354
+ // the transport protocol as "raw_buffer", we will never match filter chains
2355
+ // that do not mention it.
2356
+ if (destination_ip->transport_protocol_raw_buffer_provided &&
2357
+ transport_protocol.empty()) {
2358
+ return GRPC_ERROR_NONE;
2359
+ }
2360
+ if (!transport_protocol.empty() &&
2361
+ !destination_ip->transport_protocol_raw_buffer_provided) {
2362
+ destination_ip->transport_protocol_raw_buffer_provided = true;
2363
+ // Clear out the previous entries if any since those entries did not mention
2364
+ // "raw_buffer"
2365
+ destination_ip->source_types_array =
2366
+ InternalFilterChainMap::ConnectionSourceTypesArray();
2367
+ }
2368
+ return AddFilterChainDataForApplicationProtocols(filter_chain,
2369
+ destination_ip);
2370
+ }
2371
+
2372
+ grpc_error* AddFilterChainDataForServerNames(
2373
+ const FilterChain& filter_chain,
2374
+ InternalFilterChainMap::DestinationIp* destination_ip) {
2375
+ // Don't continue adding filter chains with server names mentioned
2376
+ if (!filter_chain.filter_chain_match.server_names.empty()) {
2377
+ return GRPC_ERROR_NONE;
2378
+ }
2379
+ return AddFilterChainDataForTransportProtocol(filter_chain, destination_ip);
2380
+ }
2381
+
2382
+ grpc_error* AddFilterChainDataForDestinationIpRange(
2383
+ const FilterChain& filter_chain,
2384
+ InternalFilterChainMap::DestinationIpMap* destination_ip_map) {
2385
+ if (filter_chain.filter_chain_match.prefix_ranges.empty()) {
2386
+ auto insert_result = destination_ip_map->emplace(
2387
+ "", InternalFilterChainMap::DestinationIp());
2388
+ return AddFilterChainDataForServerNames(filter_chain,
2389
+ &insert_result.first->second);
2390
+ } else {
2391
+ for (const auto& prefix_range :
2392
+ filter_chain.filter_chain_match.prefix_ranges) {
2393
+ auto insert_result = destination_ip_map->emplace(
2394
+ absl::StrCat(grpc_sockaddr_to_string(&prefix_range.address, false),
2395
+ "/", prefix_range.prefix_len),
2396
+ InternalFilterChainMap::DestinationIp());
2397
+ if (insert_result.second) {
2398
+ insert_result.first->second.prefix_range.emplace(prefix_range);
2399
+ }
2400
+ grpc_error* error = AddFilterChainDataForServerNames(
2401
+ filter_chain, &insert_result.first->second);
2402
+ if (error != GRPC_ERROR_NONE) return error;
2403
+ }
2404
+ }
2405
+ return GRPC_ERROR_NONE;
2406
+ }
2407
+
2408
+ XdsApi::LdsUpdate::FilterChainMap BuildFromInternalFilterChainMap(
2409
+ InternalFilterChainMap* internal_filter_chain_map) {
2410
+ XdsApi::LdsUpdate::FilterChainMap filter_chain_map;
2411
+ for (auto& destination_ip_pair :
2412
+ internal_filter_chain_map->destination_ip_map) {
2413
+ XdsApi::LdsUpdate::FilterChainMap::DestinationIp destination_ip;
2414
+ destination_ip.prefix_range = destination_ip_pair.second.prefix_range;
2415
+ for (int i = 0; i < 3; i++) {
2416
+ auto& source_ip_map = destination_ip_pair.second.source_types_array[i];
2417
+ for (auto& source_ip_pair : source_ip_map) {
2418
+ destination_ip.source_types_array[i].push_back(
2419
+ std::move(source_ip_pair.second));
2420
+ }
2421
+ }
2422
+ filter_chain_map.destination_ip_vector.push_back(std::move(destination_ip));
2423
+ }
2424
+ return filter_chain_map;
2425
+ }
2426
+
2427
+ grpc_error* BuildFilterChainMap(
2428
+ const std::vector<FilterChain>& filter_chains,
2429
+ XdsApi::LdsUpdate::FilterChainMap* filter_chain_map) {
2430
+ InternalFilterChainMap internal_filter_chain_map;
2431
+ for (const auto& filter_chain : filter_chains) {
2432
+ // Discard filter chain entries that specify destination port
2433
+ if (filter_chain.filter_chain_match.destination_port != 0) continue;
2434
+ grpc_error* error = AddFilterChainDataForDestinationIpRange(
2435
+ filter_chain, &internal_filter_chain_map.destination_ip_map);
2436
+ if (error != GRPC_ERROR_NONE) return error;
2437
+ }
2438
+ *filter_chain_map =
2439
+ BuildFromInternalFilterChainMap(&internal_filter_chain_map);
2440
+ return GRPC_ERROR_NONE;
2441
+ }
2442
+
2443
+ grpc_error* LdsResponseParseServer(
2444
+ const EncodingContext& context,
2445
+ const envoy_config_listener_v3_Listener* listener, bool is_v2,
2446
+ XdsApi::LdsUpdate* lds_update) {
2447
+ lds_update->type = XdsApi::LdsUpdate::ListenerType::kTcpListener;
2448
+ grpc_error* error =
2449
+ AddressParse(envoy_config_listener_v3_Listener_address(listener),
2450
+ &lds_update->address);
2451
+ if (error != GRPC_ERROR_NONE) return error;
2452
+ const auto* use_original_dst =
2453
+ envoy_config_listener_v3_Listener_use_original_dst(listener);
2454
+ if (use_original_dst != nullptr) {
2455
+ if (google_protobuf_BoolValue_value(use_original_dst)) {
2456
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2457
+ "Field \'use_original_dst\' is not supported.");
2458
+ }
2459
+ }
2460
+ size_t size = 0;
2461
+ auto* filter_chains =
2462
+ envoy_config_listener_v3_Listener_filter_chains(listener, &size);
2463
+ std::vector<FilterChain> parsed_filter_chains;
2464
+ parsed_filter_chains.reserve(size);
2465
+ for (size_t i = 0; i < size; i++) {
2466
+ FilterChain filter_chain;
2467
+ error = FilterChainParse(context, filter_chains[i], is_v2, &filter_chain);
2468
+ if (error != GRPC_ERROR_NONE) return error;
2469
+ parsed_filter_chains.push_back(std::move(filter_chain));
2470
+ }
2471
+ error =
2472
+ BuildFilterChainMap(parsed_filter_chains, &lds_update->filter_chain_map);
2473
+ if (error != GRPC_ERROR_NONE) return error;
2474
+ auto* default_filter_chain =
2475
+ envoy_config_listener_v3_Listener_default_filter_chain(listener);
2476
+ if (default_filter_chain != nullptr) {
2477
+ FilterChain filter_chain;
2478
+ error =
2479
+ FilterChainParse(context, default_filter_chain, is_v2, &filter_chain);
2480
+ if (error != GRPC_ERROR_NONE) return error;
2481
+ if (filter_chain.filter_chain_data != nullptr) {
2482
+ lds_update->default_filter_chain =
2483
+ std::move(*filter_chain.filter_chain_data);
2484
+ }
2485
+ }
2486
+ if (size == 0 && default_filter_chain == nullptr) {
2487
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No filter chain provided.");
2488
+ }
2489
+ return GRPC_ERROR_NONE;
2490
+ }
2491
+
1655
2492
  grpc_error* LdsResponseParse(
1656
- XdsClient* client, TraceFlag* tracer,
2493
+ const EncodingContext& context,
1657
2494
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1658
2495
  const std::set<absl::string_view>& expected_listener_names,
1659
- XdsApi::LdsUpdateMap* lds_update_map, upb_arena* arena) {
2496
+ XdsApi::LdsUpdateMap* lds_update_map,
2497
+ std::set<std::string>* resource_names_failed) {
2498
+ std::vector<grpc_error*> errors;
1660
2499
  // Get the resources from the response.
1661
2500
  size_t size;
1662
2501
  const google_protobuf_Any* const* resources =
@@ -1665,17 +2504,24 @@ grpc_error* LdsResponseParse(
1665
2504
  // Check the type_url of the resource.
1666
2505
  absl::string_view type_url =
1667
2506
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1668
- if (!IsLds(type_url)) {
1669
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not LDS.");
2507
+ bool is_v2 = false;
2508
+ if (!IsLds(type_url, &is_v2)) {
2509
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2510
+ absl::StrCat("resource index ", i, ": Resource is not LDS.")
2511
+ .c_str()));
2512
+ continue;
1670
2513
  }
1671
2514
  // Decode the listener.
1672
2515
  const upb_strview encoded_listener =
1673
2516
  google_protobuf_Any_value(resources[i]);
1674
2517
  const envoy_config_listener_v3_Listener* listener =
1675
- envoy_config_listener_v3_Listener_parse(encoded_listener.data,
1676
- encoded_listener.size, arena);
2518
+ envoy_config_listener_v3_Listener_parse(
2519
+ encoded_listener.data, encoded_listener.size, context.arena);
1677
2520
  if (listener == nullptr) {
1678
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode listener.");
2521
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2522
+ absl::StrCat("resource index ", i, ": Can't decode listener.")
2523
+ .c_str()));
2524
+ continue;
1679
2525
  }
1680
2526
  // Check listener name. Ignore unexpected listeners.
1681
2527
  std::string listener_name =
@@ -1686,75 +2532,62 @@ grpc_error* LdsResponseParse(
1686
2532
  }
1687
2533
  // Fail if listener name is duplicated.
1688
2534
  if (lds_update_map->find(listener_name) != lds_update_map->end()) {
1689
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2535
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1690
2536
  absl::StrCat("duplicate listener name \"", listener_name, "\"")
1691
- .c_str());
2537
+ .c_str()));
2538
+ resource_names_failed->insert(listener_name);
2539
+ continue;
1692
2540
  }
1693
- XdsApi::LdsUpdate& lds_update = (*lds_update_map)[listener_name];
1694
- // Get api_listener and decode it to http_connection_manager.
2541
+ // Serialize into JSON and store it in the LdsUpdateMap
2542
+ XdsApi::LdsResourceData& lds_resource_data =
2543
+ (*lds_update_map)[listener_name];
2544
+ XdsApi::LdsUpdate& lds_update = lds_resource_data.resource;
2545
+ lds_resource_data.serialized_proto = UpbStringToStdString(encoded_listener);
2546
+ // Check whether it's a client or server listener.
1695
2547
  const envoy_config_listener_v3_ApiListener* api_listener =
1696
2548
  envoy_config_listener_v3_Listener_api_listener(listener);
1697
- if (api_listener == nullptr) {
1698
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1699
- "Listener has no ApiListener.");
1700
- }
1701
- const upb_strview encoded_api_listener = google_protobuf_Any_value(
1702
- envoy_config_listener_v3_ApiListener_api_listener(api_listener));
1703
- const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
1704
- http_connection_manager =
1705
- envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
1706
- encoded_api_listener.data, encoded_api_listener.size, arena);
1707
- if (http_connection_manager == nullptr) {
1708
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1709
- "Could not parse HttpConnectionManager config from ApiListener");
1710
- }
1711
- // Found inlined route_config. Parse it to find the cluster_name.
1712
- if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
1713
- http_connection_manager)) {
1714
- const envoy_config_route_v3_RouteConfiguration* route_config =
1715
- envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
1716
- http_connection_manager);
1717
- XdsApi::RdsUpdate rds_update;
1718
- grpc_error* error =
1719
- RouteConfigParse(client, tracer, route_config, &rds_update);
1720
- if (error != GRPC_ERROR_NONE) return error;
1721
- lds_update.rds_update = std::move(rds_update);
2549
+ const envoy_config_core_v3_Address* address =
2550
+ envoy_config_listener_v3_Listener_address(listener);
2551
+ if (api_listener != nullptr && address != nullptr) {
2552
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2553
+ absl::StrCat(listener_name,
2554
+ ": Listener has both address and ApiListener")
2555
+ .c_str()));
2556
+ resource_names_failed->insert(listener_name);
1722
2557
  continue;
1723
2558
  }
1724
- // Validate that RDS must be used to get the route_config dynamically.
1725
- if (!envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_rds(
1726
- http_connection_manager)) {
1727
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1728
- "HttpConnectionManager neither has inlined route_config nor RDS.");
2559
+ if (api_listener == nullptr && address == nullptr) {
2560
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2561
+ absl::StrCat(listener_name,
2562
+ ": Listener has neither address nor ApiListener")
2563
+ .c_str()));
2564
+ resource_names_failed->insert(listener_name);
2565
+ continue;
1729
2566
  }
1730
- const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
1731
- envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
1732
- http_connection_manager);
1733
- // Check that the ConfigSource specifies ADS.
1734
- const envoy_config_core_v3_ConfigSource* config_source =
1735
- envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
1736
- rds);
1737
- if (config_source == nullptr) {
1738
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1739
- "HttpConnectionManager missing config_source for RDS.");
2567
+ grpc_error* error = GRPC_ERROR_NONE;
2568
+ if (api_listener != nullptr) {
2569
+ error = LdsResponseParseClient(context, api_listener, is_v2, &lds_update);
2570
+ } else {
2571
+ error = LdsResponseParseServer(context, listener, is_v2, &lds_update);
1740
2572
  }
1741
- if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
1742
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1743
- "HttpConnectionManager ConfigSource for RDS does not specify ADS.");
2573
+ if (error != GRPC_ERROR_NONE) {
2574
+ errors.push_back(grpc_error_add_child(
2575
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2576
+ absl::StrCat(listener_name, ": validation error").c_str()),
2577
+ error));
2578
+ resource_names_failed->insert(listener_name);
1744
2579
  }
1745
- // Get the route_config_name.
1746
- lds_update.route_config_name = UpbStringToStdString(
1747
- envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
1748
- rds));
1749
2580
  }
1750
- return GRPC_ERROR_NONE;
2581
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing LDS response", &errors);
1751
2582
  }
1752
2583
 
1753
2584
  grpc_error* RdsResponseParse(
1754
- XdsClient* client, TraceFlag* tracer,
2585
+ const EncodingContext& context,
1755
2586
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1756
2587
  const std::set<absl::string_view>& expected_route_configuration_names,
1757
- XdsApi::RdsUpdateMap* rds_update_map, upb_arena* arena) {
2588
+ XdsApi::RdsUpdateMap* rds_update_map,
2589
+ std::set<std::string>* resource_names_failed) {
2590
+ std::vector<grpc_error*> errors;
1758
2591
  // Get the resources from the response.
1759
2592
  size_t size;
1760
2593
  const google_protobuf_Any* const* resources =
@@ -1764,16 +2597,23 @@ grpc_error* RdsResponseParse(
1764
2597
  absl::string_view type_url =
1765
2598
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1766
2599
  if (!IsRds(type_url)) {
1767
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not RDS.");
2600
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2601
+ absl::StrCat("resource index ", i, ": Resource is not RDS.")
2602
+ .c_str()));
2603
+ continue;
1768
2604
  }
1769
2605
  // Decode the route_config.
1770
2606
  const upb_strview encoded_route_config =
1771
2607
  google_protobuf_Any_value(resources[i]);
1772
2608
  const envoy_config_route_v3_RouteConfiguration* route_config =
1773
2609
  envoy_config_route_v3_RouteConfiguration_parse(
1774
- encoded_route_config.data, encoded_route_config.size, arena);
2610
+ encoded_route_config.data, encoded_route_config.size,
2611
+ context.arena);
1775
2612
  if (route_config == nullptr) {
1776
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
2613
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2614
+ absl::StrCat("resource index ", i, ": Can't decode route_config.")
2615
+ .c_str()));
2616
+ continue;
1777
2617
  }
1778
2618
  // Check route_config_name. Ignore unexpected route_config.
1779
2619
  std::string route_config_name = UpbStringToStdString(
@@ -1784,112 +2624,39 @@ grpc_error* RdsResponseParse(
1784
2624
  }
1785
2625
  // Fail if route config name is duplicated.
1786
2626
  if (rds_update_map->find(route_config_name) != rds_update_map->end()) {
1787
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2627
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1788
2628
  absl::StrCat("duplicate route config name \"", route_config_name,
1789
2629
  "\"")
1790
- .c_str());
2630
+ .c_str()));
2631
+ resource_names_failed->insert(route_config_name);
2632
+ continue;
1791
2633
  }
2634
+ // Serialize into JSON and store it in the RdsUpdateMap
2635
+ XdsApi::RdsResourceData& rds_resource_data =
2636
+ (*rds_update_map)[route_config_name];
2637
+ XdsApi::RdsUpdate& rds_update = rds_resource_data.resource;
2638
+ rds_resource_data.serialized_proto =
2639
+ UpbStringToStdString(encoded_route_config);
1792
2640
  // Parse the route_config.
1793
- XdsApi::RdsUpdate& rds_update =
1794
- (*rds_update_map)[std::move(route_config_name)];
1795
- grpc_error* error =
1796
- RouteConfigParse(client, tracer, route_config, &rds_update);
1797
- if (error != GRPC_ERROR_NONE) return error;
1798
- }
1799
- return GRPC_ERROR_NONE;
1800
- }
1801
-
1802
- grpc_error* CommonTlsContextParse(
1803
- const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1804
- common_tls_context_proto,
1805
- XdsApi::CommonTlsContext* common_tls_context) GRPC_MUST_USE_RESULT;
1806
- grpc_error* CommonTlsContextParse(
1807
- const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1808
- common_tls_context_proto,
1809
- XdsApi::CommonTlsContext* common_tls_context) {
1810
- auto* combined_validation_context =
1811
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
1812
- common_tls_context_proto);
1813
- if (combined_validation_context != nullptr) {
1814
- auto* default_validation_context =
1815
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
1816
- combined_validation_context);
1817
- if (default_validation_context != nullptr) {
1818
- size_t len = 0;
1819
- auto* subject_alt_names_matchers =
1820
- envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
1821
- default_validation_context, &len);
1822
- for (size_t i = 0; i < len; ++i) {
1823
- XdsApi::StringMatcher matcher;
1824
- if (envoy_type_matcher_v3_StringMatcher_has_exact(
1825
- subject_alt_names_matchers[i])) {
1826
- matcher.type = XdsApi::StringMatcher::StringMatcherType::EXACT;
1827
- matcher.string_matcher =
1828
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
1829
- subject_alt_names_matchers[i]));
1830
- } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
1831
- subject_alt_names_matchers[i])) {
1832
- matcher.type = XdsApi::StringMatcher::StringMatcherType::PREFIX;
1833
- matcher.string_matcher =
1834
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
1835
- subject_alt_names_matchers[i]));
1836
- } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
1837
- subject_alt_names_matchers[i])) {
1838
- matcher.type = XdsApi::StringMatcher::StringMatcherType::SUFFIX;
1839
- matcher.string_matcher =
1840
- UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
1841
- subject_alt_names_matchers[i]));
1842
- } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
1843
- subject_alt_names_matchers[i])) {
1844
- matcher.type = XdsApi::StringMatcher::StringMatcherType::SAFE_REGEX;
1845
- auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
1846
- subject_alt_names_matchers[i]);
1847
- std::unique_ptr<RE2> regex =
1848
- absl::make_unique<RE2>(UpbStringToStdString(
1849
- envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher)));
1850
- if (!regex->ok()) {
1851
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1852
- "Invalid regex string specified in string matcher.");
1853
- }
1854
- matcher.regex_match = std::move(regex);
1855
- } else {
1856
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1857
- "Invalid StringMatcher specified");
1858
- }
1859
- matcher.ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
1860
- subject_alt_names_matchers[i]);
1861
- common_tls_context->combined_validation_context
1862
- .default_validation_context.match_subject_alt_names.emplace_back(
1863
- matcher);
1864
- }
2641
+ grpc_error* error = RouteConfigParse(context, route_config, &rds_update);
2642
+ if (error != GRPC_ERROR_NONE) {
2643
+ errors.push_back(grpc_error_add_child(
2644
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2645
+ absl::StrCat(route_config_name, ": validation error").c_str()),
2646
+ error));
2647
+ resource_names_failed->insert(route_config_name);
1865
2648
  }
1866
- auto* validation_context_certificate_provider_instance =
1867
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
1868
- combined_validation_context);
1869
- if (validation_context_certificate_provider_instance != nullptr) {
1870
- common_tls_context->combined_validation_context
1871
- .validation_context_certificate_provider_instance = UpbStringToStdString(
1872
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1873
- validation_context_certificate_provider_instance));
1874
- }
1875
- }
1876
- auto* tls_certificate_certificate_provider_instance =
1877
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
1878
- common_tls_context_proto);
1879
- if (tls_certificate_certificate_provider_instance != nullptr) {
1880
- common_tls_context
1881
- ->tls_certificate_certificate_provider_instance = UpbStringToStdString(
1882
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1883
- tls_certificate_certificate_provider_instance));
1884
2649
  }
1885
- return GRPC_ERROR_NONE;
2650
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing RDS response", &errors);
1886
2651
  }
1887
2652
 
1888
2653
  grpc_error* CdsResponseParse(
1889
- XdsClient* client, TraceFlag* tracer,
2654
+ const EncodingContext& context,
1890
2655
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1891
2656
  const std::set<absl::string_view>& expected_cluster_names,
1892
- XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
2657
+ XdsApi::CdsUpdateMap* cds_update_map,
2658
+ std::set<std::string>* resource_names_failed) {
2659
+ std::vector<grpc_error*> errors;
1893
2660
  // Get the resources from the response.
1894
2661
  size_t size;
1895
2662
  const google_protobuf_Any* const* resources =
@@ -1900,17 +2667,23 @@ grpc_error* CdsResponseParse(
1900
2667
  absl::string_view type_url =
1901
2668
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1902
2669
  if (!IsCds(type_url)) {
1903
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not CDS.");
2670
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2671
+ absl::StrCat("resource index ", i, ": Resource is not CDS.")
2672
+ .c_str()));
2673
+ continue;
1904
2674
  }
1905
2675
  // Decode the cluster.
1906
2676
  const upb_strview encoded_cluster = google_protobuf_Any_value(resources[i]);
1907
2677
  const envoy_config_cluster_v3_Cluster* cluster =
1908
- envoy_config_cluster_v3_Cluster_parse(encoded_cluster.data,
1909
- encoded_cluster.size, arena);
2678
+ envoy_config_cluster_v3_Cluster_parse(
2679
+ encoded_cluster.data, encoded_cluster.size, context.arena);
1910
2680
  if (cluster == nullptr) {
1911
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode cluster.");
2681
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2682
+ absl::StrCat("resource index ", i, ": Can't decode cluster.")
2683
+ .c_str()));
2684
+ continue;
1912
2685
  }
1913
- MaybeLogCluster(client, tracer, cluster);
2686
+ MaybeLogCluster(context, cluster);
1914
2687
  // Ignore unexpected cluster names.
1915
2688
  std::string cluster_name =
1916
2689
  UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
@@ -1920,69 +2693,249 @@ grpc_error* CdsResponseParse(
1920
2693
  }
1921
2694
  // Fail on duplicate resources.
1922
2695
  if (cds_update_map->find(cluster_name) != cds_update_map->end()) {
1923
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2696
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1924
2697
  absl::StrCat("duplicate resource name \"", cluster_name, "\"")
1925
- .c_str());
2698
+ .c_str()));
2699
+ resource_names_failed->insert(cluster_name);
2700
+ continue;
1926
2701
  }
1927
- XdsApi::CdsUpdate& cds_update = (*cds_update_map)[std::move(cluster_name)];
2702
+ // Serialize into JSON and store it in the CdsUpdateMap
2703
+ XdsApi::CdsResourceData& cds_resource_data =
2704
+ (*cds_update_map)[cluster_name];
2705
+ XdsApi::CdsUpdate& cds_update = cds_resource_data.resource;
2706
+ cds_resource_data.serialized_proto = UpbStringToStdString(encoded_cluster);
1928
2707
  // Check the cluster_discovery_type.
1929
- if (!envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1930
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found.");
2708
+ if (!envoy_config_cluster_v3_Cluster_has_type(cluster) &&
2709
+ !envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
2710
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2711
+ absl::StrCat(cluster_name, ": DiscoveryType not found.").c_str()));
2712
+ resource_names_failed->insert(cluster_name);
2713
+ continue;
1931
2714
  }
1932
- if (envoy_config_cluster_v3_Cluster_type(cluster) !=
2715
+ if (envoy_config_cluster_v3_Cluster_type(cluster) ==
1933
2716
  envoy_config_cluster_v3_Cluster_EDS) {
1934
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not EDS.");
1935
- }
1936
- // Check the EDS config source.
1937
- const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1938
- envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
1939
- const envoy_config_core_v3_ConfigSource* eds_config =
1940
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1941
- eds_cluster_config);
1942
- if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
1943
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1944
- "EDS ConfigSource is not ADS.");
1945
- }
1946
- // Record EDS service_name (if any).
1947
- upb_strview service_name =
1948
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1949
- eds_cluster_config);
1950
- if (service_name.size != 0) {
1951
- cds_update.eds_service_name = UpbStringToStdString(service_name);
2717
+ cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::EDS;
2718
+ // Check the EDS config source.
2719
+ const envoy_config_cluster_v3_Cluster_EdsClusterConfig*
2720
+ eds_cluster_config =
2721
+ envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
2722
+ const envoy_config_core_v3_ConfigSource* eds_config =
2723
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
2724
+ eds_cluster_config);
2725
+ if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
2726
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2727
+ absl::StrCat(cluster_name, ": EDS ConfigSource is not ADS.")
2728
+ .c_str()));
2729
+ resource_names_failed->insert(cluster_name);
2730
+ continue;
2731
+ }
2732
+ // Record EDS service_name (if any).
2733
+ upb_strview service_name =
2734
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
2735
+ eds_cluster_config);
2736
+ if (service_name.size != 0) {
2737
+ cds_update.eds_service_name = UpbStringToStdString(service_name);
2738
+ }
2739
+ } else if (!XdsAggregateAndLogicalDnsClusterEnabled()) {
2740
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2741
+ absl::StrCat(cluster_name, ": DiscoveryType is not valid.").c_str()));
2742
+ resource_names_failed->insert(cluster_name);
2743
+ continue;
2744
+ } else if (envoy_config_cluster_v3_Cluster_type(cluster) ==
2745
+ envoy_config_cluster_v3_Cluster_LOGICAL_DNS) {
2746
+ cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::LOGICAL_DNS;
2747
+ } else {
2748
+ if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
2749
+ const envoy_config_cluster_v3_Cluster_CustomClusterType*
2750
+ custom_cluster_type =
2751
+ envoy_config_cluster_v3_Cluster_cluster_type(cluster);
2752
+ upb_strview type_name =
2753
+ envoy_config_cluster_v3_Cluster_CustomClusterType_name(
2754
+ custom_cluster_type);
2755
+ if (UpbStringToAbsl(type_name) == "envoy.clusters.aggregate") {
2756
+ cds_update.cluster_type = XdsApi::CdsUpdate::ClusterType::AGGREGATE;
2757
+ // Retrieve aggregate clusters.
2758
+ const google_protobuf_Any* typed_config =
2759
+ envoy_config_cluster_v3_Cluster_CustomClusterType_typed_config(
2760
+ custom_cluster_type);
2761
+ const upb_strview aggregate_cluster_config_upb_strview =
2762
+ google_protobuf_Any_value(typed_config);
2763
+ const envoy_extensions_clusters_aggregate_v3_ClusterConfig*
2764
+ aggregate_cluster_config =
2765
+ envoy_extensions_clusters_aggregate_v3_ClusterConfig_parse(
2766
+ aggregate_cluster_config_upb_strview.data,
2767
+ aggregate_cluster_config_upb_strview.size, context.arena);
2768
+ if (aggregate_cluster_config == nullptr) {
2769
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2770
+ absl::StrCat(cluster_name, ": Can't parse aggregate cluster.")
2771
+ .c_str()));
2772
+ resource_names_failed->insert(cluster_name);
2773
+ continue;
2774
+ }
2775
+ size_t size;
2776
+ const upb_strview* clusters =
2777
+ envoy_extensions_clusters_aggregate_v3_ClusterConfig_clusters(
2778
+ aggregate_cluster_config, &size);
2779
+ for (size_t i = 0; i < size; ++i) {
2780
+ const upb_strview cluster = clusters[i];
2781
+ cds_update.prioritized_cluster_names.emplace_back(
2782
+ UpbStringToStdString(cluster));
2783
+ }
2784
+ } else {
2785
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2786
+ absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
2787
+ .c_str()));
2788
+ resource_names_failed->insert(cluster_name);
2789
+ continue;
2790
+ }
2791
+ } else {
2792
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2793
+ absl::StrCat(cluster_name, ": DiscoveryType is not valid.")
2794
+ .c_str()));
2795
+ resource_names_failed->insert(cluster_name);
2796
+ continue;
2797
+ }
1952
2798
  }
1953
2799
  // Check the LB policy.
1954
- if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) !=
2800
+ if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
1955
2801
  envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
1956
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1957
- "LB policy is not ROUND_ROBIN.");
2802
+ cds_update.lb_policy = "ROUND_ROBIN";
2803
+ } else if (XdsRingHashEnabled() &&
2804
+ envoy_config_cluster_v3_Cluster_lb_policy(cluster) ==
2805
+ envoy_config_cluster_v3_Cluster_RING_HASH) {
2806
+ cds_update.lb_policy = "RING_HASH";
2807
+ // Record ring hash lb config
2808
+ auto* ring_hash_config =
2809
+ envoy_config_cluster_v3_Cluster_ring_hash_lb_config(cluster);
2810
+ if (ring_hash_config == nullptr) {
2811
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2812
+ absl::StrCat(cluster_name,
2813
+ ": ring hash lb config required but not present.")
2814
+ .c_str()));
2815
+ resource_names_failed->insert(cluster_name);
2816
+ continue;
2817
+ }
2818
+ const google_protobuf_UInt64Value* max_ring_size =
2819
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_maximum_ring_size(
2820
+ ring_hash_config);
2821
+ if (max_ring_size != nullptr) {
2822
+ cds_update.max_ring_size =
2823
+ google_protobuf_UInt64Value_value(max_ring_size);
2824
+ if (cds_update.max_ring_size > 8388608 ||
2825
+ cds_update.max_ring_size == 0) {
2826
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2827
+ absl::StrCat(
2828
+ cluster_name,
2829
+ ": max_ring_size is not in the range of 1 to 8388608.")
2830
+ .c_str()));
2831
+ resource_names_failed->insert(cluster_name);
2832
+ continue;
2833
+ }
2834
+ }
2835
+ const google_protobuf_UInt64Value* min_ring_size =
2836
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_minimum_ring_size(
2837
+ ring_hash_config);
2838
+ if (min_ring_size != nullptr) {
2839
+ cds_update.min_ring_size =
2840
+ google_protobuf_UInt64Value_value(min_ring_size);
2841
+ if (cds_update.min_ring_size > 8388608 ||
2842
+ cds_update.min_ring_size == 0) {
2843
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2844
+ absl::StrCat(
2845
+ cluster_name,
2846
+ ": min_ring_size is not in the range of 1 to 8388608.")
2847
+ .c_str()));
2848
+ resource_names_failed->insert(cluster_name);
2849
+ continue;
2850
+ }
2851
+ if (cds_update.min_ring_size > cds_update.max_ring_size) {
2852
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2853
+ absl::StrCat(
2854
+ cluster_name,
2855
+ ": min_ring_size cannot be greater than max_ring_size.")
2856
+ .c_str()));
2857
+ resource_names_failed->insert(cluster_name);
2858
+ continue;
2859
+ }
2860
+ }
2861
+ if (envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
2862
+ ring_hash_config) ==
2863
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_XX_HASH) {
2864
+ cds_update.hash_function = XdsApi::CdsUpdate::HashFunction::XX_HASH;
2865
+ } else if (
2866
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_hash_function(
2867
+ ring_hash_config) ==
2868
+ envoy_config_cluster_v3_Cluster_RingHashLbConfig_MURMUR_HASH_2) {
2869
+ cds_update.hash_function =
2870
+ XdsApi::CdsUpdate::HashFunction::MURMUR_HASH_2;
2871
+ } else {
2872
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2873
+ absl::StrCat(cluster_name,
2874
+ ": ring hash lb config has invalid hash function.")
2875
+ .c_str()));
2876
+ resource_names_failed->insert(cluster_name);
2877
+ continue;
2878
+ }
2879
+ } else {
2880
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2881
+ absl::StrCat(cluster_name, ": LB policy is not supported.").c_str()));
2882
+ resource_names_failed->insert(cluster_name);
2883
+ continue;
1958
2884
  }
1959
- // Record Upstream tls context
1960
- auto* transport_socket =
1961
- envoy_config_cluster_v3_Cluster_transport_socket(cluster);
1962
- if (transport_socket != nullptr) {
1963
- absl::string_view name = UpbStringToAbsl(
1964
- envoy_config_core_v3_TransportSocket_name(transport_socket));
1965
- if (name == "tls") {
1966
- auto* typed_config =
1967
- envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
1968
- if (typed_config != nullptr) {
1969
- const upb_strview encoded_upstream_tls_context =
1970
- google_protobuf_Any_value(typed_config);
1971
- auto* upstream_tls_context =
1972
- envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
1973
- encoded_upstream_tls_context.data,
1974
- encoded_upstream_tls_context.size, arena);
1975
- if (upstream_tls_context == nullptr) {
1976
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1977
- "Can't decode upstream tls context.");
2885
+ if (XdsSecurityEnabled()) {
2886
+ // Record Upstream tls context
2887
+ auto* transport_socket =
2888
+ envoy_config_cluster_v3_Cluster_transport_socket(cluster);
2889
+ if (transport_socket != nullptr) {
2890
+ absl::string_view name = UpbStringToAbsl(
2891
+ envoy_config_core_v3_TransportSocket_name(transport_socket));
2892
+ if (name == "envoy.transport_sockets.tls") {
2893
+ auto* typed_config =
2894
+ envoy_config_core_v3_TransportSocket_typed_config(
2895
+ transport_socket);
2896
+ if (typed_config != nullptr) {
2897
+ const upb_strview encoded_upstream_tls_context =
2898
+ google_protobuf_Any_value(typed_config);
2899
+ auto* upstream_tls_context =
2900
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
2901
+ encoded_upstream_tls_context.data,
2902
+ encoded_upstream_tls_context.size, context.arena);
2903
+ if (upstream_tls_context == nullptr) {
2904
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2905
+ absl::StrCat(cluster_name,
2906
+ ": Can't decode upstream tls context.")
2907
+ .c_str()));
2908
+ resource_names_failed->insert(cluster_name);
2909
+ continue;
2910
+ }
2911
+ auto* common_tls_context =
2912
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
2913
+ upstream_tls_context);
2914
+ if (common_tls_context != nullptr) {
2915
+ grpc_error* error = CommonTlsContextParse(
2916
+ common_tls_context, &cds_update.common_tls_context);
2917
+ if (error != GRPC_ERROR_NONE) {
2918
+ errors.push_back(grpc_error_add_child(
2919
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2920
+ absl::StrCat(cluster_name, ": error in TLS context")
2921
+ .c_str()),
2922
+ error));
2923
+ resource_names_failed->insert(cluster_name);
2924
+ continue;
2925
+ }
2926
+ }
1978
2927
  }
1979
- auto* common_tls_context =
1980
- envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
1981
- upstream_tls_context);
1982
- if (common_tls_context != nullptr) {
1983
- grpc_error* error = CommonTlsContextParse(
1984
- common_tls_context, &cds_update.common_tls_context);
1985
- if (error != GRPC_ERROR_NONE) return error;
2928
+ if (cds_update.common_tls_context.combined_validation_context
2929
+ .validation_context_certificate_provider_instance
2930
+ .instance_name.empty()) {
2931
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2932
+ absl::StrCat(cluster_name,
2933
+ "TLS configuration provided but no "
2934
+ "validation_context_certificate_provider_instance "
2935
+ "found.")
2936
+ .c_str()));
2937
+ resource_names_failed->insert(cluster_name);
2938
+ continue;
1986
2939
  }
1987
2940
  }
1988
2941
  }
@@ -1992,8 +2945,11 @@ grpc_error* CdsResponseParse(
1992
2945
  envoy_config_cluster_v3_Cluster_lrs_server(cluster);
1993
2946
  if (lrs_server != nullptr) {
1994
2947
  if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
1995
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1996
- "LRS ConfigSource is not self.");
2948
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2949
+ absl::StrCat(cluster_name, ": LRS ConfigSource is not self.")
2950
+ .c_str()));
2951
+ resource_names_failed->insert(cluster_name);
2952
+ continue;
1997
2953
  }
1998
2954
  cds_update.lrs_load_reporting_server_name.emplace("");
1999
2955
  }
@@ -2024,7 +2980,7 @@ grpc_error* CdsResponseParse(
2024
2980
  }
2025
2981
  }
2026
2982
  }
2027
- return GRPC_ERROR_NONE;
2983
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing CDS response", &errors);
2028
2984
  }
2029
2985
 
2030
2986
  grpc_error* ServerAddressParseAndAppend(
@@ -2052,7 +3008,9 @@ grpc_error* ServerAddressParseAndAppend(
2052
3008
  }
2053
3009
  // Populate grpc_resolved_address.
2054
3010
  grpc_resolved_address addr;
2055
- grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
3011
+ grpc_error* error =
3012
+ grpc_string_to_sockaddr_new(&addr, address_str.c_str(), port);
3013
+ if (error != GRPC_ERROR_NONE) return error;
2056
3014
  // Append the address to the list.
2057
3015
  list->emplace_back(addr, nullptr);
2058
3016
  return GRPC_ERROR_NONE;
@@ -2075,6 +3033,9 @@ grpc_error* LocalityParse(
2075
3033
  const envoy_config_core_v3_Locality* locality =
2076
3034
  envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
2077
3035
  locality_lb_endpoints);
3036
+ if (locality == nullptr) {
3037
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty locality.");
3038
+ }
2078
3039
  std::string region =
2079
3040
  UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
2080
3041
  std::string zone =
@@ -2107,7 +3068,7 @@ grpc_error* DropParseAndAppend(
2107
3068
  std::string category = UpbStringToStdString(
2108
3069
  envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
2109
3070
  drop_overload));
2110
- if (category.size() == 0) {
3071
+ if (category.empty()) {
2111
3072
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
2112
3073
  }
2113
3074
  // Get the drop rate (per million).
@@ -2139,10 +3100,12 @@ grpc_error* DropParseAndAppend(
2139
3100
  }
2140
3101
 
2141
3102
  grpc_error* EdsResponseParse(
2142
- XdsClient* client, TraceFlag* tracer,
3103
+ const EncodingContext& context,
2143
3104
  const envoy_service_discovery_v3_DiscoveryResponse* response,
2144
3105
  const std::set<absl::string_view>& expected_eds_service_names,
2145
- XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
3106
+ XdsApi::EdsUpdateMap* eds_update_map,
3107
+ std::set<std::string>* resource_names_failed) {
3108
+ std::vector<grpc_error*> errors;
2146
3109
  // Get the resources from the response.
2147
3110
  size_t size;
2148
3111
  const google_protobuf_Any* const* resources =
@@ -2152,7 +3115,10 @@ grpc_error* EdsResponseParse(
2152
3115
  absl::string_view type_url =
2153
3116
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
2154
3117
  if (!IsEds(type_url)) {
2155
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not EDS.");
3118
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3119
+ absl::StrCat("resource index ", i, ": Resource is not EDS.")
3120
+ .c_str()));
3121
+ continue;
2156
3122
  }
2157
3123
  // Get the cluster_load_assignment.
2158
3124
  upb_strview encoded_cluster_load_assignment =
@@ -2160,12 +3126,15 @@ grpc_error* EdsResponseParse(
2160
3126
  envoy_config_endpoint_v3_ClusterLoadAssignment* cluster_load_assignment =
2161
3127
  envoy_config_endpoint_v3_ClusterLoadAssignment_parse(
2162
3128
  encoded_cluster_load_assignment.data,
2163
- encoded_cluster_load_assignment.size, arena);
3129
+ encoded_cluster_load_assignment.size, context.arena);
2164
3130
  if (cluster_load_assignment == nullptr) {
2165
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2166
- "Can't parse cluster_load_assignment.");
3131
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3132
+ absl::StrCat("resource index ", i,
3133
+ ": Can't parse cluster_load_assignment.")
3134
+ .c_str()));
3135
+ continue;
2167
3136
  }
2168
- MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
3137
+ MaybeLogClusterLoadAssignment(context, cluster_load_assignment);
2169
3138
  // Check the EDS service name. Ignore unexpected names.
2170
3139
  std::string eds_service_name = UpbStringToStdString(
2171
3140
  envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
@@ -2176,22 +3145,29 @@ grpc_error* EdsResponseParse(
2176
3145
  }
2177
3146
  // Fail on duplicate resources.
2178
3147
  if (eds_update_map->find(eds_service_name) != eds_update_map->end()) {
2179
- return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3148
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
2180
3149
  absl::StrCat("duplicate resource name \"", eds_service_name, "\"")
2181
- .c_str());
3150
+ .c_str()));
3151
+ resource_names_failed->insert(eds_service_name);
3152
+ continue;
2182
3153
  }
2183
- XdsApi::EdsUpdate& eds_update =
2184
- (*eds_update_map)[std::move(eds_service_name)];
3154
+ // Serialize into JSON and store it in the EdsUpdateMap
3155
+ XdsApi::EdsResourceData& eds_resource_data =
3156
+ (*eds_update_map)[eds_service_name];
3157
+ XdsApi::EdsUpdate& eds_update = eds_resource_data.resource;
3158
+ eds_resource_data.serialized_proto =
3159
+ UpbStringToStdString(encoded_cluster_load_assignment);
2185
3160
  // Get the endpoints.
2186
3161
  size_t locality_size;
2187
3162
  const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
2188
3163
  envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
2189
3164
  cluster_load_assignment, &locality_size);
3165
+ grpc_error* error = GRPC_ERROR_NONE;
2190
3166
  for (size_t j = 0; j < locality_size; ++j) {
2191
3167
  size_t priority;
2192
3168
  XdsApi::EdsUpdate::Priority::Locality locality;
2193
- grpc_error* error = LocalityParse(endpoints[j], &locality, &priority);
2194
- if (error != GRPC_ERROR_NONE) return error;
3169
+ error = LocalityParse(endpoints[j], &locality, &priority);
3170
+ if (error != GRPC_ERROR_NONE) break;
2195
3171
  // Filter out locality with weight 0.
2196
3172
  if (locality.lb_weight == 0) continue;
2197
3173
  // Make sure prorities is big enough. Note that they might not
@@ -2202,10 +3178,21 @@ grpc_error* EdsResponseParse(
2202
3178
  eds_update.priorities[priority].localities.emplace(locality.name.get(),
2203
3179
  std::move(locality));
2204
3180
  }
3181
+ if (error != GRPC_ERROR_NONE) {
3182
+ errors.push_back(grpc_error_add_child(
3183
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3184
+ absl::StrCat(eds_service_name, ": locality validation error")
3185
+ .c_str()),
3186
+ error));
3187
+ resource_names_failed->insert(eds_service_name);
3188
+ continue;
3189
+ }
2205
3190
  for (const auto& priority : eds_update.priorities) {
2206
3191
  if (priority.localities.empty()) {
2207
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2208
- "EDS update includes sparse priority list");
3192
+ errors.push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3193
+ absl::StrCat(eds_service_name, ": sparse priority list").c_str()));
3194
+ resource_names_failed->insert(eds_service_name);
3195
+ continue;
2209
3196
  }
2210
3197
  }
2211
3198
  // Get the drop config.
@@ -2220,13 +3207,22 @@ grpc_error* EdsResponseParse(
2220
3207
  envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
2221
3208
  policy, &drop_size);
2222
3209
  for (size_t j = 0; j < drop_size; ++j) {
2223
- grpc_error* error =
3210
+ error =
2224
3211
  DropParseAndAppend(drop_overload[j], eds_update.drop_config.get());
2225
- if (error != GRPC_ERROR_NONE) return error;
3212
+ if (error != GRPC_ERROR_NONE) break;
3213
+ }
3214
+ if (error != GRPC_ERROR_NONE) {
3215
+ errors.push_back(grpc_error_add_child(
3216
+ GRPC_ERROR_CREATE_FROM_COPIED_STRING(
3217
+ absl::StrCat(eds_service_name, ": drop config validation error")
3218
+ .c_str()),
3219
+ error));
3220
+ resource_names_failed->insert(eds_service_name);
3221
+ continue;
2226
3222
  }
2227
3223
  }
2228
3224
  }
2229
- return GRPC_ERROR_NONE;
3225
+ return GRPC_ERROR_CREATE_FROM_VECTOR("errors parsing EDS response", &errors);
2230
3226
  }
2231
3227
 
2232
3228
  std::string TypeUrlInternalToExternal(absl::string_view type_url) {
@@ -2242,16 +3238,27 @@ std::string TypeUrlInternalToExternal(absl::string_view type_url) {
2242
3238
  return std::string(type_url);
2243
3239
  }
2244
3240
 
3241
+ template <typename UpdateMap>
3242
+ void MoveUpdatesToFailedSet(UpdateMap* update_map,
3243
+ std::set<std::string>* resource_names_failed) {
3244
+ for (const auto& p : *update_map) {
3245
+ resource_names_failed->insert(p.first);
3246
+ }
3247
+ update_map->clear();
3248
+ }
3249
+
2245
3250
  } // namespace
2246
3251
 
2247
3252
  XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2248
- const grpc_slice& encoded_response,
3253
+ const XdsBootstrap::XdsServer& server, const grpc_slice& encoded_response,
2249
3254
  const std::set<absl::string_view>& expected_listener_names,
2250
3255
  const std::set<absl::string_view>& expected_route_configuration_names,
2251
3256
  const std::set<absl::string_view>& expected_cluster_names,
2252
3257
  const std::set<absl::string_view>& expected_eds_service_names) {
2253
3258
  AdsParseResult result;
2254
3259
  upb::Arena arena;
3260
+ const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
3261
+ server.ShouldUseV3()};
2255
3262
  // Decode the response.
2256
3263
  const envoy_service_discovery_v3_DiscoveryResponse* response =
2257
3264
  envoy_service_discovery_v3_DiscoveryResponse_parse(
@@ -2263,7 +3270,7 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2263
3270
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
2264
3271
  return result;
2265
3272
  }
2266
- MaybeLogDiscoveryResponse(client_, tracer_, response);
3273
+ MaybeLogDiscoveryResponse(context, response);
2267
3274
  // Record the type_url, the version_info, and the nonce of the response.
2268
3275
  result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
2269
3276
  envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
@@ -2274,20 +3281,36 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2274
3281
  // Parse the response according to the resource type.
2275
3282
  if (IsLds(result.type_url)) {
2276
3283
  result.parse_error =
2277
- LdsResponseParse(client_, tracer_, response, expected_listener_names,
2278
- &result.lds_update_map, arena.ptr());
3284
+ LdsResponseParse(context, response, expected_listener_names,
3285
+ &result.lds_update_map, &result.resource_names_failed);
3286
+ if (result.parse_error != GRPC_ERROR_NONE) {
3287
+ MoveUpdatesToFailedSet(&result.lds_update_map,
3288
+ &result.resource_names_failed);
3289
+ }
2279
3290
  } else if (IsRds(result.type_url)) {
2280
- result.parse_error = RdsResponseParse(client_, tracer_, response,
2281
- expected_route_configuration_names,
2282
- &result.rds_update_map, arena.ptr());
3291
+ result.parse_error =
3292
+ RdsResponseParse(context, response, expected_route_configuration_names,
3293
+ &result.rds_update_map, &result.resource_names_failed);
3294
+ if (result.parse_error != GRPC_ERROR_NONE) {
3295
+ MoveUpdatesToFailedSet(&result.rds_update_map,
3296
+ &result.resource_names_failed);
3297
+ }
2283
3298
  } else if (IsCds(result.type_url)) {
2284
3299
  result.parse_error =
2285
- CdsResponseParse(client_, tracer_, response, expected_cluster_names,
2286
- &result.cds_update_map, arena.ptr());
3300
+ CdsResponseParse(context, response, expected_cluster_names,
3301
+ &result.cds_update_map, &result.resource_names_failed);
3302
+ if (result.parse_error != GRPC_ERROR_NONE) {
3303
+ MoveUpdatesToFailedSet(&result.cds_update_map,
3304
+ &result.resource_names_failed);
3305
+ }
2287
3306
  } else if (IsEds(result.type_url)) {
2288
3307
  result.parse_error =
2289
- EdsResponseParse(client_, tracer_, response, expected_eds_service_names,
2290
- &result.eds_update_map, arena.ptr());
3308
+ EdsResponseParse(context, response, expected_eds_service_names,
3309
+ &result.eds_update_map, &result.resource_names_failed);
3310
+ if (result.parse_error != GRPC_ERROR_NONE) {
3311
+ MoveUpdatesToFailedSet(&result.eds_update_map,
3312
+ &result.resource_names_failed);
3313
+ }
2291
3314
  }
2292
3315
  return result;
2293
3316
  }
@@ -2295,136 +3318,35 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2295
3318
  namespace {
2296
3319
 
2297
3320
  void MaybeLogLrsRequest(
2298
- XdsClient* client, TraceFlag* tracer,
2299
- const envoy_service_load_stats_v3_LoadStatsRequest* request,
2300
- const std::string& build_version) {
2301
- if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
3321
+ const EncodingContext& context,
3322
+ const envoy_service_load_stats_v3_LoadStatsRequest* request) {
3323
+ if (GRPC_TRACE_FLAG_ENABLED(*context.tracer) &&
2302
3324
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
2303
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
2304
- // the raw proto instead of doing this manually.
2305
- std::vector<std::string> fields;
2306
- // node
2307
- const auto* node =
2308
- envoy_service_load_stats_v3_LoadStatsRequest_node(request);
2309
- if (node != nullptr) {
2310
- AddNodeLogFields(node, build_version, &fields);
2311
- }
2312
- // cluster_stats
2313
- size_t num_cluster_stats;
2314
- const struct envoy_config_endpoint_v3_ClusterStats* const* cluster_stats =
2315
- envoy_service_load_stats_v3_LoadStatsRequest_cluster_stats(
2316
- request, &num_cluster_stats);
2317
- for (size_t i = 0; i < num_cluster_stats; ++i) {
2318
- const auto* cluster_stat = cluster_stats[i];
2319
- fields.emplace_back("cluster_stats {");
2320
- // cluster_name
2321
- AddStringField(
2322
- " cluster_name",
2323
- envoy_config_endpoint_v3_ClusterStats_cluster_name(cluster_stat),
2324
- &fields);
2325
- // cluster_service_name
2326
- AddStringField(" cluster_service_name",
2327
- envoy_config_endpoint_v3_ClusterStats_cluster_service_name(
2328
- cluster_stat),
2329
- &fields);
2330
- // upstream_locality_stats
2331
- size_t num_stats;
2332
- const envoy_config_endpoint_v3_UpstreamLocalityStats* const* stats =
2333
- envoy_config_endpoint_v3_ClusterStats_upstream_locality_stats(
2334
- cluster_stat, &num_stats);
2335
- for (size_t j = 0; j < num_stats; ++j) {
2336
- const auto* stat = stats[j];
2337
- fields.emplace_back(" upstream_locality_stats {");
2338
- // locality
2339
- const auto* locality =
2340
- envoy_config_endpoint_v3_UpstreamLocalityStats_locality(stat);
2341
- if (locality != nullptr) {
2342
- fields.emplace_back(" locality {");
2343
- AddLocalityField(3, locality, &fields);
2344
- fields.emplace_back(" }");
2345
- }
2346
- // total_successful_requests
2347
- fields.emplace_back(absl::StrCat(
2348
- " total_successful_requests: ",
2349
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_successful_requests(
2350
- stat)));
2351
- // total_requests_in_progress
2352
- fields.emplace_back(absl::StrCat(
2353
- " total_requests_in_progress: ",
2354
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_requests_in_progress(
2355
- stat)));
2356
- // total_error_requests
2357
- fields.emplace_back(absl::StrCat(
2358
- " total_error_requests: ",
2359
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_error_requests(
2360
- stat)));
2361
- // total_issued_requests
2362
- fields.emplace_back(absl::StrCat(
2363
- " total_issued_requests: ",
2364
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_issued_requests(
2365
- stat)));
2366
- fields.emplace_back(" }");
2367
- }
2368
- // total_dropped_requests
2369
- fields.emplace_back(absl::StrCat(
2370
- " total_dropped_requests: ",
2371
- envoy_config_endpoint_v3_ClusterStats_total_dropped_requests(
2372
- cluster_stat)));
2373
- // dropped_requests
2374
- size_t num_drops;
2375
- const envoy_config_endpoint_v3_ClusterStats_DroppedRequests* const*
2376
- drops = envoy_config_endpoint_v3_ClusterStats_dropped_requests(
2377
- cluster_stat, &num_drops);
2378
- for (size_t j = 0; j < num_drops; ++j) {
2379
- const auto* drop = drops[j];
2380
- fields.emplace_back(" dropped_requests {");
2381
- // category
2382
- AddStringField(
2383
- " category",
2384
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_category(
2385
- drop),
2386
- &fields);
2387
- // dropped_count
2388
- fields.emplace_back(absl::StrCat(
2389
- " dropped_count: ",
2390
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_dropped_count(
2391
- drop)));
2392
- fields.emplace_back(" }");
2393
- }
2394
- // load_report_interval
2395
- const auto* load_report_interval =
2396
- envoy_config_endpoint_v3_ClusterStats_load_report_interval(
2397
- cluster_stat);
2398
- if (load_report_interval != nullptr) {
2399
- fields.emplace_back(" load_report_interval {");
2400
- fields.emplace_back(absl::StrCat(
2401
- " seconds: ",
2402
- google_protobuf_Duration_seconds(load_report_interval)));
2403
- fields.emplace_back(
2404
- absl::StrCat(" nanos: ",
2405
- google_protobuf_Duration_nanos(load_report_interval)));
2406
- fields.emplace_back(" }");
2407
- }
2408
- fields.emplace_back("}");
2409
- }
2410
- gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s", client,
2411
- absl::StrJoin(fields, "\n").c_str());
3325
+ const upb_msgdef* msg_type =
3326
+ envoy_service_load_stats_v3_LoadStatsRequest_getmsgdef(context.symtab);
3327
+ char buf[10240];
3328
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
3329
+ gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s",
3330
+ context.client, buf);
2412
3331
  }
2413
3332
  }
2414
3333
 
2415
3334
  grpc_slice SerializeLrsRequest(
2416
- const envoy_service_load_stats_v3_LoadStatsRequest* request,
2417
- upb_arena* arena) {
3335
+ const EncodingContext& context,
3336
+ const envoy_service_load_stats_v3_LoadStatsRequest* request) {
2418
3337
  size_t output_length;
2419
3338
  char* output = envoy_service_load_stats_v3_LoadStatsRequest_serialize(
2420
- request, arena, &output_length);
3339
+ request, context.arena, &output_length);
2421
3340
  return grpc_slice_from_copied_buffer(output, output_length);
2422
3341
  }
2423
3342
 
2424
3343
  } // namespace
2425
3344
 
2426
- grpc_slice XdsApi::CreateLrsInitialRequest() {
3345
+ grpc_slice XdsApi::CreateLrsInitialRequest(
3346
+ const XdsBootstrap::XdsServer& server) {
2427
3347
  upb::Arena arena;
3348
+ const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
3349
+ server.ShouldUseV3()};
2428
3350
  // Create a request.
2429
3351
  envoy_service_load_stats_v3_LoadStatsRequest* request =
2430
3352
  envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
@@ -2432,25 +3354,25 @@ grpc_slice XdsApi::CreateLrsInitialRequest() {
2432
3354
  envoy_config_core_v3_Node* node_msg =
2433
3355
  envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
2434
3356
  arena.ptr());
2435
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
2436
- node_msg);
3357
+ PopulateNode(context, node_, build_version_, user_agent_name_, node_msg);
2437
3358
  envoy_config_core_v3_Node_add_client_features(
2438
3359
  node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
2439
3360
  arena.ptr());
2440
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2441
- return SerializeLrsRequest(request, arena.ptr());
3361
+ MaybeLogLrsRequest(context, request);
3362
+ return SerializeLrsRequest(context, request);
2442
3363
  }
2443
3364
 
2444
3365
  namespace {
2445
3366
 
2446
3367
  void LocalityStatsPopulate(
3368
+ const EncodingContext& context,
2447
3369
  envoy_config_endpoint_v3_UpstreamLocalityStats* output,
2448
3370
  const XdsLocalityName& locality_name,
2449
- const XdsClusterLocalityStats::Snapshot& snapshot, upb_arena* arena) {
3371
+ const XdsClusterLocalityStats::Snapshot& snapshot) {
2450
3372
  // Set locality.
2451
3373
  envoy_config_core_v3_Locality* locality =
2452
- envoy_config_endpoint_v3_UpstreamLocalityStats_mutable_locality(output,
2453
- arena);
3374
+ envoy_config_endpoint_v3_UpstreamLocalityStats_mutable_locality(
3375
+ output, context.arena);
2454
3376
  if (!locality_name.region().empty()) {
2455
3377
  envoy_config_core_v3_Locality_set_region(
2456
3378
  locality, StdStringToUpbString(locality_name.region()));
@@ -2478,7 +3400,7 @@ void LocalityStatsPopulate(
2478
3400
  const XdsClusterLocalityStats::BackendMetric& metric_value = p.second;
2479
3401
  envoy_config_endpoint_v3_EndpointLoadMetricStats* load_metric =
2480
3402
  envoy_config_endpoint_v3_UpstreamLocalityStats_add_load_metric_stats(
2481
- output, arena);
3403
+ output, context.arena);
2482
3404
  envoy_config_endpoint_v3_EndpointLoadMetricStats_set_metric_name(
2483
3405
  load_metric, StdStringToUpbString(metric_name));
2484
3406
  envoy_config_endpoint_v3_EndpointLoadMetricStats_set_num_requests_finished_with_metric(
@@ -2493,6 +3415,8 @@ void LocalityStatsPopulate(
2493
3415
  grpc_slice XdsApi::CreateLrsRequest(
2494
3416
  ClusterLoadReportMap cluster_load_report_map) {
2495
3417
  upb::Arena arena;
3418
+ const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
3419
+ false};
2496
3420
  // Create a request.
2497
3421
  envoy_service_load_stats_v3_LoadStatsRequest* request =
2498
3422
  envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
@@ -2519,8 +3443,7 @@ grpc_slice XdsApi::CreateLrsRequest(
2519
3443
  envoy_config_endpoint_v3_UpstreamLocalityStats* locality_stats =
2520
3444
  envoy_config_endpoint_v3_ClusterStats_add_upstream_locality_stats(
2521
3445
  cluster_stats, arena.ptr());
2522
- LocalityStatsPopulate(locality_stats, locality_name, snapshot,
2523
- arena.ptr());
3446
+ LocalityStatsPopulate(context, locality_stats, locality_name, snapshot);
2524
3447
  }
2525
3448
  // Add dropped requests.
2526
3449
  uint64_t total_dropped_requests = 0;
@@ -2549,8 +3472,8 @@ grpc_slice XdsApi::CreateLrsRequest(
2549
3472
  google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
2550
3473
  google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
2551
3474
  }
2552
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2553
- return SerializeLrsRequest(request, arena.ptr());
3475
+ MaybeLogLrsRequest(context, request);
3476
+ return SerializeLrsRequest(context, request);
2554
3477
  }
2555
3478
 
2556
3479
  grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
@@ -2593,4 +3516,276 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
2593
3516
  return GRPC_ERROR_NONE;
2594
3517
  }
2595
3518
 
3519
+ namespace {
3520
+ google_protobuf_Timestamp* GrpcMillisToTimestamp(const EncodingContext& context,
3521
+ grpc_millis value) {
3522
+ google_protobuf_Timestamp* timestamp =
3523
+ google_protobuf_Timestamp_new(context.arena);
3524
+ gpr_timespec timespec = grpc_millis_to_timespec(value, GPR_CLOCK_MONOTONIC);
3525
+ google_protobuf_Timestamp_set_seconds(timestamp, timespec.tv_sec);
3526
+ google_protobuf_Timestamp_set_nanos(timestamp, timespec.tv_nsec);
3527
+ return timestamp;
3528
+ }
3529
+
3530
+ envoy_admin_v3_UpdateFailureState* CreateUpdateFailureStateUpb(
3531
+ const EncodingContext& context,
3532
+ const XdsApi::ResourceMetadata* resource_metadata) {
3533
+ auto* update_failure_state =
3534
+ envoy_admin_v3_UpdateFailureState_new(context.arena);
3535
+ envoy_admin_v3_UpdateFailureState_set_details(
3536
+ update_failure_state,
3537
+ StdStringToUpbString(resource_metadata->failed_details));
3538
+ envoy_admin_v3_UpdateFailureState_set_version_info(
3539
+ update_failure_state,
3540
+ StdStringToUpbString(resource_metadata->failed_version));
3541
+ envoy_admin_v3_UpdateFailureState_set_last_update_attempt(
3542
+ update_failure_state,
3543
+ GrpcMillisToTimestamp(context, resource_metadata->failed_update_time));
3544
+ return update_failure_state;
3545
+ }
3546
+
3547
+ void DumpLdsConfig(const EncodingContext& context,
3548
+ const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3549
+ envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3550
+ upb_strview kLdsTypeUrlUpb = upb_strview_makez(XdsApi::kLdsTypeUrl);
3551
+ auto* listener_config_dump =
3552
+ envoy_service_status_v3_PerXdsConfig_mutable_listener_config(
3553
+ per_xds_config, context.arena);
3554
+ envoy_admin_v3_ListenersConfigDump_set_version_info(
3555
+ listener_config_dump,
3556
+ StdStringToUpbString(resource_type_metadata.version));
3557
+ for (auto& p : resource_type_metadata.resource_metadata_map) {
3558
+ absl::string_view name = p.first;
3559
+ const XdsApi::ResourceMetadata* meta = p.second;
3560
+ const upb_strview name_upb = StdStringToUpbString(name);
3561
+ auto* dynamic_listener =
3562
+ envoy_admin_v3_ListenersConfigDump_add_dynamic_listeners(
3563
+ listener_config_dump, context.arena);
3564
+ envoy_admin_v3_ListenersConfigDump_DynamicListener_set_name(
3565
+ dynamic_listener, name_upb);
3566
+ envoy_admin_v3_ListenersConfigDump_DynamicListener_set_client_status(
3567
+ dynamic_listener, meta->client_status);
3568
+ if (!meta->serialized_proto.empty()) {
3569
+ // Set in-effective listeners
3570
+ auto* dynamic_listener_state =
3571
+ envoy_admin_v3_ListenersConfigDump_DynamicListener_mutable_active_state(
3572
+ dynamic_listener, context.arena);
3573
+ envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_version_info(
3574
+ dynamic_listener_state, StdStringToUpbString(meta->version));
3575
+ envoy_admin_v3_ListenersConfigDump_DynamicListenerState_set_last_updated(
3576
+ dynamic_listener_state,
3577
+ GrpcMillisToTimestamp(context, meta->update_time));
3578
+ auto* listener_any =
3579
+ envoy_admin_v3_ListenersConfigDump_DynamicListenerState_mutable_listener(
3580
+ dynamic_listener_state, context.arena);
3581
+ google_protobuf_Any_set_type_url(listener_any, kLdsTypeUrlUpb);
3582
+ google_protobuf_Any_set_value(
3583
+ listener_any, StdStringToUpbString(meta->serialized_proto));
3584
+ }
3585
+ if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3586
+ // Set error_state if NACKED
3587
+ envoy_admin_v3_ListenersConfigDump_DynamicListener_set_error_state(
3588
+ dynamic_listener, CreateUpdateFailureStateUpb(context, meta));
3589
+ }
3590
+ }
3591
+ }
3592
+
3593
+ void DumpRdsConfig(const EncodingContext& context,
3594
+ const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3595
+ envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3596
+ upb_strview kRdsTypeUrlUpb = upb_strview_makez(XdsApi::kRdsTypeUrl);
3597
+ auto* route_config_dump =
3598
+ envoy_service_status_v3_PerXdsConfig_mutable_route_config(per_xds_config,
3599
+ context.arena);
3600
+ for (auto& p : resource_type_metadata.resource_metadata_map) {
3601
+ absl::string_view name = p.first;
3602
+ const XdsApi::ResourceMetadata* meta = p.second;
3603
+ const upb_strview name_upb = StdStringToUpbString(name);
3604
+ auto* dynamic_route_config =
3605
+ envoy_admin_v3_RoutesConfigDump_add_dynamic_route_configs(
3606
+ route_config_dump, context.arena);
3607
+ envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_client_status(
3608
+ dynamic_route_config, meta->client_status);
3609
+ auto* route_config_any =
3610
+ envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_mutable_route_config(
3611
+ dynamic_route_config, context.arena);
3612
+ if (!meta->serialized_proto.empty()) {
3613
+ // Set in-effective route configs
3614
+ envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_version_info(
3615
+ dynamic_route_config, StdStringToUpbString(meta->version));
3616
+ envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_last_updated(
3617
+ dynamic_route_config,
3618
+ GrpcMillisToTimestamp(context, meta->update_time));
3619
+ google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
3620
+ google_protobuf_Any_set_value(
3621
+ route_config_any, StdStringToUpbString(meta->serialized_proto));
3622
+ } else {
3623
+ // If there isn't a working route config, we still need to print the
3624
+ // name.
3625
+ auto* route_config =
3626
+ envoy_config_route_v3_RouteConfiguration_new(context.arena);
3627
+ envoy_config_route_v3_RouteConfiguration_set_name(route_config, name_upb);
3628
+ size_t length;
3629
+ char* bytes = envoy_config_route_v3_RouteConfiguration_serialize(
3630
+ route_config, context.arena, &length);
3631
+ google_protobuf_Any_set_type_url(route_config_any, kRdsTypeUrlUpb);
3632
+ google_protobuf_Any_set_value(route_config_any,
3633
+ upb_strview_make(bytes, length));
3634
+ }
3635
+ if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3636
+ // Set error_state if NACKED
3637
+ envoy_admin_v3_RoutesConfigDump_DynamicRouteConfig_set_error_state(
3638
+ dynamic_route_config, CreateUpdateFailureStateUpb(context, meta));
3639
+ }
3640
+ }
3641
+ }
3642
+
3643
+ void DumpCdsConfig(const EncodingContext& context,
3644
+ const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3645
+ envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3646
+ upb_strview kCdsTypeUrlUpb = upb_strview_makez(XdsApi::kCdsTypeUrl);
3647
+ auto* cluster_config_dump =
3648
+ envoy_service_status_v3_PerXdsConfig_mutable_cluster_config(
3649
+ per_xds_config, context.arena);
3650
+ envoy_admin_v3_ClustersConfigDump_set_version_info(
3651
+ cluster_config_dump,
3652
+ StdStringToUpbString(resource_type_metadata.version));
3653
+ for (auto& p : resource_type_metadata.resource_metadata_map) {
3654
+ absl::string_view name = p.first;
3655
+ const XdsApi::ResourceMetadata* meta = p.second;
3656
+ const upb_strview name_upb = StdStringToUpbString(name);
3657
+ auto* dynamic_cluster =
3658
+ envoy_admin_v3_ClustersConfigDump_add_dynamic_active_clusters(
3659
+ cluster_config_dump, context.arena);
3660
+ envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_client_status(
3661
+ dynamic_cluster, meta->client_status);
3662
+ auto* cluster_any =
3663
+ envoy_admin_v3_ClustersConfigDump_DynamicCluster_mutable_cluster(
3664
+ dynamic_cluster, context.arena);
3665
+ if (!meta->serialized_proto.empty()) {
3666
+ // Set in-effective clusters
3667
+ envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_version_info(
3668
+ dynamic_cluster, StdStringToUpbString(meta->version));
3669
+ envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_last_updated(
3670
+ dynamic_cluster, GrpcMillisToTimestamp(context, meta->update_time));
3671
+ google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
3672
+ google_protobuf_Any_set_value(
3673
+ cluster_any, StdStringToUpbString(meta->serialized_proto));
3674
+ } else {
3675
+ // If there isn't a working cluster, we still need to print the name.
3676
+ auto* cluster = envoy_config_cluster_v3_Cluster_new(context.arena);
3677
+ envoy_config_cluster_v3_Cluster_set_name(cluster, name_upb);
3678
+ size_t length;
3679
+ char* bytes = envoy_config_cluster_v3_Cluster_serialize(
3680
+ cluster, context.arena, &length);
3681
+ google_protobuf_Any_set_type_url(cluster_any, kCdsTypeUrlUpb);
3682
+ google_protobuf_Any_set_value(cluster_any,
3683
+ upb_strview_make(bytes, length));
3684
+ }
3685
+ if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3686
+ // Set error_state if NACKED
3687
+ envoy_admin_v3_ClustersConfigDump_DynamicCluster_set_error_state(
3688
+ dynamic_cluster, CreateUpdateFailureStateUpb(context, meta));
3689
+ }
3690
+ }
3691
+ }
3692
+
3693
+ void DumpEdsConfig(const EncodingContext& context,
3694
+ const XdsApi::ResourceTypeMetadata& resource_type_metadata,
3695
+ envoy_service_status_v3_PerXdsConfig* per_xds_config) {
3696
+ upb_strview kEdsTypeUrlUpb = upb_strview_makez(XdsApi::kEdsTypeUrl);
3697
+ auto* endpoint_config_dump =
3698
+ envoy_service_status_v3_PerXdsConfig_mutable_endpoint_config(
3699
+ per_xds_config, context.arena);
3700
+ for (auto& p : resource_type_metadata.resource_metadata_map) {
3701
+ absl::string_view name = p.first;
3702
+ const XdsApi::ResourceMetadata* meta = p.second;
3703
+ const upb_strview name_upb = StdStringToUpbString(name);
3704
+ auto* dynamic_endpoint =
3705
+ envoy_admin_v3_EndpointsConfigDump_add_dynamic_endpoint_configs(
3706
+ endpoint_config_dump, context.arena);
3707
+ envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_client_status(
3708
+ dynamic_endpoint, meta->client_status);
3709
+ auto* endpoint_any =
3710
+ envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_mutable_endpoint_config(
3711
+ dynamic_endpoint, context.arena);
3712
+ if (!meta->serialized_proto.empty()) {
3713
+ // Set in-effective endpoints
3714
+ envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_version_info(
3715
+ dynamic_endpoint, StdStringToUpbString(meta->version));
3716
+ envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_last_updated(
3717
+ dynamic_endpoint, GrpcMillisToTimestamp(context, meta->update_time));
3718
+ google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
3719
+ google_protobuf_Any_set_value(
3720
+ endpoint_any, StdStringToUpbString(meta->serialized_proto));
3721
+ } else {
3722
+ // If there isn't a working endpoint, we still need to print the name.
3723
+ auto* cluster_load_assignment =
3724
+ envoy_config_endpoint_v3_ClusterLoadAssignment_new(context.arena);
3725
+ envoy_config_endpoint_v3_ClusterLoadAssignment_set_cluster_name(
3726
+ cluster_load_assignment, name_upb);
3727
+ size_t length;
3728
+ char* bytes = envoy_config_endpoint_v3_ClusterLoadAssignment_serialize(
3729
+ cluster_load_assignment, context.arena, &length);
3730
+ google_protobuf_Any_set_type_url(endpoint_any, kEdsTypeUrlUpb);
3731
+ google_protobuf_Any_set_value(endpoint_any,
3732
+ upb_strview_make(bytes, length));
3733
+ }
3734
+ if (meta->client_status == XdsApi::ResourceMetadata::NACKED) {
3735
+ // Set error_state if NACKED
3736
+ envoy_admin_v3_EndpointsConfigDump_DynamicEndpointConfig_set_error_state(
3737
+ dynamic_endpoint, CreateUpdateFailureStateUpb(context, meta));
3738
+ }
3739
+ }
3740
+ }
3741
+
3742
+ } // namespace
3743
+
3744
+ std::string XdsApi::AssembleClientConfig(
3745
+ const ResourceTypeMetadataMap& resource_type_metadata_map) {
3746
+ upb::Arena arena;
3747
+ // Create the ClientConfig for resource metadata from XdsClient
3748
+ auto* client_config = envoy_service_status_v3_ClientConfig_new(arena.ptr());
3749
+ // Fill-in the node information
3750
+ auto* node = envoy_service_status_v3_ClientConfig_mutable_node(client_config,
3751
+ arena.ptr());
3752
+ const EncodingContext context = {client_, tracer_, symtab_.ptr(), arena.ptr(),
3753
+ true};
3754
+ PopulateNode(context, node_, build_version_, user_agent_name_, node);
3755
+ // Dump each xDS-type config into PerXdsConfig
3756
+ for (auto& p : resource_type_metadata_map) {
3757
+ absl::string_view type_url = p.first;
3758
+ const ResourceTypeMetadata& resource_type_metadata = p.second;
3759
+ if (type_url == kLdsTypeUrl) {
3760
+ auto* per_xds_config =
3761
+ envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
3762
+ context.arena);
3763
+ DumpLdsConfig(context, resource_type_metadata, per_xds_config);
3764
+ } else if (type_url == kRdsTypeUrl) {
3765
+ auto* per_xds_config =
3766
+ envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
3767
+ context.arena);
3768
+ DumpRdsConfig(context, resource_type_metadata, per_xds_config);
3769
+ } else if (type_url == kCdsTypeUrl) {
3770
+ auto* per_xds_config =
3771
+ envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
3772
+ context.arena);
3773
+ DumpCdsConfig(context, resource_type_metadata, per_xds_config);
3774
+ } else if (type_url == kEdsTypeUrl) {
3775
+ auto* per_xds_config =
3776
+ envoy_service_status_v3_ClientConfig_add_xds_config(client_config,
3777
+ context.arena);
3778
+ DumpEdsConfig(context, resource_type_metadata, per_xds_config);
3779
+ } else {
3780
+ gpr_log(GPR_ERROR, "invalid type_url %s", std::string(type_url).c_str());
3781
+ return "";
3782
+ }
3783
+ }
3784
+ // Serialize the upb message to bytes
3785
+ size_t output_length;
3786
+ char* output = envoy_service_status_v3_ClientConfig_serialize(
3787
+ client_config, arena.ptr(), &output_length);
3788
+ return std::string(output, output_length);
3789
+ }
3790
+
2596
3791
  } // namespace grpc_core