grpc 1.31.1 → 1.32.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 (431) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +595 -15723
  3. data/include/grpc/grpc_security.h +31 -14
  4. data/include/grpc/impl/codegen/README.md +22 -0
  5. data/include/grpc/impl/codegen/port_platform.h +6 -1
  6. data/src/core/ext/filters/client_channel/backup_poller.cc +3 -2
  7. data/src/core/ext/filters/client_channel/client_channel.cc +64 -20
  8. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  9. data/src/core/ext/filters/client_channel/client_channel_channelz.h +0 -3
  10. data/src/core/ext/filters/client_channel/health/health_check_client.cc +6 -1
  11. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +2 -3
  12. data/src/core/ext/filters/client_channel/lb_policy.h +2 -0
  13. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +20 -13
  15. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +0 -13
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +0 -3
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +1 -37
  18. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +19 -13
  19. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +29 -10
  20. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -4
  21. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +20 -9
  22. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +18 -12
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +22 -14
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +18 -9
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +54 -56
  26. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +3 -3
  27. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_libuv.cc +1 -1
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +1 -1
  29. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  30. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -1
  31. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +363 -14
  32. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +0 -1
  33. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -4
  34. data/src/core/ext/filters/client_channel/server_address.cc +40 -7
  35. data/src/core/ext/filters/client_channel/server_address.h +42 -4
  36. data/src/core/ext/filters/client_channel/subchannel.cc +64 -23
  37. data/src/core/ext/filters/client_channel/subchannel.h +16 -4
  38. data/src/core/ext/filters/max_age/max_age_filter.cc +2 -1
  39. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +87 -31
  40. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +18 -1
  41. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +10 -35
  42. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +19 -25
  43. data/src/core/ext/transport/chttp2/server/chttp2_server.h +2 -1
  44. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +2 -2
  45. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +6 -6
  46. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +3 -2
  47. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +239 -277
  48. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -1
  49. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
  50. data/src/core/ext/transport/chttp2/transport/internal.h +5 -1
  51. data/src/core/ext/transport/chttp2/transport/parsing.cc +1 -28
  52. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -5
  53. data/src/core/ext/transport/inproc/inproc_transport.cc +12 -12
  54. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +224 -0
  55. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +700 -0
  56. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +74 -0
  57. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +226 -0
  58. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +380 -0
  59. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +1378 -0
  60. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/filter.upb.c +8 -8
  61. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +69 -0
  62. data/src/core/ext/upb-generated/envoy/{api/v2/cluster → config/cluster/v3}/outlier_detection.upb.c +8 -8
  63. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +323 -0
  64. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +112 -0
  65. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +334 -0
  66. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/backoff.upb.c +8 -8
  67. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +79 -0
  68. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +309 -0
  69. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +869 -0
  70. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +96 -0
  71. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +328 -0
  72. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +34 -0
  73. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +71 -0
  74. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +195 -0
  75. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +634 -0
  76. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +170 -0
  77. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +684 -0
  78. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/http_uri.upb.c +8 -8
  79. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +80 -0
  80. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +152 -0
  81. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +536 -0
  82. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +28 -0
  83. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +58 -0
  84. data/src/core/ext/upb-generated/envoy/{api/v2/core → config/core/v3}/socket_option.upb.c +6 -6
  85. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +88 -0
  86. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +91 -0
  87. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +220 -0
  88. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +91 -0
  89. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +273 -0
  90. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +112 -0
  91. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +332 -0
  92. data/src/core/ext/upb-generated/envoy/config/listener/{v2 → v3}/api_listener.upb.c +8 -8
  93. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +65 -0
  94. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +108 -0
  95. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +401 -0
  96. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +138 -0
  97. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +490 -0
  98. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +41 -0
  99. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +94 -0
  100. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +174 -0
  101. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +599 -0
  102. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +63 -0
  103. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +204 -0
  104. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +773 -0
  105. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +2855 -0
  106. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +59 -0
  107. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +135 -0
  108. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +50 -0
  109. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +108 -0
  110. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +312 -0
  111. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +1125 -0
  112. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.c +20 -0
  113. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +34 -0
  114. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +111 -0
  115. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +401 -0
  116. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +72 -0
  117. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +198 -0
  118. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +105 -0
  119. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +388 -0
  120. data/src/core/ext/upb-generated/envoy/{api/v2 → service/cluster/v3}/cds.upb.c +5 -6
  121. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +49 -0
  122. data/src/core/ext/upb-generated/envoy/service/discovery/{v2 → v3}/ads.upb.c +5 -4
  123. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +49 -0
  124. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +129 -0
  125. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +386 -0
  126. data/src/core/ext/upb-generated/envoy/{api/v2 → service/endpoint/v3}/eds.upb.c +5 -6
  127. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +49 -0
  128. data/src/core/ext/upb-generated/envoy/{api/v2 → service/listener/v3}/lds.upb.c +5 -6
  129. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +49 -0
  130. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +55 -0
  131. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +136 -0
  132. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/rds.upb.c +5 -6
  133. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +49 -0
  134. data/src/core/ext/upb-generated/envoy/{api/v2 → service/route/v3}/srds.upb.c +5 -6
  135. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +49 -0
  136. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +47 -0
  137. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +114 -0
  138. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +35 -0
  139. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +77 -0
  140. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +34 -0
  141. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +71 -0
  142. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +64 -0
  143. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +145 -0
  144. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +53 -0
  145. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +127 -0
  146. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +63 -0
  147. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +188 -0
  148. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +88 -0
  149. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +258 -0
  150. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +90 -0
  151. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +250 -0
  152. data/src/core/ext/upb-generated/envoy/type/{http.upb.c → v3/http.upb.c} +2 -2
  153. data/src/core/ext/upb-generated/envoy/type/{http.upb.h → v3/http.upb.h} +8 -8
  154. data/src/core/ext/upb-generated/envoy/type/{percent.upb.c → v3/percent.upb.c} +9 -8
  155. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +86 -0
  156. data/src/core/ext/upb-generated/envoy/type/{range.upb.c → v3/range.upb.c} +12 -11
  157. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +111 -0
  158. data/src/core/ext/upb-generated/envoy/type/{semantic_version.upb.c → v3/semantic_version.upb.c} +6 -5
  159. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +61 -0
  160. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +234 -0
  161. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +759 -0
  162. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +36 -36
  163. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +1 -1
  164. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +27 -0
  165. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +53 -0
  166. data/src/core/ext/upb-generated/validate/validate.upb.c +11 -11
  167. data/src/core/ext/upb-generated/validate/validate.upb.h +1 -1
  168. data/src/core/ext/{filters/client_channel/xds → xds}/xds_api.cc +1045 -767
  169. data/src/core/ext/{filters/client_channel/xds → xds}/xds_api.h +114 -99
  170. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.cc +44 -2
  171. data/src/core/ext/{filters/client_channel/xds → xds}/xds_bootstrap.h +8 -3
  172. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel.h +4 -4
  173. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_args.h +3 -3
  174. data/src/core/ext/{filters/client_channel/xds → xds}/xds_channel_secure.cc +2 -5
  175. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.cc +85 -417
  176. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client.h +12 -45
  177. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.cc +2 -2
  178. data/src/core/ext/{filters/client_channel/xds → xds}/xds_client_stats.h +3 -3
  179. data/src/core/lib/channel/channelz.cc +14 -15
  180. data/src/core/lib/channel/channelz.h +1 -1
  181. data/src/core/lib/channel/channelz_registry.cc +3 -1
  182. data/src/core/lib/gpr/sync_posix.cc +2 -8
  183. data/src/core/lib/iomgr/endpoint.cc +5 -1
  184. data/src/core/lib/iomgr/endpoint.h +7 -3
  185. data/src/core/lib/iomgr/endpoint_cfstream.cc +32 -11
  186. data/src/core/lib/iomgr/ev_posix.cc +0 -2
  187. data/src/core/lib/iomgr/iomgr.cc +0 -10
  188. data/src/core/lib/iomgr/iomgr.h +0 -10
  189. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.cc +1 -1
  190. data/src/core/{ext/filters/client_channel → lib/iomgr}/parse_address.h +3 -3
  191. data/src/core/lib/iomgr/sockaddr_utils.cc +2 -1
  192. data/src/core/lib/iomgr/sockaddr_utils.h +2 -1
  193. data/src/core/lib/iomgr/tcp_custom.cc +32 -16
  194. data/src/core/lib/iomgr/tcp_posix.cc +31 -13
  195. data/src/core/lib/iomgr/tcp_windows.cc +26 -10
  196. data/src/core/lib/security/authorization/authorization_engine.cc +177 -0
  197. data/src/core/lib/security/authorization/authorization_engine.h +84 -0
  198. data/src/core/lib/security/authorization/evaluate_args.cc +153 -0
  199. data/src/core/lib/security/authorization/evaluate_args.h +59 -0
  200. data/src/core/lib/security/authorization/mock_cel/activation.h +57 -0
  201. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +42 -0
  202. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +68 -0
  203. data/src/core/lib/security/authorization/mock_cel/cel_value.h +93 -0
  204. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +67 -0
  205. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +56 -0
  206. data/src/core/lib/security/authorization/mock_cel/statusor.h +50 -0
  207. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +56 -38
  208. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -2
  209. data/src/core/lib/security/transport/secure_endpoint.cc +7 -1
  210. data/src/core/lib/surface/call.cc +12 -12
  211. data/src/core/lib/surface/call.h +2 -1
  212. data/src/core/lib/surface/channel.cc +28 -20
  213. data/src/core/lib/surface/channel.h +12 -2
  214. data/src/core/lib/surface/completion_queue.cc +10 -272
  215. data/src/core/lib/surface/completion_queue.h +0 -8
  216. data/src/core/lib/surface/init.cc +1 -3
  217. data/src/core/lib/surface/server.cc +1066 -1244
  218. data/src/core/lib/surface/server.h +363 -87
  219. data/src/core/lib/surface/version.cc +2 -2
  220. data/src/core/lib/transport/authority_override.cc +38 -0
  221. data/src/core/lib/transport/authority_override.h +32 -0
  222. data/src/core/lib/transport/connectivity_state.cc +18 -13
  223. data/src/core/lib/transport/connectivity_state.h +18 -6
  224. data/src/core/lib/transport/error_utils.cc +13 -0
  225. data/src/core/lib/transport/error_utils.h +6 -0
  226. data/src/core/lib/transport/static_metadata.cc +295 -276
  227. data/src/core/lib/transport/static_metadata.h +80 -73
  228. data/src/core/lib/transport/transport.h +7 -0
  229. data/src/core/lib/uri/uri_parser.cc +23 -21
  230. data/src/core/lib/uri/uri_parser.h +3 -1
  231. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +22 -0
  232. data/src/core/tsi/ssl_transport_security.cc +3 -9
  233. data/src/ruby/ext/grpc/rb_channel_credentials.c +9 -0
  234. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -2
  235. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -4
  236. data/src/ruby/lib/grpc/version.rb +1 -1
  237. data/src/ruby/spec/channel_credentials_spec.rb +10 -0
  238. data/src/ruby/spec/generic/active_call_spec.rb +19 -8
  239. data/third_party/abseil-cpp/absl/algorithm/container.h +1727 -0
  240. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +161 -0
  241. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.cc +93 -0
  242. data/third_party/abseil-cpp/absl/base/internal/exponential_biased.h +130 -0
  243. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +620 -0
  244. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +126 -0
  245. data/third_party/abseil-cpp/absl/container/fixed_array.h +515 -0
  246. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +503 -0
  247. data/third_party/abseil-cpp/absl/container/internal/common.h +202 -0
  248. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +440 -0
  249. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +146 -0
  250. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +191 -0
  251. data/third_party/abseil-cpp/absl/container/internal/hashtable_debug_hooks.h +85 -0
  252. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +269 -0
  253. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +297 -0
  254. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler_force_weak_definition.cc +30 -0
  255. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +49 -0
  256. data/third_party/abseil-cpp/absl/container/internal/layout.h +741 -0
  257. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +48 -0
  258. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +1882 -0
  259. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +138 -0
  260. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.h +32 -0
  261. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +1895 -0
  262. data/third_party/abseil-cpp/absl/debugging/internal/demangle.h +71 -0
  263. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc +382 -0
  264. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +134 -0
  265. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +192 -0
  266. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +125 -0
  267. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +70 -0
  268. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +99 -0
  269. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +248 -0
  270. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_unimplemented-inl.inc +24 -0
  271. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +85 -0
  272. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +346 -0
  273. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +128 -0
  274. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +194 -0
  275. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.h +158 -0
  276. data/third_party/abseil-cpp/absl/debugging/stacktrace.cc +140 -0
  277. data/third_party/abseil-cpp/absl/debugging/stacktrace.h +231 -0
  278. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +25 -0
  279. data/third_party/abseil-cpp/absl/debugging/symbolize.h +99 -0
  280. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +1480 -0
  281. data/third_party/abseil-cpp/absl/debugging/symbolize_unimplemented.inc +40 -0
  282. data/third_party/abseil-cpp/absl/debugging/symbolize_win32.inc +81 -0
  283. data/third_party/abseil-cpp/absl/functional/function_ref.h +139 -0
  284. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +106 -0
  285. data/third_party/abseil-cpp/absl/hash/hash.h +324 -0
  286. data/third_party/abseil-cpp/absl/hash/internal/city.cc +346 -0
  287. data/third_party/abseil-cpp/absl/hash/internal/city.h +96 -0
  288. data/third_party/abseil-cpp/absl/hash/internal/hash.cc +55 -0
  289. data/third_party/abseil-cpp/absl/hash/internal/hash.h +988 -0
  290. data/third_party/abseil-cpp/absl/status/status.cc +447 -0
  291. data/third_party/abseil-cpp/absl/status/status.h +428 -0
  292. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +43 -0
  293. data/third_party/abseil-cpp/absl/status/status_payload_printer.h +51 -0
  294. data/third_party/abseil-cpp/absl/strings/cord.cc +2019 -0
  295. data/third_party/abseil-cpp/absl/strings/cord.h +1121 -0
  296. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +151 -0
  297. data/third_party/abseil-cpp/absl/synchronization/barrier.cc +52 -0
  298. data/third_party/abseil-cpp/absl/synchronization/barrier.h +79 -0
  299. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.cc +57 -0
  300. data/third_party/abseil-cpp/absl/synchronization/blocking_counter.h +99 -0
  301. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +140 -0
  302. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.h +60 -0
  303. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +697 -0
  304. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.h +141 -0
  305. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +155 -0
  306. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +261 -0
  307. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +106 -0
  308. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +115 -0
  309. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +484 -0
  310. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +159 -0
  311. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +2728 -0
  312. data/third_party/abseil-cpp/absl/synchronization/mutex.h +1056 -0
  313. data/third_party/abseil-cpp/absl/synchronization/notification.cc +78 -0
  314. data/third_party/abseil-cpp/absl/synchronization/notification.h +123 -0
  315. data/third_party/abseil-cpp/absl/types/bad_variant_access.cc +64 -0
  316. data/third_party/abseil-cpp/absl/types/bad_variant_access.h +82 -0
  317. data/third_party/abseil-cpp/absl/types/internal/variant.h +1646 -0
  318. data/third_party/abseil-cpp/absl/types/variant.h +861 -0
  319. data/third_party/boringssl-with-bazel/err_data.c +263 -257
  320. data/third_party/boringssl-with-bazel/src/crypto/evp/evp_asn1.c +16 -0
  321. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +456 -0
  322. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +192 -0
  323. data/third_party/boringssl-with-bazel/src/crypto/x509/x_sig.c +20 -0
  324. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +52 -0
  325. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +1 -1
  326. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +39 -7
  327. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +2 -3
  328. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +11 -0
  329. data/third_party/boringssl-with-bazel/src/ssl/internal.h +4 -0
  330. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +3 -6
  331. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +10 -0
  332. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +34 -9
  333. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +5 -0
  334. data/third_party/boringssl-with-bazel/src/ssl/tls_record.cc +5 -3
  335. data/third_party/upb/upb/decode.c +64 -15
  336. data/third_party/upb/upb/encode.c +2 -2
  337. data/third_party/upb/upb/msg.h +2 -2
  338. data/third_party/upb/upb/port_def.inc +1 -1
  339. data/third_party/upb/upb/table.c +0 -11
  340. data/third_party/upb/upb/table.int.h +0 -9
  341. data/third_party/upb/upb/upb.c +16 -14
  342. data/third_party/upb/upb/upb.h +26 -0
  343. data/third_party/upb/upb/upb.hpp +2 -0
  344. metadata +257 -155
  345. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -21
  346. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +0 -34
  347. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +0 -114
  348. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +0 -429
  349. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +0 -72
  350. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +0 -198
  351. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +0 -105
  352. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +0 -388
  353. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +0 -52
  354. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +0 -403
  355. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +0 -1453
  356. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -74
  357. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.h +0 -226
  358. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.h +0 -69
  359. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +0 -323
  360. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -112
  361. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.h +0 -334
  362. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +0 -79
  363. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +0 -313
  364. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +0 -891
  365. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +0 -96
  366. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +0 -328
  367. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +0 -34
  368. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +0 -71
  369. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +0 -197
  370. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.h +0 -649
  371. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +0 -172
  372. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +0 -693
  373. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.h +0 -80
  374. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +0 -152
  375. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +0 -536
  376. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +0 -88
  377. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -129
  378. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.h +0 -386
  379. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +0 -52
  380. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +0 -92
  381. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.h +0 -224
  382. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -18
  383. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.h +0 -32
  384. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +0 -91
  385. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +0 -273
  386. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -112
  387. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.h +0 -332
  388. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.h +0 -52
  389. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +0 -109
  390. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +0 -415
  391. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +0 -18
  392. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.h +0 -32
  393. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +0 -145
  394. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.h +0 -538
  395. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +0 -43
  396. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.h +0 -111
  397. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.h +0 -52
  398. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +0 -63
  399. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.h +0 -204
  400. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +0 -18
  401. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.h +0 -32
  402. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +0 -815
  403. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +0 -2984
  404. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +0 -59
  405. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.h +0 -135
  406. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.h +0 -52
  407. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +0 -228
  408. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.h +0 -732
  409. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +0 -316
  410. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +0 -1167
  411. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.h +0 -65
  412. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +0 -51
  413. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +0 -125
  414. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.h +0 -49
  415. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +0 -54
  416. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +0 -136
  417. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +0 -63
  418. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +0 -145
  419. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +0 -53
  420. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.h +0 -133
  421. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +0 -88
  422. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.h +0 -258
  423. data/src/core/ext/upb-generated/envoy/type/percent.upb.h +0 -86
  424. data/src/core/ext/upb-generated/envoy/type/range.upb.h +0 -111
  425. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.h +0 -61
  426. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +0 -89
  427. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.h +0 -250
  428. data/src/core/lib/security/transport/target_authority_table.cc +0 -75
  429. data/src/core/lib/security/transport/target_authority_table.h +0 -40
  430. data/src/core/lib/slice/slice_hash_table.h +0 -199
  431. data/src/core/lib/slice/slice_weak_hash_table.h +0 -102
@@ -36,9 +36,9 @@ static const upb_msglayout *const google_protobuf_FileDescriptorProto_submsgs[6]
36
36
  };
37
37
 
38
38
  static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12] = {
39
- {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
40
- {2, UPB_SIZE(12, 24), 2, 0, 9, 1},
41
- {3, UPB_SIZE(36, 72), 0, 0, 9, 3},
39
+ {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
40
+ {2, UPB_SIZE(12, 24), 2, 0, 12, 1},
41
+ {3, UPB_SIZE(36, 72), 0, 0, 12, 3},
42
42
  {4, UPB_SIZE(40, 80), 0, 0, 11, 3},
43
43
  {5, UPB_SIZE(44, 88), 0, 1, 11, 3},
44
44
  {6, UPB_SIZE(48, 96), 0, 4, 11, 3},
@@ -47,7 +47,7 @@ static const upb_msglayout_field google_protobuf_FileDescriptorProto__fields[12]
47
47
  {9, UPB_SIZE(32, 64), 5, 5, 11, 1},
48
48
  {10, UPB_SIZE(56, 112), 0, 0, 5, 3},
49
49
  {11, UPB_SIZE(60, 120), 0, 0, 5, 3},
50
- {12, UPB_SIZE(20, 40), 3, 0, 9, 1},
50
+ {12, UPB_SIZE(20, 40), 3, 0, 12, 1},
51
51
  };
52
52
 
53
53
  const upb_msglayout google_protobuf_FileDescriptorProto_msginit = {
@@ -67,7 +67,7 @@ static const upb_msglayout *const google_protobuf_DescriptorProto_submsgs[8] = {
67
67
  };
68
68
 
69
69
  static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = {
70
- {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
70
+ {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
71
71
  {2, UPB_SIZE(16, 32), 0, 4, 11, 3},
72
72
  {3, UPB_SIZE(20, 40), 0, 0, 11, 3},
73
73
  {4, UPB_SIZE(24, 48), 0, 3, 11, 3},
@@ -76,7 +76,7 @@ static const upb_msglayout_field google_protobuf_DescriptorProto__fields[10] = {
76
76
  {7, UPB_SIZE(12, 24), 2, 5, 11, 1},
77
77
  {8, UPB_SIZE(36, 72), 0, 6, 11, 3},
78
78
  {9, UPB_SIZE(40, 80), 0, 2, 11, 3},
79
- {10, UPB_SIZE(44, 88), 0, 0, 9, 3},
79
+ {10, UPB_SIZE(44, 88), 0, 0, 12, 3},
80
80
  };
81
81
 
82
82
  const upb_msglayout google_protobuf_DescriptorProto_msginit = {
@@ -131,16 +131,16 @@ static const upb_msglayout *const google_protobuf_FieldDescriptorProto_submsgs[1
131
131
  };
132
132
 
133
133
  static const upb_msglayout_field google_protobuf_FieldDescriptorProto__fields[11] = {
134
- {1, UPB_SIZE(36, 40), 6, 0, 9, 1},
135
- {2, UPB_SIZE(44, 56), 7, 0, 9, 1},
134
+ {1, UPB_SIZE(36, 40), 6, 0, 12, 1},
135
+ {2, UPB_SIZE(44, 56), 7, 0, 12, 1},
136
136
  {3, UPB_SIZE(24, 24), 3, 0, 5, 1},
137
137
  {4, UPB_SIZE(8, 8), 1, 0, 14, 1},
138
138
  {5, UPB_SIZE(16, 16), 2, 0, 14, 1},
139
- {6, UPB_SIZE(52, 72), 8, 0, 9, 1},
140
- {7, UPB_SIZE(60, 88), 9, 0, 9, 1},
139
+ {6, UPB_SIZE(52, 72), 8, 0, 12, 1},
140
+ {7, UPB_SIZE(60, 88), 9, 0, 12, 1},
141
141
  {8, UPB_SIZE(76, 120), 11, 0, 11, 1},
142
142
  {9, UPB_SIZE(28, 28), 4, 0, 5, 1},
143
- {10, UPB_SIZE(68, 104), 10, 0, 9, 1},
143
+ {10, UPB_SIZE(68, 104), 10, 0, 12, 1},
144
144
  {17, UPB_SIZE(32, 32), 5, 0, 8, 1},
145
145
  };
146
146
 
@@ -155,7 +155,7 @@ static const upb_msglayout *const google_protobuf_OneofDescriptorProto_submsgs[1
155
155
  };
156
156
 
157
157
  static const upb_msglayout_field google_protobuf_OneofDescriptorProto__fields[2] = {
158
- {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
158
+ {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
159
159
  {2, UPB_SIZE(12, 24), 2, 0, 11, 1},
160
160
  };
161
161
 
@@ -172,11 +172,11 @@ static const upb_msglayout *const google_protobuf_EnumDescriptorProto_submsgs[3]
172
172
  };
173
173
 
174
174
  static const upb_msglayout_field google_protobuf_EnumDescriptorProto__fields[5] = {
175
- {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
175
+ {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
176
176
  {2, UPB_SIZE(16, 32), 0, 2, 11, 3},
177
177
  {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
178
178
  {4, UPB_SIZE(20, 40), 0, 0, 11, 3},
179
- {5, UPB_SIZE(24, 48), 0, 0, 9, 3},
179
+ {5, UPB_SIZE(24, 48), 0, 0, 12, 3},
180
180
  };
181
181
 
182
182
  const upb_msglayout google_protobuf_EnumDescriptorProto_msginit = {
@@ -201,7 +201,7 @@ static const upb_msglayout *const google_protobuf_EnumValueDescriptorProto_subms
201
201
  };
202
202
 
203
203
  static const upb_msglayout_field google_protobuf_EnumValueDescriptorProto__fields[3] = {
204
- {1, UPB_SIZE(8, 8), 2, 0, 9, 1},
204
+ {1, UPB_SIZE(8, 8), 2, 0, 12, 1},
205
205
  {2, UPB_SIZE(4, 4), 1, 0, 5, 1},
206
206
  {3, UPB_SIZE(16, 24), 3, 0, 11, 1},
207
207
  };
@@ -218,7 +218,7 @@ static const upb_msglayout *const google_protobuf_ServiceDescriptorProto_submsgs
218
218
  };
219
219
 
220
220
  static const upb_msglayout_field google_protobuf_ServiceDescriptorProto__fields[3] = {
221
- {1, UPB_SIZE(4, 8), 1, 0, 9, 1},
221
+ {1, UPB_SIZE(4, 8), 1, 0, 12, 1},
222
222
  {2, UPB_SIZE(16, 32), 0, 0, 11, 3},
223
223
  {3, UPB_SIZE(12, 24), 2, 1, 11, 1},
224
224
  };
@@ -234,9 +234,9 @@ static const upb_msglayout *const google_protobuf_MethodDescriptorProto_submsgs[
234
234
  };
235
235
 
236
236
  static const upb_msglayout_field google_protobuf_MethodDescriptorProto__fields[6] = {
237
- {1, UPB_SIZE(4, 8), 3, 0, 9, 1},
238
- {2, UPB_SIZE(12, 24), 4, 0, 9, 1},
239
- {3, UPB_SIZE(20, 40), 5, 0, 9, 1},
237
+ {1, UPB_SIZE(4, 8), 3, 0, 12, 1},
238
+ {2, UPB_SIZE(12, 24), 4, 0, 12, 1},
239
+ {3, UPB_SIZE(20, 40), 5, 0, 12, 1},
240
240
  {4, UPB_SIZE(28, 56), 6, 0, 11, 1},
241
241
  {5, UPB_SIZE(1, 1), 1, 0, 8, 1},
242
242
  {6, UPB_SIZE(2, 2), 2, 0, 8, 1},
@@ -253,11 +253,11 @@ static const upb_msglayout *const google_protobuf_FileOptions_submsgs[1] = {
253
253
  };
254
254
 
255
255
  static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = {
256
- {1, UPB_SIZE(28, 32), 11, 0, 9, 1},
257
- {8, UPB_SIZE(36, 48), 12, 0, 9, 1},
256
+ {1, UPB_SIZE(28, 32), 11, 0, 12, 1},
257
+ {8, UPB_SIZE(36, 48), 12, 0, 12, 1},
258
258
  {9, UPB_SIZE(8, 8), 1, 0, 14, 1},
259
259
  {10, UPB_SIZE(16, 16), 2, 0, 8, 1},
260
- {11, UPB_SIZE(44, 64), 13, 0, 9, 1},
260
+ {11, UPB_SIZE(44, 64), 13, 0, 12, 1},
261
261
  {16, UPB_SIZE(17, 17), 3, 0, 8, 1},
262
262
  {17, UPB_SIZE(18, 18), 4, 0, 8, 1},
263
263
  {18, UPB_SIZE(19, 19), 5, 0, 8, 1},
@@ -265,14 +265,14 @@ static const upb_msglayout_field google_protobuf_FileOptions__fields[21] = {
265
265
  {23, UPB_SIZE(21, 21), 7, 0, 8, 1},
266
266
  {27, UPB_SIZE(22, 22), 8, 0, 8, 1},
267
267
  {31, UPB_SIZE(23, 23), 9, 0, 8, 1},
268
- {36, UPB_SIZE(52, 80), 14, 0, 9, 1},
269
- {37, UPB_SIZE(60, 96), 15, 0, 9, 1},
270
- {39, UPB_SIZE(68, 112), 16, 0, 9, 1},
271
- {40, UPB_SIZE(76, 128), 17, 0, 9, 1},
272
- {41, UPB_SIZE(84, 144), 18, 0, 9, 1},
268
+ {36, UPB_SIZE(52, 80), 14, 0, 12, 1},
269
+ {37, UPB_SIZE(60, 96), 15, 0, 12, 1},
270
+ {39, UPB_SIZE(68, 112), 16, 0, 12, 1},
271
+ {40, UPB_SIZE(76, 128), 17, 0, 12, 1},
272
+ {41, UPB_SIZE(84, 144), 18, 0, 12, 1},
273
273
  {42, UPB_SIZE(24, 24), 10, 0, 8, 1},
274
- {44, UPB_SIZE(92, 160), 19, 0, 9, 1},
275
- {45, UPB_SIZE(100, 176), 20, 0, 9, 1},
274
+ {44, UPB_SIZE(92, 160), 19, 0, 12, 1},
275
+ {45, UPB_SIZE(100, 176), 20, 0, 12, 1},
276
276
  {999, UPB_SIZE(108, 192), 0, 0, 11, 3},
277
277
  };
278
278
 
@@ -402,12 +402,12 @@ static const upb_msglayout *const google_protobuf_UninterpretedOption_submsgs[1]
402
402
 
403
403
  static const upb_msglayout_field google_protobuf_UninterpretedOption__fields[7] = {
404
404
  {2, UPB_SIZE(56, 80), 0, 0, 11, 3},
405
- {3, UPB_SIZE(32, 32), 4, 0, 9, 1},
405
+ {3, UPB_SIZE(32, 32), 4, 0, 12, 1},
406
406
  {4, UPB_SIZE(8, 8), 1, 0, 4, 1},
407
407
  {5, UPB_SIZE(16, 16), 2, 0, 3, 1},
408
408
  {6, UPB_SIZE(24, 24), 3, 0, 1, 1},
409
409
  {7, UPB_SIZE(40, 48), 5, 0, 12, 1},
410
- {8, UPB_SIZE(48, 64), 6, 0, 9, 1},
410
+ {8, UPB_SIZE(48, 64), 6, 0, 12, 1},
411
411
  };
412
412
 
413
413
  const upb_msglayout google_protobuf_UninterpretedOption_msginit = {
@@ -417,7 +417,7 @@ const upb_msglayout google_protobuf_UninterpretedOption_msginit = {
417
417
  };
418
418
 
419
419
  static const upb_msglayout_field google_protobuf_UninterpretedOption_NamePart__fields[2] = {
420
- {1, UPB_SIZE(4, 8), 2, 0, 9, 2},
420
+ {1, UPB_SIZE(4, 8), 2, 0, 12, 2},
421
421
  {2, UPB_SIZE(1, 1), 1, 0, 8, 2},
422
422
  };
423
423
 
@@ -444,9 +444,9 @@ const upb_msglayout google_protobuf_SourceCodeInfo_msginit = {
444
444
  static const upb_msglayout_field google_protobuf_SourceCodeInfo_Location__fields[5] = {
445
445
  {1, UPB_SIZE(20, 40), 0, 0, 5, _UPB_LABEL_PACKED},
446
446
  {2, UPB_SIZE(24, 48), 0, 0, 5, _UPB_LABEL_PACKED},
447
- {3, UPB_SIZE(4, 8), 1, 0, 9, 1},
448
- {4, UPB_SIZE(12, 24), 2, 0, 9, 1},
449
- {6, UPB_SIZE(28, 56), 0, 0, 9, 3},
447
+ {3, UPB_SIZE(4, 8), 1, 0, 12, 1},
448
+ {4, UPB_SIZE(12, 24), 2, 0, 12, 1},
449
+ {6, UPB_SIZE(28, 56), 0, 0, 12, 3},
450
450
  };
451
451
 
452
452
  const upb_msglayout google_protobuf_SourceCodeInfo_Location_msginit = {
@@ -471,7 +471,7 @@ const upb_msglayout google_protobuf_GeneratedCodeInfo_msginit = {
471
471
 
472
472
  static const upb_msglayout_field google_protobuf_GeneratedCodeInfo_Annotation__fields[4] = {
473
473
  {1, UPB_SIZE(20, 32), 0, 0, 5, _UPB_LABEL_PACKED},
474
- {2, UPB_SIZE(12, 16), 3, 0, 9, 1},
474
+ {2, UPB_SIZE(12, 16), 3, 0, 12, 1},
475
475
  {3, UPB_SIZE(4, 4), 1, 0, 5, 1},
476
476
  {4, UPB_SIZE(8, 8), 2, 0, 5, 1},
477
477
  };
@@ -105,7 +105,7 @@ typedef enum {
105
105
  UPB_INLINE google_protobuf_Value_kind_oneofcases google_protobuf_Value_kind_case(const google_protobuf_Value* msg) { return (google_protobuf_Value_kind_oneofcases)*UPB_PTR_AT(msg, UPB_SIZE(8, 16), int32_t); }
106
106
 
107
107
  UPB_INLINE bool google_protobuf_Value_has_null_value(const google_protobuf_Value *msg) { return _upb_getoneofcase(msg, UPB_SIZE(8, 16)) == 1; }
108
- UPB_INLINE int32_t google_protobuf_Value_null_value(const google_protobuf_Value *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, google_protobuf_NULL_VALUE); }
108
+ UPB_INLINE int32_t google_protobuf_Value_null_value(const google_protobuf_Value *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 1, 0); }
109
109
  UPB_INLINE bool google_protobuf_Value_has_number_value(const google_protobuf_Value *msg) { return _upb_getoneofcase(msg, UPB_SIZE(8, 16)) == 2; }
110
110
  UPB_INLINE double google_protobuf_Value_number_value(const google_protobuf_Value *msg) { return UPB_READ_ONEOF(msg, double, UPB_SIZE(0, 0), UPB_SIZE(8, 16), 2, 0); }
111
111
  UPB_INLINE bool google_protobuf_Value_has_string_value(const google_protobuf_Value *msg) { return _upb_getoneofcase(msg, UPB_SIZE(8, 16)) == 3; }
@@ -0,0 +1,27 @@
1
+ /* This file was generated by upbc (the upb compiler) from the input
2
+ * file:
3
+ *
4
+ * udpa/annotations/versioning.proto
5
+ *
6
+ * Do not edit -- your changes will be discarded when the file is
7
+ * regenerated. */
8
+
9
+ #include <stddef.h>
10
+ #include "upb/msg.h"
11
+ #include "udpa/annotations/versioning.upb.h"
12
+ #include "google/protobuf/descriptor.upb.h"
13
+
14
+ #include "upb/port_def.inc"
15
+
16
+ static const upb_msglayout_field udpa_annotations_VersioningAnnotation__fields[1] = {
17
+ {1, UPB_SIZE(0, 0), 0, 0, 9, 1},
18
+ };
19
+
20
+ const upb_msglayout udpa_annotations_VersioningAnnotation_msginit = {
21
+ NULL,
22
+ &udpa_annotations_VersioningAnnotation__fields[0],
23
+ UPB_SIZE(8, 16), 1, false,
24
+ };
25
+
26
+ #include "upb/port_undef.inc"
27
+
@@ -0,0 +1,53 @@
1
+ /* This file was generated by upbc (the upb compiler) from the input
2
+ * file:
3
+ *
4
+ * udpa/annotations/versioning.proto
5
+ *
6
+ * Do not edit -- your changes will be discarded when the file is
7
+ * regenerated. */
8
+
9
+ #ifndef UDPA_ANNOTATIONS_VERSIONING_PROTO_UPB_H_
10
+ #define UDPA_ANNOTATIONS_VERSIONING_PROTO_UPB_H_
11
+
12
+ #include "upb/msg.h"
13
+ #include "upb/decode.h"
14
+ #include "upb/encode.h"
15
+
16
+ #include "upb/port_def.inc"
17
+
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ struct udpa_annotations_VersioningAnnotation;
23
+ typedef struct udpa_annotations_VersioningAnnotation udpa_annotations_VersioningAnnotation;
24
+ extern const upb_msglayout udpa_annotations_VersioningAnnotation_msginit;
25
+
26
+
27
+ /* udpa.annotations.VersioningAnnotation */
28
+
29
+ UPB_INLINE udpa_annotations_VersioningAnnotation *udpa_annotations_VersioningAnnotation_new(upb_arena *arena) {
30
+ return (udpa_annotations_VersioningAnnotation *)_upb_msg_new(&udpa_annotations_VersioningAnnotation_msginit, arena);
31
+ }
32
+ UPB_INLINE udpa_annotations_VersioningAnnotation *udpa_annotations_VersioningAnnotation_parse(const char *buf, size_t size,
33
+ upb_arena *arena) {
34
+ udpa_annotations_VersioningAnnotation *ret = udpa_annotations_VersioningAnnotation_new(arena);
35
+ return (ret && upb_decode(buf, size, ret, &udpa_annotations_VersioningAnnotation_msginit, arena)) ? ret : NULL;
36
+ }
37
+ UPB_INLINE char *udpa_annotations_VersioningAnnotation_serialize(const udpa_annotations_VersioningAnnotation *msg, upb_arena *arena, size_t *len) {
38
+ return upb_encode(msg, &udpa_annotations_VersioningAnnotation_msginit, arena, len);
39
+ }
40
+
41
+ UPB_INLINE upb_strview udpa_annotations_VersioningAnnotation_previous_message_type(const udpa_annotations_VersioningAnnotation *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_strview); }
42
+
43
+ UPB_INLINE void udpa_annotations_VersioningAnnotation_set_previous_message_type(udpa_annotations_VersioningAnnotation *msg, upb_strview value) {
44
+ *UPB_PTR_AT(msg, UPB_SIZE(0, 0), upb_strview) = value;
45
+ }
46
+
47
+ #ifdef __cplusplus
48
+ } /* extern "C" */
49
+ #endif
50
+
51
+ #include "upb/port_undef.inc"
52
+
53
+ #endif /* UDPA_ANNOTATIONS_VERSIONING_PROTO_UPB_H_ */
@@ -274,17 +274,17 @@ const upb_msglayout validate_BoolRules_msginit = {
274
274
  };
275
275
 
276
276
  static const upb_msglayout_field validate_StringRules__fields[25] = {
277
- {1, UPB_SIZE(60, 64), 8, 0, 9, 1},
277
+ {1, UPB_SIZE(60, 64), 8, 0, 12, 1},
278
278
  {2, UPB_SIZE(8, 8), 1, 0, 4, 1},
279
279
  {3, UPB_SIZE(16, 16), 2, 0, 4, 1},
280
280
  {4, UPB_SIZE(24, 24), 3, 0, 4, 1},
281
281
  {5, UPB_SIZE(32, 32), 4, 0, 4, 1},
282
- {6, UPB_SIZE(68, 80), 9, 0, 9, 1},
283
- {7, UPB_SIZE(76, 96), 10, 0, 9, 1},
284
- {8, UPB_SIZE(84, 112), 11, 0, 9, 1},
285
- {9, UPB_SIZE(92, 128), 12, 0, 9, 1},
286
- {10, UPB_SIZE(108, 160), 0, 0, 9, 3},
287
- {11, UPB_SIZE(112, 168), 0, 0, 9, 3},
282
+ {6, UPB_SIZE(68, 80), 9, 0, 12, 1},
283
+ {7, UPB_SIZE(76, 96), 10, 0, 12, 1},
284
+ {8, UPB_SIZE(84, 112), 11, 0, 12, 1},
285
+ {9, UPB_SIZE(92, 128), 12, 0, 12, 1},
286
+ {10, UPB_SIZE(108, 160), 0, 0, 12, 3},
287
+ {11, UPB_SIZE(112, 168), 0, 0, 12, 3},
288
288
  {12, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 8, 1},
289
289
  {13, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 8, 1},
290
290
  {14, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 8, 1},
@@ -296,7 +296,7 @@ static const upb_msglayout_field validate_StringRules__fields[25] = {
296
296
  {20, UPB_SIZE(48, 48), 6, 0, 4, 1},
297
297
  {21, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 8, 1},
298
298
  {22, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 8, 1},
299
- {23, UPB_SIZE(100, 144), 13, 0, 9, 1},
299
+ {23, UPB_SIZE(100, 144), 13, 0, 12, 1},
300
300
  {24, UPB_SIZE(120, 176), UPB_SIZE(-129, -185), 0, 14, 1},
301
301
  {25, UPB_SIZE(56, 56), 7, 0, 8, 1},
302
302
  };
@@ -311,7 +311,7 @@ static const upb_msglayout_field validate_BytesRules__fields[13] = {
311
311
  {1, UPB_SIZE(32, 32), 4, 0, 12, 1},
312
312
  {2, UPB_SIZE(8, 8), 1, 0, 4, 1},
313
313
  {3, UPB_SIZE(16, 16), 2, 0, 4, 1},
314
- {4, UPB_SIZE(40, 48), 5, 0, 9, 1},
314
+ {4, UPB_SIZE(40, 48), 5, 0, 12, 1},
315
315
  {5, UPB_SIZE(48, 64), 6, 0, 12, 1},
316
316
  {6, UPB_SIZE(56, 80), 7, 0, 12, 1},
317
317
  {7, UPB_SIZE(64, 96), 8, 0, 12, 1},
@@ -390,8 +390,8 @@ const upb_msglayout validate_MapRules_msginit = {
390
390
 
391
391
  static const upb_msglayout_field validate_AnyRules__fields[3] = {
392
392
  {1, UPB_SIZE(1, 1), 1, 0, 8, 1},
393
- {2, UPB_SIZE(4, 8), 0, 0, 9, 3},
394
- {3, UPB_SIZE(8, 16), 0, 0, 9, 3},
393
+ {2, UPB_SIZE(4, 8), 0, 0, 12, 3},
394
+ {3, UPB_SIZE(8, 16), 0, 0, 12, 3},
395
395
  };
396
396
 
397
397
  const upb_msglayout validate_AnyRules_msginit = {
@@ -1363,7 +1363,7 @@ UPB_INLINE bool validate_StringRules_uuid(const validate_StringRules *msg) { ret
1363
1363
  UPB_INLINE bool validate_StringRules_has_not_contains(const validate_StringRules *msg) { return _upb_hasbit(msg, 13); }
1364
1364
  UPB_INLINE upb_strview validate_StringRules_not_contains(const validate_StringRules *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(100, 144), upb_strview); }
1365
1365
  UPB_INLINE bool validate_StringRules_has_well_known_regex(const validate_StringRules *msg) { return _upb_getoneofcase(msg, UPB_SIZE(128, 184)) == 24; }
1366
- UPB_INLINE int32_t validate_StringRules_well_known_regex(const validate_StringRules *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(120, 176), UPB_SIZE(128, 184), 24, validate_UNKNOWN); }
1366
+ UPB_INLINE int32_t validate_StringRules_well_known_regex(const validate_StringRules *msg) { return UPB_READ_ONEOF(msg, int32_t, UPB_SIZE(120, 176), UPB_SIZE(128, 184), 24, 0); }
1367
1367
  UPB_INLINE bool validate_StringRules_has_strict(const validate_StringRules *msg) { return _upb_hasbit(msg, 7); }
1368
1368
  UPB_INLINE bool validate_StringRules_strict(const validate_StringRules *msg) { return *UPB_PTR_AT(msg, UPB_SIZE(56, 56), bool); }
1369
1369
 
@@ -20,7 +20,9 @@
20
20
 
21
21
  #include <algorithm>
22
22
  #include <cctype>
23
+ #include <cstdint>
23
24
  #include <cstdlib>
25
+ #include <string>
24
26
 
25
27
  #include "absl/strings/str_cat.h"
26
28
  #include "absl/strings/str_format.h"
@@ -33,31 +35,35 @@
33
35
  #include <grpc/support/alloc.h>
34
36
  #include <grpc/support/string_util.h>
35
37
 
36
- #include "src/core/ext/filters/client_channel/xds/xds_api.h"
38
+ #include "src/core/ext/xds/xds_api.h"
37
39
  #include "src/core/lib/gpr/env.h"
38
40
  #include "src/core/lib/gpr/string.h"
39
41
  #include "src/core/lib/gpr/useful.h"
40
42
  #include "src/core/lib/iomgr/error.h"
41
43
  #include "src/core/lib/iomgr/sockaddr_utils.h"
42
44
 
43
- #include "envoy/api/v2/cds.upb.h"
44
- #include "envoy/api/v2/core/address.upb.h"
45
- #include "envoy/api/v2/core/base.upb.h"
46
- #include "envoy/api/v2/core/config_source.upb.h"
47
- #include "envoy/api/v2/core/health_check.upb.h"
48
- #include "envoy/api/v2/discovery.upb.h"
49
- #include "envoy/api/v2/eds.upb.h"
50
- #include "envoy/api/v2/endpoint/endpoint.upb.h"
51
- #include "envoy/api/v2/endpoint/load_report.upb.h"
52
- #include "envoy/api/v2/lds.upb.h"
53
- #include "envoy/api/v2/rds.upb.h"
54
- #include "envoy/api/v2/route/route.upb.h"
55
- #include "envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h"
56
- #include "envoy/config/listener/v2/api_listener.upb.h"
57
- #include "envoy/service/load_stats/v2/lrs.upb.h"
58
- #include "envoy/type/matcher/regex.upb.h"
59
- #include "envoy/type/percent.upb.h"
60
- #include "envoy/type/range.upb.h"
45
+ #include "envoy/config/cluster/v3/cluster.upb.h"
46
+ #include "envoy/config/core/v3/address.upb.h"
47
+ #include "envoy/config/core/v3/base.upb.h"
48
+ #include "envoy/config/core/v3/config_source.upb.h"
49
+ #include "envoy/config/core/v3/health_check.upb.h"
50
+ #include "envoy/config/endpoint/v3/endpoint.upb.h"
51
+ #include "envoy/config/endpoint/v3/endpoint_components.upb.h"
52
+ #include "envoy/config/endpoint/v3/load_report.upb.h"
53
+ #include "envoy/config/listener/v3/api_listener.upb.h"
54
+ #include "envoy/config/listener/v3/listener.upb.h"
55
+ #include "envoy/config/route/v3/route.upb.h"
56
+ #include "envoy/config/route/v3/route_components.upb.h"
57
+ #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
58
+ #include "envoy/service/cluster/v3/cds.upb.h"
59
+ #include "envoy/service/discovery/v3/discovery.upb.h"
60
+ #include "envoy/service/endpoint/v3/eds.upb.h"
61
+ #include "envoy/service/listener/v3/lds.upb.h"
62
+ #include "envoy/service/load_stats/v3/lrs.upb.h"
63
+ #include "envoy/service/route/v3/rds.upb.h"
64
+ #include "envoy/type/matcher/v3/regex.upb.h"
65
+ #include "envoy/type/v3/percent.upb.h"
66
+ #include "envoy/type/v3/range.upb.h"
61
67
  #include "google/protobuf/any.upb.h"
62
68
  #include "google/protobuf/duration.upb.h"
63
69
  #include "google/protobuf/struct.upb.h"
@@ -68,74 +74,43 @@
68
74
  namespace grpc_core {
69
75
 
70
76
  //
71
- // XdsApi::PriorityListUpdate
77
+ // XdsApi::Route::Matchers::PathMatcher
72
78
  //
73
79
 
74
- bool XdsApi::PriorityListUpdate::operator==(
75
- const XdsApi::PriorityListUpdate& other) const {
76
- if (priorities_.size() != other.priorities_.size()) return false;
77
- for (size_t i = 0; i < priorities_.size(); ++i) {
78
- if (priorities_[i].localities != other.priorities_[i].localities) {
79
- return false;
80
- }
80
+ XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
81
+ : type(other.type) {
82
+ if (type == PathMatcherType::REGEX) {
83
+ regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
84
+ } else {
85
+ string_matcher = other.string_matcher;
81
86
  }
82
- return true;
83
87
  }
84
88
 
85
- void XdsApi::PriorityListUpdate::Add(
86
- XdsApi::PriorityListUpdate::LocalityMap::Locality locality) {
87
- // Pad the missing priorities in case the localities are not ordered by
88
- // priority.
89
- if (!Contains(locality.priority)) priorities_.resize(locality.priority + 1);
90
- LocalityMap& locality_map = priorities_[locality.priority];
91
- locality_map.localities.emplace(locality.name, std::move(locality));
92
- }
93
-
94
- const XdsApi::PriorityListUpdate::LocalityMap* XdsApi::PriorityListUpdate::Find(
95
- uint32_t priority) const {
96
- if (!Contains(priority)) return nullptr;
97
- return &priorities_[priority];
98
- }
99
-
100
- bool XdsApi::PriorityListUpdate::Contains(
101
- const RefCountedPtr<XdsLocalityName>& name) {
102
- for (size_t i = 0; i < priorities_.size(); ++i) {
103
- const LocalityMap& locality_map = priorities_[i];
104
- if (locality_map.Contains(name)) return true;
89
+ XdsApi::Route::Matchers::PathMatcher& XdsApi::Route::Matchers::PathMatcher::
90
+ operator=(const PathMatcher& other) {
91
+ type = other.type;
92
+ if (type == PathMatcherType::REGEX) {
93
+ regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
94
+ } else {
95
+ string_matcher = other.string_matcher;
105
96
  }
106
- return false;
97
+ return *this;
107
98
  }
108
99
 
109
- //
110
- // XdsApi::DropConfig
111
- //
112
-
113
- bool XdsApi::DropConfig::ShouldDrop(const std::string** category_name) const {
114
- for (size_t i = 0; i < drop_category_list_.size(); ++i) {
115
- const auto& drop_category = drop_category_list_[i];
116
- // Generate a random number in [0, 1000000).
117
- const uint32_t random = static_cast<uint32_t>(rand()) % 1000000;
118
- if (random < drop_category.parts_per_million) {
119
- *category_name = &drop_category.name;
120
- return true;
100
+ bool XdsApi::Route::Matchers::PathMatcher::operator==(
101
+ const PathMatcher& other) const {
102
+ if (type != other.type) return false;
103
+ if (type == PathMatcherType::REGEX) {
104
+ // Should never be null.
105
+ if (regex_matcher == nullptr || other.regex_matcher == nullptr) {
106
+ return false;
121
107
  }
108
+ return regex_matcher->pattern() == other.regex_matcher->pattern();
122
109
  }
123
- return false;
110
+ return string_matcher == other.string_matcher;
124
111
  }
125
112
 
126
- //
127
- // XdsApi
128
- //
129
-
130
- const char* XdsApi::kLdsTypeUrl = "type.googleapis.com/envoy.api.v2.Listener";
131
- const char* XdsApi::kRdsTypeUrl =
132
- "type.googleapis.com/envoy.api.v2.RouteConfiguration";
133
- const char* XdsApi::kCdsTypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
134
- const char* XdsApi::kEdsTypeUrl =
135
- "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
136
-
137
- std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString()
138
- const {
113
+ std::string XdsApi::Route::Matchers::PathMatcher::ToString() const {
139
114
  std::string path_type_string;
140
115
  switch (type) {
141
116
  case PathMatcherType::PATH:
@@ -150,14 +125,75 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::PathMatcher::ToString()
150
125
  default:
151
126
  break;
152
127
  }
153
- return absl::StrFormat("Path %s:/%s/", path_type_string,
128
+ return absl::StrFormat("Path %s:%s", path_type_string,
154
129
  type == PathMatcherType::REGEX
155
130
  ? regex_matcher->pattern()
156
131
  : string_matcher);
157
132
  }
158
133
 
159
- std::string XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::ToString()
160
- const {
134
+ //
135
+ // XdsApi::Route::Matchers::HeaderMatcher
136
+ //
137
+
138
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcher(
139
+ const HeaderMatcher& other)
140
+ : name(other.name), type(other.type), invert_match(other.invert_match) {
141
+ switch (type) {
142
+ case HeaderMatcherType::REGEX:
143
+ regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
144
+ break;
145
+ case HeaderMatcherType::RANGE:
146
+ range_start = other.range_start;
147
+ range_end = other.range_end;
148
+ break;
149
+ case HeaderMatcherType::PRESENT:
150
+ present_match = other.present_match;
151
+ break;
152
+ default:
153
+ string_matcher = other.string_matcher;
154
+ }
155
+ }
156
+
157
+ XdsApi::Route::Matchers::HeaderMatcher& XdsApi::Route::Matchers::HeaderMatcher::
158
+ operator=(const HeaderMatcher& other) {
159
+ name = other.name;
160
+ type = other.type;
161
+ invert_match = other.invert_match;
162
+ switch (type) {
163
+ case HeaderMatcherType::REGEX:
164
+ regex_match = absl::make_unique<RE2>(other.regex_match->pattern());
165
+ break;
166
+ case HeaderMatcherType::RANGE:
167
+ range_start = other.range_start;
168
+ range_end = other.range_end;
169
+ break;
170
+ case HeaderMatcherType::PRESENT:
171
+ present_match = other.present_match;
172
+ break;
173
+ default:
174
+ string_matcher = other.string_matcher;
175
+ }
176
+ return *this;
177
+ }
178
+
179
+ bool XdsApi::Route::Matchers::HeaderMatcher::operator==(
180
+ const HeaderMatcher& other) const {
181
+ if (name != other.name) return false;
182
+ if (type != other.type) return false;
183
+ if (invert_match != other.invert_match) return false;
184
+ switch (type) {
185
+ case HeaderMatcherType::REGEX:
186
+ return regex_match->pattern() != other.regex_match->pattern();
187
+ case HeaderMatcherType::RANGE:
188
+ return range_start != other.range_start && range_end != other.range_end;
189
+ case HeaderMatcherType::PRESENT:
190
+ return present_match != other.present_match;
191
+ default:
192
+ return string_matcher != other.string_matcher;
193
+ }
194
+ }
195
+
196
+ std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const {
161
197
  switch (type) {
162
198
  case HeaderMatcherType::EXACT:
163
199
  return absl::StrFormat("Header exact match:%s %s:%s",
@@ -185,7 +221,11 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher::ToString()
185
221
  }
186
222
  }
187
223
 
188
- std::string XdsApi::RdsUpdate::RdsRoute::Matchers::ToString() const {
224
+ //
225
+ // XdsApi::Route
226
+ //
227
+
228
+ std::string XdsApi::Route::Matchers::ToString() const {
189
229
  std::vector<std::string> contents;
190
230
  contents.push_back(path_matcher.ToString());
191
231
  for (const auto& header_it : header_matchers) {
@@ -198,11 +238,11 @@ std::string XdsApi::RdsUpdate::RdsRoute::Matchers::ToString() const {
198
238
  return absl::StrJoin(contents, "\n");
199
239
  }
200
240
 
201
- std::string XdsApi::RdsUpdate::RdsRoute::ClusterWeight::ToString() const {
241
+ std::string XdsApi::Route::ClusterWeight::ToString() const {
202
242
  return absl::StrFormat("{cluster=%s, weight=%d}", name, weight);
203
243
  }
204
244
 
205
- std::string XdsApi::RdsUpdate::RdsRoute::ToString() const {
245
+ std::string XdsApi::Route::ToString() const {
206
246
  std::vector<std::string> contents;
207
247
  contents.push_back(matchers.ToString());
208
248
  if (!cluster_name.empty()) {
@@ -214,25 +254,240 @@ std::string XdsApi::RdsUpdate::RdsRoute::ToString() const {
214
254
  return absl::StrJoin(contents, "\n");
215
255
  }
216
256
 
257
+ //
258
+ // XdsApi::RdsUpdate
259
+ //
260
+
217
261
  std::string XdsApi::RdsUpdate::ToString() const {
218
- std::vector<std::string> contents;
219
- for (const auto& route_it : routes) {
220
- contents.push_back(route_it.ToString());
262
+ std::vector<std::string> vhosts;
263
+ for (const VirtualHost& vhost : virtual_hosts) {
264
+ vhosts.push_back(
265
+ absl::StrCat("vhost={\n"
266
+ " domains=[",
267
+ absl::StrJoin(vhost.domains, ", "),
268
+ "]\n"
269
+ " routes=[\n"));
270
+ for (const XdsApi::Route& route : vhost.routes) {
271
+ vhosts.push_back(" {\n");
272
+ vhosts.push_back(route.ToString());
273
+ vhosts.push_back("\n }\n");
274
+ }
275
+ vhosts.push_back(" ]\n");
276
+ vhosts.push_back("]\n");
277
+ }
278
+ return absl::StrJoin(vhosts, "");
279
+ }
280
+
281
+ namespace {
282
+
283
+ // Better match type has smaller value.
284
+ enum MatchType {
285
+ EXACT_MATCH,
286
+ SUFFIX_MATCH,
287
+ PREFIX_MATCH,
288
+ UNIVERSE_MATCH,
289
+ INVALID_MATCH,
290
+ };
291
+
292
+ // Returns true if match succeeds.
293
+ bool DomainMatch(MatchType match_type, std::string domain_pattern,
294
+ std::string expected_host_name) {
295
+ // Normalize the args to lower-case. Domain matching is case-insensitive.
296
+ std::transform(domain_pattern.begin(), domain_pattern.end(),
297
+ domain_pattern.begin(),
298
+ [](unsigned char c) { return std::tolower(c); });
299
+ std::transform(expected_host_name.begin(), expected_host_name.end(),
300
+ expected_host_name.begin(),
301
+ [](unsigned char c) { return std::tolower(c); });
302
+ if (match_type == EXACT_MATCH) {
303
+ return domain_pattern == expected_host_name;
304
+ } else if (match_type == SUFFIX_MATCH) {
305
+ // Asterisk must match at least one char.
306
+ if (expected_host_name.size() < domain_pattern.size()) return false;
307
+ absl::string_view pattern_suffix(domain_pattern.c_str() + 1);
308
+ absl::string_view host_suffix(expected_host_name.c_str() +
309
+ expected_host_name.size() -
310
+ pattern_suffix.size());
311
+ return pattern_suffix == host_suffix;
312
+ } else if (match_type == PREFIX_MATCH) {
313
+ // Asterisk must match at least one char.
314
+ if (expected_host_name.size() < domain_pattern.size()) return false;
315
+ absl::string_view pattern_prefix(domain_pattern.c_str(),
316
+ domain_pattern.size() - 1);
317
+ absl::string_view host_prefix(expected_host_name.c_str(),
318
+ pattern_prefix.size());
319
+ return pattern_prefix == host_prefix;
320
+ } else {
321
+ return match_type == UNIVERSE_MATCH;
221
322
  }
222
- return absl::StrJoin(contents, ",\n");
223
323
  }
224
324
 
325
+ MatchType DomainPatternMatchType(const std::string& domain_pattern) {
326
+ if (domain_pattern.empty()) return INVALID_MATCH;
327
+ if (domain_pattern.find('*') == std::string::npos) return EXACT_MATCH;
328
+ if (domain_pattern == "*") return UNIVERSE_MATCH;
329
+ if (domain_pattern[0] == '*') return SUFFIX_MATCH;
330
+ if (domain_pattern[domain_pattern.size() - 1] == '*') return PREFIX_MATCH;
331
+ return INVALID_MATCH;
332
+ }
333
+
334
+ } // namespace
335
+
336
+ const XdsApi::RdsUpdate::VirtualHost*
337
+ XdsApi::RdsUpdate::FindVirtualHostForDomain(const std::string& domain) const {
338
+ // Find the best matched virtual host.
339
+ // The search order for 4 groups of domain patterns:
340
+ // 1. Exact match.
341
+ // 2. Suffix match (e.g., "*ABC").
342
+ // 3. Prefix match (e.g., "ABC*").
343
+ // 4. Universe match (i.e., "*").
344
+ // Within each group, longest match wins.
345
+ // If the same best matched domain pattern appears in multiple virtual hosts,
346
+ // the first matched virtual host wins.
347
+ const VirtualHost* target_vhost = nullptr;
348
+ MatchType best_match_type = INVALID_MATCH;
349
+ size_t longest_match = 0;
350
+ // Check each domain pattern in each virtual host to determine the best
351
+ // matched virtual host.
352
+ for (const VirtualHost& vhost : virtual_hosts) {
353
+ for (const std::string& domain_pattern : vhost.domains) {
354
+ // Check the match type first. Skip the pattern if it's not better than
355
+ // current match.
356
+ const MatchType match_type = DomainPatternMatchType(domain_pattern);
357
+ // This should be caught by RouteConfigParse().
358
+ GPR_ASSERT(match_type != INVALID_MATCH);
359
+ if (match_type > best_match_type) continue;
360
+ if (match_type == best_match_type &&
361
+ domain_pattern.size() <= longest_match) {
362
+ continue;
363
+ }
364
+ // Skip if match fails.
365
+ if (!DomainMatch(match_type, domain_pattern, domain)) continue;
366
+ // Choose this match.
367
+ target_vhost = &vhost;
368
+ best_match_type = match_type;
369
+ longest_match = domain_pattern.size();
370
+ if (best_match_type == EXACT_MATCH) break;
371
+ }
372
+ if (best_match_type == EXACT_MATCH) break;
373
+ }
374
+ return target_vhost;
375
+ }
376
+
377
+ //
378
+ // XdsApi::PriorityListUpdate
379
+ //
380
+
381
+ bool XdsApi::PriorityListUpdate::operator==(
382
+ const XdsApi::PriorityListUpdate& other) const {
383
+ if (priorities_.size() != other.priorities_.size()) return false;
384
+ for (size_t i = 0; i < priorities_.size(); ++i) {
385
+ if (priorities_[i].localities != other.priorities_[i].localities) {
386
+ return false;
387
+ }
388
+ }
389
+ return true;
390
+ }
391
+
392
+ void XdsApi::PriorityListUpdate::Add(
393
+ XdsApi::PriorityListUpdate::LocalityMap::Locality locality) {
394
+ // Pad the missing priorities in case the localities are not ordered by
395
+ // priority.
396
+ if (!Contains(locality.priority)) priorities_.resize(locality.priority + 1);
397
+ LocalityMap& locality_map = priorities_[locality.priority];
398
+ locality_map.localities.emplace(locality.name, std::move(locality));
399
+ }
400
+
401
+ const XdsApi::PriorityListUpdate::LocalityMap* XdsApi::PriorityListUpdate::Find(
402
+ uint32_t priority) const {
403
+ if (!Contains(priority)) return nullptr;
404
+ return &priorities_[priority];
405
+ }
406
+
407
+ bool XdsApi::PriorityListUpdate::Contains(
408
+ const RefCountedPtr<XdsLocalityName>& name) {
409
+ for (size_t i = 0; i < priorities_.size(); ++i) {
410
+ const LocalityMap& locality_map = priorities_[i];
411
+ if (locality_map.Contains(name)) return true;
412
+ }
413
+ return false;
414
+ }
415
+
416
+ //
417
+ // XdsApi::DropConfig
418
+ //
419
+
420
+ bool XdsApi::DropConfig::ShouldDrop(const std::string** category_name) const {
421
+ for (size_t i = 0; i < drop_category_list_.size(); ++i) {
422
+ const auto& drop_category = drop_category_list_[i];
423
+ // Generate a random number in [0, 1000000).
424
+ const uint32_t random = static_cast<uint32_t>(rand()) % 1000000;
425
+ if (random < drop_category.parts_per_million) {
426
+ *category_name = &drop_category.name;
427
+ return true;
428
+ }
429
+ }
430
+ return false;
431
+ }
432
+
433
+ //
434
+ // XdsApi
435
+ //
436
+
437
+ const char* XdsApi::kLdsTypeUrl =
438
+ "type.googleapis.com/envoy.config.listener.v3.Listener";
439
+ const char* XdsApi::kRdsTypeUrl =
440
+ "type.googleapis.com/envoy.config.route.v3.RouteConfiguration";
441
+ const char* XdsApi::kCdsTypeUrl =
442
+ "type.googleapis.com/envoy.config.cluster.v3.Cluster";
443
+ const char* XdsApi::kEdsTypeUrl =
444
+ "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment";
445
+
446
+ namespace {
447
+
448
+ const char* kLdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Listener";
449
+ const char* kRdsV2TypeUrl =
450
+ "type.googleapis.com/envoy.api.v2.RouteConfiguration";
451
+ const char* kCdsV2TypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
452
+ const char* kEdsV2TypeUrl =
453
+ "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
454
+
455
+ bool IsLds(absl::string_view type_url) {
456
+ return type_url == XdsApi::kLdsTypeUrl || type_url == kLdsV2TypeUrl;
457
+ }
458
+
459
+ bool IsRds(absl::string_view type_url) {
460
+ return type_url == XdsApi::kRdsTypeUrl || type_url == kRdsV2TypeUrl;
461
+ }
462
+
463
+ bool IsCds(absl::string_view type_url) {
464
+ return type_url == XdsApi::kCdsTypeUrl || type_url == kCdsV2TypeUrl;
465
+ }
466
+
467
+ bool IsEds(absl::string_view type_url) {
468
+ return type_url == XdsApi::kEdsTypeUrl || type_url == kEdsV2TypeUrl;
469
+ }
470
+
471
+ } // namespace
472
+
225
473
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
226
- const XdsBootstrap::Node* node)
474
+ const XdsBootstrap* bootstrap)
227
475
  : client_(client),
228
476
  tracer_(tracer),
229
- node_(node),
477
+ use_v3_(bootstrap != nullptr && bootstrap->server().ShouldUseV3()),
478
+ bootstrap_(bootstrap),
230
479
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
231
480
  grpc_version_string())),
232
481
  user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {}
233
482
 
234
483
  namespace {
235
484
 
485
+ // Works for both std::string and absl::string_view.
486
+ template <typename T>
487
+ inline upb_strview StdStringToUpbString(const T& str) {
488
+ return upb_strview_make(str.data(), str.size());
489
+ }
490
+
236
491
  void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
237
492
  const Json& value);
238
493
 
@@ -250,7 +505,7 @@ void PopulateMetadata(upb_arena* arena, google_protobuf_Struct* metadata_pb,
250
505
  google_protobuf_Value* value = google_protobuf_Value_new(arena);
251
506
  PopulateMetadataValue(arena, value, p.second);
252
507
  google_protobuf_Struct_fields_set(
253
- metadata_pb, upb_strview_makez(p.first.c_str()), value, arena);
508
+ metadata_pb, StdStringToUpbString(p.first), value, arena);
254
509
  }
255
510
  }
256
511
 
@@ -266,7 +521,7 @@ void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
266
521
  break;
267
522
  case Json::Type::STRING:
268
523
  google_protobuf_Value_set_string_value(
269
- value_pb, upb_strview_makez(value.string_value().c_str()));
524
+ value_pb, StdStringToUpbString(value.string_value()));
270
525
  break;
271
526
  case Json::Type::JSON_TRUE:
272
527
  google_protobuf_Value_set_bool_value(value_pb, true);
@@ -289,61 +544,94 @@ void PopulateMetadataValue(upb_arena* arena, google_protobuf_Value* value_pb,
289
544
  }
290
545
  }
291
546
 
292
- void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node,
547
+ // Helper functions to manually do protobuf string encoding, so that we
548
+ // can populate the node build_version field that was removed in v3.
549
+ std::string EncodeVarint(uint64_t val) {
550
+ std::string data;
551
+ do {
552
+ uint8_t byte = val & 0x7fU;
553
+ val >>= 7;
554
+ if (val) byte |= 0x80U;
555
+ data += byte;
556
+ } while (val);
557
+ return data;
558
+ }
559
+ std::string EncodeTag(uint32_t field_number, uint8_t wire_type) {
560
+ return EncodeVarint((field_number << 3) | wire_type);
561
+ }
562
+ std::string EncodeStringField(uint32_t field_number, const std::string& str) {
563
+ static const uint8_t kDelimitedWireType = 2;
564
+ return EncodeTag(field_number, kDelimitedWireType) +
565
+ EncodeVarint(str.size()) + str;
566
+ }
567
+
568
+ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
569
+ const std::string& build_version) {
570
+ std::string encoded_build_version = EncodeStringField(5, build_version);
571
+ // TODO(roth): This should use upb_msg_addunknown(), but that API is
572
+ // broken in the current version of upb, so we're using the internal
573
+ // API for now. Change this once we upgrade to a version of upb that
574
+ // fixes this bug.
575
+ _upb_msg_addunknown(node_msg, encoded_build_version.data(),
576
+ encoded_build_version.size(), arena);
577
+ }
578
+
579
+ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
293
580
  const std::string& build_version,
294
581
  const std::string& user_agent_name,
295
582
  const std::string& server_name,
296
- envoy_api_v2_core_Node* node_msg) {
583
+ envoy_config_core_v3_Node* node_msg) {
584
+ const XdsBootstrap::Node* node = bootstrap->node();
297
585
  if (node != nullptr) {
298
586
  if (!node->id.empty()) {
299
- envoy_api_v2_core_Node_set_id(node_msg,
300
- upb_strview_makez(node->id.c_str()));
587
+ envoy_config_core_v3_Node_set_id(node_msg,
588
+ StdStringToUpbString(node->id));
301
589
  }
302
590
  if (!node->cluster.empty()) {
303
- envoy_api_v2_core_Node_set_cluster(
304
- node_msg, upb_strview_makez(node->cluster.c_str()));
591
+ envoy_config_core_v3_Node_set_cluster(
592
+ node_msg, StdStringToUpbString(node->cluster));
305
593
  }
306
594
  if (!node->metadata.object_value().empty()) {
307
595
  google_protobuf_Struct* metadata =
308
- envoy_api_v2_core_Node_mutable_metadata(node_msg, arena);
596
+ envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
309
597
  PopulateMetadata(arena, metadata, node->metadata.object_value());
310
598
  }
311
599
  if (!server_name.empty()) {
312
600
  google_protobuf_Struct* metadata =
313
- envoy_api_v2_core_Node_mutable_metadata(node_msg, arena);
601
+ envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
314
602
  google_protobuf_Value* value = google_protobuf_Value_new(arena);
315
- google_protobuf_Value_set_string_value(
316
- value, upb_strview_make(server_name.data(), server_name.size()));
603
+ google_protobuf_Value_set_string_value(value,
604
+ StdStringToUpbString(server_name));
317
605
  google_protobuf_Struct_fields_set(
318
606
  metadata, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"), value,
319
607
  arena);
320
608
  }
321
609
  if (!node->locality_region.empty() || !node->locality_zone.empty() ||
322
610
  !node->locality_subzone.empty()) {
323
- envoy_api_v2_core_Locality* locality =
324
- envoy_api_v2_core_Node_mutable_locality(node_msg, arena);
611
+ envoy_config_core_v3_Locality* locality =
612
+ envoy_config_core_v3_Node_mutable_locality(node_msg, arena);
325
613
  if (!node->locality_region.empty()) {
326
- envoy_api_v2_core_Locality_set_region(
327
- locality, upb_strview_makez(node->locality_region.c_str()));
614
+ envoy_config_core_v3_Locality_set_region(
615
+ locality, StdStringToUpbString(node->locality_region));
328
616
  }
329
617
  if (!node->locality_zone.empty()) {
330
- envoy_api_v2_core_Locality_set_zone(
331
- locality, upb_strview_makez(node->locality_zone.c_str()));
618
+ envoy_config_core_v3_Locality_set_zone(
619
+ locality, StdStringToUpbString(node->locality_zone));
332
620
  }
333
621
  if (!node->locality_subzone.empty()) {
334
- envoy_api_v2_core_Locality_set_sub_zone(
335
- locality, upb_strview_makez(node->locality_subzone.c_str()));
622
+ envoy_config_core_v3_Locality_set_sub_zone(
623
+ locality, StdStringToUpbString(node->locality_subzone));
336
624
  }
337
625
  }
338
626
  }
339
- envoy_api_v2_core_Node_set_build_version(
340
- node_msg, upb_strview_make(build_version.data(), build_version.size()));
341
- envoy_api_v2_core_Node_set_user_agent_name(
342
- node_msg,
343
- upb_strview_make(user_agent_name.data(), user_agent_name.size()));
344
- envoy_api_v2_core_Node_set_user_agent_version(
627
+ if (!bootstrap->server().ShouldUseV3()) {
628
+ PopulateBuildVersion(arena, node_msg, build_version);
629
+ }
630
+ envoy_config_core_v3_Node_set_user_agent_name(
631
+ node_msg, StdStringToUpbString(user_agent_name));
632
+ envoy_config_core_v3_Node_set_user_agent_version(
345
633
  node_msg, upb_strview_makez(grpc_version_string()));
346
- envoy_api_v2_core_Node_add_client_features(
634
+ envoy_config_core_v3_Node_add_client_features(
347
635
  node_msg, upb_strview_makez("envoy.lb.does_not_support_overprovisioning"),
348
636
  arena);
349
637
  }
@@ -375,32 +663,33 @@ inline void AddUInt32ValueField(const char* name,
375
663
  }
376
664
 
377
665
  inline void AddLocalityField(int indent_level,
378
- const envoy_api_v2_core_Locality* locality,
666
+ const envoy_config_core_v3_Locality* locality,
379
667
  std::vector<std::string>* fields) {
380
668
  std::string indent =
381
669
  absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
382
670
  // region
383
671
  std::string field = absl::StrCat(indent, "region");
384
- AddStringField(field.c_str(), envoy_api_v2_core_Locality_region(locality),
672
+ AddStringField(field.c_str(), envoy_config_core_v3_Locality_region(locality),
385
673
  fields);
386
674
  // zone
387
675
  field = absl::StrCat(indent, "zone");
388
- AddStringField(field.c_str(), envoy_api_v2_core_Locality_zone(locality),
676
+ AddStringField(field.c_str(), envoy_config_core_v3_Locality_zone(locality),
389
677
  fields);
390
678
  // sub_zone
391
679
  field = absl::StrCat(indent, "sub_zone");
392
- AddStringField(field.c_str(), envoy_api_v2_core_Locality_sub_zone(locality),
393
- fields);
680
+ AddStringField(field.c_str(),
681
+ envoy_config_core_v3_Locality_sub_zone(locality), fields);
394
682
  }
395
683
 
396
- void AddNodeLogFields(const envoy_api_v2_core_Node* node,
684
+ void AddNodeLogFields(const envoy_config_core_v3_Node* node,
685
+ const std::string& build_version,
397
686
  std::vector<std::string>* fields) {
398
687
  fields->emplace_back("node {");
399
688
  // id
400
- AddStringField(" id", envoy_api_v2_core_Node_id(node), fields);
689
+ AddStringField(" id", envoy_config_core_v3_Node_id(node), fields);
401
690
  // metadata
402
691
  const google_protobuf_Struct* metadata =
403
- envoy_api_v2_core_Node_metadata(node);
692
+ envoy_config_core_v3_Node_metadata(node);
404
693
  if (metadata != nullptr) {
405
694
  fields->emplace_back(" metadata {");
406
695
  size_t entry_idx = UPB_MAP_BEGIN;
@@ -443,65 +732,72 @@ void AddNodeLogFields(const envoy_api_v2_core_Node* node,
443
732
  fields->emplace_back(" }");
444
733
  }
445
734
  // locality
446
- const envoy_api_v2_core_Locality* locality =
447
- envoy_api_v2_core_Node_locality(node);
735
+ const envoy_config_core_v3_Locality* locality =
736
+ envoy_config_core_v3_Node_locality(node);
448
737
  if (locality != nullptr) {
449
738
  fields->emplace_back(" locality {");
450
739
  AddLocalityField(2, locality, fields);
451
740
  fields->emplace_back(" }");
452
741
  }
453
- // build_version
454
- AddStringField(" build_version", envoy_api_v2_core_Node_build_version(node),
455
- fields);
742
+ // build_version (doesn't exist in v3 proto; this is a horrible hack)
743
+ if (!build_version.empty()) {
744
+ fields->emplace_back(
745
+ absl::StrCat(" build_version: \"", build_version, "\""));
746
+ }
456
747
  // user_agent_name
457
748
  AddStringField(" user_agent_name",
458
- envoy_api_v2_core_Node_user_agent_name(node), fields);
749
+ envoy_config_core_v3_Node_user_agent_name(node), fields);
459
750
  // user_agent_version
460
751
  AddStringField(" user_agent_version",
461
- envoy_api_v2_core_Node_user_agent_version(node), fields);
752
+ envoy_config_core_v3_Node_user_agent_version(node), fields);
462
753
  // client_features
463
754
  size_t num_client_features;
464
755
  const upb_strview* client_features =
465
- envoy_api_v2_core_Node_client_features(node, &num_client_features);
756
+ envoy_config_core_v3_Node_client_features(node, &num_client_features);
466
757
  for (size_t i = 0; i < num_client_features; ++i) {
467
758
  AddStringField(" client_features", client_features[i], fields);
468
759
  }
469
760
  fields->emplace_back("}");
470
761
  }
471
762
 
472
- void MaybeLogDiscoveryRequest(XdsClient* client, TraceFlag* tracer,
473
- const envoy_api_v2_DiscoveryRequest* request) {
763
+ void MaybeLogDiscoveryRequest(
764
+ XdsClient* client, TraceFlag* tracer,
765
+ const envoy_service_discovery_v3_DiscoveryRequest* request,
766
+ const std::string& build_version) {
474
767
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
475
768
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
476
769
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
477
770
  // the raw proto instead of doing this manually.
478
771
  std::vector<std::string> fields;
479
772
  // version_info
480
- AddStringField("version_info",
481
- envoy_api_v2_DiscoveryRequest_version_info(request),
482
- &fields);
773
+ AddStringField(
774
+ "version_info",
775
+ envoy_service_discovery_v3_DiscoveryRequest_version_info(request),
776
+ &fields);
483
777
  // node
484
- const envoy_api_v2_core_Node* node =
485
- envoy_api_v2_DiscoveryRequest_node(request);
486
- if (node != nullptr) AddNodeLogFields(node, &fields);
778
+ const envoy_config_core_v3_Node* node =
779
+ envoy_service_discovery_v3_DiscoveryRequest_node(request);
780
+ if (node != nullptr) AddNodeLogFields(node, build_version, &fields);
487
781
  // resource_names
488
782
  size_t num_resource_names;
489
783
  const upb_strview* resource_names =
490
- envoy_api_v2_DiscoveryRequest_resource_names(request,
491
- &num_resource_names);
784
+ envoy_service_discovery_v3_DiscoveryRequest_resource_names(
785
+ request, &num_resource_names);
492
786
  for (size_t i = 0; i < num_resource_names; ++i) {
493
787
  AddStringField("resource_names", resource_names[i], &fields);
494
788
  }
495
789
  // type_url
496
- AddStringField("type_url", envoy_api_v2_DiscoveryRequest_type_url(request),
497
- &fields);
790
+ AddStringField(
791
+ "type_url",
792
+ envoy_service_discovery_v3_DiscoveryRequest_type_url(request), &fields);
498
793
  // response_nonce
499
- AddStringField("response_nonce",
500
- envoy_api_v2_DiscoveryRequest_response_nonce(request),
501
- &fields);
794
+ AddStringField(
795
+ "response_nonce",
796
+ envoy_service_discovery_v3_DiscoveryRequest_response_nonce(request),
797
+ &fields);
502
798
  // error_detail
503
799
  const struct google_rpc_Status* error_detail =
504
- envoy_api_v2_DiscoveryRequest_error_detail(request);
800
+ envoy_service_discovery_v3_DiscoveryRequest_error_detail(request);
505
801
  if (error_detail != nullptr) {
506
802
  fields.emplace_back("error_detail {");
507
803
  // code
@@ -517,14 +813,33 @@ void MaybeLogDiscoveryRequest(XdsClient* client, TraceFlag* tracer,
517
813
  }
518
814
  }
519
815
 
520
- grpc_slice SerializeDiscoveryRequest(upb_arena* arena,
521
- envoy_api_v2_DiscoveryRequest* request) {
816
+ grpc_slice SerializeDiscoveryRequest(
817
+ upb_arena* arena, envoy_service_discovery_v3_DiscoveryRequest* request) {
522
818
  size_t output_length;
523
- char* output =
524
- envoy_api_v2_DiscoveryRequest_serialize(request, arena, &output_length);
819
+ char* output = envoy_service_discovery_v3_DiscoveryRequest_serialize(
820
+ request, arena, &output_length);
525
821
  return grpc_slice_from_copied_buffer(output, output_length);
526
822
  }
527
823
 
824
+ absl::string_view TypeUrlExternalToInternal(bool use_v3,
825
+ const std::string& type_url) {
826
+ if (!use_v3) {
827
+ if (type_url == XdsApi::kLdsTypeUrl) {
828
+ return kLdsV2TypeUrl;
829
+ }
830
+ if (type_url == XdsApi::kRdsTypeUrl) {
831
+ return kRdsV2TypeUrl;
832
+ }
833
+ if (type_url == XdsApi::kCdsTypeUrl) {
834
+ return kCdsV2TypeUrl;
835
+ }
836
+ if (type_url == XdsApi::kEdsTypeUrl) {
837
+ return kEdsV2TypeUrl;
838
+ }
839
+ }
840
+ return type_url;
841
+ }
842
+
528
843
  } // namespace
529
844
 
530
845
  grpc_slice XdsApi::CreateAdsRequest(
@@ -534,20 +849,22 @@ grpc_slice XdsApi::CreateAdsRequest(
534
849
  bool populate_node) {
535
850
  upb::Arena arena;
536
851
  // Create a request.
537
- envoy_api_v2_DiscoveryRequest* request =
538
- envoy_api_v2_DiscoveryRequest_new(arena.ptr());
852
+ envoy_service_discovery_v3_DiscoveryRequest* request =
853
+ envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
539
854
  // Set type_url.
540
- envoy_api_v2_DiscoveryRequest_set_type_url(
541
- request, upb_strview_make(type_url.data(), type_url.size()));
855
+ absl::string_view real_type_url =
856
+ TypeUrlExternalToInternal(use_v3_, type_url);
857
+ envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
858
+ request, StdStringToUpbString(real_type_url));
542
859
  // Set version_info.
543
860
  if (!version.empty()) {
544
- envoy_api_v2_DiscoveryRequest_set_version_info(
545
- request, upb_strview_make(version.data(), version.size()));
861
+ envoy_service_discovery_v3_DiscoveryRequest_set_version_info(
862
+ request, StdStringToUpbString(version));
546
863
  }
547
864
  // Set nonce.
548
865
  if (!nonce.empty()) {
549
- envoy_api_v2_DiscoveryRequest_set_response_nonce(
550
- request, upb_strview_make(nonce.data(), nonce.size()));
866
+ envoy_service_discovery_v3_DiscoveryRequest_set_response_nonce(
867
+ request, StdStringToUpbString(nonce));
551
868
  }
552
869
  // Set error_detail if it's a NACK.
553
870
  if (error != GRPC_ERROR_NONE) {
@@ -559,51 +876,57 @@ grpc_slice XdsApi::CreateAdsRequest(
559
876
  GPR_SLICE_START_PTR(error_description_slice)),
560
877
  GPR_SLICE_LENGTH(error_description_slice));
561
878
  google_rpc_Status* error_detail =
562
- envoy_api_v2_DiscoveryRequest_mutable_error_detail(request,
563
- arena.ptr());
879
+ envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
880
+ request, arena.ptr());
564
881
  google_rpc_Status_set_message(error_detail, error_description_strview);
565
882
  GRPC_ERROR_UNREF(error);
566
883
  }
567
884
  // Populate node.
568
885
  if (populate_node) {
569
- envoy_api_v2_core_Node* node_msg =
570
- envoy_api_v2_DiscoveryRequest_mutable_node(request, arena.ptr());
571
- PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_, "",
886
+ envoy_config_core_v3_Node* node_msg =
887
+ envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
888
+ arena.ptr());
889
+ PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_, "",
572
890
  node_msg);
573
891
  }
574
892
  // Add resource_names.
575
893
  for (const auto& resource_name : resource_names) {
576
- envoy_api_v2_DiscoveryRequest_add_resource_names(
577
- request, upb_strview_make(resource_name.data(), resource_name.size()),
578
- arena.ptr());
894
+ envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
895
+ request, StdStringToUpbString(resource_name), arena.ptr());
579
896
  }
580
- MaybeLogDiscoveryRequest(client_, tracer_, request);
897
+ MaybeLogDiscoveryRequest(client_, tracer_, request, build_version_);
581
898
  return SerializeDiscoveryRequest(arena.ptr(), request);
582
899
  }
583
900
 
584
901
  namespace {
585
902
 
586
- void MaybeLogDiscoveryResponse(XdsClient* client, TraceFlag* tracer,
587
- const envoy_api_v2_DiscoveryResponse* response) {
903
+ void MaybeLogDiscoveryResponse(
904
+ XdsClient* client, TraceFlag* tracer,
905
+ const envoy_service_discovery_v3_DiscoveryResponse* response) {
588
906
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
589
907
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
590
908
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
591
909
  // the raw proto instead of doing this manually.
592
910
  std::vector<std::string> fields;
593
911
  // version_info
594
- AddStringField("version_info",
595
- envoy_api_v2_DiscoveryResponse_version_info(response),
596
- &fields);
912
+ AddStringField(
913
+ "version_info",
914
+ envoy_service_discovery_v3_DiscoveryResponse_version_info(response),
915
+ &fields);
597
916
  // resources
598
917
  size_t num_resources;
599
- envoy_api_v2_DiscoveryResponse_resources(response, &num_resources);
918
+ envoy_service_discovery_v3_DiscoveryResponse_resources(response,
919
+ &num_resources);
600
920
  fields.emplace_back(
601
921
  absl::StrCat("resources: <", num_resources, " element(s)>"));
602
922
  // type_url
603
- AddStringField("type_url",
604
- envoy_api_v2_DiscoveryResponse_type_url(response), &fields);
923
+ AddStringField(
924
+ "type_url",
925
+ envoy_service_discovery_v3_DiscoveryResponse_type_url(response),
926
+ &fields);
605
927
  // nonce
606
- AddStringField("nonce", envoy_api_v2_DiscoveryResponse_nonce(response),
928
+ AddStringField("nonce",
929
+ envoy_service_discovery_v3_DiscoveryResponse_nonce(response),
607
930
  &fields);
608
931
  gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
609
932
  absl::StrJoin(fields, "\n").c_str());
@@ -612,69 +935,69 @@ void MaybeLogDiscoveryResponse(XdsClient* client, TraceFlag* tracer,
612
935
 
613
936
  void MaybeLogRouteConfiguration(
614
937
  XdsClient* client, TraceFlag* tracer,
615
- const envoy_api_v2_RouteConfiguration* route_config) {
938
+ const envoy_config_route_v3_RouteConfiguration* route_config) {
616
939
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
617
940
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
618
941
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
619
942
  // the raw proto instead of doing this manually.
620
943
  std::vector<std::string> fields;
621
944
  // name
622
- AddStringField("name", envoy_api_v2_RouteConfiguration_name(route_config),
945
+ AddStringField("name",
946
+ envoy_config_route_v3_RouteConfiguration_name(route_config),
623
947
  &fields);
624
948
  // virtual_hosts
625
949
  size_t num_virtual_hosts;
626
- const envoy_api_v2_route_VirtualHost* const* virtual_hosts =
627
- envoy_api_v2_RouteConfiguration_virtual_hosts(route_config,
628
- &num_virtual_hosts);
950
+ const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
951
+ envoy_config_route_v3_RouteConfiguration_virtual_hosts(
952
+ route_config, &num_virtual_hosts);
629
953
  for (size_t i = 0; i < num_virtual_hosts; ++i) {
630
954
  const auto* virtual_host = virtual_hosts[i];
631
955
  fields.push_back("virtual_hosts {");
632
956
  // name
633
- AddStringField(
634
- " name", envoy_api_v2_route_VirtualHost_name(virtual_host), &fields);
957
+ AddStringField(" name",
958
+ envoy_config_route_v3_VirtualHost_name(virtual_host),
959
+ &fields);
635
960
  // domains
636
961
  size_t num_domains;
637
962
  const upb_strview* const domains =
638
- envoy_api_v2_route_VirtualHost_domains(virtual_host, &num_domains);
963
+ envoy_config_route_v3_VirtualHost_domains(virtual_host, &num_domains);
639
964
  for (size_t j = 0; j < num_domains; ++j) {
640
965
  AddStringField(" domains", domains[j], &fields);
641
966
  }
642
967
  // routes
643
968
  size_t num_routes;
644
- const envoy_api_v2_route_Route* const* routes =
645
- envoy_api_v2_route_VirtualHost_routes(virtual_host, &num_routes);
969
+ const envoy_config_route_v3_Route* const* routes =
970
+ envoy_config_route_v3_VirtualHost_routes(virtual_host, &num_routes);
646
971
  for (size_t j = 0; j < num_routes; ++j) {
647
972
  const auto* route = routes[j];
648
973
  fields.push_back(" route {");
649
974
  // name
650
- AddStringField(" name", envoy_api_v2_route_Route_name(route),
975
+ AddStringField(" name", envoy_config_route_v3_Route_name(route),
651
976
  &fields);
652
977
  // match
653
- const envoy_api_v2_route_RouteMatch* match =
654
- envoy_api_v2_route_Route_match(route);
978
+ const envoy_config_route_v3_RouteMatch* match =
979
+ envoy_config_route_v3_Route_match(route);
655
980
  if (match != nullptr) {
656
981
  fields.emplace_back(" match {");
657
982
  // path matching
658
- if (envoy_api_v2_route_RouteMatch_has_prefix(match)) {
983
+ if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
659
984
  AddStringField(" prefix",
660
- envoy_api_v2_route_RouteMatch_prefix(match), &fields,
985
+ envoy_config_route_v3_RouteMatch_prefix(match),
986
+ &fields,
661
987
  /*add_if_empty=*/true);
662
- } else if (envoy_api_v2_route_RouteMatch_has_path(match)) {
988
+ } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
663
989
  AddStringField(" path",
664
- envoy_api_v2_route_RouteMatch_path(match), &fields,
665
- /*add_if_empty=*/true);
666
- } else if (envoy_api_v2_route_RouteMatch_has_regex(match)) {
667
- AddStringField(" regex",
668
- envoy_api_v2_route_RouteMatch_regex(match), &fields,
990
+ envoy_config_route_v3_RouteMatch_path(match),
991
+ &fields,
669
992
  /*add_if_empty=*/true);
670
- } else if (envoy_api_v2_route_RouteMatch_has_safe_regex(match)) {
993
+ } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
671
994
  fields.emplace_back(" safe_regex: <not printed>");
672
995
  } else {
673
996
  fields.emplace_back(" <unknown path matching type>");
674
997
  }
675
998
  // header matching
676
999
  size_t num_headers;
677
- envoy_api_v2_route_RouteMatch_headers(match, &num_headers);
1000
+ envoy_config_route_v3_RouteMatch_headers(match, &num_headers);
678
1001
  if (num_headers > 0) {
679
1002
  fields.emplace_back(
680
1003
  absl::StrCat(" headers: <", num_headers, " element(s)>"));
@@ -682,56 +1005,59 @@ void MaybeLogRouteConfiguration(
682
1005
  fields.emplace_back(" }");
683
1006
  }
684
1007
  // action
685
- if (envoy_api_v2_route_Route_has_route(route)) {
686
- const envoy_api_v2_route_RouteAction* action =
687
- envoy_api_v2_route_Route_route(route);
1008
+ if (envoy_config_route_v3_Route_has_route(route)) {
1009
+ const envoy_config_route_v3_RouteAction* action =
1010
+ envoy_config_route_v3_Route_route(route);
688
1011
  fields.emplace_back(" route {");
689
- if (envoy_api_v2_route_RouteAction_has_cluster(action)) {
1012
+ if (envoy_config_route_v3_RouteAction_has_cluster(action)) {
690
1013
  AddStringField(" cluster",
691
- envoy_api_v2_route_RouteAction_cluster(action),
1014
+ envoy_config_route_v3_RouteAction_cluster(action),
692
1015
  &fields);
693
- } else if (envoy_api_v2_route_RouteAction_has_cluster_header(
1016
+ } else if (envoy_config_route_v3_RouteAction_has_cluster_header(
694
1017
  action)) {
695
1018
  AddStringField(
696
1019
  " cluster_header",
697
- envoy_api_v2_route_RouteAction_cluster_header(action), &fields);
698
- } else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
1020
+ envoy_config_route_v3_RouteAction_cluster_header(action),
1021
+ &fields);
1022
+ } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
699
1023
  action)) {
700
- const envoy_api_v2_route_WeightedCluster* weighted_clusters =
701
- envoy_api_v2_route_RouteAction_weighted_clusters(action);
1024
+ const envoy_config_route_v3_WeightedCluster* weighted_clusters =
1025
+ envoy_config_route_v3_RouteAction_weighted_clusters(action);
702
1026
  fields.emplace_back(" weighted_clusters {");
703
1027
  size_t num_cluster_weights;
704
- const envoy_api_v2_route_WeightedCluster_ClusterWeight* const*
705
- cluster_weights = envoy_api_v2_route_WeightedCluster_clusters(
706
- weighted_clusters, &num_cluster_weights);
1028
+ const envoy_config_route_v3_WeightedCluster_ClusterWeight* const*
1029
+ cluster_weights =
1030
+ envoy_config_route_v3_WeightedCluster_clusters(
1031
+ weighted_clusters, &num_cluster_weights);
707
1032
  for (size_t i = 0; i < num_cluster_weights; ++i) {
708
- const envoy_api_v2_route_WeightedCluster_ClusterWeight*
1033
+ const envoy_config_route_v3_WeightedCluster_ClusterWeight*
709
1034
  cluster_weight = cluster_weights[i];
710
1035
  fields.emplace_back(" clusters {");
711
1036
  AddStringField(
712
1037
  " name",
713
- envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
1038
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
714
1039
  cluster_weight),
715
1040
  &fields);
716
1041
  AddUInt32ValueField(
717
1042
  " weight",
718
- envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
1043
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
719
1044
  cluster_weight),
720
1045
  &fields);
721
1046
  fields.emplace_back(" }");
722
1047
  }
723
- AddUInt32ValueField(" total_weight",
724
- envoy_api_v2_route_WeightedCluster_total_weight(
725
- weighted_clusters),
726
- &fields);
1048
+ AddUInt32ValueField(
1049
+ " total_weight",
1050
+ envoy_config_route_v3_WeightedCluster_total_weight(
1051
+ weighted_clusters),
1052
+ &fields);
727
1053
  fields.emplace_back(" }");
728
1054
  }
729
1055
  fields.emplace_back(" }");
730
- } else if (envoy_api_v2_route_Route_has_redirect(route)) {
1056
+ } else if (envoy_config_route_v3_Route_has_redirect(route)) {
731
1057
  fields.emplace_back(" redirect: <not printed>");
732
- } else if (envoy_api_v2_route_Route_has_direct_response(route)) {
1058
+ } else if (envoy_config_route_v3_Route_has_direct_response(route)) {
733
1059
  fields.emplace_back(" direct_response: <not printed>");
734
- } else if (envoy_api_v2_route_Route_has_filter_action(route)) {
1060
+ } else if (envoy_config_route_v3_Route_has_filter_action(route)) {
735
1061
  fields.emplace_back(" filter_action: <not printed>");
736
1062
  }
737
1063
  fields.push_back(" }");
@@ -744,53 +1070,56 @@ void MaybeLogRouteConfiguration(
744
1070
  }
745
1071
 
746
1072
  void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
747
- const envoy_api_v2_Cluster* cluster) {
1073
+ const envoy_config_cluster_v3_Cluster* cluster) {
748
1074
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
749
1075
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
750
1076
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
751
1077
  // the raw proto instead of doing this manually.
752
1078
  std::vector<std::string> fields;
753
1079
  // name
754
- AddStringField("name", envoy_api_v2_Cluster_name(cluster), &fields);
1080
+ AddStringField("name", envoy_config_cluster_v3_Cluster_name(cluster),
1081
+ &fields);
755
1082
  // type
756
- if (envoy_api_v2_Cluster_has_type(cluster)) {
757
- fields.emplace_back(
758
- absl::StrCat("type: ", envoy_api_v2_Cluster_type(cluster)));
759
- } else if (envoy_api_v2_Cluster_has_cluster_type(cluster)) {
1083
+ if (envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1084
+ fields.emplace_back(absl::StrCat(
1085
+ "type: ", envoy_config_cluster_v3_Cluster_type(cluster)));
1086
+ } else if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
760
1087
  fields.emplace_back("cluster_type: <not printed>");
761
1088
  } else {
762
1089
  fields.emplace_back("<unknown type>");
763
1090
  }
764
1091
  // eds_cluster_config
765
- const envoy_api_v2_Cluster_EdsClusterConfig* eds_cluster_config =
766
- envoy_api_v2_Cluster_eds_cluster_config(cluster);
1092
+ const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1093
+ envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
767
1094
  if (eds_cluster_config != nullptr) {
768
1095
  fields.emplace_back("eds_cluster_config {");
769
1096
  // eds_config
770
- const struct envoy_api_v2_core_ConfigSource* eds_config =
771
- envoy_api_v2_Cluster_EdsClusterConfig_eds_config(eds_cluster_config);
1097
+ const struct envoy_config_core_v3_ConfigSource* eds_config =
1098
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1099
+ eds_cluster_config);
772
1100
  if (eds_config != nullptr) {
773
- if (envoy_api_v2_core_ConfigSource_has_ads(eds_config)) {
1101
+ if (envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
774
1102
  fields.emplace_back(" eds_config { ads {} }");
775
1103
  } else {
776
1104
  fields.emplace_back(" eds_config: <non-ADS type>");
777
1105
  }
778
1106
  }
779
1107
  // service_name
780
- AddStringField(" service_name",
781
- envoy_api_v2_Cluster_EdsClusterConfig_service_name(
782
- eds_cluster_config),
783
- &fields);
1108
+ AddStringField(
1109
+ " service_name",
1110
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1111
+ eds_cluster_config),
1112
+ &fields);
784
1113
  fields.emplace_back("}");
785
1114
  }
786
1115
  // lb_policy
787
- fields.emplace_back(
788
- absl::StrCat("lb_policy: ", envoy_api_v2_Cluster_lb_policy(cluster)));
1116
+ fields.emplace_back(absl::StrCat(
1117
+ "lb_policy: ", envoy_config_cluster_v3_Cluster_lb_policy(cluster)));
789
1118
  // lrs_server
790
- const envoy_api_v2_core_ConfigSource* lrs_server =
791
- envoy_api_v2_Cluster_lrs_server(cluster);
1119
+ const envoy_config_core_v3_ConfigSource* lrs_server =
1120
+ envoy_config_cluster_v3_Cluster_lrs_server(cluster);
792
1121
  if (lrs_server != nullptr) {
793
- if (envoy_api_v2_core_ConfigSource_has_self(lrs_server)) {
1122
+ if (envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
794
1123
  fields.emplace_back("lrs_server { self {} }");
795
1124
  } else {
796
1125
  fields.emplace_back("lrs_server: <non-self type>");
@@ -803,27 +1132,30 @@ void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
803
1132
 
804
1133
  void MaybeLogClusterLoadAssignment(
805
1134
  XdsClient* client, TraceFlag* tracer,
806
- const envoy_api_v2_ClusterLoadAssignment* cla) {
1135
+ const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
807
1136
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
808
1137
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
809
1138
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
810
1139
  // the raw proto instead of doing this manually.
811
1140
  std::vector<std::string> fields;
812
1141
  // cluster_name
813
- AddStringField("cluster_name",
814
- envoy_api_v2_ClusterLoadAssignment_cluster_name(cla),
815
- &fields);
1142
+ AddStringField(
1143
+ "cluster_name",
1144
+ envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(cla),
1145
+ &fields);
816
1146
  // endpoints
817
1147
  size_t num_localities;
818
- const struct envoy_api_v2_endpoint_LocalityLbEndpoints* const*
1148
+ const struct envoy_config_endpoint_v3_LocalityLbEndpoints* const*
819
1149
  locality_endpoints =
820
- envoy_api_v2_ClusterLoadAssignment_endpoints(cla, &num_localities);
1150
+ envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1151
+ cla, &num_localities);
821
1152
  for (size_t i = 0; i < num_localities; ++i) {
822
1153
  const auto* locality_endpoint = locality_endpoints[i];
823
1154
  fields.emplace_back("endpoints {");
824
1155
  // locality
825
1156
  const auto* locality =
826
- envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_endpoint);
1157
+ envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
1158
+ locality_endpoint);
827
1159
  if (locality != nullptr) {
828
1160
  fields.emplace_back(" locality {");
829
1161
  AddLocalityField(2, locality, &fields);
@@ -831,45 +1163,45 @@ void MaybeLogClusterLoadAssignment(
831
1163
  }
832
1164
  // lb_endpoints
833
1165
  size_t num_lb_endpoints;
834
- const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints =
835
- envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(
1166
+ const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
1167
+ envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
836
1168
  locality_endpoint, &num_lb_endpoints);
837
1169
  for (size_t j = 0; j < num_lb_endpoints; ++j) {
838
1170
  const auto* lb_endpoint = lb_endpoints[j];
839
1171
  fields.emplace_back(" lb_endpoints {");
840
1172
  // health_status
841
1173
  uint32_t health_status =
842
- envoy_api_v2_endpoint_LbEndpoint_health_status(lb_endpoint);
1174
+ envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
843
1175
  if (health_status > 0) {
844
1176
  fields.emplace_back(
845
1177
  absl::StrCat(" health_status: ", health_status));
846
1178
  }
847
1179
  // endpoint
848
- const envoy_api_v2_endpoint_Endpoint* endpoint =
849
- envoy_api_v2_endpoint_LbEndpoint_endpoint(lb_endpoint);
1180
+ const envoy_config_endpoint_v3_Endpoint* endpoint =
1181
+ envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
850
1182
  if (endpoint != nullptr) {
851
1183
  fields.emplace_back(" endpoint {");
852
1184
  // address
853
1185
  const auto* address =
854
- envoy_api_v2_endpoint_Endpoint_address(endpoint);
1186
+ envoy_config_endpoint_v3_Endpoint_address(endpoint);
855
1187
  if (address != nullptr) {
856
1188
  fields.emplace_back(" address {");
857
1189
  // socket_address
858
1190
  const auto* socket_address =
859
- envoy_api_v2_core_Address_socket_address(address);
1191
+ envoy_config_core_v3_Address_socket_address(address);
860
1192
  if (socket_address != nullptr) {
861
1193
  fields.emplace_back(" socket_address {");
862
1194
  // address
863
1195
  AddStringField(
864
1196
  " address",
865
- envoy_api_v2_core_SocketAddress_address(socket_address),
1197
+ envoy_config_core_v3_SocketAddress_address(socket_address),
866
1198
  &fields);
867
1199
  // port_value
868
- if (envoy_api_v2_core_SocketAddress_has_port_value(
1200
+ if (envoy_config_core_v3_SocketAddress_has_port_value(
869
1201
  socket_address)) {
870
1202
  fields.emplace_back(
871
1203
  absl::StrCat(" port_value: ",
872
- envoy_api_v2_core_SocketAddress_port_value(
1204
+ envoy_config_core_v3_SocketAddress_port_value(
873
1205
  socket_address)));
874
1206
  } else {
875
1207
  fields.emplace_back(" <non-numeric port>");
@@ -887,27 +1219,27 @@ void MaybeLogClusterLoadAssignment(
887
1219
  // load_balancing_weight
888
1220
  AddUInt32ValueField(
889
1221
  " load_balancing_weight",
890
- envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(
1222
+ envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
891
1223
  locality_endpoint),
892
1224
  &fields);
893
1225
  // priority
894
- uint32_t priority =
895
- envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_endpoint);
1226
+ uint32_t priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1227
+ locality_endpoint);
896
1228
  if (priority > 0) {
897
1229
  fields.emplace_back(absl::StrCat(" priority: ", priority));
898
1230
  }
899
1231
  fields.emplace_back("}");
900
1232
  }
901
1233
  // policy
902
- const envoy_api_v2_ClusterLoadAssignment_Policy* policy =
903
- envoy_api_v2_ClusterLoadAssignment_policy(cla);
1234
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
1235
+ envoy_config_endpoint_v3_ClusterLoadAssignment_policy(cla);
904
1236
  if (policy != nullptr) {
905
1237
  fields.emplace_back("policy {");
906
1238
  // drop_overloads
907
1239
  size_t num_drop_overloads;
908
- const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const*
1240
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
909
1241
  drop_overloads =
910
- envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(
1242
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
911
1243
  policy, &num_drop_overloads);
912
1244
  for (size_t i = 0; i < num_drop_overloads; ++i) {
913
1245
  auto* drop_overload = drop_overloads[i];
@@ -915,21 +1247,21 @@ void MaybeLogClusterLoadAssignment(
915
1247
  // category
916
1248
  AddStringField(
917
1249
  " category",
918
- envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_category(
1250
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
919
1251
  drop_overload),
920
1252
  &fields);
921
1253
  // drop_percentage
922
1254
  const auto* drop_percentage =
923
- envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1255
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
924
1256
  drop_overload);
925
1257
  if (drop_percentage != nullptr) {
926
1258
  fields.emplace_back(" drop_percentage {");
927
1259
  fields.emplace_back(absl::StrCat(
928
1260
  " numerator: ",
929
- envoy_type_FractionalPercent_numerator(drop_percentage)));
1261
+ envoy_type_v3_FractionalPercent_numerator(drop_percentage)));
930
1262
  fields.emplace_back(absl::StrCat(
931
1263
  " denominator: ",
932
- envoy_type_FractionalPercent_denominator(drop_percentage)));
1264
+ envoy_type_v3_FractionalPercent_denominator(drop_percentage)));
933
1265
  fields.emplace_back(" }");
934
1266
  }
935
1267
  fields.emplace_back(" }");
@@ -942,74 +1274,22 @@ void MaybeLogClusterLoadAssignment(
942
1274
  }
943
1275
  }
944
1276
 
945
- // Better match type has smaller value.
946
- enum MatchType {
947
- EXACT_MATCH,
948
- SUFFIX_MATCH,
949
- PREFIX_MATCH,
950
- UNIVERSE_MATCH,
951
- INVALID_MATCH,
952
- };
953
-
954
- // Returns true if match succeeds.
955
- bool DomainMatch(MatchType match_type, std::string domain_pattern,
956
- std::string expected_host_name) {
957
- // Normalize the args to lower-case. Domain matching is case-insensitive.
958
- std::transform(domain_pattern.begin(), domain_pattern.end(),
959
- domain_pattern.begin(),
960
- [](unsigned char c) { return std::tolower(c); });
961
- std::transform(expected_host_name.begin(), expected_host_name.end(),
962
- expected_host_name.begin(),
963
- [](unsigned char c) { return std::tolower(c); });
964
- if (match_type == EXACT_MATCH) {
965
- return domain_pattern == expected_host_name;
966
- } else if (match_type == SUFFIX_MATCH) {
967
- // Asterisk must match at least one char.
968
- if (expected_host_name.size() < domain_pattern.size()) return false;
969
- absl::string_view pattern_suffix(domain_pattern.c_str() + 1);
970
- absl::string_view host_suffix(expected_host_name.c_str() +
971
- expected_host_name.size() -
972
- pattern_suffix.size());
973
- return pattern_suffix == host_suffix;
974
- } else if (match_type == PREFIX_MATCH) {
975
- // Asterisk must match at least one char.
976
- if (expected_host_name.size() < domain_pattern.size()) return false;
977
- absl::string_view pattern_prefix(domain_pattern.c_str(),
978
- domain_pattern.size() - 1);
979
- absl::string_view host_prefix(expected_host_name.c_str(),
980
- pattern_prefix.size());
981
- return pattern_prefix == host_prefix;
982
- } else {
983
- return match_type == UNIVERSE_MATCH;
984
- }
985
- }
986
-
987
- MatchType DomainPatternMatchType(const std::string& domain_pattern) {
988
- if (domain_pattern.empty()) return INVALID_MATCH;
989
- if (domain_pattern.find('*') == std::string::npos) return EXACT_MATCH;
990
- if (domain_pattern == "*") return UNIVERSE_MATCH;
991
- if (domain_pattern[0] == '*') return SUFFIX_MATCH;
992
- if (domain_pattern[domain_pattern.size() - 1] == '*') return PREFIX_MATCH;
993
- return INVALID_MATCH;
994
- }
995
-
996
- grpc_error* RoutePathMatchParse(const envoy_api_v2_route_RouteMatch* match,
997
- XdsApi::RdsUpdate::RdsRoute* rds_route,
998
- bool* ignore_route) {
999
- if (envoy_api_v2_route_RouteMatch_has_prefix(match)) {
1000
- upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
1277
+ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1278
+ XdsApi::Route* route, bool* ignore_route) {
1279
+ if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1280
+ absl::string_view prefix =
1281
+ UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
1001
1282
  // Empty prefix "" is accepted.
1002
- if (prefix.size > 0) {
1283
+ if (prefix.size() > 0) {
1003
1284
  // Prefix "/" is accepted.
1004
- if (prefix.data[0] != '/') {
1285
+ if (prefix[0] != '/') {
1005
1286
  // Prefix which does not start with a / will never match anything, so
1006
1287
  // ignore this route.
1007
1288
  *ignore_route = true;
1008
1289
  return GRPC_ERROR_NONE;
1009
1290
  }
1010
1291
  std::vector<absl::string_view> prefix_elements =
1011
- absl::StrSplit(absl::string_view(prefix.data, prefix.size).substr(1),
1012
- absl::MaxSplits('/', 2));
1292
+ absl::StrSplit(prefix.substr(1), absl::MaxSplits('/', 2));
1013
1293
  if (prefix_elements.size() > 2) {
1014
1294
  // Prefix cannot have more than 2 slashes.
1015
1295
  *ignore_route = true;
@@ -1020,26 +1300,25 @@ grpc_error* RoutePathMatchParse(const envoy_api_v2_route_RouteMatch* match,
1020
1300
  return GRPC_ERROR_NONE;
1021
1301
  }
1022
1302
  }
1023
- rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
1024
- Matchers::PathMatcher::PathMatcherType::PREFIX;
1025
- rds_route->matchers.path_matcher.string_matcher =
1026
- UpbStringToStdString(prefix);
1027
- } else if (envoy_api_v2_route_RouteMatch_has_path(match)) {
1028
- upb_strview path = envoy_api_v2_route_RouteMatch_path(match);
1029
- if (path.size == 0) {
1303
+ route->matchers.path_matcher.type =
1304
+ XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PREFIX;
1305
+ route->matchers.path_matcher.string_matcher = std::string(prefix);
1306
+ } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1307
+ absl::string_view path =
1308
+ UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
1309
+ if (path.size() == 0) {
1030
1310
  // Path that is empty will never match anything, so ignore this route.
1031
1311
  *ignore_route = true;
1032
1312
  return GRPC_ERROR_NONE;
1033
1313
  }
1034
- if (path.data[0] != '/') {
1314
+ if (path[0] != '/') {
1035
1315
  // Path which does not start with a / will never match anything, so
1036
1316
  // ignore this route.
1037
1317
  *ignore_route = true;
1038
1318
  return GRPC_ERROR_NONE;
1039
1319
  }
1040
1320
  std::vector<absl::string_view> path_elements =
1041
- absl::StrSplit(absl::string_view(path.data, path.size).substr(1),
1042
- absl::MaxSplits('/', 2));
1321
+ absl::StrSplit(path.substr(1), absl::MaxSplits('/', 2));
1043
1322
  if (path_elements.size() != 2) {
1044
1323
  // Path not in the required format of /service/method will never match
1045
1324
  // anything, so ignore this route.
@@ -1056,24 +1335,23 @@ grpc_error* RoutePathMatchParse(const envoy_api_v2_route_RouteMatch* match,
1056
1335
  *ignore_route = true;
1057
1336
  return GRPC_ERROR_NONE;
1058
1337
  }
1059
- rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
1060
- Matchers::PathMatcher::PathMatcherType::PATH;
1061
- rds_route->matchers.path_matcher.string_matcher =
1062
- UpbStringToStdString(path);
1063
- } else if (envoy_api_v2_route_RouteMatch_has_safe_regex(match)) {
1064
- const envoy_type_matcher_RegexMatcher* regex_matcher =
1065
- envoy_api_v2_route_RouteMatch_safe_regex(match);
1338
+ route->matchers.path_matcher.type =
1339
+ XdsApi::Route::Matchers::PathMatcher::PathMatcherType::PATH;
1340
+ route->matchers.path_matcher.string_matcher = std::string(path);
1341
+ } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
1342
+ const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1343
+ envoy_config_route_v3_RouteMatch_safe_regex(match);
1066
1344
  GPR_ASSERT(regex_matcher != nullptr);
1067
- const std::string matcher = UpbStringToStdString(
1068
- envoy_type_matcher_RegexMatcher_regex(regex_matcher));
1069
- std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
1345
+ std::string matcher = UpbStringToStdString(
1346
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1347
+ std::unique_ptr<RE2> regex = absl::make_unique<RE2>(std::move(matcher));
1070
1348
  if (!regex->ok()) {
1071
1349
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1072
1350
  "Invalid regex string specified in path matcher.");
1073
1351
  }
1074
- rds_route->matchers.path_matcher.type = XdsApi::RdsUpdate::RdsRoute::
1075
- Matchers::PathMatcher::PathMatcherType::REGEX;
1076
- rds_route->matchers.path_matcher.regex_matcher = std::move(regex);
1352
+ route->matchers.path_matcher.type =
1353
+ XdsApi::Route::Matchers::PathMatcher::PathMatcherType::REGEX;
1354
+ route->matchers.path_matcher.regex_matcher = std::move(regex);
1077
1355
  } else {
1078
1356
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1079
1357
  "Invalid route path specifier specified.");
@@ -1081,146 +1359,145 @@ grpc_error* RoutePathMatchParse(const envoy_api_v2_route_RouteMatch* match,
1081
1359
  return GRPC_ERROR_NONE;
1082
1360
  }
1083
1361
 
1084
- grpc_error* RouteHeaderMatchersParse(const envoy_api_v2_route_RouteMatch* match,
1085
- XdsApi::RdsUpdate::RdsRoute* rds_route) {
1362
+ grpc_error* RouteHeaderMatchersParse(
1363
+ const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
1086
1364
  size_t size;
1087
- const envoy_api_v2_route_HeaderMatcher* const* headers =
1088
- envoy_api_v2_route_RouteMatch_headers(match, &size);
1365
+ const envoy_config_route_v3_HeaderMatcher* const* headers =
1366
+ envoy_config_route_v3_RouteMatch_headers(match, &size);
1089
1367
  for (size_t i = 0; i < size; ++i) {
1090
- const envoy_api_v2_route_HeaderMatcher* header = headers[i];
1091
- XdsApi::RdsUpdate::RdsRoute::Matchers::HeaderMatcher header_matcher;
1368
+ const envoy_config_route_v3_HeaderMatcher* header = headers[i];
1369
+ XdsApi::Route::Matchers::HeaderMatcher header_matcher;
1092
1370
  header_matcher.name =
1093
- UpbStringToStdString(envoy_api_v2_route_HeaderMatcher_name(header));
1094
- if (envoy_api_v2_route_HeaderMatcher_has_exact_match(header)) {
1095
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1096
- HeaderMatcher::HeaderMatcherType::EXACT;
1371
+ UpbStringToStdString(envoy_config_route_v3_HeaderMatcher_name(header));
1372
+ if (envoy_config_route_v3_HeaderMatcher_has_exact_match(header)) {
1373
+ header_matcher.type =
1374
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::EXACT;
1097
1375
  header_matcher.string_matcher = UpbStringToStdString(
1098
- envoy_api_v2_route_HeaderMatcher_exact_match(header));
1099
- } else if (envoy_api_v2_route_HeaderMatcher_has_safe_regex_match(header)) {
1100
- const envoy_type_matcher_RegexMatcher* regex_matcher =
1101
- envoy_api_v2_route_HeaderMatcher_safe_regex_match(header);
1376
+ envoy_config_route_v3_HeaderMatcher_exact_match(header));
1377
+ } else if (envoy_config_route_v3_HeaderMatcher_has_safe_regex_match(
1378
+ header)) {
1379
+ const envoy_type_matcher_v3_RegexMatcher* regex_matcher =
1380
+ envoy_config_route_v3_HeaderMatcher_safe_regex_match(header);
1102
1381
  GPR_ASSERT(regex_matcher != nullptr);
1103
1382
  const std::string matcher = UpbStringToStdString(
1104
- envoy_type_matcher_RegexMatcher_regex(regex_matcher));
1383
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1105
1384
  std::unique_ptr<RE2> regex = absl::make_unique<RE2>(matcher);
1106
1385
  if (!regex->ok()) {
1107
1386
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1108
1387
  "Invalid regex string specified in header matcher.");
1109
1388
  }
1110
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1111
- HeaderMatcher::HeaderMatcherType::REGEX;
1389
+ header_matcher.type =
1390
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::REGEX;
1112
1391
  header_matcher.regex_match = std::move(regex);
1113
- } else if (envoy_api_v2_route_HeaderMatcher_has_range_match(header)) {
1114
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1115
- HeaderMatcher::HeaderMatcherType::RANGE;
1116
- const envoy_type_Int64Range* range_matcher =
1117
- envoy_api_v2_route_HeaderMatcher_range_match(header);
1118
- header_matcher.range_start = envoy_type_Int64Range_start(range_matcher);
1119
- header_matcher.range_end = envoy_type_Int64Range_end(range_matcher);
1392
+ } else if (envoy_config_route_v3_HeaderMatcher_has_range_match(header)) {
1393
+ header_matcher.type =
1394
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::RANGE;
1395
+ const envoy_type_v3_Int64Range* range_matcher =
1396
+ envoy_config_route_v3_HeaderMatcher_range_match(header);
1397
+ header_matcher.range_start =
1398
+ envoy_type_v3_Int64Range_start(range_matcher);
1399
+ header_matcher.range_end = envoy_type_v3_Int64Range_end(range_matcher);
1120
1400
  if (header_matcher.range_end < header_matcher.range_start) {
1121
1401
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1122
1402
  "Invalid range header matcher specifier specified: end "
1123
1403
  "cannot be smaller than start.");
1124
1404
  }
1125
- } else if (envoy_api_v2_route_HeaderMatcher_has_present_match(header)) {
1126
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1127
- HeaderMatcher::HeaderMatcherType::PRESENT;
1405
+ } else if (envoy_config_route_v3_HeaderMatcher_has_present_match(header)) {
1406
+ header_matcher.type =
1407
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PRESENT;
1128
1408
  header_matcher.present_match =
1129
- envoy_api_v2_route_HeaderMatcher_present_match(header);
1130
- } else if (envoy_api_v2_route_HeaderMatcher_has_prefix_match(header)) {
1131
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1132
- HeaderMatcher::HeaderMatcherType::PREFIX;
1409
+ envoy_config_route_v3_HeaderMatcher_present_match(header);
1410
+ } else if (envoy_config_route_v3_HeaderMatcher_has_prefix_match(header)) {
1411
+ header_matcher.type =
1412
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::PREFIX;
1133
1413
  header_matcher.string_matcher = UpbStringToStdString(
1134
- envoy_api_v2_route_HeaderMatcher_prefix_match(header));
1135
- } else if (envoy_api_v2_route_HeaderMatcher_has_suffix_match(header)) {
1136
- header_matcher.type = XdsApi::RdsUpdate::RdsRoute::Matchers::
1137
- HeaderMatcher::HeaderMatcherType::SUFFIX;
1414
+ envoy_config_route_v3_HeaderMatcher_prefix_match(header));
1415
+ } else if (envoy_config_route_v3_HeaderMatcher_has_suffix_match(header)) {
1416
+ header_matcher.type =
1417
+ XdsApi::Route::Matchers::HeaderMatcher::HeaderMatcherType::SUFFIX;
1138
1418
  header_matcher.string_matcher = UpbStringToStdString(
1139
- envoy_api_v2_route_HeaderMatcher_suffix_match(header));
1419
+ envoy_config_route_v3_HeaderMatcher_suffix_match(header));
1140
1420
  } else {
1141
1421
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1142
1422
  "Invalid route header matcher specified.");
1143
1423
  }
1144
1424
  header_matcher.invert_match =
1145
- envoy_api_v2_route_HeaderMatcher_invert_match(header);
1146
- rds_route->matchers.header_matchers.emplace_back(std::move(header_matcher));
1425
+ envoy_config_route_v3_HeaderMatcher_invert_match(header);
1426
+ route->matchers.header_matchers.emplace_back(std::move(header_matcher));
1147
1427
  }
1148
1428
  return GRPC_ERROR_NONE;
1149
1429
  }
1150
1430
 
1151
1431
  grpc_error* RouteRuntimeFractionParse(
1152
- const envoy_api_v2_route_RouteMatch* match,
1153
- XdsApi::RdsUpdate::RdsRoute* rds_route) {
1154
- const envoy_api_v2_core_RuntimeFractionalPercent* runtime_fraction =
1155
- envoy_api_v2_route_RouteMatch_runtime_fraction(match);
1432
+ const envoy_config_route_v3_RouteMatch* match, XdsApi::Route* route) {
1433
+ const envoy_config_core_v3_RuntimeFractionalPercent* runtime_fraction =
1434
+ envoy_config_route_v3_RouteMatch_runtime_fraction(match);
1156
1435
  if (runtime_fraction != nullptr) {
1157
- const envoy_type_FractionalPercent* fraction =
1158
- envoy_api_v2_core_RuntimeFractionalPercent_default_value(
1436
+ const envoy_type_v3_FractionalPercent* fraction =
1437
+ envoy_config_core_v3_RuntimeFractionalPercent_default_value(
1159
1438
  runtime_fraction);
1160
1439
  if (fraction != nullptr) {
1161
- uint32_t numerator = envoy_type_FractionalPercent_numerator(fraction);
1440
+ uint32_t numerator = envoy_type_v3_FractionalPercent_numerator(fraction);
1162
1441
  const auto denominator =
1163
- static_cast<envoy_type_FractionalPercent_DenominatorType>(
1164
- envoy_type_FractionalPercent_denominator(fraction));
1442
+ static_cast<envoy_type_v3_FractionalPercent_DenominatorType>(
1443
+ envoy_type_v3_FractionalPercent_denominator(fraction));
1165
1444
  // Normalize to million.
1166
1445
  switch (denominator) {
1167
- case envoy_type_FractionalPercent_HUNDRED:
1446
+ case envoy_type_v3_FractionalPercent_HUNDRED:
1168
1447
  numerator *= 10000;
1169
1448
  break;
1170
- case envoy_type_FractionalPercent_TEN_THOUSAND:
1449
+ case envoy_type_v3_FractionalPercent_TEN_THOUSAND:
1171
1450
  numerator *= 100;
1172
1451
  break;
1173
- case envoy_type_FractionalPercent_MILLION:
1452
+ case envoy_type_v3_FractionalPercent_MILLION:
1174
1453
  break;
1175
1454
  default:
1176
1455
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1177
1456
  "Unknown denominator type");
1178
1457
  }
1179
- rds_route->matchers.fraction_per_million = numerator;
1458
+ route->matchers.fraction_per_million = numerator;
1180
1459
  }
1181
1460
  }
1182
1461
  return GRPC_ERROR_NONE;
1183
1462
  }
1184
1463
 
1185
- grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
1186
- XdsApi::RdsUpdate::RdsRoute* rds_route,
1187
- bool* ignore_route) {
1188
- if (!envoy_api_v2_route_Route_has_route(route)) {
1464
+ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1465
+ XdsApi::Route* route, bool* ignore_route) {
1466
+ if (!envoy_config_route_v3_Route_has_route(route_msg)) {
1189
1467
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1190
1468
  "No RouteAction found in route.");
1191
1469
  }
1192
- const envoy_api_v2_route_RouteAction* route_action =
1193
- envoy_api_v2_route_Route_route(route);
1470
+ const envoy_config_route_v3_RouteAction* route_action =
1471
+ envoy_config_route_v3_Route_route(route_msg);
1194
1472
  // Get the cluster or weighted_clusters in the RouteAction.
1195
- if (envoy_api_v2_route_RouteAction_has_cluster(route_action)) {
1196
- const upb_strview cluster_name =
1197
- envoy_api_v2_route_RouteAction_cluster(route_action);
1198
- if (cluster_name.size == 0) {
1473
+ if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
1474
+ route->cluster_name = UpbStringToStdString(
1475
+ envoy_config_route_v3_RouteAction_cluster(route_action));
1476
+ if (route->cluster_name.size() == 0) {
1199
1477
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1200
1478
  "RouteAction cluster contains empty cluster name.");
1201
1479
  }
1202
- rds_route->cluster_name = UpbStringToStdString(cluster_name);
1203
- } else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
1480
+ } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
1204
1481
  route_action)) {
1205
- const envoy_api_v2_route_WeightedCluster* weighted_cluster =
1206
- envoy_api_v2_route_RouteAction_weighted_clusters(route_action);
1482
+ const envoy_config_route_v3_WeightedCluster* weighted_cluster =
1483
+ envoy_config_route_v3_RouteAction_weighted_clusters(route_action);
1207
1484
  uint32_t total_weight = 100;
1208
1485
  const google_protobuf_UInt32Value* weight =
1209
- envoy_api_v2_route_WeightedCluster_total_weight(weighted_cluster);
1486
+ envoy_config_route_v3_WeightedCluster_total_weight(weighted_cluster);
1210
1487
  if (weight != nullptr) {
1211
1488
  total_weight = google_protobuf_UInt32Value_value(weight);
1212
1489
  }
1213
1490
  size_t clusters_size;
1214
- const envoy_api_v2_route_WeightedCluster_ClusterWeight* const* clusters =
1215
- envoy_api_v2_route_WeightedCluster_clusters(weighted_cluster,
1216
- &clusters_size);
1491
+ const envoy_config_route_v3_WeightedCluster_ClusterWeight* const* clusters =
1492
+ envoy_config_route_v3_WeightedCluster_clusters(weighted_cluster,
1493
+ &clusters_size);
1217
1494
  uint32_t sum_of_weights = 0;
1218
1495
  for (size_t j = 0; j < clusters_size; ++j) {
1219
- const envoy_api_v2_route_WeightedCluster_ClusterWeight* cluster_weight =
1220
- clusters[j];
1221
- XdsApi::RdsUpdate::RdsRoute::ClusterWeight cluster;
1496
+ const envoy_config_route_v3_WeightedCluster_ClusterWeight*
1497
+ cluster_weight = clusters[j];
1498
+ XdsApi::Route::ClusterWeight cluster;
1222
1499
  cluster.name = UpbStringToStdString(
1223
- envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
1500
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
1224
1501
  cluster_weight));
1225
1502
  if (cluster.name.empty()) {
1226
1503
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1228,7 +1505,7 @@ grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
1228
1505
  "name.");
1229
1506
  }
1230
1507
  const google_protobuf_UInt32Value* weight =
1231
- envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
1508
+ envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
1232
1509
  cluster_weight);
1233
1510
  if (weight == nullptr) {
1234
1511
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@@ -1236,13 +1513,13 @@ grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
1236
1513
  }
1237
1514
  cluster.weight = google_protobuf_UInt32Value_value(weight);
1238
1515
  sum_of_weights += cluster.weight;
1239
- rds_route->weighted_clusters.emplace_back(std::move(cluster));
1516
+ route->weighted_clusters.emplace_back(std::move(cluster));
1240
1517
  }
1241
1518
  if (total_weight != sum_of_weights) {
1242
1519
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1243
1520
  "RouteAction weighted_cluster has incorrect total weight");
1244
1521
  }
1245
- if (rds_route->weighted_clusters.empty()) {
1522
+ if (route->weighted_clusters.empty()) {
1246
1523
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1247
1524
  "RouteAction weighted_cluster has no valid clusters specified.");
1248
1525
  }
@@ -1256,185 +1533,163 @@ grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
1256
1533
 
1257
1534
  grpc_error* RouteConfigParse(
1258
1535
  XdsClient* client, TraceFlag* tracer,
1259
- const envoy_api_v2_RouteConfiguration* route_config,
1260
- const std::string& expected_server_name, XdsApi::RdsUpdate* rds_update) {
1536
+ const envoy_config_route_v3_RouteConfiguration* route_config,
1537
+ XdsApi::RdsUpdate* rds_update) {
1261
1538
  MaybeLogRouteConfiguration(client, tracer, route_config);
1262
1539
  // Get the virtual hosts.
1263
1540
  size_t size;
1264
- const envoy_api_v2_route_VirtualHost* const* virtual_hosts =
1265
- envoy_api_v2_RouteConfiguration_virtual_hosts(route_config, &size);
1266
- // Find the best matched virtual host.
1267
- // The search order for 4 groups of domain patterns:
1268
- // 1. Exact match.
1269
- // 2. Suffix match (e.g., "*ABC").
1270
- // 3. Prefix match (e.g., "ABC*").
1271
- // 4. Universe match (i.e., "*").
1272
- // Within each group, longest match wins.
1273
- // If the same best matched domain pattern appears in multiple virtual hosts,
1274
- // the first matched virtual host wins.
1275
- const envoy_api_v2_route_VirtualHost* target_virtual_host = nullptr;
1276
- MatchType best_match_type = INVALID_MATCH;
1277
- size_t longest_match = 0;
1278
- // Check each domain pattern in each virtual host to determine the best
1279
- // matched virtual host.
1541
+ const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
1542
+ envoy_config_route_v3_RouteConfiguration_virtual_hosts(route_config,
1543
+ &size);
1280
1544
  for (size_t i = 0; i < size; ++i) {
1545
+ rds_update->virtual_hosts.emplace_back();
1546
+ XdsApi::RdsUpdate::VirtualHost& vhost = rds_update->virtual_hosts.back();
1547
+ // Parse domains.
1281
1548
  size_t domain_size;
1282
- upb_strview const* domains =
1283
- envoy_api_v2_route_VirtualHost_domains(virtual_hosts[i], &domain_size);
1549
+ upb_strview const* domains = envoy_config_route_v3_VirtualHost_domains(
1550
+ virtual_hosts[i], &domain_size);
1284
1551
  for (size_t j = 0; j < domain_size; ++j) {
1285
- const std::string domain_pattern(domains[j].data, domains[j].size);
1286
- // Check the match type first. Skip the pattern if it's not better than
1287
- // current match.
1552
+ std::string domain_pattern = UpbStringToStdString(domains[j]);
1288
1553
  const MatchType match_type = DomainPatternMatchType(domain_pattern);
1289
1554
  if (match_type == INVALID_MATCH) {
1290
1555
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid domain pattern.");
1291
1556
  }
1292
- if (match_type > best_match_type) continue;
1293
- if (match_type == best_match_type &&
1294
- domain_pattern.size() <= longest_match) {
1557
+ vhost.domains.emplace_back(std::move(domain_pattern));
1558
+ }
1559
+ if (vhost.domains.empty()) {
1560
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("VirtualHost has no domains");
1561
+ }
1562
+ // Parse routes.
1563
+ size_t num_routes;
1564
+ const envoy_config_route_v3_Route* const* routes =
1565
+ envoy_config_route_v3_VirtualHost_routes(virtual_hosts[i], &num_routes);
1566
+ if (num_routes < 1) {
1567
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1568
+ "No route found in the virtual host.");
1569
+ }
1570
+ // Loop over the whole list of routes
1571
+ for (size_t j = 0; j < num_routes; ++j) {
1572
+ const envoy_config_route_v3_RouteMatch* match =
1573
+ envoy_config_route_v3_Route_match(routes[j]);
1574
+ size_t query_parameters_size;
1575
+ static_cast<void>(envoy_config_route_v3_RouteMatch_query_parameters(
1576
+ match, &query_parameters_size));
1577
+ if (query_parameters_size > 0) {
1295
1578
  continue;
1296
1579
  }
1297
- // Skip if match fails.
1298
- if (!DomainMatch(match_type, domain_pattern, expected_server_name)) {
1299
- continue;
1580
+ XdsApi::Route route;
1581
+ bool ignore_route = false;
1582
+ grpc_error* error = RoutePathMatchParse(match, &route, &ignore_route);
1583
+ if (error != GRPC_ERROR_NONE) return error;
1584
+ if (ignore_route) continue;
1585
+ error = RouteHeaderMatchersParse(match, &route);
1586
+ if (error != GRPC_ERROR_NONE) return error;
1587
+ error = RouteRuntimeFractionParse(match, &route);
1588
+ if (error != GRPC_ERROR_NONE) return error;
1589
+ error = RouteActionParse(routes[j], &route, &ignore_route);
1590
+ if (error != GRPC_ERROR_NONE) return error;
1591
+ if (ignore_route) continue;
1592
+ const google_protobuf_BoolValue* case_sensitive =
1593
+ envoy_config_route_v3_RouteMatch_case_sensitive(match);
1594
+ if (case_sensitive != nullptr &&
1595
+ !google_protobuf_BoolValue_value(case_sensitive)) {
1596
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1597
+ "case_sensitive if set must be set to true.");
1300
1598
  }
1301
- // Choose this match.
1302
- target_virtual_host = virtual_hosts[i];
1303
- best_match_type = match_type;
1304
- longest_match = domain_pattern.size();
1305
- if (best_match_type == EXACT_MATCH) break;
1599
+ vhost.routes.emplace_back(std::move(route));
1306
1600
  }
1307
- if (best_match_type == EXACT_MATCH) break;
1308
- }
1309
- if (target_virtual_host == nullptr) {
1310
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1311
- "No matched virtual host found in the route config.");
1312
- }
1313
- // Get the route list from the matched virtual host.
1314
- const envoy_api_v2_route_Route* const* routes =
1315
- envoy_api_v2_route_VirtualHost_routes(target_virtual_host, &size);
1316
- if (size < 1) {
1317
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1318
- "No route found in the virtual host.");
1319
- }
1320
- // Loop over the whole list of routes
1321
- for (size_t i = 0; i < size; ++i) {
1322
- const envoy_api_v2_route_Route* route = routes[i];
1323
- const envoy_api_v2_route_RouteMatch* match =
1324
- envoy_api_v2_route_Route_match(route);
1325
- size_t query_parameters_size;
1326
- static_cast<void>(envoy_api_v2_route_RouteMatch_query_parameters(
1327
- match, &query_parameters_size));
1328
- if (query_parameters_size > 0) {
1329
- continue;
1330
- }
1331
- XdsApi::RdsUpdate::RdsRoute rds_route;
1332
- bool ignore_route = false;
1333
- grpc_error* error = RoutePathMatchParse(match, &rds_route, &ignore_route);
1334
- if (error != GRPC_ERROR_NONE) return error;
1335
- if (ignore_route) continue;
1336
- error = RouteHeaderMatchersParse(match, &rds_route);
1337
- if (error != GRPC_ERROR_NONE) return error;
1338
- error = RouteRuntimeFractionParse(match, &rds_route);
1339
- if (error != GRPC_ERROR_NONE) return error;
1340
- error = RouteActionParse(route, &rds_route, &ignore_route);
1341
- if (error != GRPC_ERROR_NONE) return error;
1342
- if (ignore_route) continue;
1343
- const google_protobuf_BoolValue* case_sensitive =
1344
- envoy_api_v2_route_RouteMatch_case_sensitive(match);
1345
- if (case_sensitive != nullptr &&
1346
- !google_protobuf_BoolValue_value(case_sensitive)) {
1347
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1348
- "case_sensitive if set must be set to true.");
1601
+ if (vhost.routes.empty()) {
1602
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified.");
1349
1603
  }
1350
- rds_update->routes.emplace_back(std::move(rds_route));
1351
- }
1352
- if (rds_update->routes.empty()) {
1353
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified.");
1354
1604
  }
1355
1605
  return GRPC_ERROR_NONE;
1356
1606
  }
1357
1607
 
1358
- grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1359
- const envoy_api_v2_DiscoveryResponse* response,
1360
- const std::string& expected_server_name,
1361
- absl::optional<XdsApi::LdsUpdate>* lds_update,
1362
- upb_arena* arena) {
1608
+ grpc_error* LdsResponseParse(
1609
+ XdsClient* client, TraceFlag* tracer,
1610
+ const envoy_service_discovery_v3_DiscoveryResponse* response,
1611
+ const std::string& expected_server_name,
1612
+ absl::optional<XdsApi::LdsUpdate>* lds_update, upb_arena* arena) {
1363
1613
  // Get the resources from the response.
1364
1614
  size_t size;
1365
1615
  const google_protobuf_Any* const* resources =
1366
- envoy_api_v2_DiscoveryResponse_resources(response, &size);
1616
+ envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1367
1617
  for (size_t i = 0; i < size; ++i) {
1368
1618
  // Check the type_url of the resource.
1369
- const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
1370
- if (!upb_strview_eql(type_url, upb_strview_makez(XdsApi::kLdsTypeUrl))) {
1619
+ absl::string_view type_url =
1620
+ UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1621
+ if (!IsLds(type_url)) {
1371
1622
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not LDS.");
1372
1623
  }
1373
1624
  // Decode the listener.
1374
1625
  const upb_strview encoded_listener =
1375
1626
  google_protobuf_Any_value(resources[i]);
1376
- const envoy_api_v2_Listener* listener = envoy_api_v2_Listener_parse(
1377
- encoded_listener.data, encoded_listener.size, arena);
1627
+ const envoy_config_listener_v3_Listener* listener =
1628
+ envoy_config_listener_v3_Listener_parse(encoded_listener.data,
1629
+ encoded_listener.size, arena);
1378
1630
  if (listener == nullptr) {
1379
1631
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode listener.");
1380
1632
  }
1381
1633
  // Check listener name. Ignore unexpected listeners.
1382
- const upb_strview name = envoy_api_v2_Listener_name(listener);
1383
- const upb_strview expected_name =
1384
- upb_strview_makez(expected_server_name.c_str());
1385
- if (!upb_strview_eql(name, expected_name)) continue;
1634
+ absl::string_view name =
1635
+ UpbStringToAbsl(envoy_config_listener_v3_Listener_name(listener));
1636
+ if (name != expected_server_name) continue;
1386
1637
  // Get api_listener and decode it to http_connection_manager.
1387
- const envoy_config_listener_v2_ApiListener* api_listener =
1388
- envoy_api_v2_Listener_api_listener(listener);
1638
+ const envoy_config_listener_v3_ApiListener* api_listener =
1639
+ envoy_config_listener_v3_Listener_api_listener(listener);
1389
1640
  if (api_listener == nullptr) {
1390
1641
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1391
1642
  "Listener has no ApiListener.");
1392
1643
  }
1393
1644
  const upb_strview encoded_api_listener = google_protobuf_Any_value(
1394
- envoy_config_listener_v2_ApiListener_api_listener(api_listener));
1395
- const envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager*
1645
+ envoy_config_listener_v3_ApiListener_api_listener(api_listener));
1646
+ const envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager*
1396
1647
  http_connection_manager =
1397
- envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_parse(
1648
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_parse(
1398
1649
  encoded_api_listener.data, encoded_api_listener.size, arena);
1650
+ if (http_connection_manager == nullptr) {
1651
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1652
+ "Could not parse HttpConnectionManager config from ApiListener");
1653
+ }
1399
1654
  // Found inlined route_config. Parse it to find the cluster_name.
1400
- if (envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_has_route_config(
1655
+ if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
1401
1656
  http_connection_manager)) {
1402
- const envoy_api_v2_RouteConfiguration* route_config =
1403
- envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_route_config(
1657
+ const envoy_config_route_v3_RouteConfiguration* route_config =
1658
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_route_config(
1404
1659
  http_connection_manager);
1405
1660
  XdsApi::RdsUpdate rds_update;
1406
- grpc_error* error = RouteConfigParse(client, tracer, route_config,
1407
- expected_server_name, &rds_update);
1661
+ grpc_error* error =
1662
+ RouteConfigParse(client, tracer, route_config, &rds_update);
1408
1663
  if (error != GRPC_ERROR_NONE) return error;
1409
1664
  lds_update->emplace();
1410
- (*lds_update)->rds_update.emplace(std::move(rds_update));
1665
+ (*lds_update)->rds_update = std::move(rds_update);
1411
1666
  return GRPC_ERROR_NONE;
1412
1667
  }
1413
1668
  // Validate that RDS must be used to get the route_config dynamically.
1414
- if (!envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_has_rds(
1669
+ if (!envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_rds(
1415
1670
  http_connection_manager)) {
1416
1671
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1417
1672
  "HttpConnectionManager neither has inlined route_config nor RDS.");
1418
1673
  }
1419
- const envoy_config_filter_network_http_connection_manager_v2_Rds* rds =
1420
- envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_rds(
1674
+ const envoy_extensions_filters_network_http_connection_manager_v3_Rds* rds =
1675
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_rds(
1421
1676
  http_connection_manager);
1422
1677
  // Check that the ConfigSource specifies ADS.
1423
- const envoy_api_v2_core_ConfigSource* config_source =
1424
- envoy_config_filter_network_http_connection_manager_v2_Rds_config_source(
1678
+ const envoy_config_core_v3_ConfigSource* config_source =
1679
+ envoy_extensions_filters_network_http_connection_manager_v3_Rds_config_source(
1425
1680
  rds);
1426
1681
  if (config_source == nullptr) {
1427
1682
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1428
1683
  "HttpConnectionManager missing config_source for RDS.");
1429
1684
  }
1430
- if (!envoy_api_v2_core_ConfigSource_has_ads(config_source)) {
1685
+ if (!envoy_config_core_v3_ConfigSource_has_ads(config_source)) {
1431
1686
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1432
1687
  "HttpConnectionManager ConfigSource for RDS does not specify ADS.");
1433
1688
  }
1434
1689
  // Get the route_config_name.
1435
1690
  lds_update->emplace();
1436
1691
  (*lds_update)->route_config_name = UpbStringToStdString(
1437
- envoy_config_filter_network_http_connection_manager_v2_Rds_route_config_name(
1692
+ envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
1438
1693
  rds));
1439
1694
  return GRPC_ERROR_NONE;
1440
1695
  }
@@ -1443,42 +1698,40 @@ grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1443
1698
 
1444
1699
  grpc_error* RdsResponseParse(
1445
1700
  XdsClient* client, TraceFlag* tracer,
1446
- const envoy_api_v2_DiscoveryResponse* response,
1447
- const std::string& expected_server_name,
1701
+ const envoy_service_discovery_v3_DiscoveryResponse* response,
1448
1702
  const std::set<absl::string_view>& expected_route_configuration_names,
1449
1703
  absl::optional<XdsApi::RdsUpdate>* rds_update, upb_arena* arena) {
1450
1704
  // Get the resources from the response.
1451
1705
  size_t size;
1452
1706
  const google_protobuf_Any* const* resources =
1453
- envoy_api_v2_DiscoveryResponse_resources(response, &size);
1707
+ envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1454
1708
  for (size_t i = 0; i < size; ++i) {
1455
1709
  // Check the type_url of the resource.
1456
- const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
1457
- if (!upb_strview_eql(type_url, upb_strview_makez(XdsApi::kRdsTypeUrl))) {
1710
+ absl::string_view type_url =
1711
+ UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1712
+ if (!IsRds(type_url)) {
1458
1713
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not RDS.");
1459
1714
  }
1460
1715
  // Decode the route_config.
1461
1716
  const upb_strview encoded_route_config =
1462
1717
  google_protobuf_Any_value(resources[i]);
1463
- const envoy_api_v2_RouteConfiguration* route_config =
1464
- envoy_api_v2_RouteConfiguration_parse(encoded_route_config.data,
1465
- encoded_route_config.size, arena);
1718
+ const envoy_config_route_v3_RouteConfiguration* route_config =
1719
+ envoy_config_route_v3_RouteConfiguration_parse(
1720
+ encoded_route_config.data, encoded_route_config.size, arena);
1466
1721
  if (route_config == nullptr) {
1467
1722
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
1468
1723
  }
1469
1724
  // Check route_config_name. Ignore unexpected route_config.
1470
- const upb_strview route_config_name =
1471
- envoy_api_v2_RouteConfiguration_name(route_config);
1472
- absl::string_view route_config_name_strview(route_config_name.data,
1473
- route_config_name.size);
1474
- if (expected_route_configuration_names.find(route_config_name_strview) ==
1725
+ absl::string_view route_config_name = UpbStringToAbsl(
1726
+ envoy_config_route_v3_RouteConfiguration_name(route_config));
1727
+ if (expected_route_configuration_names.find(route_config_name) ==
1475
1728
  expected_route_configuration_names.end()) {
1476
1729
  continue;
1477
1730
  }
1478
1731
  // Parse the route_config.
1479
1732
  XdsApi::RdsUpdate local_rds_update;
1480
- grpc_error* error = RouteConfigParse(
1481
- client, tracer, route_config, expected_server_name, &local_rds_update);
1733
+ grpc_error* error =
1734
+ RouteConfigParse(client, tracer, route_config, &local_rds_update);
1482
1735
  if (error != GRPC_ERROR_NONE) return error;
1483
1736
  rds_update->emplace(std::move(local_rds_update));
1484
1737
  return GRPC_ERROR_NONE;
@@ -1488,122 +1741,127 @@ grpc_error* RdsResponseParse(
1488
1741
 
1489
1742
  grpc_error* CdsResponseParse(
1490
1743
  XdsClient* client, TraceFlag* tracer,
1491
- const envoy_api_v2_DiscoveryResponse* response,
1744
+ const envoy_service_discovery_v3_DiscoveryResponse* response,
1492
1745
  const std::set<absl::string_view>& expected_cluster_names,
1493
1746
  XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
1494
1747
  // Get the resources from the response.
1495
1748
  size_t size;
1496
1749
  const google_protobuf_Any* const* resources =
1497
- envoy_api_v2_DiscoveryResponse_resources(response, &size);
1750
+ envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1498
1751
  // Parse all the resources in the CDS response.
1499
1752
  for (size_t i = 0; i < size; ++i) {
1500
1753
  XdsApi::CdsUpdate cds_update;
1501
1754
  // Check the type_url of the resource.
1502
- const upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
1503
- if (!upb_strview_eql(type_url, upb_strview_makez(XdsApi::kCdsTypeUrl))) {
1755
+ absl::string_view type_url =
1756
+ UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1757
+ if (!IsCds(type_url)) {
1504
1758
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not CDS.");
1505
1759
  }
1506
1760
  // Decode the cluster.
1507
1761
  const upb_strview encoded_cluster = google_protobuf_Any_value(resources[i]);
1508
- const envoy_api_v2_Cluster* cluster = envoy_api_v2_Cluster_parse(
1509
- encoded_cluster.data, encoded_cluster.size, arena);
1762
+ const envoy_config_cluster_v3_Cluster* cluster =
1763
+ envoy_config_cluster_v3_Cluster_parse(encoded_cluster.data,
1764
+ encoded_cluster.size, arena);
1510
1765
  if (cluster == nullptr) {
1511
1766
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode cluster.");
1512
1767
  }
1513
1768
  MaybeLogCluster(client, tracer, cluster);
1514
1769
  // Ignore unexpected cluster names.
1515
- upb_strview cluster_name = envoy_api_v2_Cluster_name(cluster);
1516
- absl::string_view cluster_name_strview(cluster_name.data,
1517
- cluster_name.size);
1518
- if (expected_cluster_names.find(cluster_name_strview) ==
1770
+ std::string cluster_name =
1771
+ UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
1772
+ if (expected_cluster_names.find(cluster_name) ==
1519
1773
  expected_cluster_names.end()) {
1520
1774
  continue;
1521
1775
  }
1776
+ // Fail on duplicate resources.
1777
+ if (cds_update_map->find(cluster_name) != cds_update_map->end()) {
1778
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1779
+ absl::StrCat("duplicate resource name \"", cluster_name, "\"")
1780
+ .c_str());
1781
+ }
1522
1782
  // Check the cluster_discovery_type.
1523
- if (!envoy_api_v2_Cluster_has_type(cluster)) {
1783
+ if (!envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1524
1784
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found.");
1525
1785
  }
1526
- if (envoy_api_v2_Cluster_type(cluster) != envoy_api_v2_Cluster_EDS) {
1786
+ if (envoy_config_cluster_v3_Cluster_type(cluster) !=
1787
+ envoy_config_cluster_v3_Cluster_EDS) {
1527
1788
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType is not EDS.");
1528
1789
  }
1529
1790
  // Check the EDS config source.
1530
- const envoy_api_v2_Cluster_EdsClusterConfig* eds_cluster_config =
1531
- envoy_api_v2_Cluster_eds_cluster_config(cluster);
1532
- const envoy_api_v2_core_ConfigSource* eds_config =
1533
- envoy_api_v2_Cluster_EdsClusterConfig_eds_config(eds_cluster_config);
1534
- if (!envoy_api_v2_core_ConfigSource_has_ads(eds_config)) {
1791
+ const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1792
+ envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
1793
+ const envoy_config_core_v3_ConfigSource* eds_config =
1794
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1795
+ eds_cluster_config);
1796
+ if (!envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
1535
1797
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1536
1798
  "EDS ConfigSource is not ADS.");
1537
1799
  }
1538
1800
  // Record EDS service_name (if any).
1539
1801
  upb_strview service_name =
1540
- envoy_api_v2_Cluster_EdsClusterConfig_service_name(eds_cluster_config);
1802
+ envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1803
+ eds_cluster_config);
1541
1804
  if (service_name.size != 0) {
1542
1805
  cds_update.eds_service_name = UpbStringToStdString(service_name);
1543
1806
  }
1544
1807
  // Check the LB policy.
1545
- if (envoy_api_v2_Cluster_lb_policy(cluster) !=
1546
- envoy_api_v2_Cluster_ROUND_ROBIN) {
1808
+ if (envoy_config_cluster_v3_Cluster_lb_policy(cluster) !=
1809
+ envoy_config_cluster_v3_Cluster_ROUND_ROBIN) {
1547
1810
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1548
1811
  "LB policy is not ROUND_ROBIN.");
1549
1812
  }
1550
1813
  // Record LRS server name (if any).
1551
- const envoy_api_v2_core_ConfigSource* lrs_server =
1552
- envoy_api_v2_Cluster_lrs_server(cluster);
1814
+ const envoy_config_core_v3_ConfigSource* lrs_server =
1815
+ envoy_config_cluster_v3_Cluster_lrs_server(cluster);
1553
1816
  if (lrs_server != nullptr) {
1554
- if (!envoy_api_v2_core_ConfigSource_has_self(lrs_server)) {
1817
+ if (!envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
1555
1818
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1556
1819
  "LRS ConfigSource is not self.");
1557
1820
  }
1558
1821
  cds_update.lrs_load_reporting_server_name.emplace("");
1559
1822
  }
1560
- cds_update_map->emplace(UpbStringToStdString(cluster_name),
1561
- std::move(cds_update));
1823
+ cds_update_map->emplace(std::move(cluster_name), std::move(cds_update));
1562
1824
  }
1563
1825
  return GRPC_ERROR_NONE;
1564
1826
  }
1565
1827
 
1566
1828
  grpc_error* ServerAddressParseAndAppend(
1567
- const envoy_api_v2_endpoint_LbEndpoint* lb_endpoint,
1829
+ const envoy_config_endpoint_v3_LbEndpoint* lb_endpoint,
1568
1830
  ServerAddressList* list) {
1569
1831
  // If health_status is not HEALTHY or UNKNOWN, skip this endpoint.
1570
1832
  const int32_t health_status =
1571
- envoy_api_v2_endpoint_LbEndpoint_health_status(lb_endpoint);
1572
- if (health_status != envoy_api_v2_core_UNKNOWN &&
1573
- health_status != envoy_api_v2_core_HEALTHY) {
1833
+ envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
1834
+ if (health_status != envoy_config_core_v3_UNKNOWN &&
1835
+ health_status != envoy_config_core_v3_HEALTHY) {
1574
1836
  return GRPC_ERROR_NONE;
1575
1837
  }
1576
1838
  // Find the ip:port.
1577
- const envoy_api_v2_endpoint_Endpoint* endpoint =
1578
- envoy_api_v2_endpoint_LbEndpoint_endpoint(lb_endpoint);
1579
- const envoy_api_v2_core_Address* address =
1580
- envoy_api_v2_endpoint_Endpoint_address(endpoint);
1581
- const envoy_api_v2_core_SocketAddress* socket_address =
1582
- envoy_api_v2_core_Address_socket_address(address);
1583
- upb_strview address_strview =
1584
- envoy_api_v2_core_SocketAddress_address(socket_address);
1585
- uint32_t port = envoy_api_v2_core_SocketAddress_port_value(socket_address);
1839
+ const envoy_config_endpoint_v3_Endpoint* endpoint =
1840
+ envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
1841
+ const envoy_config_core_v3_Address* address =
1842
+ envoy_config_endpoint_v3_Endpoint_address(endpoint);
1843
+ const envoy_config_core_v3_SocketAddress* socket_address =
1844
+ envoy_config_core_v3_Address_socket_address(address);
1845
+ std::string address_str = UpbStringToStdString(
1846
+ envoy_config_core_v3_SocketAddress_address(socket_address));
1847
+ uint32_t port = envoy_config_core_v3_SocketAddress_port_value(socket_address);
1586
1848
  if (GPR_UNLIKELY(port >> 16) != 0) {
1587
1849
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid port.");
1588
1850
  }
1589
1851
  // Populate grpc_resolved_address.
1590
1852
  grpc_resolved_address addr;
1591
- char* address_str = static_cast<char*>(gpr_malloc(address_strview.size + 1));
1592
- memcpy(address_str, address_strview.data, address_strview.size);
1593
- address_str[address_strview.size] = '\0';
1594
- grpc_string_to_sockaddr(&addr, address_str, port);
1595
- gpr_free(address_str);
1853
+ grpc_string_to_sockaddr(&addr, address_str.c_str(), port);
1596
1854
  // Append the address to the list.
1597
1855
  list->emplace_back(addr, nullptr);
1598
1856
  return GRPC_ERROR_NONE;
1599
1857
  }
1600
1858
 
1601
1859
  grpc_error* LocalityParse(
1602
- const envoy_api_v2_endpoint_LocalityLbEndpoints* locality_lb_endpoints,
1860
+ const envoy_config_endpoint_v3_LocalityLbEndpoints* locality_lb_endpoints,
1603
1861
  XdsApi::PriorityListUpdate::LocalityMap::Locality* output_locality) {
1604
1862
  // Parse LB weight.
1605
1863
  const google_protobuf_UInt32Value* lb_weight =
1606
- envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(
1864
+ envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
1607
1865
  locality_lb_endpoints);
1608
1866
  // If LB weight is not specified, it means this locality is assigned no load.
1609
1867
  // TODO(juanlishen): When we support CDS to configure the inter-locality
@@ -1612,18 +1870,21 @@ grpc_error* LocalityParse(
1612
1870
  lb_weight != nullptr ? google_protobuf_UInt32Value_value(lb_weight) : 0;
1613
1871
  if (output_locality->lb_weight == 0) return GRPC_ERROR_NONE;
1614
1872
  // Parse locality name.
1615
- const envoy_api_v2_core_Locality* locality =
1616
- envoy_api_v2_endpoint_LocalityLbEndpoints_locality(locality_lb_endpoints);
1617
- upb_strview region = envoy_api_v2_core_Locality_region(locality);
1618
- upb_strview zone = envoy_api_v2_core_Locality_region(locality);
1619
- upb_strview sub_zone = envoy_api_v2_core_Locality_sub_zone(locality);
1873
+ const envoy_config_core_v3_Locality* locality =
1874
+ envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
1875
+ locality_lb_endpoints);
1876
+ std::string region =
1877
+ UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
1878
+ std::string zone =
1879
+ UpbStringToStdString(envoy_config_core_v3_Locality_region(locality));
1880
+ std::string sub_zone =
1881
+ UpbStringToStdString(envoy_config_core_v3_Locality_sub_zone(locality));
1620
1882
  output_locality->name = MakeRefCounted<XdsLocalityName>(
1621
- UpbStringToStdString(region), UpbStringToStdString(zone),
1622
- UpbStringToStdString(sub_zone));
1883
+ std::move(region), std::move(zone), std::move(sub_zone));
1623
1884
  // Parse the addresses.
1624
1885
  size_t size;
1625
- const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints =
1626
- envoy_api_v2_endpoint_LocalityLbEndpoints_lb_endpoints(
1886
+ const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
1887
+ envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
1627
1888
  locality_lb_endpoints, &size);
1628
1889
  for (size_t i = 0; i < size; ++i) {
1629
1890
  grpc_error* error = ServerAddressParseAndAppend(
@@ -1632,68 +1893,72 @@ grpc_error* LocalityParse(
1632
1893
  }
1633
1894
  // Parse the priority.
1634
1895
  output_locality->priority =
1635
- envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_lb_endpoints);
1896
+ envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1897
+ locality_lb_endpoints);
1636
1898
  return GRPC_ERROR_NONE;
1637
1899
  }
1638
1900
 
1639
1901
  grpc_error* DropParseAndAppend(
1640
- const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* drop_overload,
1902
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload*
1903
+ drop_overload,
1641
1904
  XdsApi::DropConfig* drop_config) {
1642
1905
  // Get the category.
1643
- upb_strview category =
1644
- envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_category(
1645
- drop_overload);
1646
- if (category.size == 0) {
1906
+ std::string category = UpbStringToStdString(
1907
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
1908
+ drop_overload));
1909
+ if (category.size() == 0) {
1647
1910
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
1648
1911
  }
1649
1912
  // Get the drop rate (per million).
1650
- const envoy_type_FractionalPercent* drop_percentage =
1651
- envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1913
+ const envoy_type_v3_FractionalPercent* drop_percentage =
1914
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1652
1915
  drop_overload);
1653
- uint32_t numerator = envoy_type_FractionalPercent_numerator(drop_percentage);
1916
+ uint32_t numerator =
1917
+ envoy_type_v3_FractionalPercent_numerator(drop_percentage);
1654
1918
  const auto denominator =
1655
- static_cast<envoy_type_FractionalPercent_DenominatorType>(
1656
- envoy_type_FractionalPercent_denominator(drop_percentage));
1919
+ static_cast<envoy_type_v3_FractionalPercent_DenominatorType>(
1920
+ envoy_type_v3_FractionalPercent_denominator(drop_percentage));
1657
1921
  // Normalize to million.
1658
1922
  switch (denominator) {
1659
- case envoy_type_FractionalPercent_HUNDRED:
1923
+ case envoy_type_v3_FractionalPercent_HUNDRED:
1660
1924
  numerator *= 10000;
1661
1925
  break;
1662
- case envoy_type_FractionalPercent_TEN_THOUSAND:
1926
+ case envoy_type_v3_FractionalPercent_TEN_THOUSAND:
1663
1927
  numerator *= 100;
1664
1928
  break;
1665
- case envoy_type_FractionalPercent_MILLION:
1929
+ case envoy_type_v3_FractionalPercent_MILLION:
1666
1930
  break;
1667
1931
  default:
1668
1932
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Unknown denominator type");
1669
1933
  }
1670
1934
  // Cap numerator to 1000000.
1671
1935
  numerator = GPR_MIN(numerator, 1000000);
1672
- drop_config->AddCategory(UpbStringToStdString(category), numerator);
1936
+ drop_config->AddCategory(std::move(category), numerator);
1673
1937
  return GRPC_ERROR_NONE;
1674
1938
  }
1675
1939
 
1676
1940
  grpc_error* EdsResponseParse(
1677
1941
  XdsClient* client, TraceFlag* tracer,
1678
- const envoy_api_v2_DiscoveryResponse* response,
1942
+ const envoy_service_discovery_v3_DiscoveryResponse* response,
1679
1943
  const std::set<absl::string_view>& expected_eds_service_names,
1680
1944
  XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
1681
1945
  // Get the resources from the response.
1682
1946
  size_t size;
1683
1947
  const google_protobuf_Any* const* resources =
1684
- envoy_api_v2_DiscoveryResponse_resources(response, &size);
1948
+ envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1685
1949
  for (size_t i = 0; i < size; ++i) {
1686
1950
  XdsApi::EdsUpdate eds_update;
1687
1951
  // Check the type_url of the resource.
1688
- upb_strview type_url = google_protobuf_Any_type_url(resources[i]);
1689
- if (!upb_strview_eql(type_url, upb_strview_makez(XdsApi::kEdsTypeUrl))) {
1952
+ absl::string_view type_url =
1953
+ UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
1954
+ if (!IsEds(type_url)) {
1690
1955
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Resource is not EDS.");
1691
1956
  }
1692
1957
  // Get the cluster_load_assignment.
1693
1958
  upb_strview encoded_cluster_load_assignment =
1694
1959
  google_protobuf_Any_value(resources[i]);
1695
- envoy_api_v2_ClusterLoadAssignment* cluster_load_assignment =
1696
- envoy_api_v2_ClusterLoadAssignment_parse(
1960
+ envoy_config_endpoint_v3_ClusterLoadAssignment* cluster_load_assignment =
1961
+ envoy_config_endpoint_v3_ClusterLoadAssignment_parse(
1697
1962
  encoded_cluster_load_assignment.data,
1698
1963
  encoded_cluster_load_assignment.size, arena);
1699
1964
  if (cluster_load_assignment == nullptr) {
@@ -1701,21 +1966,25 @@ grpc_error* EdsResponseParse(
1701
1966
  "Can't parse cluster_load_assignment.");
1702
1967
  }
1703
1968
  MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
1704
- // Check the cluster name (which actually means eds_service_name). Ignore
1705
- // unexpected names.
1706
- upb_strview cluster_name = envoy_api_v2_ClusterLoadAssignment_cluster_name(
1707
- cluster_load_assignment);
1708
- absl::string_view cluster_name_strview(cluster_name.data,
1709
- cluster_name.size);
1710
- if (expected_eds_service_names.find(cluster_name_strview) ==
1969
+ // Check the EDS service name. Ignore unexpected names.
1970
+ std::string eds_service_name = UpbStringToStdString(
1971
+ envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
1972
+ cluster_load_assignment));
1973
+ if (expected_eds_service_names.find(eds_service_name) ==
1711
1974
  expected_eds_service_names.end()) {
1712
1975
  continue;
1713
1976
  }
1977
+ // Fail on duplicate resources.
1978
+ if (eds_update_map->find(eds_service_name) != eds_update_map->end()) {
1979
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1980
+ absl::StrCat("duplicate resource name \"", eds_service_name, "\"")
1981
+ .c_str());
1982
+ }
1714
1983
  // Get the endpoints.
1715
1984
  size_t locality_size;
1716
- const envoy_api_v2_endpoint_LocalityLbEndpoints* const* endpoints =
1717
- envoy_api_v2_ClusterLoadAssignment_endpoints(cluster_load_assignment,
1718
- &locality_size);
1985
+ const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
1986
+ envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1987
+ cluster_load_assignment, &locality_size);
1719
1988
  for (size_t j = 0; j < locality_size; ++j) {
1720
1989
  XdsApi::PriorityListUpdate::LocalityMap::Locality locality;
1721
1990
  grpc_error* error = LocalityParse(endpoints[j], &locality);
@@ -1734,13 +2003,14 @@ grpc_error* EdsResponseParse(
1734
2003
  }
1735
2004
  // Get the drop config.
1736
2005
  eds_update.drop_config = MakeRefCounted<XdsApi::DropConfig>();
1737
- const envoy_api_v2_ClusterLoadAssignment_Policy* policy =
1738
- envoy_api_v2_ClusterLoadAssignment_policy(cluster_load_assignment);
2006
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
2007
+ envoy_config_endpoint_v3_ClusterLoadAssignment_policy(
2008
+ cluster_load_assignment);
1739
2009
  if (policy != nullptr) {
1740
2010
  size_t drop_size;
1741
- const envoy_api_v2_ClusterLoadAssignment_Policy_DropOverload* const*
2011
+ const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
1742
2012
  drop_overload =
1743
- envoy_api_v2_ClusterLoadAssignment_Policy_drop_overloads(
2013
+ envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
1744
2014
  policy, &drop_size);
1745
2015
  for (size_t j = 0; j < drop_size; ++j) {
1746
2016
  grpc_error* error =
@@ -1748,71 +2018,79 @@ grpc_error* EdsResponseParse(
1748
2018
  if (error != GRPC_ERROR_NONE) return error;
1749
2019
  }
1750
2020
  }
1751
- eds_update_map->emplace(UpbStringToStdString(cluster_name),
1752
- std::move(eds_update));
2021
+ eds_update_map->emplace(std::move(eds_service_name), std::move(eds_update));
1753
2022
  }
1754
2023
  return GRPC_ERROR_NONE;
1755
2024
  }
1756
2025
 
2026
+ std::string TypeUrlInternalToExternal(absl::string_view type_url) {
2027
+ if (type_url == kLdsV2TypeUrl) {
2028
+ return XdsApi::kLdsTypeUrl;
2029
+ } else if (type_url == kRdsV2TypeUrl) {
2030
+ return XdsApi::kRdsTypeUrl;
2031
+ } else if (type_url == kCdsV2TypeUrl) {
2032
+ return XdsApi::kCdsTypeUrl;
2033
+ } else if (type_url == kEdsV2TypeUrl) {
2034
+ return XdsApi::kEdsTypeUrl;
2035
+ }
2036
+ return std::string(type_url);
2037
+ }
2038
+
1757
2039
  } // namespace
1758
2040
 
1759
- grpc_error* XdsApi::ParseAdsResponse(
2041
+ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
1760
2042
  const grpc_slice& encoded_response, const std::string& expected_server_name,
1761
2043
  const std::set<absl::string_view>& expected_route_configuration_names,
1762
2044
  const std::set<absl::string_view>& expected_cluster_names,
1763
- const std::set<absl::string_view>& expected_eds_service_names,
1764
- absl::optional<LdsUpdate>* lds_update,
1765
- absl::optional<RdsUpdate>* rds_update, CdsUpdateMap* cds_update_map,
1766
- EdsUpdateMap* eds_update_map, std::string* version, std::string* nonce,
1767
- std::string* type_url) {
2045
+ const std::set<absl::string_view>& expected_eds_service_names) {
2046
+ AdsParseResult result;
1768
2047
  upb::Arena arena;
1769
2048
  // Decode the response.
1770
- const envoy_api_v2_DiscoveryResponse* response =
1771
- envoy_api_v2_DiscoveryResponse_parse(
2049
+ const envoy_service_discovery_v3_DiscoveryResponse* response =
2050
+ envoy_service_discovery_v3_DiscoveryResponse_parse(
1772
2051
  reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(encoded_response)),
1773
2052
  GRPC_SLICE_LENGTH(encoded_response), arena.ptr());
1774
2053
  // If decoding fails, output an empty type_url and return.
1775
2054
  if (response == nullptr) {
1776
- *type_url = "";
1777
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1778
- "Can't decode the whole response.");
2055
+ result.parse_error =
2056
+ GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
2057
+ return result;
1779
2058
  }
1780
2059
  MaybeLogDiscoveryResponse(client_, tracer_, response);
1781
2060
  // Record the type_url, the version_info, and the nonce of the response.
1782
- upb_strview type_url_strview =
1783
- envoy_api_v2_DiscoveryResponse_type_url(response);
1784
- *type_url = UpbStringToStdString(type_url_strview);
1785
- upb_strview version_info =
1786
- envoy_api_v2_DiscoveryResponse_version_info(response);
1787
- *version = UpbStringToStdString(version_info);
1788
- upb_strview nonce_strview = envoy_api_v2_DiscoveryResponse_nonce(response);
1789
- *nonce = UpbStringToStdString(nonce_strview);
2061
+ result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
2062
+ envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
2063
+ result.version = UpbStringToStdString(
2064
+ envoy_service_discovery_v3_DiscoveryResponse_version_info(response));
2065
+ result.nonce = UpbStringToStdString(
2066
+ envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
1790
2067
  // Parse the response according to the resource type.
1791
- if (*type_url == kLdsTypeUrl) {
1792
- return LdsResponseParse(client_, tracer_, response, expected_server_name,
1793
- lds_update, arena.ptr());
1794
- } else if (*type_url == kRdsTypeUrl) {
1795
- return RdsResponseParse(client_, tracer_, response, expected_server_name,
1796
- expected_route_configuration_names, rds_update,
1797
- arena.ptr());
1798
- } else if (*type_url == kCdsTypeUrl) {
1799
- return CdsResponseParse(client_, tracer_, response, expected_cluster_names,
1800
- cds_update_map, arena.ptr());
1801
- } else if (*type_url == kEdsTypeUrl) {
1802
- return EdsResponseParse(client_, tracer_, response,
1803
- expected_eds_service_names, eds_update_map,
1804
- arena.ptr());
1805
- } else {
1806
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1807
- "Unsupported ADS resource type.");
2068
+ if (IsLds(result.type_url)) {
2069
+ result.parse_error =
2070
+ LdsResponseParse(client_, tracer_, response, expected_server_name,
2071
+ &result.lds_update, arena.ptr());
2072
+ } else if (IsRds(result.type_url)) {
2073
+ result.parse_error = RdsResponseParse(client_, tracer_, response,
2074
+ expected_route_configuration_names,
2075
+ &result.rds_update, arena.ptr());
2076
+ } else if (IsCds(result.type_url)) {
2077
+ result.parse_error =
2078
+ CdsResponseParse(client_, tracer_, response, expected_cluster_names,
2079
+ &result.cds_update_map, arena.ptr());
2080
+ } else if (IsEds(result.type_url)) {
2081
+ result.parse_error =
2082
+ EdsResponseParse(client_, tracer_, response, expected_eds_service_names,
2083
+ &result.eds_update_map, arena.ptr());
1808
2084
  }
2085
+ return result;
1809
2086
  }
1810
2087
 
1811
2088
  namespace {
1812
2089
 
1813
2090
  void MaybeLogLrsRequest(
1814
2091
  XdsClient* client, TraceFlag* tracer,
1815
- const envoy_service_load_stats_v2_LoadStatsRequest* request) {
2092
+ const envoy_service_load_stats_v3_LoadStatsRequest* request,
2093
+ const std::string& build_version) {
1816
2094
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1817
2095
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1818
2096
  // TODO(roth): When we can upgrade upb, use upb textformat code to dump
@@ -1820,14 +2098,14 @@ void MaybeLogLrsRequest(
1820
2098
  std::vector<std::string> fields;
1821
2099
  // node
1822
2100
  const auto* node =
1823
- envoy_service_load_stats_v2_LoadStatsRequest_node(request);
2101
+ envoy_service_load_stats_v3_LoadStatsRequest_node(request);
1824
2102
  if (node != nullptr) {
1825
- AddNodeLogFields(node, &fields);
2103
+ AddNodeLogFields(node, build_version, &fields);
1826
2104
  }
1827
2105
  // cluster_stats
1828
2106
  size_t num_cluster_stats;
1829
- const struct envoy_api_v2_endpoint_ClusterStats* const* cluster_stats =
1830
- envoy_service_load_stats_v2_LoadStatsRequest_cluster_stats(
2107
+ const struct envoy_config_endpoint_v3_ClusterStats* const* cluster_stats =
2108
+ envoy_service_load_stats_v3_LoadStatsRequest_cluster_stats(
1831
2109
  request, &num_cluster_stats);
1832
2110
  for (size_t i = 0; i < num_cluster_stats; ++i) {
1833
2111
  const auto* cluster_stat = cluster_stats[i];
@@ -1835,24 +2113,24 @@ void MaybeLogLrsRequest(
1835
2113
  // cluster_name
1836
2114
  AddStringField(
1837
2115
  " cluster_name",
1838
- envoy_api_v2_endpoint_ClusterStats_cluster_name(cluster_stat),
2116
+ envoy_config_endpoint_v3_ClusterStats_cluster_name(cluster_stat),
1839
2117
  &fields);
1840
2118
  // cluster_service_name
1841
- AddStringField(
1842
- " cluster_service_name",
1843
- envoy_api_v2_endpoint_ClusterStats_cluster_service_name(cluster_stat),
1844
- &fields);
2119
+ AddStringField(" cluster_service_name",
2120
+ envoy_config_endpoint_v3_ClusterStats_cluster_service_name(
2121
+ cluster_stat),
2122
+ &fields);
1845
2123
  // upstream_locality_stats
1846
2124
  size_t num_stats;
1847
- const envoy_api_v2_endpoint_UpstreamLocalityStats* const* stats =
1848
- envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(
2125
+ const envoy_config_endpoint_v3_UpstreamLocalityStats* const* stats =
2126
+ envoy_config_endpoint_v3_ClusterStats_upstream_locality_stats(
1849
2127
  cluster_stat, &num_stats);
1850
2128
  for (size_t j = 0; j < num_stats; ++j) {
1851
2129
  const auto* stat = stats[j];
1852
2130
  fields.emplace_back(" upstream_locality_stats {");
1853
2131
  // locality
1854
2132
  const auto* locality =
1855
- envoy_api_v2_endpoint_UpstreamLocalityStats_locality(stat);
2133
+ envoy_config_endpoint_v3_UpstreamLocalityStats_locality(stat);
1856
2134
  if (locality != nullptr) {
1857
2135
  fields.emplace_back(" locality {");
1858
2136
  AddLocalityField(3, locality, &fields);
@@ -1861,53 +2139,55 @@ void MaybeLogLrsRequest(
1861
2139
  // total_successful_requests
1862
2140
  fields.emplace_back(absl::StrCat(
1863
2141
  " total_successful_requests: ",
1864
- envoy_api_v2_endpoint_UpstreamLocalityStats_total_successful_requests(
2142
+ envoy_config_endpoint_v3_UpstreamLocalityStats_total_successful_requests(
1865
2143
  stat)));
1866
2144
  // total_requests_in_progress
1867
2145
  fields.emplace_back(absl::StrCat(
1868
2146
  " total_requests_in_progress: ",
1869
- envoy_api_v2_endpoint_UpstreamLocalityStats_total_requests_in_progress(
2147
+ envoy_config_endpoint_v3_UpstreamLocalityStats_total_requests_in_progress(
1870
2148
  stat)));
1871
2149
  // total_error_requests
1872
2150
  fields.emplace_back(absl::StrCat(
1873
2151
  " total_error_requests: ",
1874
- envoy_api_v2_endpoint_UpstreamLocalityStats_total_error_requests(
2152
+ envoy_config_endpoint_v3_UpstreamLocalityStats_total_error_requests(
1875
2153
  stat)));
1876
2154
  // total_issued_requests
1877
2155
  fields.emplace_back(absl::StrCat(
1878
2156
  " total_issued_requests: ",
1879
- envoy_api_v2_endpoint_UpstreamLocalityStats_total_issued_requests(
2157
+ envoy_config_endpoint_v3_UpstreamLocalityStats_total_issued_requests(
1880
2158
  stat)));
1881
2159
  fields.emplace_back(" }");
1882
2160
  }
1883
2161
  // total_dropped_requests
1884
2162
  fields.emplace_back(absl::StrCat(
1885
2163
  " total_dropped_requests: ",
1886
- envoy_api_v2_endpoint_ClusterStats_total_dropped_requests(
2164
+ envoy_config_endpoint_v3_ClusterStats_total_dropped_requests(
1887
2165
  cluster_stat)));
1888
2166
  // dropped_requests
1889
2167
  size_t num_drops;
1890
- const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* drops =
1891
- envoy_api_v2_endpoint_ClusterStats_dropped_requests(cluster_stat,
1892
- &num_drops);
2168
+ const envoy_config_endpoint_v3_ClusterStats_DroppedRequests* const*
2169
+ drops = envoy_config_endpoint_v3_ClusterStats_dropped_requests(
2170
+ cluster_stat, &num_drops);
1893
2171
  for (size_t j = 0; j < num_drops; ++j) {
1894
2172
  const auto* drop = drops[j];
1895
2173
  fields.emplace_back(" dropped_requests {");
1896
2174
  // category
1897
2175
  AddStringField(
1898
2176
  " category",
1899
- envoy_api_v2_endpoint_ClusterStats_DroppedRequests_category(drop),
2177
+ envoy_config_endpoint_v3_ClusterStats_DroppedRequests_category(
2178
+ drop),
1900
2179
  &fields);
1901
2180
  // dropped_count
1902
2181
  fields.emplace_back(absl::StrCat(
1903
2182
  " dropped_count: ",
1904
- envoy_api_v2_endpoint_ClusterStats_DroppedRequests_dropped_count(
2183
+ envoy_config_endpoint_v3_ClusterStats_DroppedRequests_dropped_count(
1905
2184
  drop)));
1906
2185
  fields.emplace_back(" }");
1907
2186
  }
1908
2187
  // load_report_interval
1909
2188
  const auto* load_report_interval =
1910
- envoy_api_v2_endpoint_ClusterStats_load_report_interval(cluster_stat);
2189
+ envoy_config_endpoint_v3_ClusterStats_load_report_interval(
2190
+ cluster_stat);
1911
2191
  if (load_report_interval != nullptr) {
1912
2192
  fields.emplace_back(" load_report_interval {");
1913
2193
  fields.emplace_back(absl::StrCat(
@@ -1926,10 +2206,10 @@ void MaybeLogLrsRequest(
1926
2206
  }
1927
2207
 
1928
2208
  grpc_slice SerializeLrsRequest(
1929
- const envoy_service_load_stats_v2_LoadStatsRequest* request,
2209
+ const envoy_service_load_stats_v3_LoadStatsRequest* request,
1930
2210
  upb_arena* arena) {
1931
2211
  size_t output_length;
1932
- char* output = envoy_service_load_stats_v2_LoadStatsRequest_serialize(
2212
+ char* output = envoy_service_load_stats_v3_LoadStatsRequest_serialize(
1933
2213
  request, arena, &output_length);
1934
2214
  return grpc_slice_from_copied_buffer(output, output_length);
1935
2215
  }
@@ -1939,64 +2219,64 @@ grpc_slice SerializeLrsRequest(
1939
2219
  grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
1940
2220
  upb::Arena arena;
1941
2221
  // Create a request.
1942
- envoy_service_load_stats_v2_LoadStatsRequest* request =
1943
- envoy_service_load_stats_v2_LoadStatsRequest_new(arena.ptr());
2222
+ envoy_service_load_stats_v3_LoadStatsRequest* request =
2223
+ envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
1944
2224
  // Populate node.
1945
- envoy_api_v2_core_Node* node_msg =
1946
- envoy_service_load_stats_v2_LoadStatsRequest_mutable_node(request,
2225
+ envoy_config_core_v3_Node* node_msg =
2226
+ envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
1947
2227
  arena.ptr());
1948
- PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_,
2228
+ PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
1949
2229
  server_name, node_msg);
1950
- envoy_api_v2_core_Node_add_client_features(
2230
+ envoy_config_core_v3_Node_add_client_features(
1951
2231
  node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
1952
2232
  arena.ptr());
1953
- MaybeLogLrsRequest(client_, tracer_, request);
2233
+ MaybeLogLrsRequest(client_, tracer_, request, build_version_);
1954
2234
  return SerializeLrsRequest(request, arena.ptr());
1955
2235
  }
1956
2236
 
1957
2237
  namespace {
1958
2238
 
1959
- void LocalityStatsPopulate(envoy_api_v2_endpoint_UpstreamLocalityStats* output,
1960
- const XdsLocalityName& locality_name,
1961
- const XdsClusterLocalityStats::Snapshot& snapshot,
1962
- upb_arena* arena) {
2239
+ void LocalityStatsPopulate(
2240
+ envoy_config_endpoint_v3_UpstreamLocalityStats* output,
2241
+ const XdsLocalityName& locality_name,
2242
+ const XdsClusterLocalityStats::Snapshot& snapshot, upb_arena* arena) {
1963
2243
  // Set locality.
1964
- envoy_api_v2_core_Locality* locality =
1965
- envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_locality(output,
1966
- arena);
2244
+ envoy_config_core_v3_Locality* locality =
2245
+ envoy_config_endpoint_v3_UpstreamLocalityStats_mutable_locality(output,
2246
+ arena);
1967
2247
  if (!locality_name.region().empty()) {
1968
- envoy_api_v2_core_Locality_set_region(
1969
- locality, upb_strview_makez(locality_name.region().c_str()));
2248
+ envoy_config_core_v3_Locality_set_region(
2249
+ locality, StdStringToUpbString(locality_name.region()));
1970
2250
  }
1971
2251
  if (!locality_name.zone().empty()) {
1972
- envoy_api_v2_core_Locality_set_zone(
1973
- locality, upb_strview_makez(locality_name.zone().c_str()));
2252
+ envoy_config_core_v3_Locality_set_zone(
2253
+ locality, StdStringToUpbString(locality_name.zone()));
1974
2254
  }
1975
2255
  if (!locality_name.sub_zone().empty()) {
1976
- envoy_api_v2_core_Locality_set_sub_zone(
1977
- locality, upb_strview_makez(locality_name.sub_zone().c_str()));
2256
+ envoy_config_core_v3_Locality_set_sub_zone(
2257
+ locality, StdStringToUpbString(locality_name.sub_zone()));
1978
2258
  }
1979
2259
  // Set total counts.
1980
- envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_successful_requests(
2260
+ envoy_config_endpoint_v3_UpstreamLocalityStats_set_total_successful_requests(
1981
2261
  output, snapshot.total_successful_requests);
1982
- envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_requests_in_progress(
2262
+ envoy_config_endpoint_v3_UpstreamLocalityStats_set_total_requests_in_progress(
1983
2263
  output, snapshot.total_requests_in_progress);
1984
- envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_error_requests(
2264
+ envoy_config_endpoint_v3_UpstreamLocalityStats_set_total_error_requests(
1985
2265
  output, snapshot.total_error_requests);
1986
- envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_issued_requests(
2266
+ envoy_config_endpoint_v3_UpstreamLocalityStats_set_total_issued_requests(
1987
2267
  output, snapshot.total_issued_requests);
1988
2268
  // Add backend metrics.
1989
2269
  for (const auto& p : snapshot.backend_metrics) {
1990
2270
  const std::string& metric_name = p.first;
1991
2271
  const XdsClusterLocalityStats::BackendMetric& metric_value = p.second;
1992
- envoy_api_v2_endpoint_EndpointLoadMetricStats* load_metric =
1993
- envoy_api_v2_endpoint_UpstreamLocalityStats_add_load_metric_stats(
2272
+ envoy_config_endpoint_v3_EndpointLoadMetricStats* load_metric =
2273
+ envoy_config_endpoint_v3_UpstreamLocalityStats_add_load_metric_stats(
1994
2274
  output, arena);
1995
- envoy_api_v2_endpoint_EndpointLoadMetricStats_set_metric_name(
1996
- load_metric, upb_strview_make(metric_name.data(), metric_name.size()));
1997
- envoy_api_v2_endpoint_EndpointLoadMetricStats_set_num_requests_finished_with_metric(
2275
+ envoy_config_endpoint_v3_EndpointLoadMetricStats_set_metric_name(
2276
+ load_metric, StdStringToUpbString(metric_name));
2277
+ envoy_config_endpoint_v3_EndpointLoadMetricStats_set_num_requests_finished_with_metric(
1998
2278
  load_metric, metric_value.num_requests_finished_with_metric);
1999
- envoy_api_v2_endpoint_EndpointLoadMetricStats_set_total_metric_value(
2279
+ envoy_config_endpoint_v3_EndpointLoadMetricStats_set_total_metric_value(
2000
2280
  load_metric, metric_value.total_metric_value);
2001
2281
  }
2002
2282
  }
@@ -2007,32 +2287,30 @@ grpc_slice XdsApi::CreateLrsRequest(
2007
2287
  ClusterLoadReportMap cluster_load_report_map) {
2008
2288
  upb::Arena arena;
2009
2289
  // Create a request.
2010
- envoy_service_load_stats_v2_LoadStatsRequest* request =
2011
- envoy_service_load_stats_v2_LoadStatsRequest_new(arena.ptr());
2290
+ envoy_service_load_stats_v3_LoadStatsRequest* request =
2291
+ envoy_service_load_stats_v3_LoadStatsRequest_new(arena.ptr());
2012
2292
  for (auto& p : cluster_load_report_map) {
2013
2293
  const std::string& cluster_name = p.first.first;
2014
2294
  const std::string& eds_service_name = p.first.second;
2015
2295
  const ClusterLoadReport& load_report = p.second;
2016
2296
  // Add cluster stats.
2017
- envoy_api_v2_endpoint_ClusterStats* cluster_stats =
2018
- envoy_service_load_stats_v2_LoadStatsRequest_add_cluster_stats(
2297
+ envoy_config_endpoint_v3_ClusterStats* cluster_stats =
2298
+ envoy_service_load_stats_v3_LoadStatsRequest_add_cluster_stats(
2019
2299
  request, arena.ptr());
2020
2300
  // Set the cluster name.
2021
- envoy_api_v2_endpoint_ClusterStats_set_cluster_name(
2022
- cluster_stats,
2023
- upb_strview_make(cluster_name.data(), cluster_name.size()));
2301
+ envoy_config_endpoint_v3_ClusterStats_set_cluster_name(
2302
+ cluster_stats, StdStringToUpbString(cluster_name));
2024
2303
  // Set EDS service name, if non-empty.
2025
2304
  if (!eds_service_name.empty()) {
2026
- envoy_api_v2_endpoint_ClusterStats_set_cluster_service_name(
2027
- cluster_stats,
2028
- upb_strview_make(eds_service_name.data(), eds_service_name.size()));
2305
+ envoy_config_endpoint_v3_ClusterStats_set_cluster_service_name(
2306
+ cluster_stats, StdStringToUpbString(eds_service_name));
2029
2307
  }
2030
2308
  // Add locality stats.
2031
2309
  for (const auto& p : load_report.locality_stats) {
2032
2310
  const XdsLocalityName& locality_name = *p.first;
2033
2311
  const auto& snapshot = p.second;
2034
- envoy_api_v2_endpoint_UpstreamLocalityStats* locality_stats =
2035
- envoy_api_v2_endpoint_ClusterStats_add_upstream_locality_stats(
2312
+ envoy_config_endpoint_v3_UpstreamLocalityStats* locality_stats =
2313
+ envoy_config_endpoint_v3_ClusterStats_add_upstream_locality_stats(
2036
2314
  cluster_stats, arena.ptr());
2037
2315
  LocalityStatsPopulate(locality_stats, locality_name, snapshot,
2038
2316
  arena.ptr());
@@ -2040,30 +2318,30 @@ grpc_slice XdsApi::CreateLrsRequest(
2040
2318
  // Add dropped requests.
2041
2319
  uint64_t total_dropped_requests = 0;
2042
2320
  for (const auto& p : load_report.dropped_requests) {
2043
- const char* category = p.first.c_str();
2321
+ const std::string& category = p.first;
2044
2322
  const uint64_t count = p.second;
2045
- envoy_api_v2_endpoint_ClusterStats_DroppedRequests* dropped_requests =
2046
- envoy_api_v2_endpoint_ClusterStats_add_dropped_requests(cluster_stats,
2047
- arena.ptr());
2048
- envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_category(
2049
- dropped_requests, upb_strview_makez(category));
2050
- envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_dropped_count(
2323
+ envoy_config_endpoint_v3_ClusterStats_DroppedRequests* dropped_requests =
2324
+ envoy_config_endpoint_v3_ClusterStats_add_dropped_requests(
2325
+ cluster_stats, arena.ptr());
2326
+ envoy_config_endpoint_v3_ClusterStats_DroppedRequests_set_category(
2327
+ dropped_requests, StdStringToUpbString(category));
2328
+ envoy_config_endpoint_v3_ClusterStats_DroppedRequests_set_dropped_count(
2051
2329
  dropped_requests, count);
2052
2330
  total_dropped_requests += count;
2053
2331
  }
2054
2332
  // Set total dropped requests.
2055
- envoy_api_v2_endpoint_ClusterStats_set_total_dropped_requests(
2333
+ envoy_config_endpoint_v3_ClusterStats_set_total_dropped_requests(
2056
2334
  cluster_stats, total_dropped_requests);
2057
2335
  // Set real load report interval.
2058
2336
  gpr_timespec timespec =
2059
2337
  grpc_millis_to_timespec(load_report.load_report_interval, GPR_TIMESPAN);
2060
2338
  google_protobuf_Duration* load_report_interval =
2061
- envoy_api_v2_endpoint_ClusterStats_mutable_load_report_interval(
2339
+ envoy_config_endpoint_v3_ClusterStats_mutable_load_report_interval(
2062
2340
  cluster_stats, arena.ptr());
2063
2341
  google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
2064
2342
  google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
2065
2343
  }
2066
- MaybeLogLrsRequest(client_, tracer_, request);
2344
+ MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2067
2345
  return SerializeLrsRequest(request, arena.ptr());
2068
2346
  }
2069
2347
 
@@ -2073,8 +2351,8 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
2073
2351
  grpc_millis* load_reporting_interval) {
2074
2352
  upb::Arena arena;
2075
2353
  // Decode the response.
2076
- const envoy_service_load_stats_v2_LoadStatsResponse* decoded_response =
2077
- envoy_service_load_stats_v2_LoadStatsResponse_parse(
2354
+ const envoy_service_load_stats_v3_LoadStatsResponse* decoded_response =
2355
+ envoy_service_load_stats_v3_LoadStatsResponse_parse(
2078
2356
  reinterpret_cast<const char*>(GRPC_SLICE_START_PTR(encoded_response)),
2079
2357
  GRPC_SLICE_LENGTH(encoded_response), arena.ptr());
2080
2358
  // Parse the response.
@@ -2082,22 +2360,22 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
2082
2360
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode response.");
2083
2361
  }
2084
2362
  // Check send_all_clusters.
2085
- if (envoy_service_load_stats_v2_LoadStatsResponse_send_all_clusters(
2363
+ if (envoy_service_load_stats_v3_LoadStatsResponse_send_all_clusters(
2086
2364
  decoded_response)) {
2087
2365
  *send_all_clusters = true;
2088
2366
  } else {
2089
2367
  // Store the cluster names.
2090
2368
  size_t size;
2091
2369
  const upb_strview* clusters =
2092
- envoy_service_load_stats_v2_LoadStatsResponse_clusters(decoded_response,
2370
+ envoy_service_load_stats_v3_LoadStatsResponse_clusters(decoded_response,
2093
2371
  &size);
2094
2372
  for (size_t i = 0; i < size; ++i) {
2095
- cluster_names->emplace(clusters[i].data, clusters[i].size);
2373
+ cluster_names->emplace(UpbStringToStdString(clusters[i]));
2096
2374
  }
2097
2375
  }
2098
2376
  // Get the load report interval.
2099
2377
  const google_protobuf_Duration* load_reporting_interval_duration =
2100
- envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval(
2378
+ envoy_service_load_stats_v3_LoadStatsResponse_load_reporting_interval(
2101
2379
  decoded_response);
2102
2380
  gpr_timespec timespec{
2103
2381
  google_protobuf_Duration_seconds(load_reporting_interval_duration),