grpc 1.28.0 → 1.30.2

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 (503) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +7694 -11190
  3. data/include/grpc/grpc.h +2 -2
  4. data/include/grpc/grpc_security.h +30 -9
  5. data/include/grpc/grpc_security_constants.h +1 -0
  6. data/include/grpc/impl/codegen/grpc_types.h +19 -21
  7. data/include/grpc/impl/codegen/port_platform.h +6 -2
  8. data/include/grpc/module.modulemap +24 -39
  9. data/src/core/ext/filters/client_channel/backend_metric.cc +7 -4
  10. data/src/core/ext/filters/client_channel/client_channel.cc +212 -241
  11. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -2
  12. data/src/core/ext/filters/client_channel/health/health_check_client.cc +7 -22
  13. data/src/core/ext/filters/client_channel/health/health_check_client.h +3 -3
  14. data/src/core/ext/filters/client_channel/http_proxy.cc +17 -10
  15. data/src/core/ext/filters/client_channel/lb_policy.cc +19 -18
  16. data/src/core/ext/filters/client_channel/lb_policy.h +42 -33
  17. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +83 -0
  18. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +99 -0
  19. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +10 -4
  20. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +240 -301
  21. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +11 -9
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +3 -2
  25. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +871 -0
  26. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +1 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +5 -11
  28. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +734 -0
  29. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +84 -37
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +938 -0
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +528 -0
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +1 -2
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +834 -0
  34. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +6 -2
  35. data/src/core/ext/filters/client_channel/local_subchannel_pool.h +2 -1
  36. data/src/core/ext/filters/client_channel/parse_address.cc +22 -21
  37. data/src/core/ext/filters/client_channel/resolver.cc +5 -8
  38. data/src/core/ext/filters/client_channel/resolver.h +12 -14
  39. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +73 -59
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +35 -35
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +8 -7
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +16 -20
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +4 -4
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +72 -117
  45. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +184 -133
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -3
  47. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +7 -4
  48. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +40 -43
  49. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +93 -102
  50. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +0 -4
  51. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +2 -2
  52. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +32 -5
  53. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -2
  54. data/src/core/ext/filters/client_channel/resolver_registry.cc +6 -3
  55. data/src/core/ext/filters/client_channel/resolver_registry.h +8 -8
  56. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +16 -16
  57. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +19 -16
  58. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +20 -31
  59. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +4 -3
  60. data/src/core/ext/filters/client_channel/server_address.cc +6 -9
  61. data/src/core/ext/filters/client_channel/server_address.h +6 -12
  62. data/src/core/ext/filters/client_channel/service_config.cc +104 -144
  63. data/src/core/ext/filters/client_channel/service_config.h +28 -98
  64. data/src/core/ext/filters/client_channel/service_config_call_data.h +68 -0
  65. data/src/core/ext/filters/client_channel/service_config_parser.cc +87 -0
  66. data/src/core/ext/filters/client_channel/service_config_parser.h +89 -0
  67. data/src/core/ext/filters/client_channel/subchannel.cc +54 -24
  68. data/src/core/ext/filters/client_channel/subchannel.h +35 -11
  69. data/src/core/ext/filters/client_channel/xds/xds_api.cc +348 -221
  70. data/src/core/ext/filters/client_channel/xds/xds_api.h +37 -37
  71. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +44 -49
  72. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +4 -3
  73. data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +4 -2
  74. data/src/core/ext/filters/client_channel/xds/xds_client.cc +532 -339
  75. data/src/core/ext/filters/client_channel/xds/xds_client.h +57 -22
  76. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +11 -12
  77. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +31 -19
  78. data/src/core/ext/filters/http/client/http_client_filter.cc +23 -28
  79. data/src/core/ext/filters/http/client_authority_filter.cc +4 -4
  80. data/src/core/ext/filters/http/http_filters_plugin.cc +27 -12
  81. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +258 -221
  82. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +358 -0
  83. data/src/core/ext/filters/http/message_compress/message_decompress_filter.h +29 -0
  84. data/src/core/ext/filters/message_size/message_size_filter.cc +7 -10
  85. data/src/core/ext/filters/message_size/message_size_filter.h +4 -4
  86. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +4 -4
  87. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +4 -6
  88. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +23 -22
  89. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +1 -0
  90. data/src/core/ext/transport/chttp2/transport/flow_control.cc +3 -3
  91. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +2 -3
  92. data/src/core/ext/transport/chttp2/transport/frame_ping.h +2 -3
  93. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +2 -3
  94. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -3
  95. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +2 -3
  96. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +29 -16
  97. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -3
  98. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +2 -3
  99. data/src/core/ext/transport/chttp2/transport/hpack_table.h +2 -2
  100. data/src/core/ext/transport/chttp2/transport/http2_settings.h +4 -5
  101. data/src/core/ext/transport/chttp2/transport/huffsyms.h +2 -3
  102. data/src/core/ext/transport/chttp2/transport/internal.h +14 -21
  103. data/src/core/ext/transport/chttp2/transport/stream_map.h +2 -3
  104. data/src/core/ext/transport/chttp2/transport/writing.cc +15 -8
  105. data/src/core/ext/transport/inproc/inproc_transport.cc +19 -0
  106. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +4 -229
  107. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.h +5 -875
  108. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.c +114 -0
  109. data/src/core/ext/upb-generated/envoy/api/v2/auth/common.upb.h +418 -0
  110. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.c +72 -0
  111. data/src/core/ext/upb-generated/envoy/api/v2/auth/secret.upb.h +197 -0
  112. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.c +105 -0
  113. data/src/core/ext/upb-generated/envoy/api/v2/auth/tls.upb.h +378 -0
  114. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +1 -0
  115. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.c +21 -8
  116. data/src/core/ext/upb-generated/envoy/api/v2/cluster.upb.h +43 -7
  117. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +1 -0
  118. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +1 -0
  119. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +1 -0
  120. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +2 -1
  121. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.c +35 -0
  122. data/src/core/ext/upb-generated/envoy/api/v2/core/backoff.upb.h +78 -0
  123. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +47 -26
  124. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +115 -65
  125. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +1 -0
  126. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.c +34 -0
  127. data/src/core/ext/upb-generated/envoy/api/v2/core/event_service_config.upb.h +72 -0
  128. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +2 -1
  129. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +24 -20
  130. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -13
  131. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +1 -0
  132. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +38 -18
  133. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +88 -6
  134. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.c +34 -0
  135. data/src/core/ext/upb-generated/envoy/api/v2/core/socket_option.upb.h +89 -0
  136. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +1 -0
  137. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +1 -0
  138. data/src/core/ext/upb-generated/envoy/api/v2/endpoint.upb.c +1 -0
  139. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +1 -0
  140. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.c +9 -6
  141. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint_components.upb.h +12 -4
  142. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +1 -0
  143. data/src/core/ext/upb-generated/envoy/api/v2/lds.upb.c +1 -0
  144. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.c +15 -10
  145. data/src/core/ext/upb-generated/envoy/api/v2/listener.upb.h +16 -0
  146. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener.upb.c +1 -0
  147. data/src/core/ext/upb-generated/envoy/api/v2/listener/listener_components.upb.c +2 -1
  148. data/src/core/ext/upb-generated/envoy/api/v2/listener/udp_listener_config.upb.c +1 -0
  149. data/src/core/ext/upb-generated/envoy/api/v2/rds.upb.c +1 -0
  150. data/src/core/ext/upb-generated/envoy/api/v2/route.upb.c +1 -0
  151. data/src/core/ext/upb-generated/envoy/api/v2/route/route.upb.c +1 -0
  152. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.c +63 -41
  153. data/src/core/ext/upb-generated/envoy/api/v2/route/route_components.upb.h +173 -77
  154. data/src/core/ext/upb-generated/envoy/api/v2/scoped_route.upb.c +1 -0
  155. data/src/core/ext/upb-generated/envoy/api/v2/srds.upb.c +1 -0
  156. data/src/core/ext/upb-generated/envoy/config/filter/accesslog/v2/accesslog.upb.c +1 -0
  157. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.c +48 -28
  158. data/src/core/ext/upb-generated/envoy/config/filter/network/http_connection_manager/v2/http_connection_manager.upb.h +90 -30
  159. data/src/core/ext/upb-generated/envoy/config/listener/v2/api_listener.upb.c +1 -0
  160. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.c +51 -0
  161. data/src/core/ext/upb-generated/envoy/config/trace/v2/http_tracer.upb.h +125 -0
  162. data/src/core/ext/upb-generated/envoy/service/discovery/v2/ads.upb.c +1 -0
  163. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.c +4 -2
  164. data/src/core/ext/upb-generated/envoy/service/load_stats/v2/lrs.upb.h +4 -0
  165. data/src/core/ext/upb-generated/envoy/type/http.upb.c +1 -0
  166. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.c +16 -0
  167. data/src/core/ext/upb-generated/envoy/type/matcher/regex.upb.h +36 -0
  168. data/src/core/ext/upb-generated/envoy/type/matcher/string.upb.c +1 -0
  169. data/src/core/ext/upb-generated/envoy/type/metadata/v2/metadata.upb.c +1 -0
  170. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +1 -0
  171. data/src/core/ext/upb-generated/envoy/type/range.upb.c +1 -0
  172. data/src/core/ext/upb-generated/envoy/type/semantic_version.upb.c +1 -0
  173. data/src/core/ext/upb-generated/envoy/type/tracing/v2/custom_tag.upb.c +1 -0
  174. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +9 -8
  175. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +30 -24
  176. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +28 -0
  177. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +65 -0
  178. data/src/core/ext/upb-generated/validate/validate.upb.c +21 -20
  179. data/src/core/ext/upb-generated/validate/validate.upb.h +69 -63
  180. data/src/core/lib/channel/channel_args.cc +15 -14
  181. data/src/core/lib/channel/channel_args.h +3 -1
  182. data/src/core/lib/channel/channel_stack.h +20 -13
  183. data/src/core/lib/channel/channelz.cc +5 -6
  184. data/src/core/lib/channel/channelz.h +3 -2
  185. data/src/core/lib/channel/channelz_registry.cc +5 -3
  186. data/src/core/lib/channel/connected_channel.cc +7 -5
  187. data/src/core/lib/channel/context.h +1 -1
  188. data/src/core/lib/channel/handshaker.cc +11 -13
  189. data/src/core/lib/channel/handshaker.h +4 -2
  190. data/src/core/lib/channel/handshaker_registry.cc +5 -17
  191. data/src/core/lib/channel/status_util.cc +2 -3
  192. data/src/core/lib/compression/message_compress.cc +5 -1
  193. data/src/core/lib/debug/stats.cc +21 -27
  194. data/src/core/lib/debug/stats.h +3 -1
  195. data/src/core/lib/gpr/spinlock.h +2 -3
  196. data/src/core/lib/gpr/string.cc +2 -26
  197. data/src/core/lib/gpr/string.h +0 -16
  198. data/src/core/lib/gpr/sync_abseil.cc +2 -0
  199. data/src/core/lib/gpr/time.cc +4 -0
  200. data/src/core/lib/gpr/time_posix.cc +1 -1
  201. data/src/core/lib/gprpp/atomic.h +6 -6
  202. data/src/core/lib/gprpp/fork.cc +1 -1
  203. data/src/core/lib/gprpp/host_port.cc +29 -35
  204. data/src/core/lib/gprpp/host_port.h +14 -17
  205. data/src/core/lib/gprpp/map.h +5 -11
  206. data/src/core/lib/gprpp/ref_counted_ptr.h +5 -0
  207. data/src/core/lib/http/format_request.cc +46 -65
  208. data/src/core/lib/http/httpcli.cc +2 -3
  209. data/src/core/lib/http/httpcli.h +2 -3
  210. data/src/core/lib/http/httpcli_security_connector.cc +5 -5
  211. data/src/core/lib/http/parser.h +2 -3
  212. data/src/core/lib/iomgr/buffer_list.h +22 -21
  213. data/src/core/lib/iomgr/call_combiner.h +3 -2
  214. data/src/core/lib/iomgr/cfstream_handle.cc +3 -2
  215. data/src/core/lib/iomgr/closure.h +2 -3
  216. data/src/core/lib/iomgr/dualstack_socket_posix.cc +47 -0
  217. data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -3
  218. data/src/core/lib/iomgr/endpoint_pair.h +2 -3
  219. data/src/core/lib/iomgr/error.cc +6 -9
  220. data/src/core/lib/iomgr/error.h +0 -1
  221. data/src/core/lib/iomgr/ev_apple.cc +356 -0
  222. data/src/core/lib/iomgr/ev_apple.h +43 -0
  223. data/src/core/lib/iomgr/ev_epoll1_linux.cc +20 -23
  224. data/src/core/lib/iomgr/ev_epollex_linux.cc +2 -3
  225. data/src/core/lib/iomgr/ev_poll_posix.cc +3 -3
  226. data/src/core/lib/iomgr/ev_posix.cc +2 -3
  227. data/src/core/lib/iomgr/exec_ctx.h +14 -2
  228. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +84 -20
  229. data/src/core/lib/iomgr/pollset_set_custom.cc +10 -10
  230. data/src/core/lib/{gprpp/optional.h → iomgr/pollset_uv.h} +11 -12
  231. data/src/core/lib/iomgr/port.h +1 -0
  232. data/src/core/lib/iomgr/python_util.h +46 -0
  233. data/src/core/lib/iomgr/resolve_address.h +4 -6
  234. data/src/core/lib/iomgr/resolve_address_custom.cc +29 -39
  235. data/src/core/lib/iomgr/resolve_address_custom.h +4 -2
  236. data/src/core/lib/iomgr/resolve_address_posix.cc +10 -11
  237. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -17
  238. data/src/core/lib/iomgr/resource_quota.cc +4 -6
  239. data/src/core/lib/iomgr/sockaddr_utils.cc +23 -29
  240. data/src/core/lib/iomgr/sockaddr_utils.h +9 -14
  241. data/src/core/lib/iomgr/socket_factory_posix.h +2 -3
  242. data/src/core/lib/iomgr/socket_mutator.h +2 -3
  243. data/src/core/lib/iomgr/socket_utils_common_posix.cc +7 -26
  244. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  245. data/src/core/lib/iomgr/tcp_client_cfstream.cc +5 -7
  246. data/src/core/lib/iomgr/tcp_client_posix.cc +8 -5
  247. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -3
  248. data/src/core/lib/iomgr/tcp_custom.cc +2 -3
  249. data/src/core/lib/iomgr/tcp_server_custom.cc +5 -9
  250. data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
  251. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +5 -4
  252. data/src/core/lib/iomgr/tcp_server_utils_posix_ifaddrs.cc +8 -11
  253. data/src/core/lib/iomgr/tcp_uv.cc +3 -2
  254. data/src/core/lib/iomgr/time_averaged_stats.h +2 -3
  255. data/src/core/lib/iomgr/timer_generic.cc +2 -3
  256. data/src/core/lib/{gprpp/inlined_vector.h → iomgr/timer_generic.h} +19 -17
  257. data/src/core/lib/iomgr/timer_heap.h +2 -3
  258. data/src/core/lib/iomgr/udp_server.cc +9 -14
  259. data/src/core/lib/json/json.h +3 -2
  260. data/src/core/lib/json/json_reader.cc +5 -5
  261. data/src/core/lib/json/json_writer.cc +13 -12
  262. data/src/core/lib/security/credentials/composite/composite_credentials.cc +12 -0
  263. data/src/core/lib/security/credentials/composite/composite_credentials.h +6 -3
  264. data/src/core/lib/security/credentials/credentials.cc +0 -84
  265. data/src/core/lib/security/credentials/credentials.h +8 -59
  266. data/src/core/lib/security/credentials/fake/fake_credentials.h +4 -0
  267. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +3 -8
  268. data/src/core/lib/security/credentials/iam/iam_credentials.cc +8 -6
  269. data/src/core/lib/security/credentials/iam/iam_credentials.h +4 -0
  270. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  271. data/src/core/lib/security/credentials/jwt/json_token.h +2 -5
  272. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +12 -0
  273. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +8 -15
  274. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +2 -3
  275. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +55 -27
  276. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +9 -3
  277. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +13 -0
  278. data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -0
  279. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +23 -13
  280. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +38 -11
  281. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +21 -6
  282. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +7 -7
  283. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +3 -2
  284. data/src/core/lib/security/security_connector/local/local_security_connector.cc +1 -1
  285. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  286. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +20 -25
  287. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.h +4 -6
  288. data/src/core/lib/security/security_connector/ssl_utils.cc +59 -12
  289. data/src/core/lib/security/security_connector/ssl_utils.h +12 -10
  290. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +77 -51
  291. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +27 -5
  292. data/src/core/lib/security/transport/auth_filters.h +0 -5
  293. data/src/core/lib/security/transport/client_auth_filter.cc +1 -2
  294. data/src/core/lib/slice/slice_intern.cc +2 -3
  295. data/src/core/lib/slice/slice_internal.h +14 -0
  296. data/src/core/lib/slice/slice_utils.h +9 -0
  297. data/src/core/lib/surface/byte_buffer_reader.cc +2 -47
  298. data/src/core/lib/surface/call.cc +2 -3
  299. data/src/core/lib/surface/call_log_batch.cc +50 -58
  300. data/src/core/lib/surface/channel.cc +53 -31
  301. data/src/core/lib/surface/channel.h +35 -4
  302. data/src/core/lib/surface/channel_ping.cc +2 -3
  303. data/src/core/lib/surface/completion_queue.cc +33 -33
  304. data/src/core/lib/surface/event_string.cc +18 -25
  305. data/src/core/lib/surface/event_string.h +3 -1
  306. data/src/core/lib/surface/init_secure.cc +1 -4
  307. data/src/core/lib/surface/server.cc +570 -369
  308. data/src/core/lib/surface/server.h +32 -0
  309. data/src/core/lib/surface/version.cc +2 -2
  310. data/src/core/lib/transport/byte_stream.h +7 -2
  311. data/src/core/lib/transport/connectivity_state.cc +7 -6
  312. data/src/core/lib/transport/connectivity_state.h +5 -3
  313. data/src/core/lib/transport/metadata.cc +3 -3
  314. data/src/core/lib/transport/metadata_batch.h +2 -3
  315. data/src/core/lib/transport/static_metadata.h +1 -1
  316. data/src/core/lib/transport/status_conversion.cc +6 -14
  317. data/src/core/lib/transport/transport.cc +2 -3
  318. data/src/core/lib/transport/transport.h +3 -2
  319. data/src/core/lib/transport/transport_op_string.cc +61 -102
  320. data/src/core/lib/uri/uri_parser.h +2 -3
  321. data/src/core/plugin_registry/grpc_plugin_registry.cc +20 -4
  322. data/src/core/tsi/alts/crypt/aes_gcm.cc +0 -2
  323. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +8 -1
  324. data/src/core/tsi/alts/handshaker/alts_handshaker_client.h +8 -4
  325. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +32 -2
  326. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +9 -1
  327. data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.h +2 -3
  328. data/src/core/tsi/fake_transport_security.cc +10 -15
  329. data/src/core/tsi/ssl/session_cache/ssl_session.h +0 -2
  330. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +0 -2
  331. data/src/core/tsi/ssl_transport_security.cc +52 -39
  332. data/src/core/tsi/ssl_transport_security.h +8 -8
  333. data/src/core/tsi/ssl_types.h +0 -2
  334. data/src/core/tsi/transport_security.h +6 -9
  335. data/src/core/tsi/transport_security_grpc.h +2 -3
  336. data/src/core/tsi/transport_security_interface.h +3 -3
  337. data/src/ruby/ext/grpc/rb_call.c +9 -1
  338. data/src/ruby/ext/grpc/rb_call_credentials.c +3 -2
  339. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  340. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
  341. data/src/ruby/lib/grpc/errors.rb +103 -42
  342. data/src/ruby/lib/grpc/generic/active_call.rb +2 -3
  343. data/src/ruby/lib/grpc/generic/interceptors.rb +4 -4
  344. data/src/ruby/lib/grpc/generic/rpc_server.rb +9 -10
  345. data/src/ruby/lib/grpc/generic/service.rb +5 -4
  346. data/src/ruby/lib/grpc/structs.rb +1 -1
  347. data/src/ruby/lib/grpc/version.rb +1 -1
  348. data/src/ruby/pb/generate_proto_ruby.sh +5 -3
  349. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +11 -0
  350. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +16 -0
  351. data/src/ruby/spec/debug_message_spec.rb +134 -0
  352. data/src/ruby/spec/generic/service_spec.rb +2 -0
  353. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_import2.proto +23 -0
  354. data/src/ruby/spec/pb/codegen/grpc/testing/package_options_ruby_style.proto +7 -0
  355. data/src/ruby/spec/pb/codegen/package_option_spec.rb +7 -1
  356. data/src/ruby/spec/support/services.rb +10 -4
  357. data/src/ruby/spec/testdata/ca.pem +18 -13
  358. data/src/ruby/spec/testdata/client.key +26 -14
  359. data/src/ruby/spec/testdata/client.pem +18 -12
  360. data/src/ruby/spec/testdata/server1.key +26 -14
  361. data/src/ruby/spec/testdata/server1.pem +20 -14
  362. data/third_party/abseil-cpp/absl/time/civil_time.cc +175 -0
  363. data/third_party/abseil-cpp/absl/time/civil_time.h +538 -0
  364. data/third_party/abseil-cpp/absl/time/clock.cc +569 -0
  365. data/third_party/abseil-cpp/absl/time/clock.h +74 -0
  366. data/third_party/abseil-cpp/absl/time/duration.cc +922 -0
  367. data/third_party/abseil-cpp/absl/time/format.cc +153 -0
  368. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time.h +332 -0
  369. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +622 -0
  370. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +384 -0
  371. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +102 -0
  372. data/third_party/abseil-cpp/absl/time/internal/cctz/src/civil_time_detail.cc +94 -0
  373. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +140 -0
  374. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.h +52 -0
  375. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +922 -0
  376. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +45 -0
  377. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +76 -0
  378. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +121 -0
  379. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +93 -0
  380. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +958 -0
  381. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +138 -0
  382. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +308 -0
  383. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +55 -0
  384. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +187 -0
  385. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.cc +159 -0
  386. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +132 -0
  387. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +122 -0
  388. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +115 -0
  389. data/third_party/abseil-cpp/absl/time/internal/get_current_time_chrono.inc +31 -0
  390. data/third_party/abseil-cpp/absl/time/internal/get_current_time_posix.inc +24 -0
  391. data/third_party/abseil-cpp/absl/time/time.cc +499 -0
  392. data/third_party/abseil-cpp/absl/time/time.h +1584 -0
  393. data/third_party/boringssl-with-bazel/err_data.c +329 -297
  394. data/third_party/boringssl-with-bazel/src/crypto/cipher_extra/derive_key.c +1 -1
  395. data/third_party/boringssl-with-bazel/src/crypto/cpu-arm-linux.c +7 -5
  396. data/third_party/boringssl-with-bazel/src/crypto/cpu-intel.c +13 -4
  397. data/third_party/boringssl-with-bazel/src/crypto/crypto.c +11 -0
  398. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519.c +18 -26
  399. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/curve25519_tables.h +13 -21
  400. data/third_party/boringssl-with-bazel/src/{third_party/fiat → crypto/curve25519}/internal.h +14 -22
  401. data/third_party/boringssl-with-bazel/src/crypto/curve25519/spake25519.c +1 -1
  402. data/third_party/boringssl-with-bazel/src/crypto/dh/dh.c +15 -0
  403. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +10 -0
  404. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +425 -0
  405. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +78 -0
  406. data/third_party/boringssl-with-bazel/src/crypto/ecdh_extra/ecdh_extra.c +2 -2
  407. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +33 -32
  408. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/aes/aes_nohw.c +1 -1
  409. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bcm.c +2 -1
  410. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/exponentiation.c +3 -3
  411. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/internal.h +14 -11
  412. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/montgomery.c +8 -8
  413. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/mul.c +30 -154
  414. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digests.c +16 -0
  415. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec.c +289 -117
  416. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_key.c +13 -27
  417. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/ec_montgomery.c +96 -55
  418. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/felem.c +25 -7
  419. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/internal.h +432 -160
  420. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/oct.c +63 -71
  421. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p224-64.c +5 -14
  422. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64-table.h +9481 -9485
  423. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256-x86_64.c +80 -99
  424. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256.c +736 -0
  425. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/p256_table.h +297 -0
  426. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/scalar.c +90 -11
  427. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple.c +125 -148
  428. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/simple_mul.c +189 -3
  429. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ec/wnaf.c +61 -18
  430. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdh/ecdh.c +2 -2
  431. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/ecdsa/ecdsa.c +20 -5
  432. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.c +137 -0
  433. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/fork_detect.h +49 -0
  434. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/getrandom_fillin.h +64 -0
  435. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/internal.h +41 -5
  436. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/rand.c +32 -17
  437. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rand/urandom.c +24 -114
  438. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/blinding.c +4 -0
  439. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +1 -0
  440. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +51 -38
  441. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +15 -1
  442. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +44 -35
  443. data/third_party/boringssl-with-bazel/src/crypto/mem.c +29 -12
  444. data/third_party/boringssl-with-bazel/src/crypto/obj/obj_dat.h +15 -1
  445. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/deterministic.c +6 -10
  446. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/windows.c +16 -0
  447. data/third_party/boringssl-with-bazel/src/crypto/thread_pthread.c +4 -0
  448. data/third_party/boringssl-with-bazel/src/crypto/thread_win.c +4 -0
  449. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +278 -0
  450. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +1474 -0
  451. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +720 -0
  452. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +16 -0
  453. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +5 -0
  454. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +4 -3
  455. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -1
  456. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +9 -4
  457. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +20 -0
  458. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +1 -0
  459. data/third_party/boringssl-with-bazel/src/include/openssl/dsa.h +16 -0
  460. data/third_party/boringssl-with-bazel/src/include/openssl/ecdsa.h +6 -0
  461. data/third_party/boringssl-with-bazel/src/include/openssl/err.h +2 -0
  462. data/third_party/boringssl-with-bazel/src/include/openssl/nid.h +5 -0
  463. data/third_party/boringssl-with-bazel/src/include/openssl/rand.h +3 -17
  464. data/third_party/boringssl-with-bazel/src/include/openssl/rsa.h +31 -0
  465. data/third_party/boringssl-with-bazel/src/include/openssl/sha.h +26 -0
  466. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +172 -77
  467. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +1 -0
  468. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +291 -0
  469. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +5 -3
  470. data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +1 -0
  471. data/third_party/boringssl-with-bazel/src/ssl/d1_both.cc +0 -4
  472. data/third_party/boringssl-with-bazel/src/ssl/d1_lib.cc +3 -3
  473. data/third_party/boringssl-with-bazel/src/ssl/dtls_method.cc +13 -4
  474. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +146 -57
  475. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +14 -3
  476. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +28 -20
  477. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +12 -4
  478. data/third_party/boringssl-with-bazel/src/ssl/internal.h +64 -47
  479. data/third_party/boringssl-with-bazel/src/ssl/s3_both.cc +10 -10
  480. data/third_party/boringssl-with-bazel/src/ssl/s3_lib.cc +2 -2
  481. data/third_party/boringssl-with-bazel/src/ssl/s3_pkt.cc +21 -21
  482. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +29 -0
  483. data/third_party/boringssl-with-bazel/src/ssl/ssl_cert.cc +4 -0
  484. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +6 -1
  485. data/third_party/boringssl-with-bazel/src/ssl/ssl_privkey.cc +13 -2
  486. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +64 -5
  487. data/third_party/boringssl-with-bazel/src/ssl/ssl_stat.cc +6 -0
  488. data/third_party/boringssl-with-bazel/src/ssl/t1_enc.cc +6 -2
  489. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +47 -53
  490. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -1
  491. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +98 -27
  492. data/third_party/boringssl-with-bazel/src/ssl/tls13_enc.cc +23 -75
  493. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +50 -20
  494. data/third_party/boringssl-with-bazel/src/ssl/tls_method.cc +63 -25
  495. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_32.h +245 -175
  496. data/third_party/boringssl-with-bazel/src/third_party/fiat/curve25519_64.h +135 -75
  497. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_32.h +1593 -1672
  498. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256_64.h +512 -503
  499. metadata +115 -39
  500. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +0 -1754
  501. data/src/core/lib/gprpp/string_view.h +0 -60
  502. data/src/core/tsi/grpc_shadow_boringssl.h +0 -3311
  503. data/third_party/boringssl-with-bazel/src/third_party/fiat/p256.c +0 -1063
@@ -24,13 +24,16 @@
24
24
 
25
25
  #include "absl/strings/str_cat.h"
26
26
  #include "absl/strings/str_join.h"
27
+ #include "absl/strings/str_split.h"
27
28
 
28
29
  #include <grpc/impl/codegen/log.h>
29
30
  #include <grpc/support/alloc.h>
30
31
  #include <grpc/support/string_util.h>
31
32
 
32
33
  #include "src/core/ext/filters/client_channel/xds/xds_api.h"
33
- #include "src/core/lib/gprpp/inlined_vector.h"
34
+ #include "src/core/lib/gpr/env.h"
35
+ #include "src/core/lib/gpr/string.h"
36
+ #include "src/core/lib/gpr/useful.h"
34
37
  #include "src/core/lib/iomgr/error.h"
35
38
  #include "src/core/lib/iomgr/sockaddr_utils.h"
36
39
 
@@ -126,10 +129,23 @@ const char* XdsApi::kCdsTypeUrl = "type.googleapis.com/envoy.api.v2.Cluster";
126
129
  const char* XdsApi::kEdsTypeUrl =
127
130
  "type.googleapis.com/envoy.api.v2.ClusterLoadAssignment";
128
131
 
132
+ namespace {
133
+
134
+ bool XdsRoutingEnabled() {
135
+ char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_ROUTING");
136
+ bool parsed_value;
137
+ bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
138
+ gpr_free(value);
139
+ return parse_succeeded && parsed_value;
140
+ }
141
+
142
+ } // namespace
143
+
129
144
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
130
145
  const XdsBootstrap::Node* node)
131
146
  : client_(client),
132
147
  tracer_(tracer),
148
+ xds_routing_enabled_(XdsRoutingEnabled()),
133
149
  node_(node),
134
150
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
135
151
  grpc_version_string())),
@@ -257,46 +273,14 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node,
257
273
  arena);
258
274
  }
259
275
 
260
- envoy_api_v2_DiscoveryRequest* CreateDiscoveryRequest(
261
- upb_arena* arena, const char* type_url, const std::string& version,
262
- const std::string& nonce, grpc_error* error) {
263
- // Create a request.
264
- envoy_api_v2_DiscoveryRequest* request =
265
- envoy_api_v2_DiscoveryRequest_new(arena);
266
- // Set type_url.
267
- envoy_api_v2_DiscoveryRequest_set_type_url(request,
268
- upb_strview_makez(type_url));
269
- // Set version_info.
270
- if (!version.empty()) {
271
- envoy_api_v2_DiscoveryRequest_set_version_info(
272
- request, upb_strview_makez(version.c_str()));
273
- }
274
- // Set nonce.
275
- if (!nonce.empty()) {
276
- envoy_api_v2_DiscoveryRequest_set_response_nonce(
277
- request, upb_strview_makez(nonce.c_str()));
278
- }
279
- // Set error_detail if it's a NACK.
280
- if (error != GRPC_ERROR_NONE) {
281
- grpc_slice error_description_slice;
282
- GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
283
- &error_description_slice));
284
- upb_strview error_description_strview =
285
- upb_strview_make(reinterpret_cast<const char*>(
286
- GPR_SLICE_START_PTR(error_description_slice)),
287
- GPR_SLICE_LENGTH(error_description_slice));
288
- google_rpc_Status* error_detail =
289
- envoy_api_v2_DiscoveryRequest_mutable_error_detail(request, arena);
290
- google_rpc_Status_set_message(error_detail, error_description_strview);
291
- GRPC_ERROR_UNREF(error);
292
- }
293
- return request;
294
- }
295
-
296
276
  inline absl::string_view UpbStringToAbsl(const upb_strview& str) {
297
277
  return absl::string_view(str.data, str.size);
298
278
  }
299
279
 
280
+ inline std::string UpbStringToStdString(const upb_strview& str) {
281
+ return std::string(str.data, str.size);
282
+ }
283
+
300
284
  inline void AddStringField(const char* name, const upb_strview& value,
301
285
  std::vector<std::string>* fields,
302
286
  bool add_if_empty = false) {
@@ -306,6 +290,15 @@ inline void AddStringField(const char* name, const upb_strview& value,
306
290
  }
307
291
  }
308
292
 
293
+ inline void AddUInt32ValueField(const char* name,
294
+ const google_protobuf_UInt32Value* value,
295
+ std::vector<std::string>* fields) {
296
+ if (value != nullptr) {
297
+ fields->emplace_back(absl::StrCat(
298
+ name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
299
+ }
300
+ }
301
+
309
302
  inline void AddLocalityField(int indent_level,
310
303
  const envoy_api_v2_core_Locality* locality,
311
304
  std::vector<std::string>* fields) {
@@ -459,91 +452,43 @@ grpc_slice SerializeDiscoveryRequest(upb_arena* arena,
459
452
 
460
453
  } // namespace
461
454
 
462
- grpc_slice XdsApi::CreateUnsupportedTypeNackRequest(const std::string& type_url,
463
- const std::string& nonce,
464
- grpc_error* error) {
465
- upb::Arena arena;
466
- envoy_api_v2_DiscoveryRequest* request = CreateDiscoveryRequest(
467
- arena.ptr(), type_url.c_str(), /*version=*/"", nonce, error);
468
- MaybeLogDiscoveryRequest(client_, tracer_, request);
469
- return SerializeDiscoveryRequest(arena.ptr(), request);
470
- }
471
-
472
- grpc_slice XdsApi::CreateLdsRequest(const std::string& server_name,
473
- const std::string& version,
474
- const std::string& nonce, grpc_error* error,
475
- bool populate_node) {
476
- upb::Arena arena;
477
- envoy_api_v2_DiscoveryRequest* request =
478
- CreateDiscoveryRequest(arena.ptr(), kLdsTypeUrl, version, nonce, error);
479
- // Populate node.
480
- if (populate_node) {
481
- envoy_api_v2_core_Node* node_msg =
482
- envoy_api_v2_DiscoveryRequest_mutable_node(request, arena.ptr());
483
- PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_, "",
484
- node_msg);
485
- }
486
- // Add resource_name.
487
- envoy_api_v2_DiscoveryRequest_add_resource_names(
488
- request, upb_strview_make(server_name.data(), server_name.size()),
489
- arena.ptr());
490
- MaybeLogDiscoveryRequest(client_, tracer_, request);
491
- return SerializeDiscoveryRequest(arena.ptr(), request);
492
- }
493
-
494
- grpc_slice XdsApi::CreateRdsRequest(const std::string& route_config_name,
495
- const std::string& version,
496
- const std::string& nonce, grpc_error* error,
497
- bool populate_node) {
455
+ grpc_slice XdsApi::CreateAdsRequest(
456
+ const std::string& type_url,
457
+ const std::set<absl::string_view>& resource_names,
458
+ const std::string& version, const std::string& nonce, grpc_error* error,
459
+ bool populate_node) {
498
460
  upb::Arena arena;
461
+ // Create a request.
499
462
  envoy_api_v2_DiscoveryRequest* request =
500
- CreateDiscoveryRequest(arena.ptr(), kRdsTypeUrl, version, nonce, error);
501
- // Populate node.
502
- if (populate_node) {
503
- envoy_api_v2_core_Node* node_msg =
504
- envoy_api_v2_DiscoveryRequest_mutable_node(request, arena.ptr());
505
- PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_, "",
506
- node_msg);
463
+ envoy_api_v2_DiscoveryRequest_new(arena.ptr());
464
+ // Set type_url.
465
+ envoy_api_v2_DiscoveryRequest_set_type_url(
466
+ request, upb_strview_make(type_url.data(), type_url.size()));
467
+ // Set version_info.
468
+ if (!version.empty()) {
469
+ envoy_api_v2_DiscoveryRequest_set_version_info(
470
+ request, upb_strview_make(version.data(), version.size()));
507
471
  }
508
- // Add resource_name.
509
- envoy_api_v2_DiscoveryRequest_add_resource_names(
510
- request,
511
- upb_strview_make(route_config_name.data(), route_config_name.size()),
512
- arena.ptr());
513
- MaybeLogDiscoveryRequest(client_, tracer_, request);
514
- return SerializeDiscoveryRequest(arena.ptr(), request);
515
- }
516
-
517
- grpc_slice XdsApi::CreateCdsRequest(const std::set<StringView>& cluster_names,
518
- const std::string& version,
519
- const std::string& nonce, grpc_error* error,
520
- bool populate_node) {
521
- upb::Arena arena;
522
- envoy_api_v2_DiscoveryRequest* request =
523
- CreateDiscoveryRequest(arena.ptr(), kCdsTypeUrl, version, nonce, error);
524
- // Populate node.
525
- if (populate_node) {
526
- envoy_api_v2_core_Node* node_msg =
527
- envoy_api_v2_DiscoveryRequest_mutable_node(request, arena.ptr());
528
- PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_, "",
529
- node_msg);
472
+ // Set nonce.
473
+ if (!nonce.empty()) {
474
+ envoy_api_v2_DiscoveryRequest_set_response_nonce(
475
+ request, upb_strview_make(nonce.data(), nonce.size()));
530
476
  }
531
- // Add resource_names.
532
- for (const auto& cluster_name : cluster_names) {
533
- envoy_api_v2_DiscoveryRequest_add_resource_names(
534
- request, upb_strview_make(cluster_name.data(), cluster_name.size()),
535
- arena.ptr());
477
+ // Set error_detail if it's a NACK.
478
+ if (error != GRPC_ERROR_NONE) {
479
+ grpc_slice error_description_slice;
480
+ GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
481
+ &error_description_slice));
482
+ upb_strview error_description_strview =
483
+ upb_strview_make(reinterpret_cast<const char*>(
484
+ GPR_SLICE_START_PTR(error_description_slice)),
485
+ GPR_SLICE_LENGTH(error_description_slice));
486
+ google_rpc_Status* error_detail =
487
+ envoy_api_v2_DiscoveryRequest_mutable_error_detail(request,
488
+ arena.ptr());
489
+ google_rpc_Status_set_message(error_detail, error_description_strview);
490
+ GRPC_ERROR_UNREF(error);
536
491
  }
537
- MaybeLogDiscoveryRequest(client_, tracer_, request);
538
- return SerializeDiscoveryRequest(arena.ptr(), request);
539
- }
540
-
541
- grpc_slice XdsApi::CreateEdsRequest(
542
- const std::set<StringView>& eds_service_names, const std::string& version,
543
- const std::string& nonce, grpc_error* error, bool populate_node) {
544
- upb::Arena arena;
545
- envoy_api_v2_DiscoveryRequest* request =
546
- CreateDiscoveryRequest(arena.ptr(), kEdsTypeUrl, version, nonce, error);
547
492
  // Populate node.
548
493
  if (populate_node) {
549
494
  envoy_api_v2_core_Node* node_msg =
@@ -552,10 +497,9 @@ grpc_slice XdsApi::CreateEdsRequest(
552
497
  node_msg);
553
498
  }
554
499
  // Add resource_names.
555
- for (const auto& eds_service_name : eds_service_names) {
500
+ for (const auto& resource_name : resource_names) {
556
501
  envoy_api_v2_DiscoveryRequest_add_resource_names(
557
- request,
558
- upb_strview_make(eds_service_name.data(), eds_service_name.size()),
502
+ request, upb_strview_make(resource_name.data(), resource_name.size()),
559
503
  arena.ptr());
560
504
  }
561
505
  MaybeLogDiscoveryRequest(client_, tracer_, request);
@@ -678,7 +622,34 @@ void MaybeLogRouteConfiguration(
678
622
  envoy_api_v2_route_RouteAction_cluster_header(action), &fields);
679
623
  } else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
680
624
  action)) {
681
- fields.emplace_back(" weighted_clusters: <not printed>");
625
+ const envoy_api_v2_route_WeightedCluster* weighted_clusters =
626
+ envoy_api_v2_route_RouteAction_weighted_clusters(action);
627
+ fields.emplace_back(" weighted_clusters {");
628
+ size_t num_cluster_weights;
629
+ const envoy_api_v2_route_WeightedCluster_ClusterWeight* const*
630
+ cluster_weights = envoy_api_v2_route_WeightedCluster_clusters(
631
+ weighted_clusters, &num_cluster_weights);
632
+ for (size_t i = 0; i < num_cluster_weights; ++i) {
633
+ const envoy_api_v2_route_WeightedCluster_ClusterWeight*
634
+ cluster_weight = cluster_weights[i];
635
+ fields.emplace_back(" clusters {");
636
+ AddStringField(
637
+ " name",
638
+ envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
639
+ cluster_weight),
640
+ &fields);
641
+ AddUInt32ValueField(
642
+ " weight",
643
+ envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
644
+ cluster_weight),
645
+ &fields);
646
+ fields.emplace_back(" }");
647
+ }
648
+ AddUInt32ValueField(" total_weight",
649
+ envoy_api_v2_route_WeightedCluster_total_weight(
650
+ weighted_clusters),
651
+ &fields);
652
+ fields.emplace_back(" }");
682
653
  }
683
654
  fields.emplace_back(" }");
684
655
  } else if (envoy_api_v2_route_Route_has_redirect(route)) {
@@ -839,14 +810,11 @@ void MaybeLogClusterLoadAssignment(
839
810
  fields.emplace_back(" }");
840
811
  }
841
812
  // load_balancing_weight
842
- const google_protobuf_UInt32Value* lb_weight =
813
+ AddUInt32ValueField(
814
+ " load_balancing_weight",
843
815
  envoy_api_v2_endpoint_LocalityLbEndpoints_load_balancing_weight(
844
- locality_endpoint);
845
- if (lb_weight != nullptr) {
846
- fields.emplace_back(
847
- absl::StrCat(" load_balancing_weight { value: ",
848
- google_protobuf_UInt32Value_value(lb_weight), " }"));
849
- }
816
+ locality_endpoint),
817
+ &fields);
850
818
  // priority
851
819
  uint32_t priority =
852
820
  envoy_api_v2_endpoint_LocalityLbEndpoints_priority(locality_endpoint);
@@ -923,16 +891,18 @@ bool DomainMatch(MatchType match_type, std::string domain_pattern,
923
891
  } else if (match_type == SUFFIX_MATCH) {
924
892
  // Asterisk must match at least one char.
925
893
  if (expected_host_name.size() < domain_pattern.size()) return false;
926
- StringView pattern_suffix(domain_pattern.c_str() + 1);
927
- StringView host_suffix(expected_host_name.c_str() +
928
- expected_host_name.size() - pattern_suffix.size());
894
+ absl::string_view pattern_suffix(domain_pattern.c_str() + 1);
895
+ absl::string_view host_suffix(expected_host_name.c_str() +
896
+ expected_host_name.size() -
897
+ pattern_suffix.size());
929
898
  return pattern_suffix == host_suffix;
930
899
  } else if (match_type == PREFIX_MATCH) {
931
900
  // Asterisk must match at least one char.
932
901
  if (expected_host_name.size() < domain_pattern.size()) return false;
933
- StringView pattern_prefix(domain_pattern.c_str(),
934
- domain_pattern.size() - 1);
935
- StringView host_prefix(expected_host_name.c_str(), pattern_prefix.size());
902
+ absl::string_view pattern_prefix(domain_pattern.c_str(),
903
+ domain_pattern.size() - 1);
904
+ absl::string_view host_prefix(expected_host_name.c_str(),
905
+ pattern_prefix.size());
936
906
  return pattern_prefix == host_prefix;
937
907
  } else {
938
908
  return match_type == UNIVERSE_MATCH;
@@ -948,10 +918,81 @@ MatchType DomainPatternMatchType(const std::string& domain_pattern) {
948
918
  return INVALID_MATCH;
949
919
  }
950
920
 
921
+ grpc_error* RouteActionParse(const envoy_api_v2_route_Route* route,
922
+ XdsApi::RdsUpdate::RdsRoute* rds_route) {
923
+ if (!envoy_api_v2_route_Route_has_route(route)) {
924
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
925
+ "No RouteAction found in route.");
926
+ }
927
+ const envoy_api_v2_route_RouteAction* route_action =
928
+ envoy_api_v2_route_Route_route(route);
929
+ // Get the cluster or weighted_clusters in the RouteAction.
930
+ if (envoy_api_v2_route_RouteAction_has_cluster(route_action)) {
931
+ const upb_strview cluster_name =
932
+ envoy_api_v2_route_RouteAction_cluster(route_action);
933
+ if (cluster_name.size == 0) {
934
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
935
+ "RouteAction cluster contains empty cluster name.");
936
+ }
937
+ rds_route->cluster_name = UpbStringToStdString(cluster_name);
938
+ } else if (envoy_api_v2_route_RouteAction_has_weighted_clusters(
939
+ route_action)) {
940
+ const envoy_api_v2_route_WeightedCluster* weighted_cluster =
941
+ envoy_api_v2_route_RouteAction_weighted_clusters(route_action);
942
+ uint32_t total_weight = 100;
943
+ const google_protobuf_UInt32Value* weight =
944
+ envoy_api_v2_route_WeightedCluster_total_weight(weighted_cluster);
945
+ if (weight != nullptr) {
946
+ total_weight = google_protobuf_UInt32Value_value(weight);
947
+ }
948
+ size_t clusters_size;
949
+ const envoy_api_v2_route_WeightedCluster_ClusterWeight* const* clusters =
950
+ envoy_api_v2_route_WeightedCluster_clusters(weighted_cluster,
951
+ &clusters_size);
952
+ uint32_t sum_of_weights = 0;
953
+ for (size_t j = 0; j < clusters_size; ++j) {
954
+ const envoy_api_v2_route_WeightedCluster_ClusterWeight* cluster_weight =
955
+ clusters[j];
956
+ XdsApi::RdsUpdate::RdsRoute::ClusterWeight cluster;
957
+ cluster.name = UpbStringToStdString(
958
+ envoy_api_v2_route_WeightedCluster_ClusterWeight_name(
959
+ cluster_weight));
960
+ if (cluster.name.empty()) {
961
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
962
+ "RouteAction weighted_cluster cluster contains empty cluster "
963
+ "name.");
964
+ }
965
+ const google_protobuf_UInt32Value* weight =
966
+ envoy_api_v2_route_WeightedCluster_ClusterWeight_weight(
967
+ cluster_weight);
968
+ if (weight == nullptr) {
969
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
970
+ "RouteAction weighted_cluster cluster missing weight");
971
+ }
972
+ cluster.weight = google_protobuf_UInt32Value_value(weight);
973
+ sum_of_weights += cluster.weight;
974
+ rds_route->weighted_clusters.emplace_back(std::move(cluster));
975
+ }
976
+ if (total_weight != sum_of_weights) {
977
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
978
+ "RouteAction weighted_cluster has incorrect total weight");
979
+ }
980
+ if (rds_route->weighted_clusters.empty()) {
981
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
982
+ "RouteAction weighted_cluster has no valid clusters specified.");
983
+ }
984
+ } else {
985
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
986
+ "No cluster or weighted_clusters found in RouteAction.");
987
+ }
988
+ return GRPC_ERROR_NONE;
989
+ }
990
+
951
991
  grpc_error* RouteConfigParse(
952
992
  XdsClient* client, TraceFlag* tracer,
953
993
  const envoy_api_v2_RouteConfiguration* route_config,
954
- const std::string& expected_server_name, XdsApi::RdsUpdate* rds_update) {
994
+ const std::string& expected_server_name, const bool xds_routing_enabled,
995
+ XdsApi::RdsUpdate* rds_update) {
955
996
  MaybeLogRouteConfiguration(client, tracer, route_config);
956
997
  // Get the virtual hosts.
957
998
  size_t size;
@@ -1011,40 +1052,105 @@ grpc_error* RouteConfigParse(
1011
1052
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1012
1053
  "No route found in the virtual host.");
1013
1054
  }
1014
- // Only look at the last one in the route list (the default route),
1015
- const envoy_api_v2_route_Route* route = routes[size - 1];
1016
- // Validate that the match field must have a prefix field which is an empty
1017
- // string.
1018
- const envoy_api_v2_route_RouteMatch* match =
1019
- envoy_api_v2_route_Route_match(route);
1020
- if (!envoy_api_v2_route_RouteMatch_has_prefix(match)) {
1021
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1022
- "No prefix field found in RouteMatch.");
1023
- }
1024
- const upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
1025
- if (!upb_strview_eql(prefix, upb_strview_makez(""))) {
1026
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Prefix is not empty string.");
1055
+ // If xds_routing is not configured, only look at the last one in the route
1056
+ // list (the default route)
1057
+ if (!xds_routing_enabled) {
1058
+ const envoy_api_v2_route_Route* route = routes[size - 1];
1059
+ const envoy_api_v2_route_RouteMatch* match =
1060
+ envoy_api_v2_route_Route_match(route);
1061
+ XdsApi::RdsUpdate::RdsRoute rds_route;
1062
+ // if xds routing is not enabled, we must be working on the default route;
1063
+ // in this case, we must have an empty or single slash prefix.
1064
+ if (!envoy_api_v2_route_RouteMatch_has_prefix(match)) {
1065
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1066
+ "No prefix field found in Default RouteMatch.");
1067
+ }
1068
+ const upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
1069
+ if (!upb_strview_eql(prefix, upb_strview_makez("")) &&
1070
+ !upb_strview_eql(prefix, upb_strview_makez("/"))) {
1071
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1072
+ "Default route must have empty prefix.");
1073
+ }
1074
+ grpc_error* error = RouteActionParse(route, &rds_route);
1075
+ if (error != GRPC_ERROR_NONE) return error;
1076
+ rds_update->routes.emplace_back(std::move(rds_route));
1077
+ return GRPC_ERROR_NONE;
1027
1078
  }
1028
- if (!envoy_api_v2_route_Route_has_route(route)) {
1029
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1030
- "No RouteAction found in route.");
1079
+ // Loop over the whole list of routes
1080
+ for (size_t i = 0; i < size; ++i) {
1081
+ const envoy_api_v2_route_Route* route = routes[i];
1082
+ const envoy_api_v2_route_RouteMatch* match =
1083
+ envoy_api_v2_route_Route_match(route);
1084
+ XdsApi::RdsUpdate::RdsRoute rds_route;
1085
+ if (envoy_api_v2_route_RouteMatch_has_prefix(match)) {
1086
+ upb_strview prefix = envoy_api_v2_route_RouteMatch_prefix(match);
1087
+ // Empty prefix "" is accepted.
1088
+ if (prefix.size > 0) {
1089
+ // Prefix "/" is accepted.
1090
+ if (prefix.data[0] != '/') {
1091
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1092
+ "Prefix does not start with a /");
1093
+ }
1094
+ if (prefix.size > 1) {
1095
+ std::vector<absl::string_view> prefix_elements = absl::StrSplit(
1096
+ absl::string_view(prefix.data, prefix.size).substr(1),
1097
+ absl::MaxSplits('/', 1));
1098
+ if (prefix_elements.size() != 2) {
1099
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1100
+ "Prefix not in the required format of /service/");
1101
+ } else if (!prefix_elements[1].empty()) {
1102
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1103
+ "Prefix does not end with a /");
1104
+ } else if (prefix_elements[0].empty()) {
1105
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1106
+ "Prefix contains empty service name");
1107
+ }
1108
+ rds_route.service = std::string(prefix_elements[0]);
1109
+ }
1110
+ }
1111
+ } else if (envoy_api_v2_route_RouteMatch_has_path(match)) {
1112
+ upb_strview path = envoy_api_v2_route_RouteMatch_path(match);
1113
+ if (path.size == 0) {
1114
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1115
+ "Path if set cannot be empty");
1116
+ }
1117
+ if (path.data[0] != '/') {
1118
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1119
+ "Path does not start with a /");
1120
+ }
1121
+ std::vector<absl::string_view> path_elements = absl::StrSplit(
1122
+ absl::string_view(path.data, path.size).substr(1), '/');
1123
+ if (path_elements.size() != 2) {
1124
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1125
+ "Path not in the required format of /service/method");
1126
+ } else if (path_elements[0].empty()) {
1127
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1128
+ "Path contains empty service name");
1129
+ } else if (path_elements[1].empty()) {
1130
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1131
+ "Path contains empty method name");
1132
+ }
1133
+ rds_route.service = std::string(path_elements[0]);
1134
+ rds_route.method = std::string(path_elements[1]);
1135
+ } else {
1136
+ // Path specifier types will be supported, ignore but not reject until
1137
+ // they are implemented.
1138
+ continue;
1139
+ }
1140
+ grpc_error* error = RouteActionParse(route, &rds_route);
1141
+ if (error != GRPC_ERROR_NONE) return error;
1142
+ rds_update->routes.emplace_back(std::move(rds_route));
1031
1143
  }
1032
- const envoy_api_v2_route_RouteAction* route_action =
1033
- envoy_api_v2_route_Route_route(route);
1034
- // Get the cluster in the RouteAction.
1035
- if (!envoy_api_v2_route_RouteAction_has_cluster(route_action)) {
1036
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1037
- "No cluster found in RouteAction.");
1144
+ if (rds_update->routes.empty()) {
1145
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING("No valid routes specified.");
1038
1146
  }
1039
- const upb_strview cluster =
1040
- envoy_api_v2_route_RouteAction_cluster(route_action);
1041
- rds_update->cluster_name = std::string(cluster.data, cluster.size);
1042
1147
  return GRPC_ERROR_NONE;
1043
1148
  }
1044
1149
 
1045
1150
  grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1046
1151
  const envoy_api_v2_DiscoveryResponse* response,
1047
1152
  const std::string& expected_server_name,
1153
+ const bool xds_routing_enabled,
1048
1154
  absl::optional<XdsApi::LdsUpdate>* lds_update,
1049
1155
  upb_arena* arena) {
1050
1156
  // Get the resources from the response.
@@ -1075,7 +1181,7 @@ grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1075
1181
  envoy_api_v2_Listener_api_listener(listener);
1076
1182
  if (api_listener == nullptr) {
1077
1183
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1078
- "Listener doesn't have ApiListener.");
1184
+ "Listener has no ApiListener.");
1079
1185
  }
1080
1186
  const upb_strview encoded_api_listener = google_protobuf_Any_value(
1081
1187
  envoy_config_listener_v2_ApiListener_api_listener(api_listener));
@@ -1090,8 +1196,9 @@ grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1090
1196
  envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_route_config(
1091
1197
  http_connection_manager);
1092
1198
  XdsApi::RdsUpdate rds_update;
1093
- grpc_error* error = RouteConfigParse(client, tracer, route_config,
1094
- expected_server_name, &rds_update);
1199
+ grpc_error* error =
1200
+ RouteConfigParse(client, tracer, route_config, expected_server_name,
1201
+ xds_routing_enabled, &rds_update);
1095
1202
  if (error != GRPC_ERROR_NONE) return error;
1096
1203
  lds_update->emplace();
1097
1204
  (*lds_update)->rds_update.emplace(std::move(rds_update));
@@ -1103,27 +1210,38 @@ grpc_error* LdsResponseParse(XdsClient* client, TraceFlag* tracer,
1103
1210
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1104
1211
  "HttpConnectionManager neither has inlined route_config nor RDS.");
1105
1212
  }
1106
- // Get the route_config_name.
1107
1213
  const envoy_config_filter_network_http_connection_manager_v2_Rds* rds =
1108
1214
  envoy_config_filter_network_http_connection_manager_v2_HttpConnectionManager_rds(
1109
1215
  http_connection_manager);
1110
- const upb_strview route_config_name =
1111
- envoy_config_filter_network_http_connection_manager_v2_Rds_route_config_name(
1216
+ // Check that the ConfigSource specifies ADS.
1217
+ const envoy_api_v2_core_ConfigSource* config_source =
1218
+ envoy_config_filter_network_http_connection_manager_v2_Rds_config_source(
1112
1219
  rds);
1220
+ if (config_source == nullptr) {
1221
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1222
+ "HttpConnectionManager missing config_source for RDS.");
1223
+ }
1224
+ if (!envoy_api_v2_core_ConfigSource_has_ads(config_source)) {
1225
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1226
+ "HttpConnectionManager ConfigSource for RDS does not specify ADS.");
1227
+ }
1228
+ // Get the route_config_name.
1113
1229
  lds_update->emplace();
1114
- (*lds_update)->route_config_name =
1115
- std::string(route_config_name.data, route_config_name.size);
1230
+ (*lds_update)->route_config_name = UpbStringToStdString(
1231
+ envoy_config_filter_network_http_connection_manager_v2_Rds_route_config_name(
1232
+ rds));
1116
1233
  return GRPC_ERROR_NONE;
1117
1234
  }
1118
1235
  return GRPC_ERROR_NONE;
1119
1236
  }
1120
1237
 
1121
- grpc_error* RdsResponseParse(XdsClient* client, TraceFlag* tracer,
1122
- const envoy_api_v2_DiscoveryResponse* response,
1123
- const std::string& expected_server_name,
1124
- const std::string& expected_route_config_name,
1125
- absl::optional<XdsApi::RdsUpdate>* rds_update,
1126
- upb_arena* arena) {
1238
+ grpc_error* RdsResponseParse(
1239
+ XdsClient* client, TraceFlag* tracer,
1240
+ const envoy_api_v2_DiscoveryResponse* response,
1241
+ const std::string& expected_server_name,
1242
+ const std::set<absl::string_view>& expected_route_configuration_names,
1243
+ const bool xds_routing_enabled,
1244
+ absl::optional<XdsApi::RdsUpdate>* rds_update, upb_arena* arena) {
1127
1245
  // Get the resources from the response.
1128
1246
  size_t size;
1129
1247
  const google_protobuf_Any* const* resources =
@@ -1144,14 +1262,19 @@ grpc_error* RdsResponseParse(XdsClient* client, TraceFlag* tracer,
1144
1262
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
1145
1263
  }
1146
1264
  // Check route_config_name. Ignore unexpected route_config.
1147
- const upb_strview name = envoy_api_v2_RouteConfiguration_name(route_config);
1148
- const upb_strview expected_name =
1149
- upb_strview_makez(expected_route_config_name.c_str());
1150
- if (!upb_strview_eql(name, expected_name)) continue;
1265
+ const upb_strview route_config_name =
1266
+ envoy_api_v2_RouteConfiguration_name(route_config);
1267
+ absl::string_view route_config_name_strview(route_config_name.data,
1268
+ route_config_name.size);
1269
+ if (expected_route_configuration_names.find(route_config_name_strview) ==
1270
+ expected_route_configuration_names.end()) {
1271
+ continue;
1272
+ }
1151
1273
  // Parse the route_config.
1152
1274
  XdsApi::RdsUpdate local_rds_update;
1153
- grpc_error* error = RouteConfigParse(
1154
- client, tracer, route_config, expected_server_name, &local_rds_update);
1275
+ grpc_error* error =
1276
+ RouteConfigParse(client, tracer, route_config, expected_server_name,
1277
+ xds_routing_enabled, &local_rds_update);
1155
1278
  if (error != GRPC_ERROR_NONE) return error;
1156
1279
  rds_update->emplace(std::move(local_rds_update));
1157
1280
  return GRPC_ERROR_NONE;
@@ -1159,11 +1282,11 @@ grpc_error* RdsResponseParse(XdsClient* client, TraceFlag* tracer,
1159
1282
  return GRPC_ERROR_NONE;
1160
1283
  }
1161
1284
 
1162
- grpc_error* CdsResponseParse(XdsClient* client, TraceFlag* tracer,
1163
- const envoy_api_v2_DiscoveryResponse* response,
1164
- const std::set<StringView>& expected_cluster_names,
1165
- XdsApi::CdsUpdateMap* cds_update_map,
1166
- upb_arena* arena) {
1285
+ grpc_error* CdsResponseParse(
1286
+ XdsClient* client, TraceFlag* tracer,
1287
+ const envoy_api_v2_DiscoveryResponse* response,
1288
+ const std::set<absl::string_view>& expected_cluster_names,
1289
+ XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
1167
1290
  // Get the resources from the response.
1168
1291
  size_t size;
1169
1292
  const google_protobuf_Any* const* resources =
@@ -1186,7 +1309,8 @@ grpc_error* CdsResponseParse(XdsClient* client, TraceFlag* tracer,
1186
1309
  MaybeLogCluster(client, tracer, cluster);
1187
1310
  // Ignore unexpected cluster names.
1188
1311
  upb_strview cluster_name = envoy_api_v2_Cluster_name(cluster);
1189
- StringView cluster_name_strview(cluster_name.data, cluster_name.size);
1312
+ absl::string_view cluster_name_strview(cluster_name.data,
1313
+ cluster_name.size);
1190
1314
  if (expected_cluster_names.find(cluster_name_strview) ==
1191
1315
  expected_cluster_names.end()) {
1192
1316
  continue;
@@ -1204,14 +1328,14 @@ grpc_error* CdsResponseParse(XdsClient* client, TraceFlag* tracer,
1204
1328
  const envoy_api_v2_core_ConfigSource* eds_config =
1205
1329
  envoy_api_v2_Cluster_EdsClusterConfig_eds_config(eds_cluster_config);
1206
1330
  if (!envoy_api_v2_core_ConfigSource_has_ads(eds_config)) {
1207
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("ConfigSource is not ADS.");
1331
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1332
+ "EDS ConfigSource is not ADS.");
1208
1333
  }
1209
1334
  // Record EDS service_name (if any).
1210
1335
  upb_strview service_name =
1211
1336
  envoy_api_v2_Cluster_EdsClusterConfig_service_name(eds_cluster_config);
1212
1337
  if (service_name.size != 0) {
1213
- cds_update.eds_service_name =
1214
- std::string(service_name.data, service_name.size);
1338
+ cds_update.eds_service_name = UpbStringToStdString(service_name);
1215
1339
  }
1216
1340
  // Check the LB policy.
1217
1341
  if (envoy_api_v2_Cluster_lb_policy(cluster) !=
@@ -1225,11 +1349,11 @@ grpc_error* CdsResponseParse(XdsClient* client, TraceFlag* tracer,
1225
1349
  if (lrs_server != nullptr) {
1226
1350
  if (!envoy_api_v2_core_ConfigSource_has_self(lrs_server)) {
1227
1351
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1228
- "ConfigSource is not self.");
1352
+ "LRS ConfigSource is not self.");
1229
1353
  }
1230
1354
  cds_update.lrs_load_reporting_server_name.emplace("");
1231
1355
  }
1232
- cds_update_map->emplace(std::string(cluster_name.data, cluster_name.size),
1356
+ cds_update_map->emplace(UpbStringToStdString(cluster_name),
1233
1357
  std::move(cds_update));
1234
1358
  }
1235
1359
  return GRPC_ERROR_NONE;
@@ -1290,8 +1414,8 @@ grpc_error* LocalityParse(
1290
1414
  upb_strview zone = envoy_api_v2_core_Locality_region(locality);
1291
1415
  upb_strview sub_zone = envoy_api_v2_core_Locality_sub_zone(locality);
1292
1416
  output_locality->name = MakeRefCounted<XdsLocalityName>(
1293
- std::string(region.data, region.size), std::string(zone.data, zone.size),
1294
- std::string(sub_zone.data, sub_zone.size));
1417
+ UpbStringToStdString(region), UpbStringToStdString(zone),
1418
+ UpbStringToStdString(sub_zone));
1295
1419
  // Parse the addresses.
1296
1420
  size_t size;
1297
1421
  const envoy_api_v2_endpoint_LbEndpoint* const* lb_endpoints =
@@ -1341,15 +1465,14 @@ grpc_error* DropParseAndAppend(
1341
1465
  }
1342
1466
  // Cap numerator to 1000000.
1343
1467
  numerator = GPR_MIN(numerator, 1000000);
1344
- drop_config->AddCategory(std::string(category.data, category.size),
1345
- numerator);
1468
+ drop_config->AddCategory(UpbStringToStdString(category), numerator);
1346
1469
  return GRPC_ERROR_NONE;
1347
1470
  }
1348
1471
 
1349
1472
  grpc_error* EdsResponseParse(
1350
1473
  XdsClient* client, TraceFlag* tracer,
1351
1474
  const envoy_api_v2_DiscoveryResponse* response,
1352
- const std::set<StringView>& expected_eds_service_names,
1475
+ const std::set<absl::string_view>& expected_eds_service_names,
1353
1476
  XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
1354
1477
  // Get the resources from the response.
1355
1478
  size_t size;
@@ -1378,7 +1501,8 @@ grpc_error* EdsResponseParse(
1378
1501
  // unexpected names.
1379
1502
  upb_strview cluster_name = envoy_api_v2_ClusterLoadAssignment_cluster_name(
1380
1503
  cluster_load_assignment);
1381
- StringView cluster_name_strview(cluster_name.data, cluster_name.size);
1504
+ absl::string_view cluster_name_strview(cluster_name.data,
1505
+ cluster_name.size);
1382
1506
  if (expected_eds_service_names.find(cluster_name_strview) ==
1383
1507
  expected_eds_service_names.end()) {
1384
1508
  continue;
@@ -1420,14 +1544,7 @@ grpc_error* EdsResponseParse(
1420
1544
  if (error != GRPC_ERROR_NONE) return error;
1421
1545
  }
1422
1546
  }
1423
- // Validate the update content.
1424
- if (eds_update.priority_list_update.empty() &&
1425
- !eds_update.drop_config->drop_all()) {
1426
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1427
- "EDS response doesn't contain any valid "
1428
- "locality but doesn't require to drop all calls.");
1429
- }
1430
- eds_update_map->emplace(std::string(cluster_name.data, cluster_name.size),
1547
+ eds_update_map->emplace(UpbStringToStdString(cluster_name),
1431
1548
  std::move(eds_update));
1432
1549
  }
1433
1550
  return GRPC_ERROR_NONE;
@@ -1437,9 +1554,9 @@ grpc_error* EdsResponseParse(
1437
1554
 
1438
1555
  grpc_error* XdsApi::ParseAdsResponse(
1439
1556
  const grpc_slice& encoded_response, const std::string& expected_server_name,
1440
- const std::string& expected_route_config_name,
1441
- const std::set<StringView>& expected_cluster_names,
1442
- const std::set<StringView>& expected_eds_service_names,
1557
+ const std::set<absl::string_view>& expected_route_configuration_names,
1558
+ const std::set<absl::string_view>& expected_cluster_names,
1559
+ const std::set<absl::string_view>& expected_eds_service_names,
1443
1560
  absl::optional<LdsUpdate>* lds_update,
1444
1561
  absl::optional<RdsUpdate>* rds_update, CdsUpdateMap* cds_update_map,
1445
1562
  EdsUpdateMap* eds_update_map, std::string* version, std::string* nonce,
@@ -1460,20 +1577,20 @@ grpc_error* XdsApi::ParseAdsResponse(
1460
1577
  // Record the type_url, the version_info, and the nonce of the response.
1461
1578
  upb_strview type_url_strview =
1462
1579
  envoy_api_v2_DiscoveryResponse_type_url(response);
1463
- *type_url = std::string(type_url_strview.data, type_url_strview.size);
1580
+ *type_url = UpbStringToStdString(type_url_strview);
1464
1581
  upb_strview version_info =
1465
1582
  envoy_api_v2_DiscoveryResponse_version_info(response);
1466
- *version = std::string(version_info.data, version_info.size);
1583
+ *version = UpbStringToStdString(version_info);
1467
1584
  upb_strview nonce_strview = envoy_api_v2_DiscoveryResponse_nonce(response);
1468
- *nonce = std::string(nonce_strview.data, nonce_strview.size);
1585
+ *nonce = UpbStringToStdString(nonce_strview);
1469
1586
  // Parse the response according to the resource type.
1470
1587
  if (*type_url == kLdsTypeUrl) {
1471
1588
  return LdsResponseParse(client_, tracer_, response, expected_server_name,
1472
- lds_update, arena.ptr());
1589
+ xds_routing_enabled_, lds_update, arena.ptr());
1473
1590
  } else if (*type_url == kRdsTypeUrl) {
1474
1591
  return RdsResponseParse(client_, tracer_, response, expected_server_name,
1475
- expected_route_config_name, rds_update,
1476
- arena.ptr());
1592
+ expected_route_configuration_names,
1593
+ xds_routing_enabled_, rds_update, arena.ptr());
1477
1594
  } else if (*type_url == kCdsTypeUrl) {
1478
1595
  return CdsResponseParse(client_, tracer_, response, expected_cluster_names,
1479
1596
  cds_update_map, arena.ptr());
@@ -1626,6 +1743,9 @@ grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
1626
1743
  arena.ptr());
1627
1744
  PopulateNode(arena.ptr(), node_, build_version_, user_agent_name_,
1628
1745
  server_name, node_msg);
1746
+ envoy_api_v2_core_Node_add_client_features(
1747
+ node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
1748
+ arena.ptr());
1629
1749
  MaybeLogLrsRequest(client_, tracer_, request);
1630
1750
  return SerializeLrsRequest(request, arena.ptr());
1631
1751
  }
@@ -1744,6 +1864,7 @@ grpc_slice XdsApi::CreateLrsRequest(
1744
1864
  }
1745
1865
 
1746
1866
  grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
1867
+ bool* send_all_clusters,
1747
1868
  std::set<std::string>* cluster_names,
1748
1869
  grpc_millis* load_reporting_interval) {
1749
1870
  upb::Arena arena;
@@ -1756,13 +1877,19 @@ grpc_error* XdsApi::ParseLrsResponse(const grpc_slice& encoded_response,
1756
1877
  if (decoded_response == nullptr) {
1757
1878
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode response.");
1758
1879
  }
1759
- // Store the cluster names.
1760
- size_t size;
1761
- const upb_strview* clusters =
1762
- envoy_service_load_stats_v2_LoadStatsResponse_clusters(decoded_response,
1763
- &size);
1764
- for (size_t i = 0; i < size; ++i) {
1765
- cluster_names->emplace(clusters[i].data, clusters[i].size);
1880
+ // Check send_all_clusters.
1881
+ if (envoy_service_load_stats_v2_LoadStatsResponse_send_all_clusters(
1882
+ decoded_response)) {
1883
+ *send_all_clusters = true;
1884
+ } else {
1885
+ // Store the cluster names.
1886
+ size_t size;
1887
+ const upb_strview* clusters =
1888
+ envoy_service_load_stats_v2_LoadStatsResponse_clusters(decoded_response,
1889
+ &size);
1890
+ for (size_t i = 0; i < size; ++i) {
1891
+ cluster_names->emplace(clusters[i].data, clusters[i].size);
1892
+ }
1766
1893
  }
1767
1894
  // Get the load report interval.
1768
1895
  const google_protobuf_Duration* load_reporting_interval_duration =