grpc 1.32.0 → 1.35.0

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 (938) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +1078 -3049
  3. data/etc/roots.pem +257 -573
  4. data/include/grpc/compression.h +1 -1
  5. data/include/grpc/grpc.h +15 -7
  6. data/include/grpc/grpc_security.h +222 -171
  7. data/include/grpc/impl/codegen/atm_windows.h +4 -0
  8. data/include/grpc/impl/codegen/byte_buffer.h +1 -1
  9. data/include/grpc/impl/codegen/grpc_types.h +10 -8
  10. data/include/grpc/impl/codegen/log.h +0 -2
  11. data/include/grpc/impl/codegen/port_platform.h +22 -55
  12. data/include/grpc/impl/codegen/sync_windows.h +4 -0
  13. data/include/grpc/slice_buffer.h +3 -3
  14. data/include/grpc/support/sync.h +3 -3
  15. data/include/grpc/support/time.h +7 -7
  16. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -4
  17. data/src/core/ext/filters/client_channel/client_channel.cc +2776 -1529
  18. data/src/core/ext/filters/client_channel/client_channel.h +0 -4
  19. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +1 -1
  20. data/src/core/ext/filters/client_channel/config_selector.cc +0 -4
  21. data/src/core/ext/filters/client_channel/config_selector.h +40 -8
  22. data/src/core/ext/filters/client_channel/dynamic_filters.cc +186 -0
  23. data/src/core/ext/filters/client_channel/dynamic_filters.h +99 -0
  24. data/src/core/ext/filters/client_channel/health/health_check_client.cc +10 -7
  25. data/src/core/ext/filters/client_channel/health/health_check_client.h +4 -4
  26. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +5 -6
  27. data/src/core/ext/filters/client_channel/http_proxy.cc +21 -20
  28. data/src/core/ext/filters/client_channel/lb_policy.cc +6 -2
  29. data/src/core/ext/filters/client_channel/lb_policy.h +6 -7
  30. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +48 -35
  31. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  32. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +4 -3
  33. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +1 -1
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +201 -190
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +3 -1
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +3 -3
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +1 -1
  38. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +4 -4
  39. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +50 -20
  40. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +5 -5
  41. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +14 -34
  42. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +6 -6
  43. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +341 -127
  44. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +52 -24
  45. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +24 -0
  46. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +812 -0
  47. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +722 -0
  48. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +1262 -0
  49. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +8 -1
  50. data/src/core/ext/filters/client_channel/resolver.cc +3 -1
  51. data/src/core/ext/filters/client_channel/resolver.h +4 -1
  52. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +9 -16
  53. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -32
  54. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -3
  55. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +454 -16
  56. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -0
  57. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +7 -10
  58. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +3 -3
  59. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -1
  60. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +34 -27
  61. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +618 -366
  62. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h +28 -0
  63. data/src/core/ext/filters/client_channel/resolver_factory.h +6 -6
  64. data/src/core/ext/filters/client_channel/resolver_registry.cc +40 -39
  65. data/src/core/ext/filters/client_channel/resolver_registry.h +2 -2
  66. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +29 -74
  67. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +12 -10
  68. data/src/core/ext/filters/client_channel/retry_throttle.cc +5 -3
  69. data/src/core/ext/filters/client_channel/retry_throttle.h +4 -2
  70. data/src/core/ext/filters/client_channel/server_address.cc +80 -0
  71. data/src/core/ext/filters/client_channel/server_address.h +21 -36
  72. data/src/core/ext/filters/client_channel/service_config.cc +18 -13
  73. data/src/core/ext/filters/client_channel/service_config.h +8 -5
  74. data/src/core/ext/filters/client_channel/service_config_call_data.h +19 -1
  75. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +2 -2
  76. data/src/core/ext/filters/client_channel/service_config_parser.cc +8 -6
  77. data/src/core/ext/filters/client_channel/service_config_parser.h +8 -5
  78. data/src/core/ext/filters/client_channel/subchannel.cc +51 -64
  79. data/src/core/ext/filters/client_channel/subchannel.h +14 -20
  80. data/src/core/ext/filters/client_channel/subchannel_interface.h +41 -5
  81. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +6 -2
  82. data/src/core/ext/filters/deadline/deadline_filter.cc +87 -79
  83. data/src/core/ext/filters/deadline/deadline_filter.h +7 -11
  84. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -1
  85. data/src/core/ext/filters/http/client_authority_filter.cc +6 -6
  86. data/src/core/ext/filters/http/http_filters_plugin.cc +6 -3
  87. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -3
  88. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  89. data/src/core/ext/filters/message_size/message_size_filter.cc +3 -2
  90. data/src/core/ext/filters/message_size/message_size_filter.h +2 -1
  91. data/src/core/ext/filters/workarounds/workaround_utils.cc +1 -1
  92. data/src/core/ext/transport/chttp2/client/authority.cc +3 -3
  93. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  94. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +20 -8
  95. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +21 -10
  96. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +26 -14
  97. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +185 -79
  98. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +12 -5
  99. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -7
  100. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +28 -42
  101. data/src/core/ext/transport/chttp2/transport/flow_control.cc +10 -2
  102. data/src/core/ext/transport/chttp2/transport/flow_control.h +13 -3
  103. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
  104. data/src/core/ext/transport/chttp2/transport/frame_settings.h +2 -1
  105. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +6 -6
  106. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +12 -8
  107. data/src/core/ext/transport/chttp2/transport/internal.h +5 -1
  108. data/src/core/ext/transport/chttp2/transport/parsing.cc +18 -3
  109. data/src/core/ext/transport/chttp2/transport/writing.cc +2 -3
  110. data/src/core/ext/transport/inproc/inproc_transport.cc +42 -8
  111. data/src/core/ext/upb-generated/envoy/annotations/deprecation.upb.h +1 -0
  112. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.c +1 -1
  113. data/src/core/ext/upb-generated/envoy/annotations/resource.upb.h +7 -0
  114. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.c +52 -32
  115. data/src/core/ext/upb-generated/envoy/config/accesslog/v3/accesslog.upb.h +199 -34
  116. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.c +13 -13
  117. data/src/core/ext/upb-generated/envoy/config/cluster/v3/circuit_breaker.upb.h +44 -17
  118. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +177 -99
  119. data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +642 -202
  120. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.c +3 -3
  121. data/src/core/ext/upb-generated/envoy/config/cluster/v3/filter.upb.h +13 -5
  122. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.c +22 -22
  123. data/src/core/ext/upb-generated/envoy/config/cluster/v3/outlier_detection.upb.h +47 -21
  124. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.c +36 -24
  125. data/src/core/ext/upb-generated/envoy/config/core/v3/address.upb.h +133 -39
  126. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.c +4 -4
  127. data/src/core/ext/upb-generated/envoy/config/core/v3/backoff.upb.h +15 -6
  128. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +45 -44
  129. data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +200 -78
  130. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.c +31 -24
  131. data/src/core/ext/upb-generated/envoy/config/core/v3/config_source.upb.h +107 -47
  132. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.c +1 -1
  133. data/src/core/ext/upb-generated/envoy/config/core/v3/event_service_config.upb.h +7 -0
  134. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.c +53 -0
  135. data/src/core/ext/upb-generated/envoy/config/core/v3/extension.upb.h +149 -0
  136. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.c +74 -28
  137. data/src/core/ext/upb-generated/envoy/config/core/v3/grpc_service.upb.h +248 -43
  138. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +39 -39
  139. data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +157 -89
  140. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.c +4 -4
  141. data/src/core/ext/upb-generated/envoy/config/core/v3/http_uri.upb.h +17 -9
  142. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +63 -39
  143. data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +254 -60
  144. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.c +1 -1
  145. data/src/core/ext/upb-generated/envoy/config/core/v3/proxy_protocol.upb.h +7 -0
  146. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.c +2 -2
  147. data/src/core/ext/upb-generated/envoy/config/core/v3/socket_option.upb.h +9 -2
  148. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.c +36 -0
  149. data/src/core/ext/upb-generated/envoy/config/core/v3/substitution_format_string.upb.h +92 -0
  150. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.c +13 -13
  151. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint.upb.h +59 -36
  152. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +16 -16
  153. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.h +61 -29
  154. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.c +26 -26
  155. data/src/core/ext/upb-generated/envoy/config/endpoint/v3/load_report.upb.h +101 -66
  156. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.c +2 -2
  157. data/src/core/ext/upb-generated/envoy/config/listener/v3/api_listener.upb.h +11 -3
  158. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.c +46 -26
  159. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener.upb.h +179 -68
  160. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.c +39 -22
  161. data/src/core/ext/upb-generated/envoy/config/listener/v3/listener_components.upb.h +149 -48
  162. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.c +2 -2
  163. data/src/core/ext/upb-generated/envoy/config/listener/v3/udp_listener_config.upb.h +13 -0
  164. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +21 -17
  165. data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +96 -33
  166. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.c +7 -7
  167. data/src/core/ext/upb-generated/envoy/config/route/v3/route.upb.h +38 -22
  168. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +321 -194
  169. data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +1228 -443
  170. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.c +8 -7
  171. data/src/core/ext/upb-generated/envoy/config/route/v3/scoped_route.upb.h +34 -10
  172. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.c +3 -3
  173. data/src/core/ext/upb-generated/envoy/config/trace/v3/http_tracer.upb.h +17 -3
  174. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.c +132 -80
  175. data/src/core/ext/upb-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h +516 -166
  176. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/cert.upb.h +1 -0
  177. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.c +24 -25
  178. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/common.upb.h +96 -71
  179. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.c +12 -8
  180. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/secret.upb.h +46 -8
  181. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.c +71 -29
  182. data/src/core/ext/upb-generated/envoy/extensions/transport_sockets/tls/v3/tls.upb.h +296 -63
  183. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.c +1 -1
  184. data/src/core/ext/upb-generated/envoy/service/cluster/v3/cds.upb.h +7 -0
  185. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.c +1 -1
  186. data/src/core/ext/upb-generated/envoy/service/discovery/v3/ads.upb.h +7 -0
  187. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.c +41 -31
  188. data/src/core/ext/upb-generated/envoy/service/discovery/v3/discovery.upb.h +165 -64
  189. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.c +1 -1
  190. data/src/core/ext/upb-generated/envoy/service/endpoint/v3/eds.upb.h +7 -0
  191. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.c +1 -1
  192. data/src/core/ext/upb-generated/envoy/service/listener/v3/lds.upb.h +7 -0
  193. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.c +7 -7
  194. data/src/core/ext/upb-generated/envoy/service/load_stats/v3/lrs.upb.h +31 -16
  195. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.c +1 -1
  196. data/src/core/ext/upb-generated/envoy/service/route/v3/rds.upb.h +7 -0
  197. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.c +1 -1
  198. data/src/core/ext/upb-generated/envoy/service/route/v3/srds.upb.h +7 -0
  199. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.c +5 -5
  200. data/src/core/ext/upb-generated/envoy/type/matcher/v3/metadata.upb.h +25 -11
  201. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.c +1 -1
  202. data/src/core/ext/upb-generated/envoy/type/matcher/v3/number.upb.h +7 -0
  203. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.c +1 -1
  204. data/src/core/ext/upb-generated/envoy/type/matcher/v3/path.upb.h +7 -0
  205. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.c +6 -6
  206. data/src/core/ext/upb-generated/envoy/type/matcher/v3/regex.upb.h +29 -8
  207. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.c +4 -3
  208. data/src/core/ext/upb-generated/envoy/type/matcher/v3/string.upb.h +22 -3
  209. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.c +3 -3
  210. data/src/core/ext/upb-generated/envoy/type/matcher/v3/value.upb.h +19 -0
  211. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.c +7 -7
  212. data/src/core/ext/upb-generated/envoy/type/metadata/v3/metadata.upb.h +46 -3
  213. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.c +8 -8
  214. data/src/core/ext/upb-generated/envoy/type/tracing/v3/custom_tag.upb.h +41 -8
  215. data/src/core/ext/upb-generated/envoy/type/v3/http.upb.h +1 -0
  216. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.c +3 -3
  217. data/src/core/ext/upb-generated/envoy/type/v3/percent.upb.h +15 -2
  218. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.c +3 -3
  219. data/src/core/ext/upb-generated/envoy/type/v3/range.upb.h +19 -0
  220. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.c +1 -1
  221. data/src/core/ext/upb-generated/envoy/type/v3/semantic_version.upb.h +7 -0
  222. data/src/core/ext/upb-generated/google/api/annotations.upb.h +1 -0
  223. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.c +242 -0
  224. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/checked.upb.h +830 -0
  225. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.c +34 -34
  226. data/src/core/ext/upb-generated/google/api/expr/v1alpha1/syntax.upb.h +142 -59
  227. data/src/core/ext/upb-generated/google/api/http.upb.c +3 -3
  228. data/src/core/ext/upb-generated/google/api/http.upb.h +25 -6
  229. data/src/core/ext/upb-generated/google/protobuf/any.upb.c +1 -1
  230. data/src/core/ext/upb-generated/google/protobuf/any.upb.h +7 -0
  231. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.c +90 -90
  232. data/src/core/ext/upb-generated/google/protobuf/descriptor.upb.h +455 -292
  233. data/src/core/ext/upb-generated/google/protobuf/duration.upb.c +1 -1
  234. data/src/core/ext/upb-generated/google/protobuf/duration.upb.h +7 -0
  235. data/src/core/ext/upb-generated/google/protobuf/empty.upb.c +1 -1
  236. data/src/core/ext/upb-generated/google/protobuf/empty.upb.h +7 -0
  237. data/src/core/ext/upb-generated/google/protobuf/struct.upb.c +4 -4
  238. data/src/core/ext/upb-generated/google/protobuf/struct.upb.h +22 -3
  239. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.c +1 -1
  240. data/src/core/ext/upb-generated/google/protobuf/timestamp.upb.h +7 -0
  241. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.c +9 -9
  242. data/src/core/ext/upb-generated/google/protobuf/wrappers.upb.h +55 -0
  243. data/src/core/ext/upb-generated/google/rpc/status.upb.c +1 -1
  244. data/src/core/ext/upb-generated/google/rpc/status.upb.h +10 -3
  245. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.c +4 -4
  246. data/src/core/ext/upb-generated/src/proto/grpc/gcp/altscontext.upb.h +11 -3
  247. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.c +41 -41
  248. data/src/core/ext/upb-generated/src/proto/grpc/gcp/handshaker.upb.h +149 -76
  249. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.c +5 -5
  250. data/src/core/ext/upb-generated/src/proto/grpc/gcp/transport_security_common.upb.h +21 -6
  251. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.c +2 -2
  252. data/src/core/ext/upb-generated/src/proto/grpc/health/v1/health.upb.h +13 -0
  253. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +17 -17
  254. data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +82 -25
  255. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.c +3 -3
  256. data/src/core/ext/upb-generated/udpa/annotations/migrate.upb.h +19 -0
  257. data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +31 -0
  258. data/src/core/ext/upb-generated/udpa/annotations/security.upb.h +64 -0
  259. data/src/core/ext/upb-generated/udpa/annotations/sensitive.upb.h +1 -0
  260. data/src/core/ext/upb-generated/udpa/annotations/status.upb.c +2 -2
  261. data/src/core/ext/upb-generated/udpa/annotations/status.upb.h +9 -2
  262. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.c +1 -1
  263. data/src/core/ext/upb-generated/udpa/annotations/versioning.upb.h +7 -0
  264. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.c +28 -0
  265. data/src/core/ext/upb-generated/udpa/core/v1/authority.upb.h +60 -0
  266. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.c +52 -0
  267. data/src/core/ext/upb-generated/udpa/core/v1/collection_entry.upb.h +143 -0
  268. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.c +42 -0
  269. data/src/core/ext/upb-generated/udpa/core/v1/context_params.upb.h +84 -0
  270. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.c +36 -0
  271. data/src/core/ext/upb-generated/udpa/core/v1/resource.upb.h +94 -0
  272. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.c +54 -0
  273. data/src/core/ext/upb-generated/udpa/core/v1/resource_locator.upb.h +173 -0
  274. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.c +36 -0
  275. data/src/core/ext/upb-generated/udpa/core/v1/resource_name.upb.h +92 -0
  276. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +3 -3
  277. data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +7 -0
  278. data/src/core/ext/upb-generated/validate/validate.upb.c +64 -64
  279. data/src/core/ext/upb-generated/validate/validate.upb.h +296 -157
  280. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +38 -0
  281. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.h +30 -0
  282. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +41 -0
  283. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.h +35 -0
  284. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +254 -0
  285. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +105 -0
  286. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +100 -0
  287. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.h +45 -0
  288. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +558 -0
  289. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +145 -0
  290. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +53 -0
  291. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.h +35 -0
  292. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +133 -0
  293. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.h +35 -0
  294. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +127 -0
  295. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +65 -0
  296. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +56 -0
  297. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.h +35 -0
  298. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +266 -0
  299. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +125 -0
  300. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +143 -0
  301. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +55 -0
  302. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +56 -0
  303. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.h +35 -0
  304. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +66 -0
  305. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +40 -0
  306. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +263 -0
  307. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.h +100 -0
  308. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +233 -0
  309. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +70 -0
  310. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +56 -0
  311. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.h +35 -0
  312. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +228 -0
  313. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +80 -0
  314. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +46 -0
  315. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +35 -0
  316. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +59 -0
  317. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +35 -0
  318. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +55 -0
  319. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.h +35 -0
  320. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +110 -0
  321. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.h +50 -0
  322. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +113 -0
  323. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +50 -0
  324. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +146 -0
  325. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.h +55 -0
  326. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +50 -0
  327. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.h +35 -0
  328. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +190 -0
  329. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +55 -0
  330. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +185 -0
  331. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.h +65 -0
  332. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +62 -0
  333. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.h +40 -0
  334. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +97 -0
  335. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +40 -0
  336. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +915 -0
  337. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +280 -0
  338. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +71 -0
  339. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.h +45 -0
  340. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +64 -0
  341. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.h +40 -0
  342. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +511 -0
  343. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +115 -0
  344. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +48 -0
  345. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.h +30 -0
  346. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +166 -0
  347. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +55 -0
  348. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +105 -0
  349. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.h +45 -0
  350. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +249 -0
  351. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +60 -0
  352. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +72 -0
  353. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.h +35 -0
  354. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +60 -0
  355. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.h +35 -0
  356. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +152 -0
  357. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +60 -0
  358. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +83 -0
  359. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.h +35 -0
  360. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +82 -0
  361. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.h +35 -0
  362. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +83 -0
  363. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.h +40 -0
  364. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +86 -0
  365. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.h +35 -0
  366. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +74 -0
  367. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.h +35 -0
  368. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +64 -0
  369. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.h +40 -0
  370. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +54 -0
  371. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.h +35 -0
  372. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +53 -0
  373. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.h +35 -0
  374. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +73 -0
  375. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.h +45 -0
  376. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +72 -0
  377. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.h +40 -0
  378. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +81 -0
  379. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.h +45 -0
  380. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +92 -0
  381. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.h +65 -0
  382. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +95 -0
  383. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.h +55 -0
  384. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +34 -0
  385. data/src/core/ext/{upb-generated/gogoproto/gogo.upb.h → upbdefs-generated/envoy/type/v3/http.upbdefs.h} +10 -9
  386. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +59 -0
  387. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.h +40 -0
  388. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +54 -0
  389. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.h +45 -0
  390. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +47 -0
  391. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.h +35 -0
  392. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +40 -0
  393. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.h +30 -0
  394. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +61 -0
  395. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.h +45 -0
  396. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +39 -0
  397. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.h +35 -0
  398. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +386 -0
  399. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.h +165 -0
  400. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +40 -0
  401. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.h +35 -0
  402. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +37 -0
  403. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.h +35 -0
  404. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +65 -0
  405. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.h +50 -0
  406. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +40 -0
  407. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.h +35 -0
  408. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +66 -0
  409. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.h +75 -0
  410. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +42 -0
  411. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.h +35 -0
  412. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +70 -0
  413. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.h +45 -0
  414. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +56 -0
  415. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.h +35 -0
  416. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +33 -0
  417. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.h +30 -0
  418. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +49 -0
  419. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.h +35 -0
  420. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +43 -0
  421. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.h +35 -0
  422. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.c +42 -0
  423. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.h +35 -0
  424. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.c +62 -0
  425. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.h +40 -0
  426. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.c +45 -0
  427. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.h +40 -0
  428. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.c +49 -0
  429. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.h +35 -0
  430. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.c +68 -0
  431. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.h +40 -0
  432. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.c +51 -0
  433. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.h +35 -0
  434. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +307 -0
  435. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.h +145 -0
  436. data/src/core/ext/xds/certificate_provider_factory.h +61 -0
  437. data/src/core/ext/xds/certificate_provider_registry.cc +103 -0
  438. data/src/core/ext/xds/certificate_provider_registry.h +57 -0
  439. data/src/core/ext/xds/certificate_provider_store.cc +87 -0
  440. data/src/core/ext/xds/certificate_provider_store.h +112 -0
  441. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +144 -0
  442. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +69 -0
  443. data/src/core/ext/xds/xds_api.cc +687 -767
  444. data/src/core/ext/xds/xds_api.h +207 -98
  445. data/src/core/ext/xds/xds_bootstrap.cc +172 -25
  446. data/src/core/ext/xds/xds_bootstrap.h +23 -8
  447. data/src/core/ext/xds/xds_certificate_provider.cc +299 -0
  448. data/src/core/ext/xds/xds_certificate_provider.h +112 -0
  449. data/src/core/ext/xds/xds_channel_args.h +6 -3
  450. data/src/core/ext/xds/xds_client.cc +617 -494
  451. data/src/core/ext/xds/xds_client.h +118 -58
  452. data/src/core/ext/xds/xds_client_stats.cc +59 -16
  453. data/src/core/ext/xds/xds_client_stats.h +35 -7
  454. data/src/core/ext/xds/xds_server_config_fetcher.cc +131 -0
  455. data/src/core/lib/channel/channel_args.cc +9 -8
  456. data/src/core/lib/channel/channel_args.h +0 -1
  457. data/src/core/lib/channel/channel_trace.cc +4 -2
  458. data/src/core/lib/channel/channel_trace.h +1 -1
  459. data/src/core/lib/channel/channelz.cc +23 -59
  460. data/src/core/lib/channel/channelz.h +13 -22
  461. data/src/core/lib/channel/channelz_registry.cc +12 -11
  462. data/src/core/lib/channel/channelz_registry.h +3 -1
  463. data/src/core/lib/channel/handshaker.cc +2 -2
  464. data/src/core/lib/channel/handshaker.h +2 -2
  465. data/src/core/lib/compression/compression.cc +8 -4
  466. data/src/core/lib/compression/compression_args.cc +3 -2
  467. data/src/core/lib/compression/compression_internal.cc +10 -5
  468. data/src/core/lib/compression/compression_internal.h +2 -1
  469. data/src/core/lib/compression/stream_compression_identity.cc +1 -3
  470. data/src/core/lib/debug/stats.h +2 -2
  471. data/src/core/lib/debug/stats_data.cc +1 -0
  472. data/src/core/lib/debug/stats_data.h +13 -13
  473. data/src/core/lib/gpr/alloc.cc +3 -2
  474. data/src/core/lib/gpr/cpu_iphone.cc +10 -2
  475. data/src/core/lib/gpr/log.cc +53 -16
  476. data/src/core/lib/gpr/log_linux.cc +19 -3
  477. data/src/core/lib/gpr/log_posix.cc +15 -1
  478. data/src/core/lib/gpr/log_windows.cc +18 -4
  479. data/src/core/lib/gpr/murmur_hash.cc +1 -1
  480. data/src/core/lib/gpr/spinlock.h +10 -2
  481. data/src/core/lib/gpr/string.cc +23 -22
  482. data/src/core/lib/gpr/string.h +5 -6
  483. data/src/core/lib/gpr/sync.cc +4 -4
  484. data/src/core/lib/gpr/time.cc +12 -12
  485. data/src/core/lib/gpr/time_precise.cc +5 -2
  486. data/src/core/lib/gpr/time_precise.h +6 -2
  487. data/src/core/lib/gpr/tls.h +4 -0
  488. data/src/core/lib/gpr/tls_msvc.h +2 -0
  489. data/src/core/lib/gpr/tls_stdcpp.h +48 -0
  490. data/src/core/lib/gpr/useful.h +5 -4
  491. data/src/core/lib/gprpp/arena.h +3 -2
  492. data/src/core/lib/gprpp/dual_ref_counted.h +331 -0
  493. data/src/core/lib/gprpp/examine_stack.cc +43 -0
  494. data/src/core/lib/gprpp/examine_stack.h +46 -0
  495. data/src/core/lib/gprpp/fork.cc +2 -2
  496. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  497. data/src/core/lib/gprpp/orphanable.h +4 -8
  498. data/src/core/lib/gprpp/ref_counted.h +91 -68
  499. data/src/core/lib/gprpp/ref_counted_ptr.h +166 -7
  500. data/src/core/lib/{security/authorization/mock_cel/statusor.h → gprpp/stat.h} +13 -25
  501. data/src/core/lib/gprpp/stat_posix.cc +49 -0
  502. data/src/core/lib/gprpp/stat_windows.cc +48 -0
  503. data/src/core/lib/gprpp/thd.h +2 -2
  504. data/src/core/lib/gprpp/thd_posix.cc +42 -37
  505. data/src/core/lib/gprpp/thd_windows.cc +3 -1
  506. data/src/core/lib/http/httpcli.cc +1 -1
  507. data/src/core/lib/http/httpcli.h +2 -3
  508. data/src/core/lib/http/httpcli_security_connector.cc +1 -1
  509. data/src/core/lib/http/parser.cc +47 -27
  510. data/src/core/lib/iomgr/call_combiner.cc +8 -5
  511. data/src/core/lib/iomgr/combiner.cc +2 -1
  512. data/src/core/lib/iomgr/endpoint.h +1 -1
  513. data/src/core/lib/iomgr/endpoint_cfstream.cc +9 -5
  514. data/src/core/lib/iomgr/error.cc +17 -12
  515. data/src/core/lib/iomgr/error_internal.h +1 -1
  516. data/src/core/lib/iomgr/ev_epoll1_linux.cc +20 -13
  517. data/src/core/lib/iomgr/ev_epollex_linux.cc +25 -17
  518. data/src/core/lib/iomgr/ev_poll_posix.cc +9 -7
  519. data/src/core/lib/iomgr/exec_ctx.cc +1 -1
  520. data/src/core/lib/iomgr/exec_ctx.h +16 -12
  521. data/src/core/lib/iomgr/executor.cc +2 -1
  522. data/src/core/lib/iomgr/executor.h +1 -1
  523. data/src/core/lib/iomgr/executor/mpmcqueue.h +5 -5
  524. data/src/core/lib/iomgr/executor/threadpool.h +4 -4
  525. data/src/core/lib/iomgr/iomgr.cc +1 -1
  526. data/src/core/lib/iomgr/load_file.h +1 -1
  527. data/src/core/lib/iomgr/lockfree_event.cc +19 -14
  528. data/src/core/lib/iomgr/lockfree_event.h +2 -2
  529. data/src/core/lib/iomgr/parse_address.cc +127 -43
  530. data/src/core/lib/iomgr/parse_address.h +32 -8
  531. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +2 -1
  532. data/src/core/lib/iomgr/poller/eventmanager_libuv.h +1 -1
  533. data/src/core/lib/iomgr/pollset_set_custom.cc +1 -1
  534. data/src/core/lib/iomgr/python_util.h +4 -4
  535. data/src/core/lib/iomgr/resolve_address.cc +4 -4
  536. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -5
  537. data/src/core/lib/iomgr/resource_quota.cc +4 -4
  538. data/src/core/lib/iomgr/sockaddr_utils.cc +10 -10
  539. data/src/core/lib/iomgr/sockaddr_utils.h +1 -1
  540. data/src/core/lib/iomgr/socket_factory_posix.cc +3 -2
  541. data/src/core/lib/iomgr/socket_mutator.cc +3 -2
  542. data/src/core/lib/iomgr/tcp_client.cc +3 -3
  543. data/src/core/lib/iomgr/tcp_client_custom.cc +7 -6
  544. data/src/core/lib/iomgr/tcp_custom.cc +22 -17
  545. data/src/core/lib/iomgr/tcp_posix.cc +12 -8
  546. data/src/core/lib/iomgr/tcp_server_custom.cc +28 -22
  547. data/src/core/lib/iomgr/timer_custom.cc +5 -5
  548. data/src/core/lib/iomgr/timer_generic.cc +3 -3
  549. data/src/core/lib/iomgr/timer_manager.cc +2 -2
  550. data/src/core/lib/iomgr/udp_server.cc +1 -2
  551. data/src/core/lib/iomgr/udp_server.h +1 -2
  552. data/src/core/lib/iomgr/unix_sockets_posix.cc +32 -21
  553. data/src/core/lib/iomgr/unix_sockets_posix.h +5 -0
  554. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +7 -0
  555. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -2
  556. data/src/core/lib/json/json.h +12 -2
  557. data/src/core/lib/json/json_reader.cc +8 -4
  558. data/src/core/lib/json/json_util.cc +58 -0
  559. data/src/core/lib/json/json_util.h +204 -0
  560. data/src/core/lib/json/json_writer.cc +2 -1
  561. data/src/core/lib/security/authorization/evaluate_args.cc +5 -10
  562. data/src/core/lib/security/authorization/evaluate_args.h +1 -1
  563. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +3 -1
  564. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +5 -4
  565. data/src/core/lib/security/authorization/mock_cel/cel_value.h +4 -0
  566. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +6 -6
  567. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +10 -9
  568. data/src/core/lib/security/context/security_context.cc +4 -3
  569. data/src/core/lib/security/context/security_context.h +3 -1
  570. data/src/core/lib/security/credentials/alts/check_gcp_environment.cc +1 -1
  571. data/src/core/lib/security/credentials/credentials.cc +7 -7
  572. data/src/core/lib/security/credentials/credentials.h +3 -3
  573. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +413 -0
  574. data/src/core/lib/security/credentials/external/aws_external_account_credentials.h +80 -0
  575. data/src/core/lib/security/credentials/external/aws_request_signer.cc +213 -0
  576. data/src/core/lib/security/credentials/external/aws_request_signer.h +72 -0
  577. data/src/core/lib/security/credentials/external/external_account_credentials.cc +497 -0
  578. data/src/core/lib/security/credentials/external/external_account_credentials.h +120 -0
  579. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +135 -0
  580. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +48 -0
  581. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +213 -0
  582. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +58 -0
  583. data/src/core/lib/security/credentials/fake/fake_credentials.cc +2 -1
  584. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +18 -12
  585. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +64 -0
  586. data/src/core/lib/security/credentials/jwt/json_token.cc +6 -3
  587. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +4 -3
  588. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +8 -4
  589. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +39 -46
  590. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +5 -4
  591. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +1 -1
  592. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +5 -5
  593. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +1 -1
  594. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +346 -0
  595. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +213 -0
  596. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +399 -0
  597. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +138 -0
  598. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +78 -150
  599. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +57 -187
  600. data/src/core/lib/security/credentials/tls/tls_credentials.cc +16 -12
  601. data/src/core/lib/security/credentials/tls/tls_credentials.h +2 -2
  602. data/src/core/lib/security/credentials/tls/tls_utils.cc +91 -0
  603. data/src/core/lib/security/credentials/tls/tls_utils.h +38 -0
  604. data/src/core/lib/security/credentials/xds/xds_credentials.cc +175 -0
  605. data/src/core/lib/security/credentials/xds/xds_credentials.h +69 -0
  606. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -1
  607. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +9 -13
  608. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +121 -0
  609. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +87 -0
  610. data/src/core/lib/security/security_connector/load_system_roots.h +4 -0
  611. data/src/core/lib/security/security_connector/load_system_roots_linux.h +2 -0
  612. data/src/core/lib/security/security_connector/local/local_security_connector.cc +3 -3
  613. data/src/core/lib/security/security_connector/security_connector.cc +4 -3
  614. data/src/core/lib/security/security_connector/security_connector.h +4 -2
  615. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +4 -4
  616. data/src/core/lib/security/security_connector/ssl_utils.cc +2 -2
  617. data/src/core/lib/security/security_connector/ssl_utils.h +19 -19
  618. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +342 -279
  619. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +105 -61
  620. data/src/core/lib/security/transport/secure_endpoint.cc +2 -2
  621. data/src/core/lib/security/transport/security_handshaker.cc +3 -3
  622. data/src/core/lib/security/transport/server_auth_filter.cc +2 -1
  623. data/src/core/lib/security/util/json_util.h +1 -0
  624. data/src/core/lib/slice/slice.cc +7 -4
  625. data/src/core/lib/slice/slice_buffer.cc +2 -1
  626. data/src/core/lib/slice/slice_intern.cc +6 -7
  627. data/src/core/lib/slice/slice_internal.h +2 -2
  628. data/src/core/lib/surface/call.cc +41 -32
  629. data/src/core/lib/surface/call_details.cc +8 -8
  630. data/src/core/lib/surface/channel.cc +25 -41
  631. data/src/core/lib/surface/channel.h +9 -3
  632. data/src/core/lib/surface/channel_init.cc +1 -1
  633. data/src/core/lib/surface/completion_queue.cc +30 -24
  634. data/src/core/lib/surface/completion_queue.h +16 -16
  635. data/src/core/lib/surface/init.cc +32 -14
  636. data/src/core/lib/surface/lame_client.cc +20 -46
  637. data/src/core/lib/surface/lame_client.h +4 -0
  638. data/src/core/lib/surface/server.cc +63 -17
  639. data/src/core/lib/surface/server.h +39 -7
  640. data/src/core/lib/surface/validate_metadata.h +3 -0
  641. data/src/core/lib/surface/version.cc +2 -2
  642. data/src/core/lib/transport/authority_override.cc +6 -4
  643. data/src/core/lib/transport/authority_override.h +7 -2
  644. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  645. data/src/core/lib/transport/bdp_estimator.h +2 -1
  646. data/src/core/lib/transport/byte_stream.h +3 -3
  647. data/src/core/lib/transport/connectivity_state.h +11 -9
  648. data/src/core/lib/transport/error_utils.h +1 -1
  649. data/src/core/lib/transport/metadata.cc +11 -1
  650. data/src/core/lib/transport/metadata.h +2 -2
  651. data/src/core/lib/transport/metadata_batch.h +4 -4
  652. data/src/core/lib/transport/static_metadata.cc +1 -1
  653. data/src/core/lib/transport/status_metadata.cc +4 -3
  654. data/src/core/lib/transport/timeout_encoding.cc +4 -4
  655. data/src/core/lib/transport/transport.cc +5 -3
  656. data/src/core/lib/transport/transport.h +8 -8
  657. data/src/core/lib/uri/uri_parser.cc +131 -249
  658. data/src/core/lib/uri/uri_parser.h +57 -21
  659. data/src/core/plugin_registry/grpc_plugin_registry.cc +41 -20
  660. data/src/core/tsi/alts/crypt/gsec.cc +5 -4
  661. data/src/core/tsi/alts/frame_protector/frame_handler.cc +8 -6
  662. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -1
  663. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +27 -26
  664. data/src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc +8 -6
  665. data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +4 -4
  666. data/src/core/tsi/fake_transport_security.cc +6 -3
  667. data/src/core/tsi/local_transport_security.cc +5 -1
  668. data/src/core/tsi/local_transport_security.h +6 -7
  669. data/src/core/tsi/ssl/session_cache/ssl_session.h +3 -0
  670. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  671. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -1
  672. data/src/core/tsi/ssl_transport_security.cc +78 -58
  673. data/src/core/tsi/ssl_transport_security.h +9 -6
  674. data/src/core/tsi/transport_security.cc +10 -8
  675. data/src/core/tsi/transport_security_interface.h +1 -1
  676. data/src/ruby/ext/grpc/extconf.rb +1 -1
  677. data/src/ruby/ext/grpc/rb_event_thread.c +2 -0
  678. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +36 -16
  679. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +70 -40
  680. data/src/ruby/lib/grpc/version.rb +1 -1
  681. data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +28 -0
  682. data/src/ruby/pb/src/proto/grpc/testing/test_services_pb.rb +18 -0
  683. data/src/ruby/spec/pb/codegen/package_option_spec.rb +2 -6
  684. data/third_party/abseil-cpp/absl/algorithm/container.h +59 -22
  685. data/third_party/abseil-cpp/absl/base/attributes.h +99 -38
  686. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  687. data/third_party/abseil-cpp/absl/base/casts.h +9 -6
  688. data/third_party/abseil-cpp/absl/base/config.h +60 -17
  689. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +428 -335
  690. data/third_party/abseil-cpp/absl/base/internal/bits.h +17 -16
  691. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +5 -0
  692. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +398 -0
  693. data/third_party/abseil-cpp/absl/base/internal/invoke.h +4 -4
  694. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +1 -1
  695. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +29 -1
  696. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +2 -2
  697. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +7 -5
  698. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +25 -38
  699. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +19 -25
  700. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +8 -0
  701. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +28 -5
  702. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +8 -0
  703. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +3 -1
  704. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +2 -2
  705. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -3
  706. data/third_party/abseil-cpp/absl/base/macros.h +36 -109
  707. data/third_party/abseil-cpp/absl/base/optimization.h +61 -1
  708. data/third_party/abseil-cpp/absl/base/options.h +31 -4
  709. data/third_party/abseil-cpp/absl/base/policy_checks.h +1 -1
  710. data/third_party/abseil-cpp/absl/base/thread_annotations.h +94 -39
  711. data/third_party/abseil-cpp/absl/container/fixed_array.h +42 -25
  712. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +606 -0
  713. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +2 -1
  714. data/third_party/abseil-cpp/absl/container/inlined_vector.h +33 -36
  715. data/third_party/abseil-cpp/absl/container/internal/common.h +6 -2
  716. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +33 -8
  717. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +49 -29
  718. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +15 -0
  719. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +24 -7
  720. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -1
  721. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +35 -11
  722. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +10 -9
  723. data/third_party/abseil-cpp/absl/container/internal/layout.h +7 -5
  724. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +197 -0
  725. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +55 -34
  726. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +5 -4
  727. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +66 -16
  728. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +4 -0
  729. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +13 -4
  730. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +43 -24
  731. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +12 -3
  732. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +10 -2
  733. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +22 -1
  734. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +0 -21
  735. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +12 -1
  736. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +101 -0
  737. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +100 -20
  738. data/third_party/abseil-cpp/absl/functional/bind_front.h +184 -0
  739. data/third_party/abseil-cpp/absl/functional/function_ref.h +1 -1
  740. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +95 -0
  741. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -2
  742. data/third_party/abseil-cpp/absl/hash/hash.h +6 -5
  743. data/third_party/abseil-cpp/absl/hash/internal/hash.h +73 -65
  744. data/third_party/abseil-cpp/absl/memory/memory.h +4 -0
  745. data/third_party/abseil-cpp/absl/meta/type_traits.h +2 -8
  746. data/third_party/abseil-cpp/absl/numeric/int128.cc +13 -27
  747. data/third_party/abseil-cpp/absl/numeric/int128.h +16 -15
  748. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +51 -0
  749. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +399 -0
  750. data/third_party/abseil-cpp/absl/status/status.cc +4 -6
  751. data/third_party/abseil-cpp/absl/status/status.h +502 -113
  752. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +5 -10
  753. data/third_party/abseil-cpp/absl/status/statusor.cc +71 -0
  754. data/third_party/abseil-cpp/absl/status/statusor.h +760 -0
  755. data/third_party/abseil-cpp/absl/strings/charconv.cc +2 -2
  756. data/third_party/abseil-cpp/absl/strings/cord.cc +91 -112
  757. data/third_party/abseil-cpp/absl/strings/cord.h +360 -205
  758. data/third_party/abseil-cpp/absl/strings/escaping.cc +9 -9
  759. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +1 -1
  760. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
  761. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +2 -2
  762. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  763. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +45 -23
  764. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +222 -136
  765. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +136 -64
  766. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +1 -1
  767. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +14 -21
  768. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +7 -14
  769. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +31 -7
  770. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +147 -135
  771. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +999 -87
  772. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +3 -3
  773. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +4 -12
  774. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +8 -6
  775. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +13 -11
  776. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -2
  777. data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
  778. data/third_party/abseil-cpp/absl/strings/str_cat.h +1 -1
  779. data/third_party/abseil-cpp/absl/strings/str_format.h +289 -13
  780. data/third_party/abseil-cpp/absl/strings/str_split.cc +2 -2
  781. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -0
  782. data/third_party/abseil-cpp/absl/strings/string_view.h +26 -19
  783. data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -5
  784. data/third_party/abseil-cpp/absl/strings/substitute.h +32 -29
  785. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +3 -3
  786. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +3 -3
  787. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +28 -28
  788. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +4 -16
  789. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +1 -1
  790. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +8 -0
  791. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -2
  792. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +75 -64
  793. data/third_party/abseil-cpp/absl/synchronization/mutex.h +15 -6
  794. data/third_party/abseil-cpp/absl/time/civil_time.cc +9 -9
  795. data/third_party/abseil-cpp/absl/time/clock.cc +3 -3
  796. data/third_party/abseil-cpp/absl/time/duration.cc +90 -59
  797. data/third_party/abseil-cpp/absl/time/format.cc +43 -36
  798. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +26 -16
  799. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +4 -2
  800. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +1 -1
  801. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +136 -29
  802. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +13 -21
  803. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +1 -1
  804. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +136 -129
  805. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +4 -5
  806. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +8 -7
  807. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +6 -6
  808. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +2 -1
  809. data/third_party/abseil-cpp/absl/time/time.h +15 -16
  810. data/third_party/abseil-cpp/absl/types/internal/variant.h +4 -4
  811. data/third_party/abseil-cpp/absl/types/optional.h +9 -9
  812. data/third_party/abseil-cpp/absl/types/span.h +49 -36
  813. data/third_party/abseil-cpp/absl/utility/utility.h +2 -2
  814. data/third_party/address_sorting/include/address_sorting/address_sorting.h +2 -0
  815. data/third_party/boringssl-with-bazel/err_data.c +469 -463
  816. data/third_party/boringssl-with-bazel/src/crypto/asn1/asn1_lib.c +0 -6
  817. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +2 -0
  818. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa.c +9 -43
  819. data/third_party/boringssl-with-bazel/src/crypto/dsa/dsa_asn1.c +55 -4
  820. data/third_party/boringssl-with-bazel/src/crypto/dsa/internal.h +34 -0
  821. data/third_party/boringssl-with-bazel/src/crypto/evp/evp.c +4 -0
  822. data/third_party/boringssl-with-bazel/src/crypto/evp/p_dsa_asn1.c +6 -2
  823. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +173 -35
  824. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/digest/digest.c +2 -0
  825. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/internal.h +4 -0
  826. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa.c +30 -10
  827. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +56 -22
  828. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +8 -2
  829. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +98 -11
  830. data/third_party/boringssl-with-bazel/src/crypto/hpke/internal.h +51 -6
  831. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +118 -49
  832. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +267 -95
  833. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +210 -34
  834. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +766 -0
  835. data/third_party/boringssl-with-bazel/src/crypto/x509/a_strex.c +3 -3
  836. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +6 -4
  837. data/third_party/boringssl-with-bazel/src/crypto/x509/t_crl.c +3 -3
  838. data/third_party/boringssl-with-bazel/src/crypto/x509/t_x509.c +1 -1
  839. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_cmp.c +7 -2
  840. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_ext.c +21 -18
  841. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_obj.c +1 -1
  842. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_set.c +24 -3
  843. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_trs.c +3 -3
  844. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_txt.c +67 -67
  845. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_v3.c +3 -3
  846. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_vfy.c +29 -35
  847. data/third_party/boringssl-with-bazel/src/crypto/x509/x509cset.c +13 -2
  848. data/third_party/boringssl-with-bazel/src/crypto/x509/x509name.c +9 -8
  849. data/third_party/boringssl-with-bazel/src/crypto/x509/x_all.c +10 -10
  850. data/third_party/boringssl-with-bazel/src/crypto/x509/x_crl.c +2 -2
  851. data/third_party/boringssl-with-bazel/src/crypto/x509/x_name.c +28 -40
  852. data/third_party/boringssl-with-bazel/src/crypto/x509/x_x509.c +3 -1
  853. data/third_party/boringssl-with-bazel/src/crypto/x509v3/ext_dat.h +1 -4
  854. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +5 -3
  855. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +14 -14
  856. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_conf.c +7 -3
  857. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_genn.c +2 -2
  858. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_info.c +1 -1
  859. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +1 -1
  860. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +55 -8
  861. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_skey.c +1 -1
  862. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +24 -0
  863. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +7 -5
  864. data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +0 -1
  865. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +6 -3
  866. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +4 -0
  867. data/third_party/boringssl-with-bazel/src/include/openssl/cipher.h +6 -0
  868. data/third_party/boringssl-with-bazel/src/include/openssl/crypto.h +1 -1
  869. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +6 -0
  870. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +12 -0
  871. data/third_party/boringssl-with-bazel/src/include/openssl/digest.h +9 -0
  872. data/third_party/boringssl-with-bazel/src/include/openssl/evp.h +4 -1
  873. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +3 -0
  874. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +202 -134
  875. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +64 -3
  876. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  877. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +42 -14
  878. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +188 -78
  879. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +482 -432
  880. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +18 -5
  881. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +35 -0
  882. data/third_party/boringssl-with-bazel/src/ssl/handshake.cc +18 -18
  883. data/third_party/boringssl-with-bazel/src/ssl/handshake_client.cc +2 -3
  884. data/third_party/boringssl-with-bazel/src/ssl/handshake_server.cc +1 -1
  885. data/third_party/boringssl-with-bazel/src/ssl/internal.h +45 -10
  886. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +42 -1
  887. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +8 -9
  888. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +67 -0
  889. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +11 -14
  890. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +216 -11
  891. data/third_party/boringssl-with-bazel/src/ssl/tls13_both.cc +1 -2
  892. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +57 -19
  893. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +135 -41
  894. data/third_party/upb/third_party/wyhash/wyhash.h +145 -0
  895. data/third_party/upb/upb/decode.c +248 -167
  896. data/third_party/upb/upb/decode.h +20 -1
  897. data/third_party/upb/upb/decode.int.h +163 -0
  898. data/third_party/upb/upb/decode_fast.c +1040 -0
  899. data/third_party/upb/upb/decode_fast.h +126 -0
  900. data/third_party/upb/upb/def.c +2178 -0
  901. data/third_party/upb/upb/def.h +315 -0
  902. data/third_party/upb/upb/def.hpp +439 -0
  903. data/third_party/upb/upb/encode.c +227 -169
  904. data/third_party/upb/upb/encode.h +27 -2
  905. data/third_party/upb/upb/json_decode.c +1443 -0
  906. data/third_party/upb/upb/json_decode.h +23 -0
  907. data/third_party/upb/upb/json_encode.c +713 -0
  908. data/third_party/upb/upb/json_encode.h +36 -0
  909. data/third_party/upb/upb/msg.c +167 -88
  910. data/third_party/upb/upb/msg.h +174 -34
  911. data/third_party/upb/upb/port_def.inc +74 -61
  912. data/third_party/upb/upb/port_undef.inc +3 -7
  913. data/third_party/upb/upb/reflection.c +408 -0
  914. data/third_party/upb/upb/reflection.h +168 -0
  915. data/third_party/upb/upb/table.c +34 -197
  916. data/third_party/upb/upb/table.int.h +14 -5
  917. data/third_party/upb/upb/text_encode.c +421 -0
  918. data/third_party/upb/upb/text_encode.h +38 -0
  919. data/third_party/upb/upb/upb.c +18 -41
  920. data/third_party/upb/upb/upb.h +36 -7
  921. data/third_party/upb/upb/upb.hpp +4 -4
  922. data/third_party/upb/upb/upb.int.h +29 -0
  923. metadata +288 -54
  924. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +0 -946
  925. data/src/core/ext/filters/client_channel/lb_policy/xds/lrs.cc +0 -537
  926. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_routing.cc +0 -1141
  927. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +0 -485
  928. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +0 -68
  929. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +0 -354
  930. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +0 -142
  931. data/src/core/ext/upb-generated/gogoproto/gogo.upb.c +0 -17
  932. data/src/core/ext/xds/xds_channel.h +0 -46
  933. data/src/core/ext/xds/xds_channel_secure.cc +0 -103
  934. data/src/core/lib/gprpp/map.h +0 -53
  935. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +0 -129
  936. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_pku.c +0 -110
  937. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_sxnet.c +0 -274
  938. data/third_party/upb/upb/port.c +0 -26
@@ -0,0 +1,112 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #ifndef GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_STORE_H
20
+ #define GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_STORE_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ #include <map>
25
+
26
+ #include "absl/strings/string_view.h"
27
+
28
+ #include "src/core/ext/xds/certificate_provider_factory.h"
29
+ #include "src/core/lib/gprpp/orphanable.h"
30
+ #include "src/core/lib/gprpp/ref_counted_ptr.h"
31
+ #include "src/core/lib/gprpp/sync.h"
32
+ #include "src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h"
33
+
34
+ namespace grpc_core {
35
+
36
+ // Map for xDS based grpc_tls_certificate_provider instances.
37
+ class CertificateProviderStore
38
+ : public InternallyRefCounted<CertificateProviderStore> {
39
+ public:
40
+ struct PluginDefinition {
41
+ std::string plugin_name;
42
+ RefCountedPtr<CertificateProviderFactory::Config> config;
43
+ };
44
+
45
+ // Maps plugin instance (opaque) name to plugin defition.
46
+ typedef std::map<std::string, PluginDefinition> PluginDefinitionMap;
47
+
48
+ explicit CertificateProviderStore(PluginDefinitionMap plugin_config_map)
49
+ : plugin_config_map_(std::move(plugin_config_map)) {}
50
+
51
+ // If a certificate provider corresponding to the instance name \a key is
52
+ // found, a ref to the grpc_tls_certificate_provider is returned. If no
53
+ // provider is found for the key, a new provider is created from the plugin
54
+ // definition map.
55
+ // Returns nullptr on failure to get or create a new certificate provider.
56
+ RefCountedPtr<grpc_tls_certificate_provider> CreateOrGetCertificateProvider(
57
+ absl::string_view key);
58
+
59
+ void Orphan() override { Unref(); }
60
+
61
+ private:
62
+ // A thin wrapper around `grpc_tls_certificate_provider` which allows removing
63
+ // the entry from the CertificateProviderStore when the refcount reaches zero.
64
+ class CertificateProviderWrapper : public grpc_tls_certificate_provider {
65
+ public:
66
+ CertificateProviderWrapper(
67
+ RefCountedPtr<grpc_tls_certificate_provider> certificate_provider,
68
+ RefCountedPtr<CertificateProviderStore> store, absl::string_view key)
69
+ : certificate_provider_(std::move(certificate_provider)),
70
+ store_(std::move(store)),
71
+ key_(key) {}
72
+
73
+ ~CertificateProviderWrapper() override {
74
+ store_->ReleaseCertificateProvider(key_, this);
75
+ }
76
+
77
+ grpc_core::RefCountedPtr<grpc_tls_certificate_distributor> distributor()
78
+ const override {
79
+ return certificate_provider_->distributor();
80
+ }
81
+
82
+ grpc_pollset_set* interested_parties() const override {
83
+ return certificate_provider_->interested_parties();
84
+ }
85
+
86
+ absl::string_view key() const { return key_; }
87
+
88
+ private:
89
+ RefCountedPtr<grpc_tls_certificate_provider> certificate_provider_;
90
+ RefCountedPtr<CertificateProviderStore> store_;
91
+ absl::string_view key_;
92
+ };
93
+
94
+ RefCountedPtr<CertificateProviderWrapper> CreateCertificateProviderLocked(
95
+ absl::string_view key);
96
+
97
+ // Releases a previously created certificate provider from the certificate
98
+ // provider map if the value matches \a wrapper.
99
+ void ReleaseCertificateProvider(absl::string_view key,
100
+ CertificateProviderWrapper* wrapper);
101
+
102
+ Mutex mu_;
103
+ // Map of plugin configurations
104
+ PluginDefinitionMap plugin_config_map_;
105
+ // Underlying map for the providers.
106
+ std::map<absl::string_view, CertificateProviderWrapper*>
107
+ certificate_providers_map_;
108
+ };
109
+
110
+ } // namespace grpc_core
111
+
112
+ #endif // GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_STORE_H
@@ -0,0 +1,144 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/ext/xds/file_watcher_certificate_provider_factory.h"
22
+
23
+ #include "absl/strings/str_format.h"
24
+ #include "absl/strings/str_join.h"
25
+
26
+ #include "src/core/ext/xds/certificate_provider_registry.h"
27
+ #include "src/core/lib/json/json_util.h"
28
+
29
+ namespace grpc_core {
30
+
31
+ namespace {
32
+
33
+ const char* kFileWatcherPlugin = "file_watcher";
34
+
35
+ } // namespace
36
+
37
+ //
38
+ // FileWatcherCertificateProviderFactory::Config
39
+ //
40
+
41
+ const char* FileWatcherCertificateProviderFactory::Config::name() const {
42
+ return kFileWatcherPlugin;
43
+ }
44
+
45
+ std::string FileWatcherCertificateProviderFactory::Config::ToString() const {
46
+ std::vector<std::string> parts;
47
+ parts.push_back("{");
48
+ if (!identity_cert_file_.empty()) {
49
+ parts.push_back(
50
+ absl::StrFormat("certificate_file=\"%s\", ", identity_cert_file_));
51
+ }
52
+ if (!identity_cert_file_.empty()) {
53
+ parts.push_back(
54
+ absl::StrFormat("private_key_file=\"%s\", ", private_key_file_));
55
+ }
56
+ if (!identity_cert_file_.empty()) {
57
+ parts.push_back(
58
+ absl::StrFormat("ca_certificate_file=\"%s\", ", root_cert_file_));
59
+ }
60
+ parts.push_back(
61
+ absl::StrFormat("refresh_interval=%ldms}", refresh_interval_ms_));
62
+ return absl::StrJoin(parts, "");
63
+ }
64
+
65
+ RefCountedPtr<FileWatcherCertificateProviderFactory::Config>
66
+ FileWatcherCertificateProviderFactory::Config::Parse(const Json& config_json,
67
+ grpc_error** error) {
68
+ auto config = MakeRefCounted<FileWatcherCertificateProviderFactory::Config>();
69
+ if (config_json.type() != Json::Type::OBJECT) {
70
+ *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
71
+ "error:config type should be OBJECT.");
72
+ return nullptr;
73
+ }
74
+ std::vector<grpc_error*> error_list;
75
+ ParseJsonObjectField(config_json.object_value(), "certificate_file",
76
+ &config->identity_cert_file_, &error_list, false);
77
+ ParseJsonObjectField(config_json.object_value(), "private_key_file",
78
+ &config->private_key_file_, &error_list, false);
79
+ if (config->identity_cert_file_.empty() !=
80
+ config->private_key_file_.empty()) {
81
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
82
+ "fields \"certificate_file\" and \"private_key_file\" must be both set "
83
+ "or both unset."));
84
+ }
85
+ ParseJsonObjectField(config_json.object_value(), "ca_certificate_file",
86
+ &config->root_cert_file_, &error_list, false);
87
+ if (config->identity_cert_file_.empty() && config->root_cert_file_.empty()) {
88
+ error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
89
+ "At least one of \"certificate_file\" and \"ca_certificate_file\" must "
90
+ "be specified."));
91
+ }
92
+ if (!ParseJsonObjectFieldAsDuration(
93
+ config_json.object_value(), "refresh_interval",
94
+ &config->refresh_interval_ms_, &error_list, false)) {
95
+ config->refresh_interval_ms_ = 10 * 60 * 1000; // 10 minutes default
96
+ }
97
+ if (!error_list.empty()) {
98
+ *error = GRPC_ERROR_CREATE_FROM_VECTOR(
99
+ "Error parsing file watcher certificate provider config", &error_list);
100
+ return nullptr;
101
+ }
102
+ return config;
103
+ }
104
+
105
+ //
106
+ // FileWatcherCertificateProviderFactory
107
+ //
108
+
109
+ const char* FileWatcherCertificateProviderFactory::name() const {
110
+ return kFileWatcherPlugin;
111
+ }
112
+
113
+ RefCountedPtr<CertificateProviderFactory::Config>
114
+ FileWatcherCertificateProviderFactory::CreateCertificateProviderConfig(
115
+ const Json& config_json, grpc_error** error) {
116
+ return FileWatcherCertificateProviderFactory::Config::Parse(config_json,
117
+ error);
118
+ }
119
+
120
+ RefCountedPtr<grpc_tls_certificate_provider>
121
+ FileWatcherCertificateProviderFactory::CreateCertificateProvider(
122
+ RefCountedPtr<CertificateProviderFactory::Config> config) {
123
+ if (config->name() != name()) {
124
+ gpr_log(GPR_ERROR, "Wrong config type Actual:%s vs Expected:%s",
125
+ config->name(), name());
126
+ return nullptr;
127
+ }
128
+ auto* file_watcher_config =
129
+ static_cast<FileWatcherCertificateProviderFactory::Config*>(config.get());
130
+ return MakeRefCounted<FileWatcherCertificateProvider>(
131
+ file_watcher_config->private_key_file(),
132
+ file_watcher_config->identity_cert_file(),
133
+ file_watcher_config->root_cert_file(),
134
+ file_watcher_config->refresh_interval_ms() / GPR_MS_PER_SEC);
135
+ }
136
+
137
+ void FileWatcherCertificateProviderInit() {
138
+ CertificateProviderRegistry::RegisterCertificateProviderFactory(
139
+ absl::make_unique<FileWatcherCertificateProviderFactory>());
140
+ }
141
+
142
+ void FileWatcherCertificateProviderShutdown() {}
143
+
144
+ } // namespace grpc_core
@@ -0,0 +1,69 @@
1
+ //
2
+ //
3
+ // Copyright 2020 gRPC authors.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 (the "License");
6
+ // you may not use this file except in compliance with the License.
7
+ // You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing, software
12
+ // distributed under the License is distributed on an "AS IS" BASIS,
13
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ // See the License for the specific language governing permissions and
15
+ // limitations under the License.
16
+ //
17
+ //
18
+
19
+ #ifndef GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
20
+ #define GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
21
+
22
+ #include <grpc/support/port_platform.h>
23
+
24
+ #include "src/core/ext/xds/certificate_provider_factory.h"
25
+
26
+ namespace grpc_core {
27
+
28
+ class FileWatcherCertificateProviderFactory
29
+ : public CertificateProviderFactory {
30
+ public:
31
+ class Config : public CertificateProviderFactory::Config {
32
+ public:
33
+ static RefCountedPtr<Config> Parse(const Json& config_json,
34
+ grpc_error** error);
35
+
36
+ const char* name() const override;
37
+
38
+ std::string ToString() const override;
39
+
40
+ const std::string& identity_cert_file() const {
41
+ return identity_cert_file_;
42
+ }
43
+
44
+ const std::string& private_key_file() const { return private_key_file_; }
45
+
46
+ const std::string& root_cert_file() const { return root_cert_file_; }
47
+
48
+ grpc_millis refresh_interval_ms() const { return refresh_interval_ms_; }
49
+
50
+ private:
51
+ std::string identity_cert_file_;
52
+ std::string private_key_file_;
53
+ std::string root_cert_file_;
54
+ grpc_millis refresh_interval_ms_;
55
+ };
56
+
57
+ const char* name() const override;
58
+
59
+ RefCountedPtr<CertificateProviderFactory::Config>
60
+ CreateCertificateProviderConfig(const Json& config_json,
61
+ grpc_error** error) override;
62
+
63
+ RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
64
+ RefCountedPtr<CertificateProviderFactory::Config> config) override;
65
+ };
66
+
67
+ } // namespace grpc_core
68
+
69
+ #endif // GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
@@ -41,27 +41,41 @@
41
41
  #include "src/core/lib/gpr/useful.h"
42
42
  #include "src/core/lib/iomgr/error.h"
43
43
  #include "src/core/lib/iomgr/sockaddr_utils.h"
44
+ #include "src/core/lib/slice/slice_utils.h"
44
45
 
46
+ #include "envoy/config/cluster/v3/circuit_breaker.upb.h"
45
47
  #include "envoy/config/cluster/v3/cluster.upb.h"
48
+ #include "envoy/config/cluster/v3/cluster.upbdefs.h"
46
49
  #include "envoy/config/core/v3/address.upb.h"
47
50
  #include "envoy/config/core/v3/base.upb.h"
48
51
  #include "envoy/config/core/v3/config_source.upb.h"
49
52
  #include "envoy/config/core/v3/health_check.upb.h"
53
+ #include "envoy/config/core/v3/protocol.upb.h"
50
54
  #include "envoy/config/endpoint/v3/endpoint.upb.h"
55
+ #include "envoy/config/endpoint/v3/endpoint.upbdefs.h"
51
56
  #include "envoy/config/endpoint/v3/endpoint_components.upb.h"
52
57
  #include "envoy/config/endpoint/v3/load_report.upb.h"
53
58
  #include "envoy/config/listener/v3/api_listener.upb.h"
54
59
  #include "envoy/config/listener/v3/listener.upb.h"
55
60
  #include "envoy/config/route/v3/route.upb.h"
61
+ #include "envoy/config/route/v3/route.upbdefs.h"
56
62
  #include "envoy/config/route/v3/route_components.upb.h"
57
63
  #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
64
+ #include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
65
+ #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
58
66
  #include "envoy/service/cluster/v3/cds.upb.h"
67
+ #include "envoy/service/cluster/v3/cds.upbdefs.h"
59
68
  #include "envoy/service/discovery/v3/discovery.upb.h"
69
+ #include "envoy/service/discovery/v3/discovery.upbdefs.h"
60
70
  #include "envoy/service/endpoint/v3/eds.upb.h"
71
+ #include "envoy/service/endpoint/v3/eds.upbdefs.h"
61
72
  #include "envoy/service/listener/v3/lds.upb.h"
62
73
  #include "envoy/service/load_stats/v3/lrs.upb.h"
74
+ #include "envoy/service/load_stats/v3/lrs.upbdefs.h"
63
75
  #include "envoy/service/route/v3/rds.upb.h"
76
+ #include "envoy/service/route/v3/rds.upbdefs.h"
64
77
  #include "envoy/type/matcher/v3/regex.upb.h"
78
+ #include "envoy/type/matcher/v3/string.upb.h"
65
79
  #include "envoy/type/v3/percent.upb.h"
66
80
  #include "envoy/type/v3/range.upb.h"
67
81
  #include "google/protobuf/any.upb.h"
@@ -69,18 +83,44 @@
69
83
  #include "google/protobuf/struct.upb.h"
70
84
  #include "google/protobuf/wrappers.upb.h"
71
85
  #include "google/rpc/status.upb.h"
86
+ #include "upb/text_encode.h"
72
87
  #include "upb/upb.h"
73
88
 
74
89
  namespace grpc_core {
75
90
 
91
+ // TODO (donnadionne): Check to see if timeout is enabled, this will be
92
+ // removed once timeout feature is fully integration-tested and enabled by
93
+ // default.
94
+ bool XdsTimeoutEnabled() {
95
+ char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT");
96
+ bool parsed_value;
97
+ bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
98
+ gpr_free(value);
99
+ return parse_succeeded && parsed_value;
100
+ }
101
+
102
+ // TODO(yashykt): Check to see if xDS security is enabled. This will be
103
+ // removed once this feature is fully integration-tested and enabled by
104
+ // default.
105
+ bool XdsSecurityEnabled() {
106
+ char* value = gpr_getenv("GRPC_XDS_EXPERIMENTAL_SECURITY_SUPPORT");
107
+ bool parsed_value;
108
+ bool parse_succeeded = gpr_parse_bool_value(value, &parsed_value);
109
+ gpr_free(value);
110
+ return parse_succeeded && parsed_value;
111
+ }
112
+
76
113
  //
77
114
  // XdsApi::Route::Matchers::PathMatcher
78
115
  //
79
116
 
80
117
  XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
81
- : type(other.type) {
118
+ : type(other.type), case_sensitive(other.case_sensitive) {
82
119
  if (type == PathMatcherType::REGEX) {
83
- regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
120
+ RE2::Options options;
121
+ options.set_case_sensitive(case_sensitive);
122
+ regex_matcher =
123
+ absl::make_unique<RE2>(other.regex_matcher->pattern(), options);
84
124
  } else {
85
125
  string_matcher = other.string_matcher;
86
126
  }
@@ -89,8 +129,12 @@ XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
89
129
  XdsApi::Route::Matchers::PathMatcher& XdsApi::Route::Matchers::PathMatcher::
90
130
  operator=(const PathMatcher& other) {
91
131
  type = other.type;
132
+ case_sensitive = other.case_sensitive;
92
133
  if (type == PathMatcherType::REGEX) {
93
- regex_matcher = absl::make_unique<RE2>(other.regex_matcher->pattern());
134
+ RE2::Options options;
135
+ options.set_case_sensitive(case_sensitive);
136
+ regex_matcher =
137
+ absl::make_unique<RE2>(other.regex_matcher->pattern(), options);
94
138
  } else {
95
139
  string_matcher = other.string_matcher;
96
140
  }
@@ -100,6 +144,7 @@ operator=(const PathMatcher& other) {
100
144
  bool XdsApi::Route::Matchers::PathMatcher::operator==(
101
145
  const PathMatcher& other) const {
102
146
  if (type != other.type) return false;
147
+ if (case_sensitive != other.case_sensitive) return false;
103
148
  if (type == PathMatcherType::REGEX) {
104
149
  // Should never be null.
105
150
  if (regex_matcher == nullptr || other.regex_matcher == nullptr) {
@@ -125,10 +170,11 @@ std::string XdsApi::Route::Matchers::PathMatcher::ToString() const {
125
170
  default:
126
171
  break;
127
172
  }
128
- return absl::StrFormat("Path %s:%s", path_type_string,
173
+ return absl::StrFormat("Path %s:%s%s", path_type_string,
129
174
  type == PathMatcherType::REGEX
130
175
  ? regex_matcher->pattern()
131
- : string_matcher);
176
+ : string_matcher,
177
+ case_sensitive ? "" : "[case_sensitive=false]");
132
178
  }
133
179
 
134
180
  //
@@ -228,8 +274,8 @@ std::string XdsApi::Route::Matchers::HeaderMatcher::ToString() const {
228
274
  std::string XdsApi::Route::Matchers::ToString() const {
229
275
  std::vector<std::string> contents;
230
276
  contents.push_back(path_matcher.ToString());
231
- for (const auto& header_it : header_matchers) {
232
- contents.push_back(header_it.ToString());
277
+ for (const HeaderMatcher& header_matcher : header_matchers) {
278
+ contents.push_back(header_matcher.ToString());
233
279
  }
234
280
  if (fraction_per_million.has_value()) {
235
281
  contents.push_back(absl::StrFormat("Fraction Per Million %d",
@@ -248,8 +294,11 @@ std::string XdsApi::Route::ToString() const {
248
294
  if (!cluster_name.empty()) {
249
295
  contents.push_back(absl::StrFormat("Cluster name: %s", cluster_name));
250
296
  }
251
- for (const auto& weighted_it : weighted_clusters) {
252
- contents.push_back(weighted_it.ToString());
297
+ for (const ClusterWeight& cluster_weight : weighted_clusters) {
298
+ contents.push_back(cluster_weight.ToString());
299
+ }
300
+ if (max_stream_duration.has_value()) {
301
+ contents.push_back(max_stream_duration->ToString());
253
302
  }
254
303
  return absl::StrJoin(contents, "\n");
255
304
  }
@@ -290,9 +339,11 @@ enum MatchType {
290
339
  };
291
340
 
292
341
  // Returns true if match succeeds.
293
- bool DomainMatch(MatchType match_type, std::string domain_pattern,
294
- std::string expected_host_name) {
342
+ bool DomainMatch(MatchType match_type, const std::string& domain_pattern_in,
343
+ const std::string& expected_host_name_in) {
295
344
  // Normalize the args to lower-case. Domain matching is case-insensitive.
345
+ std::string domain_pattern = domain_pattern_in;
346
+ std::string expected_host_name = expected_host_name_in;
296
347
  std::transform(domain_pattern.begin(), domain_pattern.end(),
297
348
  domain_pattern.begin(),
298
349
  [](unsigned char c) { return std::tolower(c); });
@@ -333,8 +384,8 @@ MatchType DomainPatternMatchType(const std::string& domain_pattern) {
333
384
 
334
385
  } // namespace
335
386
 
336
- const XdsApi::RdsUpdate::VirtualHost*
337
- XdsApi::RdsUpdate::FindVirtualHostForDomain(const std::string& domain) const {
387
+ XdsApi::RdsUpdate::VirtualHost* XdsApi::RdsUpdate::FindVirtualHostForDomain(
388
+ const std::string& domain) {
338
389
  // Find the best matched virtual host.
339
390
  // The search order for 4 groups of domain patterns:
340
391
  // 1. Exact match.
@@ -344,12 +395,12 @@ XdsApi::RdsUpdate::FindVirtualHostForDomain(const std::string& domain) const {
344
395
  // Within each group, longest match wins.
345
396
  // If the same best matched domain pattern appears in multiple virtual hosts,
346
397
  // the first matched virtual host wins.
347
- const VirtualHost* target_vhost = nullptr;
398
+ VirtualHost* target_vhost = nullptr;
348
399
  MatchType best_match_type = INVALID_MATCH;
349
400
  size_t longest_match = 0;
350
401
  // Check each domain pattern in each virtual host to determine the best
351
402
  // matched virtual host.
352
- for (const VirtualHost& vhost : virtual_hosts) {
403
+ for (VirtualHost& vhost : virtual_hosts) {
353
404
  for (const std::string& domain_pattern : vhost.domains) {
354
405
  // Check the match type first. Skip the pattern if it's not better than
355
406
  // current match.
@@ -375,49 +426,249 @@ XdsApi::RdsUpdate::FindVirtualHostForDomain(const std::string& domain) const {
375
426
  }
376
427
 
377
428
  //
378
- // XdsApi::PriorityListUpdate
429
+ // XdsApi::StringMatcher
379
430
  //
380
431
 
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) {
432
+ XdsApi::StringMatcher::StringMatcher(StringMatcherType type,
433
+ const std::string& matcher,
434
+ bool ignore_case)
435
+ : type_(type), ignore_case_(ignore_case) {
436
+ if (type_ == StringMatcherType::SAFE_REGEX) {
437
+ regex_matcher_ = absl::make_unique<RE2>(matcher);
438
+ } else {
439
+ string_matcher_ = matcher;
440
+ }
441
+ }
442
+
443
+ XdsApi::StringMatcher::StringMatcher(const StringMatcher& other)
444
+ : type_(other.type_), ignore_case_(other.ignore_case_) {
445
+ switch (type_) {
446
+ case StringMatcherType::SAFE_REGEX:
447
+ regex_matcher_ = absl::make_unique<RE2>(other.regex_matcher_->pattern());
448
+ break;
449
+ default:
450
+ string_matcher_ = other.string_matcher_;
451
+ }
452
+ }
453
+
454
+ XdsApi::StringMatcher& XdsApi::StringMatcher::operator=(
455
+ const StringMatcher& other) {
456
+ type_ = other.type_;
457
+ switch (type_) {
458
+ case StringMatcherType::SAFE_REGEX:
459
+ regex_matcher_ = absl::make_unique<RE2>(other.regex_matcher_->pattern());
460
+ break;
461
+ default:
462
+ string_matcher_ = other.string_matcher_;
463
+ }
464
+ ignore_case_ = other.ignore_case_;
465
+ return *this;
466
+ }
467
+
468
+ bool XdsApi::StringMatcher::operator==(const StringMatcher& other) const {
469
+ if (type_ != other.type_ || ignore_case_ != other.ignore_case_) return false;
470
+ switch (type_) {
471
+ case StringMatcherType::SAFE_REGEX:
472
+ return regex_matcher_->pattern() == other.regex_matcher_->pattern();
473
+ default:
474
+ return string_matcher_ == other.string_matcher_;
475
+ }
476
+ }
477
+
478
+ bool XdsApi::StringMatcher::Match(absl::string_view value) const {
479
+ switch (type_) {
480
+ case XdsApi::StringMatcher::StringMatcherType::EXACT:
481
+ return ignore_case_ ? absl::EqualsIgnoreCase(value, string_matcher_)
482
+ : value == string_matcher_;
483
+ case XdsApi::StringMatcher::StringMatcherType::PREFIX:
484
+ return ignore_case_ ? absl::StartsWithIgnoreCase(value, string_matcher_)
485
+ : absl::StartsWith(value, string_matcher_);
486
+ case XdsApi::StringMatcher::StringMatcherType::SUFFIX:
487
+ return ignore_case_ ? absl::EndsWithIgnoreCase(value, string_matcher_)
488
+ : absl::EndsWith(value, string_matcher_);
489
+ case XdsApi::StringMatcher::StringMatcherType::CONTAINS:
490
+ return ignore_case_
491
+ ? absl::StrContains(absl::AsciiStrToLower(value),
492
+ absl::AsciiStrToLower(string_matcher_))
493
+ : absl::StrContains(value, string_matcher_);
494
+ case XdsApi::StringMatcher::StringMatcherType::SAFE_REGEX:
495
+ // ignore_case_ is ignored for SAFE_REGEX
496
+ return RE2::FullMatch(std::string(value), *regex_matcher_);
497
+ default:
386
498
  return false;
387
- }
388
499
  }
389
- return true;
390
500
  }
391
501
 
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));
502
+ std::string XdsApi::StringMatcher::ToString() const {
503
+ switch (type_) {
504
+ case StringMatcherType::EXACT:
505
+ return absl::StrFormat("StringMatcher{exact=%s%s}", string_matcher_,
506
+ ignore_case_ ? ", ignore_case" : "");
507
+ case StringMatcherType::PREFIX:
508
+ return absl::StrFormat("StringMatcher{prefix=%s%s}", string_matcher_,
509
+ ignore_case_ ? ", ignore_case" : "");
510
+ case StringMatcherType::SUFFIX:
511
+ return absl::StrFormat("StringMatcher{suffix=%s%s}", string_matcher_,
512
+ ignore_case_ ? ", ignore_case" : "");
513
+ case StringMatcherType::CONTAINS:
514
+ return absl::StrFormat("StringMatcher{contains=%s%s}", string_matcher_,
515
+ ignore_case_ ? ", ignore_case" : "");
516
+ case StringMatcherType::SAFE_REGEX:
517
+ return absl::StrFormat("StringMatcher{safe_regex=%s}",
518
+ regex_matcher_->pattern());
519
+ default:
520
+ return "";
521
+ }
399
522
  }
400
523
 
401
- const XdsApi::PriorityListUpdate::LocalityMap* XdsApi::PriorityListUpdate::Find(
402
- uint32_t priority) const {
403
- if (!Contains(priority)) return nullptr;
404
- return &priorities_[priority];
524
+ //
525
+ // XdsApi::CommonTlsContext::CertificateValidationContext
526
+ //
527
+
528
+ std::string XdsApi::CommonTlsContext::CertificateValidationContext::ToString()
529
+ const {
530
+ std::vector<std::string> contents;
531
+ for (const auto& match : match_subject_alt_names) {
532
+ contents.push_back(match.ToString());
533
+ }
534
+ return absl::StrFormat("{match_subject_alt_names=[%s]}",
535
+ absl::StrJoin(contents, ", "));
405
536
  }
406
537
 
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;
538
+ bool XdsApi::CommonTlsContext::CertificateValidationContext::Empty() const {
539
+ return match_subject_alt_names.empty();
540
+ }
541
+
542
+ //
543
+ // XdsApi::CommonTlsContext::CertificateValidationContext
544
+ //
545
+
546
+ std::string XdsApi::CommonTlsContext::CertificateProviderInstance::ToString()
547
+ const {
548
+ absl::InlinedVector<std::string, 2> contents;
549
+ if (!instance_name.empty()) {
550
+ contents.push_back(absl::StrFormat("instance_name=%s", instance_name));
412
551
  }
413
- return false;
552
+ if (!certificate_name.empty()) {
553
+ contents.push_back(
554
+ absl::StrFormat("certificate_name=%s", certificate_name));
555
+ }
556
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
557
+ }
558
+
559
+ bool XdsApi::CommonTlsContext::CertificateProviderInstance::Empty() const {
560
+ return instance_name.empty() && certificate_name.empty();
561
+ }
562
+
563
+ //
564
+ // XdsApi::CommonTlsContext::CombinedCertificateValidationContext
565
+ //
566
+
567
+ std::string
568
+ XdsApi::CommonTlsContext::CombinedCertificateValidationContext::ToString()
569
+ const {
570
+ absl::InlinedVector<std::string, 2> contents;
571
+ if (!default_validation_context.Empty()) {
572
+ contents.push_back(absl::StrFormat("default_validation_context=%s",
573
+ default_validation_context.ToString()));
574
+ }
575
+ if (!validation_context_certificate_provider_instance.Empty()) {
576
+ contents.push_back(absl::StrFormat(
577
+ "validation_context_certificate_provider_instance=%s",
578
+ validation_context_certificate_provider_instance.ToString()));
579
+ }
580
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
581
+ }
582
+
583
+ bool XdsApi::CommonTlsContext::CombinedCertificateValidationContext::Empty()
584
+ const {
585
+ return default_validation_context.Empty() &&
586
+ validation_context_certificate_provider_instance.Empty();
414
587
  }
415
588
 
416
589
  //
417
- // XdsApi::DropConfig
590
+ // XdsApi::CommonTlsContext
418
591
  //
419
592
 
420
- bool XdsApi::DropConfig::ShouldDrop(const std::string** category_name) const {
593
+ std::string XdsApi::CommonTlsContext::ToString() const {
594
+ absl::InlinedVector<std::string, 2> contents;
595
+ if (!tls_certificate_certificate_provider_instance.Empty()) {
596
+ contents.push_back(absl::StrFormat(
597
+ "tls_certificate_certificate_provider_instance=%s",
598
+ tls_certificate_certificate_provider_instance.ToString()));
599
+ }
600
+ if (!combined_validation_context.Empty()) {
601
+ contents.push_back(absl::StrFormat("combined_validation_context=%s",
602
+ combined_validation_context.ToString()));
603
+ }
604
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
605
+ }
606
+
607
+ bool XdsApi::CommonTlsContext::Empty() const {
608
+ return tls_certificate_certificate_provider_instance.Empty() &&
609
+ combined_validation_context.Empty();
610
+ }
611
+
612
+ //
613
+ // XdsApi::CdsUpdate
614
+ //
615
+
616
+ std::string XdsApi::CdsUpdate::ToString() const {
617
+ absl::InlinedVector<std::string, 4> contents;
618
+ if (!eds_service_name.empty()) {
619
+ contents.push_back(
620
+ absl::StrFormat("eds_service_name=%s", eds_service_name));
621
+ }
622
+ if (!common_tls_context.Empty()) {
623
+ contents.push_back(absl::StrFormat("common_tls_context=%s",
624
+ common_tls_context.ToString()));
625
+ }
626
+ if (lrs_load_reporting_server_name.has_value()) {
627
+ contents.push_back(absl::StrFormat("lrs_load_reporting_server_name=%s",
628
+ lrs_load_reporting_server_name.value()));
629
+ }
630
+ contents.push_back(
631
+ absl::StrFormat("max_concurrent_requests=%d", max_concurrent_requests));
632
+ return absl::StrCat("{", absl::StrJoin(contents, ", "), "}");
633
+ }
634
+
635
+ //
636
+ // XdsApi::EdsUpdate
637
+ //
638
+
639
+ std::string XdsApi::EdsUpdate::Priority::Locality::ToString() const {
640
+ std::vector<std::string> endpoint_strings;
641
+ for (const ServerAddress& endpoint : endpoints) {
642
+ endpoint_strings.emplace_back(endpoint.ToString());
643
+ }
644
+ return absl::StrCat("{name=", name->AsHumanReadableString(),
645
+ ", lb_weight=", lb_weight, ", endpoints=[",
646
+ absl::StrJoin(endpoint_strings, ", "), "]}");
647
+ }
648
+
649
+ bool XdsApi::EdsUpdate::Priority::operator==(const Priority& other) const {
650
+ if (localities.size() != other.localities.size()) return false;
651
+ auto it1 = localities.begin();
652
+ auto it2 = other.localities.begin();
653
+ while (it1 != localities.end()) {
654
+ if (*it1->first != *it2->first) return false;
655
+ if (it1->second != it2->second) return false;
656
+ ++it1;
657
+ ++it2;
658
+ }
659
+ return true;
660
+ }
661
+
662
+ std::string XdsApi::EdsUpdate::Priority::ToString() const {
663
+ std::vector<std::string> locality_strings;
664
+ for (const auto& p : localities) {
665
+ locality_strings.emplace_back(p.second.ToString());
666
+ }
667
+ return absl::StrCat("[", absl::StrJoin(locality_strings, ", "), "]");
668
+ }
669
+
670
+ bool XdsApi::EdsUpdate::DropConfig::ShouldDrop(
671
+ const std::string** category_name) const {
421
672
  for (size_t i = 0; i < drop_category_list_.size(); ++i) {
422
673
  const auto& drop_category = drop_category_list_[i];
423
674
  // Generate a random number in [0, 1000000).
@@ -430,6 +681,27 @@ bool XdsApi::DropConfig::ShouldDrop(const std::string** category_name) const {
430
681
  return false;
431
682
  }
432
683
 
684
+ std::string XdsApi::EdsUpdate::DropConfig::ToString() const {
685
+ std::vector<std::string> category_strings;
686
+ for (const DropCategory& category : drop_category_list_) {
687
+ category_strings.emplace_back(
688
+ absl::StrCat(category.name, "=", category.parts_per_million));
689
+ }
690
+ return absl::StrCat("{[", absl::StrJoin(category_strings, ", "),
691
+ "], drop_all=", drop_all_, "}");
692
+ }
693
+
694
+ std::string XdsApi::EdsUpdate::ToString() const {
695
+ std::vector<std::string> priority_strings;
696
+ for (size_t i = 0; i < priorities.size(); ++i) {
697
+ const Priority& priority = priorities[i];
698
+ priority_strings.emplace_back(
699
+ absl::StrCat("priority ", i, ": ", priority.ToString()));
700
+ }
701
+ return absl::StrCat("priorities=[", absl::StrJoin(priority_strings, ", "),
702
+ "], drop_config=", drop_config->ToString());
703
+ }
704
+
433
705
  //
434
706
  // XdsApi
435
707
  //
@@ -471,11 +743,10 @@ bool IsEds(absl::string_view type_url) {
471
743
  } // namespace
472
744
 
473
745
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
474
- const XdsBootstrap* bootstrap)
746
+ const XdsBootstrap::Node* node)
475
747
  : client_(client),
476
748
  tracer_(tracer),
477
- use_v3_(bootstrap != nullptr && bootstrap->server().ShouldUseV3()),
478
- bootstrap_(bootstrap),
749
+ node_(node),
479
750
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
480
751
  grpc_version_string())),
481
752
  user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {}
@@ -576,12 +847,10 @@ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
576
847
  encoded_build_version.size(), arena);
577
848
  }
578
849
 
579
- void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
850
+ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node, bool use_v3,
580
851
  const std::string& build_version,
581
852
  const std::string& user_agent_name,
582
- const std::string& server_name,
583
853
  envoy_config_core_v3_Node* node_msg) {
584
- const XdsBootstrap::Node* node = bootstrap->node();
585
854
  if (node != nullptr) {
586
855
  if (!node->id.empty()) {
587
856
  envoy_config_core_v3_Node_set_id(node_msg,
@@ -596,16 +865,6 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
596
865
  envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
597
866
  PopulateMetadata(arena, metadata, node->metadata.object_value());
598
867
  }
599
- if (!server_name.empty()) {
600
- google_protobuf_Struct* metadata =
601
- envoy_config_core_v3_Node_mutable_metadata(node_msg, arena);
602
- google_protobuf_Value* value = google_protobuf_Value_new(arena);
603
- google_protobuf_Value_set_string_value(value,
604
- StdStringToUpbString(server_name));
605
- google_protobuf_Struct_fields_set(
606
- metadata, upb_strview_makez("PROXYLESS_CLIENT_HOSTNAME"), value,
607
- arena);
608
- }
609
868
  if (!node->locality_region.empty() || !node->locality_zone.empty() ||
610
869
  !node->locality_subzone.empty()) {
611
870
  envoy_config_core_v3_Locality* locality =
@@ -624,7 +883,7 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
624
883
  }
625
884
  }
626
885
  }
627
- if (!bootstrap->server().ShouldUseV3()) {
886
+ if (!use_v3) {
628
887
  PopulateBuildVersion(arena, node_msg, build_version);
629
888
  }
630
889
  envoy_config_core_v3_Node_set_user_agent_name(
@@ -644,172 +903,17 @@ inline std::string UpbStringToStdString(const upb_strview& str) {
644
903
  return std::string(str.data, str.size);
645
904
  }
646
905
 
647
- inline void AddStringField(const char* name, const upb_strview& value,
648
- std::vector<std::string>* fields,
649
- bool add_if_empty = false) {
650
- if (value.size > 0 || add_if_empty) {
651
- fields->emplace_back(
652
- absl::StrCat(name, ": \"", UpbStringToAbsl(value), "\""));
653
- }
654
- }
655
-
656
- inline void AddUInt32ValueField(const char* name,
657
- const google_protobuf_UInt32Value* value,
658
- std::vector<std::string>* fields) {
659
- if (value != nullptr) {
660
- fields->emplace_back(absl::StrCat(
661
- name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
662
- }
663
- }
664
-
665
- inline void AddLocalityField(int indent_level,
666
- const envoy_config_core_v3_Locality* locality,
667
- std::vector<std::string>* fields) {
668
- std::string indent =
669
- absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
670
- // region
671
- std::string field = absl::StrCat(indent, "region");
672
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_region(locality),
673
- fields);
674
- // zone
675
- field = absl::StrCat(indent, "zone");
676
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_zone(locality),
677
- fields);
678
- // sub_zone
679
- field = absl::StrCat(indent, "sub_zone");
680
- AddStringField(field.c_str(),
681
- envoy_config_core_v3_Locality_sub_zone(locality), fields);
682
- }
683
-
684
- void AddNodeLogFields(const envoy_config_core_v3_Node* node,
685
- const std::string& build_version,
686
- std::vector<std::string>* fields) {
687
- fields->emplace_back("node {");
688
- // id
689
- AddStringField(" id", envoy_config_core_v3_Node_id(node), fields);
690
- // metadata
691
- const google_protobuf_Struct* metadata =
692
- envoy_config_core_v3_Node_metadata(node);
693
- if (metadata != nullptr) {
694
- fields->emplace_back(" metadata {");
695
- size_t entry_idx = UPB_MAP_BEGIN;
696
- while (true) {
697
- const google_protobuf_Struct_FieldsEntry* entry =
698
- google_protobuf_Struct_fields_next(metadata, &entry_idx);
699
- if (entry == nullptr) break;
700
- fields->emplace_back(" field {");
701
- // key
702
- AddStringField(" key", google_protobuf_Struct_FieldsEntry_key(entry),
703
- fields);
704
- // value
705
- const google_protobuf_Value* value =
706
- google_protobuf_Struct_FieldsEntry_value(entry);
707
- if (value != nullptr) {
708
- std::string value_str;
709
- if (google_protobuf_Value_has_string_value(value)) {
710
- value_str = absl::StrCat(
711
- "string_value: \"",
712
- UpbStringToAbsl(google_protobuf_Value_string_value(value)), "\"");
713
- } else if (google_protobuf_Value_has_null_value(value)) {
714
- value_str = "null_value: NULL_VALUE";
715
- } else if (google_protobuf_Value_has_number_value(value)) {
716
- value_str = absl::StrCat("double_value: ",
717
- google_protobuf_Value_number_value(value));
718
- } else if (google_protobuf_Value_has_bool_value(value)) {
719
- value_str = absl::StrCat("bool_value: ",
720
- google_protobuf_Value_bool_value(value));
721
- } else if (google_protobuf_Value_has_struct_value(value)) {
722
- value_str = "struct_value: <not printed>";
723
- } else if (google_protobuf_Value_has_list_value(value)) {
724
- value_str = "list_value: <not printed>";
725
- } else {
726
- value_str = "<unknown>";
727
- }
728
- fields->emplace_back(absl::StrCat(" value { ", value_str, " }"));
729
- }
730
- fields->emplace_back(" }");
731
- }
732
- fields->emplace_back(" }");
733
- }
734
- // locality
735
- const envoy_config_core_v3_Locality* locality =
736
- envoy_config_core_v3_Node_locality(node);
737
- if (locality != nullptr) {
738
- fields->emplace_back(" locality {");
739
- AddLocalityField(2, locality, fields);
740
- fields->emplace_back(" }");
741
- }
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
- }
747
- // user_agent_name
748
- AddStringField(" user_agent_name",
749
- envoy_config_core_v3_Node_user_agent_name(node), fields);
750
- // user_agent_version
751
- AddStringField(" user_agent_version",
752
- envoy_config_core_v3_Node_user_agent_version(node), fields);
753
- // client_features
754
- size_t num_client_features;
755
- const upb_strview* client_features =
756
- envoy_config_core_v3_Node_client_features(node, &num_client_features);
757
- for (size_t i = 0; i < num_client_features; ++i) {
758
- AddStringField(" client_features", client_features[i], fields);
759
- }
760
- fields->emplace_back("}");
761
- }
762
-
763
906
  void MaybeLogDiscoveryRequest(
764
- XdsClient* client, TraceFlag* tracer,
765
- const envoy_service_discovery_v3_DiscoveryRequest* request,
766
- const std::string& build_version) {
907
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
908
+ const envoy_service_discovery_v3_DiscoveryRequest* request) {
767
909
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
768
910
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
769
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
770
- // the raw proto instead of doing this manually.
771
- std::vector<std::string> fields;
772
- // version_info
773
- AddStringField(
774
- "version_info",
775
- envoy_service_discovery_v3_DiscoveryRequest_version_info(request),
776
- &fields);
777
- // node
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);
781
- // resource_names
782
- size_t num_resource_names;
783
- const upb_strview* resource_names =
784
- envoy_service_discovery_v3_DiscoveryRequest_resource_names(
785
- request, &num_resource_names);
786
- for (size_t i = 0; i < num_resource_names; ++i) {
787
- AddStringField("resource_names", resource_names[i], &fields);
788
- }
789
- // type_url
790
- AddStringField(
791
- "type_url",
792
- envoy_service_discovery_v3_DiscoveryRequest_type_url(request), &fields);
793
- // response_nonce
794
- AddStringField(
795
- "response_nonce",
796
- envoy_service_discovery_v3_DiscoveryRequest_response_nonce(request),
797
- &fields);
798
- // error_detail
799
- const struct google_rpc_Status* error_detail =
800
- envoy_service_discovery_v3_DiscoveryRequest_error_detail(request);
801
- if (error_detail != nullptr) {
802
- fields.emplace_back("error_detail {");
803
- // code
804
- int32_t code = google_rpc_Status_code(error_detail);
805
- if (code != 0) fields.emplace_back(absl::StrCat(" code: ", code));
806
- // message
807
- AddStringField(" message", google_rpc_Status_message(error_detail),
808
- &fields);
809
- fields.emplace_back("}");
810
- }
911
+ const upb_msgdef* msg_type =
912
+ envoy_service_discovery_v3_DiscoveryRequest_getmsgdef(symtab);
913
+ char buf[10240];
914
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
811
915
  gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s", client,
812
- absl::StrJoin(fields, "\n").c_str());
916
+ buf);
813
917
  }
814
918
  }
815
919
 
@@ -843,7 +947,7 @@ absl::string_view TypeUrlExternalToInternal(bool use_v3,
843
947
  } // namespace
844
948
 
845
949
  grpc_slice XdsApi::CreateAdsRequest(
846
- const std::string& type_url,
950
+ const XdsBootstrap::XdsServer& server, const std::string& type_url,
847
951
  const std::set<absl::string_view>& resource_names,
848
952
  const std::string& version, const std::string& nonce, grpc_error* error,
849
953
  bool populate_node) {
@@ -853,7 +957,7 @@ grpc_slice XdsApi::CreateAdsRequest(
853
957
  envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
854
958
  // Set type_url.
855
959
  absl::string_view real_type_url =
856
- TypeUrlExternalToInternal(use_v3_, type_url);
960
+ TypeUrlExternalToInternal(server.ShouldUseV3(), type_url);
857
961
  envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
858
962
  request, StdStringToUpbString(real_type_url));
859
963
  // Set version_info.
@@ -868,16 +972,20 @@ grpc_slice XdsApi::CreateAdsRequest(
868
972
  }
869
973
  // Set error_detail if it's a NACK.
870
974
  if (error != GRPC_ERROR_NONE) {
975
+ google_rpc_Status* error_detail =
976
+ envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
977
+ request, arena.ptr());
978
+ // Hard-code INVALID_ARGUMENT as the status code.
979
+ // TODO(roth): If at some point we decide we care about this value,
980
+ // we could attach a status code to the individual errors where we
981
+ // generate them in the parsing code, and then use that here.
982
+ google_rpc_Status_set_code(error_detail, GRPC_STATUS_INVALID_ARGUMENT);
983
+ // Error description comes from the error that was passed in.
871
984
  grpc_slice error_description_slice;
872
985
  GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
873
986
  &error_description_slice));
874
987
  upb_strview error_description_strview =
875
- upb_strview_make(reinterpret_cast<const char*>(
876
- GPR_SLICE_START_PTR(error_description_slice)),
877
- GPR_SLICE_LENGTH(error_description_slice));
878
- google_rpc_Status* error_detail =
879
- envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
880
- request, arena.ptr());
988
+ StdStringToUpbString(StringViewFromSlice(error_description_slice));
881
989
  google_rpc_Status_set_message(error_detail, error_description_strview);
882
990
  GRPC_ERROR_UNREF(error);
883
991
  }
@@ -886,401 +994,84 @@ grpc_slice XdsApi::CreateAdsRequest(
886
994
  envoy_config_core_v3_Node* node_msg =
887
995
  envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
888
996
  arena.ptr());
889
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_, "",
890
- node_msg);
997
+ PopulateNode(arena.ptr(), node_, server.ShouldUseV3(), build_version_,
998
+ user_agent_name_, node_msg);
891
999
  }
892
1000
  // Add resource_names.
893
1001
  for (const auto& resource_name : resource_names) {
894
1002
  envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
895
1003
  request, StdStringToUpbString(resource_name), arena.ptr());
896
1004
  }
897
- MaybeLogDiscoveryRequest(client_, tracer_, request, build_version_);
1005
+ MaybeLogDiscoveryRequest(client_, tracer_, symtab_.ptr(), request);
898
1006
  return SerializeDiscoveryRequest(arena.ptr(), request);
899
1007
  }
900
1008
 
901
1009
  namespace {
902
1010
 
903
1011
  void MaybeLogDiscoveryResponse(
904
- XdsClient* client, TraceFlag* tracer,
1012
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
905
1013
  const envoy_service_discovery_v3_DiscoveryResponse* response) {
906
1014
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
907
1015
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
908
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
909
- // the raw proto instead of doing this manually.
910
- std::vector<std::string> fields;
911
- // version_info
912
- AddStringField(
913
- "version_info",
914
- envoy_service_discovery_v3_DiscoveryResponse_version_info(response),
915
- &fields);
916
- // resources
917
- size_t num_resources;
918
- envoy_service_discovery_v3_DiscoveryResponse_resources(response,
919
- &num_resources);
920
- fields.emplace_back(
921
- absl::StrCat("resources: <", num_resources, " element(s)>"));
922
- // type_url
923
- AddStringField(
924
- "type_url",
925
- envoy_service_discovery_v3_DiscoveryResponse_type_url(response),
926
- &fields);
927
- // nonce
928
- AddStringField("nonce",
929
- envoy_service_discovery_v3_DiscoveryResponse_nonce(response),
930
- &fields);
931
- gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
932
- absl::StrJoin(fields, "\n").c_str());
1016
+ const upb_msgdef* msg_type =
1017
+ envoy_service_discovery_v3_DiscoveryResponse_getmsgdef(symtab);
1018
+ char buf[10240];
1019
+ upb_text_encode(response, msg_type, nullptr, 0, buf, sizeof(buf));
1020
+ gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client, buf);
933
1021
  }
934
1022
  }
935
1023
 
936
1024
  void MaybeLogRouteConfiguration(
937
- XdsClient* client, TraceFlag* tracer,
1025
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
938
1026
  const envoy_config_route_v3_RouteConfiguration* route_config) {
939
1027
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
940
1028
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
941
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
942
- // the raw proto instead of doing this manually.
943
- std::vector<std::string> fields;
944
- // name
945
- AddStringField("name",
946
- envoy_config_route_v3_RouteConfiguration_name(route_config),
947
- &fields);
948
- // virtual_hosts
949
- size_t 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);
953
- for (size_t i = 0; i < num_virtual_hosts; ++i) {
954
- const auto* virtual_host = virtual_hosts[i];
955
- fields.push_back("virtual_hosts {");
956
- // name
957
- AddStringField(" name",
958
- envoy_config_route_v3_VirtualHost_name(virtual_host),
959
- &fields);
960
- // domains
961
- size_t num_domains;
962
- const upb_strview* const domains =
963
- envoy_config_route_v3_VirtualHost_domains(virtual_host, &num_domains);
964
- for (size_t j = 0; j < num_domains; ++j) {
965
- AddStringField(" domains", domains[j], &fields);
966
- }
967
- // routes
968
- size_t num_routes;
969
- const envoy_config_route_v3_Route* const* routes =
970
- envoy_config_route_v3_VirtualHost_routes(virtual_host, &num_routes);
971
- for (size_t j = 0; j < num_routes; ++j) {
972
- const auto* route = routes[j];
973
- fields.push_back(" route {");
974
- // name
975
- AddStringField(" name", envoy_config_route_v3_Route_name(route),
976
- &fields);
977
- // match
978
- const envoy_config_route_v3_RouteMatch* match =
979
- envoy_config_route_v3_Route_match(route);
980
- if (match != nullptr) {
981
- fields.emplace_back(" match {");
982
- // path matching
983
- if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
984
- AddStringField(" prefix",
985
- envoy_config_route_v3_RouteMatch_prefix(match),
986
- &fields,
987
- /*add_if_empty=*/true);
988
- } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
989
- AddStringField(" path",
990
- envoy_config_route_v3_RouteMatch_path(match),
991
- &fields,
992
- /*add_if_empty=*/true);
993
- } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
994
- fields.emplace_back(" safe_regex: <not printed>");
995
- } else {
996
- fields.emplace_back(" <unknown path matching type>");
997
- }
998
- // header matching
999
- size_t num_headers;
1000
- envoy_config_route_v3_RouteMatch_headers(match, &num_headers);
1001
- if (num_headers > 0) {
1002
- fields.emplace_back(
1003
- absl::StrCat(" headers: <", num_headers, " element(s)>"));
1004
- }
1005
- fields.emplace_back(" }");
1006
- }
1007
- // action
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);
1011
- fields.emplace_back(" route {");
1012
- if (envoy_config_route_v3_RouteAction_has_cluster(action)) {
1013
- AddStringField(" cluster",
1014
- envoy_config_route_v3_RouteAction_cluster(action),
1015
- &fields);
1016
- } else if (envoy_config_route_v3_RouteAction_has_cluster_header(
1017
- action)) {
1018
- AddStringField(
1019
- " cluster_header",
1020
- envoy_config_route_v3_RouteAction_cluster_header(action),
1021
- &fields);
1022
- } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
1023
- action)) {
1024
- const envoy_config_route_v3_WeightedCluster* weighted_clusters =
1025
- envoy_config_route_v3_RouteAction_weighted_clusters(action);
1026
- fields.emplace_back(" weighted_clusters {");
1027
- size_t 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);
1032
- for (size_t i = 0; i < num_cluster_weights; ++i) {
1033
- const envoy_config_route_v3_WeightedCluster_ClusterWeight*
1034
- cluster_weight = cluster_weights[i];
1035
- fields.emplace_back(" clusters {");
1036
- AddStringField(
1037
- " name",
1038
- envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
1039
- cluster_weight),
1040
- &fields);
1041
- AddUInt32ValueField(
1042
- " weight",
1043
- envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
1044
- cluster_weight),
1045
- &fields);
1046
- fields.emplace_back(" }");
1047
- }
1048
- AddUInt32ValueField(
1049
- " total_weight",
1050
- envoy_config_route_v3_WeightedCluster_total_weight(
1051
- weighted_clusters),
1052
- &fields);
1053
- fields.emplace_back(" }");
1054
- }
1055
- fields.emplace_back(" }");
1056
- } else if (envoy_config_route_v3_Route_has_redirect(route)) {
1057
- fields.emplace_back(" redirect: <not printed>");
1058
- } else if (envoy_config_route_v3_Route_has_direct_response(route)) {
1059
- fields.emplace_back(" direct_response: <not printed>");
1060
- } else if (envoy_config_route_v3_Route_has_filter_action(route)) {
1061
- fields.emplace_back(" filter_action: <not printed>");
1062
- }
1063
- fields.push_back(" }");
1064
- }
1065
- fields.push_back("}");
1066
- }
1067
- gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client,
1068
- absl::StrJoin(fields, "\n").c_str());
1029
+ const upb_msgdef* msg_type =
1030
+ envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab);
1031
+ char buf[10240];
1032
+ upb_text_encode(route_config, msg_type, nullptr, 0, buf, sizeof(buf));
1033
+ gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client, buf);
1069
1034
  }
1070
1035
  }
1071
1036
 
1072
- void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
1037
+ void MaybeLogCluster(XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1073
1038
  const envoy_config_cluster_v3_Cluster* cluster) {
1074
1039
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1075
1040
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1076
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1077
- // the raw proto instead of doing this manually.
1078
- std::vector<std::string> fields;
1079
- // name
1080
- AddStringField("name", envoy_config_cluster_v3_Cluster_name(cluster),
1081
- &fields);
1082
- // type
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)) {
1087
- fields.emplace_back("cluster_type: <not printed>");
1088
- } else {
1089
- fields.emplace_back("<unknown type>");
1090
- }
1091
- // eds_cluster_config
1092
- const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1093
- envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
1094
- if (eds_cluster_config != nullptr) {
1095
- fields.emplace_back("eds_cluster_config {");
1096
- // eds_config
1097
- const struct envoy_config_core_v3_ConfigSource* eds_config =
1098
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1099
- eds_cluster_config);
1100
- if (eds_config != nullptr) {
1101
- if (envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
1102
- fields.emplace_back(" eds_config { ads {} }");
1103
- } else {
1104
- fields.emplace_back(" eds_config: <non-ADS type>");
1105
- }
1106
- }
1107
- // service_name
1108
- AddStringField(
1109
- " service_name",
1110
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1111
- eds_cluster_config),
1112
- &fields);
1113
- fields.emplace_back("}");
1114
- }
1115
- // lb_policy
1116
- fields.emplace_back(absl::StrCat(
1117
- "lb_policy: ", envoy_config_cluster_v3_Cluster_lb_policy(cluster)));
1118
- // lrs_server
1119
- const envoy_config_core_v3_ConfigSource* lrs_server =
1120
- envoy_config_cluster_v3_Cluster_lrs_server(cluster);
1121
- if (lrs_server != nullptr) {
1122
- if (envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
1123
- fields.emplace_back("lrs_server { self {} }");
1124
- } else {
1125
- fields.emplace_back("lrs_server: <non-self type>");
1126
- }
1127
- }
1128
- gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client,
1129
- absl::StrJoin(fields, "\n").c_str());
1041
+ const upb_msgdef* msg_type =
1042
+ envoy_config_cluster_v3_Cluster_getmsgdef(symtab);
1043
+ char buf[10240];
1044
+ upb_text_encode(cluster, msg_type, nullptr, 0, buf, sizeof(buf));
1045
+ gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client, buf);
1130
1046
  }
1131
1047
  }
1132
1048
 
1133
1049
  void MaybeLogClusterLoadAssignment(
1134
- XdsClient* client, TraceFlag* tracer,
1050
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1135
1051
  const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
1136
1052
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1137
1053
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1138
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1139
- // the raw proto instead of doing this manually.
1140
- std::vector<std::string> fields;
1141
- // cluster_name
1142
- AddStringField(
1143
- "cluster_name",
1144
- envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(cla),
1145
- &fields);
1146
- // endpoints
1147
- size_t num_localities;
1148
- const struct envoy_config_endpoint_v3_LocalityLbEndpoints* const*
1149
- locality_endpoints =
1150
- envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1151
- cla, &num_localities);
1152
- for (size_t i = 0; i < num_localities; ++i) {
1153
- const auto* locality_endpoint = locality_endpoints[i];
1154
- fields.emplace_back("endpoints {");
1155
- // locality
1156
- const auto* locality =
1157
- envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
1158
- locality_endpoint);
1159
- if (locality != nullptr) {
1160
- fields.emplace_back(" locality {");
1161
- AddLocalityField(2, locality, &fields);
1162
- fields.emplace_back(" }");
1163
- }
1164
- // lb_endpoints
1165
- size_t num_lb_endpoints;
1166
- const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
1167
- envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
1168
- locality_endpoint, &num_lb_endpoints);
1169
- for (size_t j = 0; j < num_lb_endpoints; ++j) {
1170
- const auto* lb_endpoint = lb_endpoints[j];
1171
- fields.emplace_back(" lb_endpoints {");
1172
- // health_status
1173
- uint32_t health_status =
1174
- envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
1175
- if (health_status > 0) {
1176
- fields.emplace_back(
1177
- absl::StrCat(" health_status: ", health_status));
1178
- }
1179
- // endpoint
1180
- const envoy_config_endpoint_v3_Endpoint* endpoint =
1181
- envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
1182
- if (endpoint != nullptr) {
1183
- fields.emplace_back(" endpoint {");
1184
- // address
1185
- const auto* address =
1186
- envoy_config_endpoint_v3_Endpoint_address(endpoint);
1187
- if (address != nullptr) {
1188
- fields.emplace_back(" address {");
1189
- // socket_address
1190
- const auto* socket_address =
1191
- envoy_config_core_v3_Address_socket_address(address);
1192
- if (socket_address != nullptr) {
1193
- fields.emplace_back(" socket_address {");
1194
- // address
1195
- AddStringField(
1196
- " address",
1197
- envoy_config_core_v3_SocketAddress_address(socket_address),
1198
- &fields);
1199
- // port_value
1200
- if (envoy_config_core_v3_SocketAddress_has_port_value(
1201
- socket_address)) {
1202
- fields.emplace_back(
1203
- absl::StrCat(" port_value: ",
1204
- envoy_config_core_v3_SocketAddress_port_value(
1205
- socket_address)));
1206
- } else {
1207
- fields.emplace_back(" <non-numeric port>");
1208
- }
1209
- fields.emplace_back(" }");
1210
- } else {
1211
- fields.emplace_back(" <non-socket address>");
1212
- }
1213
- fields.emplace_back(" }");
1214
- }
1215
- fields.emplace_back(" }");
1216
- }
1217
- fields.emplace_back(" }");
1218
- }
1219
- // load_balancing_weight
1220
- AddUInt32ValueField(
1221
- " load_balancing_weight",
1222
- envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
1223
- locality_endpoint),
1224
- &fields);
1225
- // priority
1226
- uint32_t priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1227
- locality_endpoint);
1228
- if (priority > 0) {
1229
- fields.emplace_back(absl::StrCat(" priority: ", priority));
1230
- }
1231
- fields.emplace_back("}");
1232
- }
1233
- // policy
1234
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
1235
- envoy_config_endpoint_v3_ClusterLoadAssignment_policy(cla);
1236
- if (policy != nullptr) {
1237
- fields.emplace_back("policy {");
1238
- // drop_overloads
1239
- size_t num_drop_overloads;
1240
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
1241
- drop_overloads =
1242
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
1243
- policy, &num_drop_overloads);
1244
- for (size_t i = 0; i < num_drop_overloads; ++i) {
1245
- auto* drop_overload = drop_overloads[i];
1246
- fields.emplace_back(" drop_overloads {");
1247
- // category
1248
- AddStringField(
1249
- " category",
1250
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
1251
- drop_overload),
1252
- &fields);
1253
- // drop_percentage
1254
- const auto* drop_percentage =
1255
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1256
- drop_overload);
1257
- if (drop_percentage != nullptr) {
1258
- fields.emplace_back(" drop_percentage {");
1259
- fields.emplace_back(absl::StrCat(
1260
- " numerator: ",
1261
- envoy_type_v3_FractionalPercent_numerator(drop_percentage)));
1262
- fields.emplace_back(absl::StrCat(
1263
- " denominator: ",
1264
- envoy_type_v3_FractionalPercent_denominator(drop_percentage)));
1265
- fields.emplace_back(" }");
1266
- }
1267
- fields.emplace_back(" }");
1268
- }
1269
- // overprovisioning_factor
1270
- fields.emplace_back("}");
1271
- }
1054
+ const upb_msgdef* msg_type =
1055
+ envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab);
1056
+ char buf[10240];
1057
+ upb_text_encode(cla, msg_type, nullptr, 0, buf, sizeof(buf));
1272
1058
  gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s", client,
1273
- absl::StrJoin(fields, "\n").c_str());
1059
+ buf);
1274
1060
  }
1275
1061
  }
1276
1062
 
1277
1063
  grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1278
1064
  XdsApi::Route* route, bool* ignore_route) {
1065
+ auto* case_sensitive = envoy_config_route_v3_RouteMatch_case_sensitive(match);
1066
+ if (case_sensitive != nullptr) {
1067
+ route->matchers.path_matcher.case_sensitive =
1068
+ google_protobuf_BoolValue_value(case_sensitive);
1069
+ }
1279
1070
  if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1280
1071
  absl::string_view prefix =
1281
1072
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
1282
1073
  // Empty prefix "" is accepted.
1283
- if (prefix.size() > 0) {
1074
+ if (!prefix.empty()) {
1284
1075
  // Prefix "/" is accepted.
1285
1076
  if (prefix[0] != '/') {
1286
1077
  // Prefix which does not start with a / will never match anything, so
@@ -1306,7 +1097,7 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1306
1097
  } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1307
1098
  absl::string_view path =
1308
1099
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
1309
- if (path.size() == 0) {
1100
+ if (path.empty()) {
1310
1101
  // Path that is empty will never match anything, so ignore this route.
1311
1102
  *ignore_route = true;
1312
1103
  return GRPC_ERROR_NONE;
@@ -1344,7 +1135,9 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1344
1135
  GPR_ASSERT(regex_matcher != nullptr);
1345
1136
  std::string matcher = UpbStringToStdString(
1346
1137
  envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1347
- std::unique_ptr<RE2> regex = absl::make_unique<RE2>(std::move(matcher));
1138
+ RE2::Options options;
1139
+ options.set_case_sensitive(route->matchers.path_matcher.case_sensitive);
1140
+ auto regex = absl::make_unique<RE2>(std::move(matcher), options);
1348
1141
  if (!regex->ok()) {
1349
1142
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1350
1143
  "Invalid regex string specified in path matcher.");
@@ -1473,7 +1266,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1473
1266
  if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
1474
1267
  route->cluster_name = UpbStringToStdString(
1475
1268
  envoy_config_route_v3_RouteAction_cluster(route_action));
1476
- if (route->cluster_name.size() == 0) {
1269
+ if (route->cluster_name.empty()) {
1477
1270
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1478
1271
  "RouteAction cluster contains empty cluster name.");
1479
1272
  }
@@ -1512,6 +1305,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1512
1305
  "RouteAction weighted_cluster cluster missing weight");
1513
1306
  }
1514
1307
  cluster.weight = google_protobuf_UInt32Value_value(weight);
1308
+ if (cluster.weight == 0) continue;
1515
1309
  sum_of_weights += cluster.weight;
1516
1310
  route->weighted_clusters.emplace_back(std::move(cluster));
1517
1311
  }
@@ -1526,16 +1320,36 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1526
1320
  } else {
1527
1321
  // No cluster or weighted_clusters found in RouteAction, ignore this route.
1528
1322
  *ignore_route = true;
1529
- return GRPC_ERROR_NONE;
1323
+ }
1324
+ if (XdsTimeoutEnabled() && !*ignore_route) {
1325
+ const envoy_config_route_v3_RouteAction_MaxStreamDuration*
1326
+ max_stream_duration =
1327
+ envoy_config_route_v3_RouteAction_max_stream_duration(route_action);
1328
+ if (max_stream_duration != nullptr) {
1329
+ const google_protobuf_Duration* duration =
1330
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_grpc_timeout_header_max(
1331
+ max_stream_duration);
1332
+ if (duration == nullptr) {
1333
+ duration =
1334
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_max_stream_duration(
1335
+ max_stream_duration);
1336
+ }
1337
+ if (duration != nullptr) {
1338
+ XdsApi::Duration duration_in_route;
1339
+ duration_in_route.seconds = google_protobuf_Duration_seconds(duration);
1340
+ duration_in_route.nanos = google_protobuf_Duration_nanos(duration);
1341
+ route->max_stream_duration = duration_in_route;
1342
+ }
1343
+ }
1530
1344
  }
1531
1345
  return GRPC_ERROR_NONE;
1532
1346
  }
1533
1347
 
1534
1348
  grpc_error* RouteConfigParse(
1535
- XdsClient* client, TraceFlag* tracer,
1349
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1536
1350
  const envoy_config_route_v3_RouteConfiguration* route_config,
1537
1351
  XdsApi::RdsUpdate* rds_update) {
1538
- MaybeLogRouteConfiguration(client, tracer, route_config);
1352
+ MaybeLogRouteConfiguration(client, tracer, symtab, route_config);
1539
1353
  // Get the virtual hosts.
1540
1354
  size_t size;
1541
1355
  const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
@@ -1552,7 +1366,9 @@ grpc_error* RouteConfigParse(
1552
1366
  std::string domain_pattern = UpbStringToStdString(domains[j]);
1553
1367
  const MatchType match_type = DomainPatternMatchType(domain_pattern);
1554
1368
  if (match_type == INVALID_MATCH) {
1555
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Invalid domain pattern.");
1369
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1370
+ absl::StrCat("Invalid domain pattern \"", domain_pattern, "\".")
1371
+ .c_str());
1556
1372
  }
1557
1373
  vhost.domains.emplace_back(std::move(domain_pattern));
1558
1374
  }
@@ -1589,13 +1405,6 @@ grpc_error* RouteConfigParse(
1589
1405
  error = RouteActionParse(routes[j], &route, &ignore_route);
1590
1406
  if (error != GRPC_ERROR_NONE) return error;
1591
1407
  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.");
1598
- }
1599
1408
  vhost.routes.emplace_back(std::move(route));
1600
1409
  }
1601
1410
  if (vhost.routes.empty()) {
@@ -1606,10 +1415,10 @@ grpc_error* RouteConfigParse(
1606
1415
  }
1607
1416
 
1608
1417
  grpc_error* LdsResponseParse(
1609
- XdsClient* client, TraceFlag* tracer,
1418
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1610
1419
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1611
- const std::string& expected_server_name,
1612
- absl::optional<XdsApi::LdsUpdate>* lds_update, upb_arena* arena) {
1420
+ const std::set<absl::string_view>& expected_listener_names,
1421
+ XdsApi::LdsUpdateMap* lds_update_map, upb_arena* arena) {
1613
1422
  // Get the resources from the response.
1614
1423
  size_t size;
1615
1424
  const google_protobuf_Any* const* resources =
@@ -1631,9 +1440,19 @@ grpc_error* LdsResponseParse(
1631
1440
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode listener.");
1632
1441
  }
1633
1442
  // Check listener name. Ignore unexpected listeners.
1634
- absl::string_view name =
1635
- UpbStringToAbsl(envoy_config_listener_v3_Listener_name(listener));
1636
- if (name != expected_server_name) continue;
1443
+ std::string listener_name =
1444
+ UpbStringToStdString(envoy_config_listener_v3_Listener_name(listener));
1445
+ if (expected_listener_names.find(listener_name) ==
1446
+ expected_listener_names.end()) {
1447
+ continue;
1448
+ }
1449
+ // Fail if listener name is duplicated.
1450
+ if (lds_update_map->find(listener_name) != lds_update_map->end()) {
1451
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1452
+ absl::StrCat("duplicate listener name \"", listener_name, "\"")
1453
+ .c_str());
1454
+ }
1455
+ XdsApi::LdsUpdate& lds_update = (*lds_update_map)[listener_name];
1637
1456
  // Get api_listener and decode it to http_connection_manager.
1638
1457
  const envoy_config_listener_v3_ApiListener* api_listener =
1639
1458
  envoy_config_listener_v3_Listener_api_listener(listener);
@@ -1651,6 +1470,23 @@ grpc_error* LdsResponseParse(
1651
1470
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1652
1471
  "Could not parse HttpConnectionManager config from ApiListener");
1653
1472
  }
1473
+ if (XdsTimeoutEnabled()) {
1474
+ // Obtain max_stream_duration from Http Protocol Options.
1475
+ const envoy_config_core_v3_HttpProtocolOptions* options =
1476
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
1477
+ http_connection_manager);
1478
+ if (options != nullptr) {
1479
+ const google_protobuf_Duration* duration =
1480
+ envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(
1481
+ options);
1482
+ if (duration != nullptr) {
1483
+ lds_update.http_max_stream_duration.seconds =
1484
+ google_protobuf_Duration_seconds(duration);
1485
+ lds_update.http_max_stream_duration.nanos =
1486
+ google_protobuf_Duration_nanos(duration);
1487
+ }
1488
+ }
1489
+ }
1654
1490
  // Found inlined route_config. Parse it to find the cluster_name.
1655
1491
  if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
1656
1492
  http_connection_manager)) {
@@ -1659,11 +1495,10 @@ grpc_error* LdsResponseParse(
1659
1495
  http_connection_manager);
1660
1496
  XdsApi::RdsUpdate rds_update;
1661
1497
  grpc_error* error =
1662
- RouteConfigParse(client, tracer, route_config, &rds_update);
1498
+ RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
1663
1499
  if (error != GRPC_ERROR_NONE) return error;
1664
- lds_update->emplace();
1665
- (*lds_update)->rds_update = std::move(rds_update);
1666
- return GRPC_ERROR_NONE;
1500
+ lds_update.rds_update = std::move(rds_update);
1501
+ continue;
1667
1502
  }
1668
1503
  // Validate that RDS must be used to get the route_config dynamically.
1669
1504
  if (!envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_rds(
@@ -1687,20 +1522,18 @@ grpc_error* LdsResponseParse(
1687
1522
  "HttpConnectionManager ConfigSource for RDS does not specify ADS.");
1688
1523
  }
1689
1524
  // Get the route_config_name.
1690
- lds_update->emplace();
1691
- (*lds_update)->route_config_name = UpbStringToStdString(
1525
+ lds_update.route_config_name = UpbStringToStdString(
1692
1526
  envoy_extensions_filters_network_http_connection_manager_v3_Rds_route_config_name(
1693
1527
  rds));
1694
- return GRPC_ERROR_NONE;
1695
1528
  }
1696
1529
  return GRPC_ERROR_NONE;
1697
1530
  }
1698
1531
 
1699
1532
  grpc_error* RdsResponseParse(
1700
- XdsClient* client, TraceFlag* tracer,
1533
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1701
1534
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1702
1535
  const std::set<absl::string_view>& expected_route_configuration_names,
1703
- absl::optional<XdsApi::RdsUpdate>* rds_update, upb_arena* arena) {
1536
+ XdsApi::RdsUpdateMap* rds_update_map, upb_arena* arena) {
1704
1537
  // Get the resources from the response.
1705
1538
  size_t size;
1706
1539
  const google_protobuf_Any* const* resources =
@@ -1722,25 +1555,141 @@ grpc_error* RdsResponseParse(
1722
1555
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode route_config.");
1723
1556
  }
1724
1557
  // Check route_config_name. Ignore unexpected route_config.
1725
- absl::string_view route_config_name = UpbStringToAbsl(
1558
+ std::string route_config_name = UpbStringToStdString(
1726
1559
  envoy_config_route_v3_RouteConfiguration_name(route_config));
1727
1560
  if (expected_route_configuration_names.find(route_config_name) ==
1728
1561
  expected_route_configuration_names.end()) {
1729
1562
  continue;
1730
1563
  }
1564
+ // Fail if route config name is duplicated.
1565
+ if (rds_update_map->find(route_config_name) != rds_update_map->end()) {
1566
+ return GRPC_ERROR_CREATE_FROM_COPIED_STRING(
1567
+ absl::StrCat("duplicate route config name \"", route_config_name,
1568
+ "\"")
1569
+ .c_str());
1570
+ }
1731
1571
  // Parse the route_config.
1732
- XdsApi::RdsUpdate local_rds_update;
1572
+ XdsApi::RdsUpdate& rds_update =
1573
+ (*rds_update_map)[std::move(route_config_name)];
1733
1574
  grpc_error* error =
1734
- RouteConfigParse(client, tracer, route_config, &local_rds_update);
1575
+ RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
1735
1576
  if (error != GRPC_ERROR_NONE) return error;
1736
- rds_update->emplace(std::move(local_rds_update));
1737
- return GRPC_ERROR_NONE;
1577
+ }
1578
+ return GRPC_ERROR_NONE;
1579
+ }
1580
+
1581
+ XdsApi::CommonTlsContext::CertificateProviderInstance
1582
+ CertificateProviderInstanceParse(
1583
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
1584
+ certificate_provider_instance_proto) {
1585
+ return {
1586
+ UpbStringToStdString(
1587
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1588
+ certificate_provider_instance_proto)),
1589
+ UpbStringToStdString(
1590
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
1591
+ certificate_provider_instance_proto))};
1592
+ }
1593
+
1594
+ grpc_error* CommonTlsContextParse(
1595
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1596
+ common_tls_context_proto,
1597
+ XdsApi::CommonTlsContext* common_tls_context) GRPC_MUST_USE_RESULT;
1598
+ grpc_error* CommonTlsContextParse(
1599
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1600
+ common_tls_context_proto,
1601
+ XdsApi::CommonTlsContext* common_tls_context) {
1602
+ auto* combined_validation_context =
1603
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
1604
+ common_tls_context_proto);
1605
+ if (combined_validation_context != nullptr) {
1606
+ auto* default_validation_context =
1607
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
1608
+ combined_validation_context);
1609
+ if (default_validation_context != nullptr) {
1610
+ size_t len = 0;
1611
+ auto* subject_alt_names_matchers =
1612
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
1613
+ default_validation_context, &len);
1614
+ for (size_t i = 0; i < len; ++i) {
1615
+ XdsApi::StringMatcher::StringMatcherType type;
1616
+ std::string matcher;
1617
+ if (envoy_type_matcher_v3_StringMatcher_has_exact(
1618
+ subject_alt_names_matchers[i])) {
1619
+ type = XdsApi::StringMatcher::StringMatcherType::EXACT;
1620
+ matcher =
1621
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_exact(
1622
+ subject_alt_names_matchers[i]));
1623
+ } else if (envoy_type_matcher_v3_StringMatcher_has_prefix(
1624
+ subject_alt_names_matchers[i])) {
1625
+ type = XdsApi::StringMatcher::StringMatcherType::PREFIX;
1626
+ matcher =
1627
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_prefix(
1628
+ subject_alt_names_matchers[i]));
1629
+ } else if (envoy_type_matcher_v3_StringMatcher_has_suffix(
1630
+ subject_alt_names_matchers[i])) {
1631
+ type = XdsApi::StringMatcher::StringMatcherType::SUFFIX;
1632
+ matcher =
1633
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_suffix(
1634
+ subject_alt_names_matchers[i]));
1635
+ } else if (envoy_type_matcher_v3_StringMatcher_has_contains(
1636
+ subject_alt_names_matchers[i])) {
1637
+ type = XdsApi::StringMatcher::StringMatcherType::CONTAINS;
1638
+ matcher =
1639
+ UpbStringToStdString(envoy_type_matcher_v3_StringMatcher_contains(
1640
+ subject_alt_names_matchers[i]));
1641
+ } else if (envoy_type_matcher_v3_StringMatcher_has_safe_regex(
1642
+ subject_alt_names_matchers[i])) {
1643
+ type = XdsApi::StringMatcher::StringMatcherType::SAFE_REGEX;
1644
+ auto* regex_matcher = envoy_type_matcher_v3_StringMatcher_safe_regex(
1645
+ subject_alt_names_matchers[i]);
1646
+ matcher = UpbStringToStdString(
1647
+ envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1648
+ } else {
1649
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1650
+ "Invalid StringMatcher specified");
1651
+ }
1652
+ bool ignore_case = envoy_type_matcher_v3_StringMatcher_ignore_case(
1653
+ subject_alt_names_matchers[i]);
1654
+ XdsApi::StringMatcher string_matcher(type, matcher, ignore_case);
1655
+ if (type == XdsApi::StringMatcher::StringMatcherType::SAFE_REGEX) {
1656
+ if (!string_matcher.regex_matcher()->ok()) {
1657
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1658
+ "Invalid regex string specified in string matcher.");
1659
+ }
1660
+ if (ignore_case) {
1661
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1662
+ "StringMatcher: ignore_case has no effect for SAFE_REGEX.");
1663
+ }
1664
+ }
1665
+ common_tls_context->combined_validation_context
1666
+ .default_validation_context.match_subject_alt_names.push_back(
1667
+ std::move(string_matcher));
1668
+ }
1669
+ }
1670
+ auto* validation_context_certificate_provider_instance =
1671
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
1672
+ combined_validation_context);
1673
+ if (validation_context_certificate_provider_instance != nullptr) {
1674
+ common_tls_context->combined_validation_context
1675
+ .validation_context_certificate_provider_instance =
1676
+ CertificateProviderInstanceParse(
1677
+ validation_context_certificate_provider_instance);
1678
+ }
1679
+ }
1680
+ auto* tls_certificate_certificate_provider_instance =
1681
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
1682
+ common_tls_context_proto);
1683
+ if (tls_certificate_certificate_provider_instance != nullptr) {
1684
+ common_tls_context->tls_certificate_certificate_provider_instance =
1685
+ CertificateProviderInstanceParse(
1686
+ tls_certificate_certificate_provider_instance);
1738
1687
  }
1739
1688
  return GRPC_ERROR_NONE;
1740
1689
  }
1741
1690
 
1742
1691
  grpc_error* CdsResponseParse(
1743
- XdsClient* client, TraceFlag* tracer,
1692
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1744
1693
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1745
1694
  const std::set<absl::string_view>& expected_cluster_names,
1746
1695
  XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
@@ -1750,7 +1699,6 @@ grpc_error* CdsResponseParse(
1750
1699
  envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1751
1700
  // Parse all the resources in the CDS response.
1752
1701
  for (size_t i = 0; i < size; ++i) {
1753
- XdsApi::CdsUpdate cds_update;
1754
1702
  // Check the type_url of the resource.
1755
1703
  absl::string_view type_url =
1756
1704
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
@@ -1765,7 +1713,7 @@ grpc_error* CdsResponseParse(
1765
1713
  if (cluster == nullptr) {
1766
1714
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode cluster.");
1767
1715
  }
1768
- MaybeLogCluster(client, tracer, cluster);
1716
+ MaybeLogCluster(client, tracer, symtab, cluster);
1769
1717
  // Ignore unexpected cluster names.
1770
1718
  std::string cluster_name =
1771
1719
  UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
@@ -1779,6 +1727,7 @@ grpc_error* CdsResponseParse(
1779
1727
  absl::StrCat("duplicate resource name \"", cluster_name, "\"")
1780
1728
  .c_str());
1781
1729
  }
1730
+ XdsApi::CdsUpdate& cds_update = (*cds_update_map)[std::move(cluster_name)];
1782
1731
  // Check the cluster_discovery_type.
1783
1732
  if (!envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1784
1733
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("DiscoveryType not found.");
@@ -1810,6 +1759,47 @@ grpc_error* CdsResponseParse(
1810
1759
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1811
1760
  "LB policy is not ROUND_ROBIN.");
1812
1761
  }
1762
+ if (XdsSecurityEnabled()) {
1763
+ // Record Upstream tls context
1764
+ auto* transport_socket =
1765
+ envoy_config_cluster_v3_Cluster_transport_socket(cluster);
1766
+ if (transport_socket != nullptr) {
1767
+ absl::string_view name = UpbStringToAbsl(
1768
+ envoy_config_core_v3_TransportSocket_name(transport_socket));
1769
+ if (name == "envoy.transport_sockets.tls") {
1770
+ auto* typed_config =
1771
+ envoy_config_core_v3_TransportSocket_typed_config(
1772
+ transport_socket);
1773
+ if (typed_config != nullptr) {
1774
+ const upb_strview encoded_upstream_tls_context =
1775
+ google_protobuf_Any_value(typed_config);
1776
+ auto* upstream_tls_context =
1777
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
1778
+ encoded_upstream_tls_context.data,
1779
+ encoded_upstream_tls_context.size, arena);
1780
+ if (upstream_tls_context == nullptr) {
1781
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1782
+ "Can't decode upstream tls context.");
1783
+ }
1784
+ auto* common_tls_context =
1785
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
1786
+ upstream_tls_context);
1787
+ if (common_tls_context != nullptr) {
1788
+ grpc_error* error = CommonTlsContextParse(
1789
+ common_tls_context, &cds_update.common_tls_context);
1790
+ if (error != GRPC_ERROR_NONE) return error;
1791
+ }
1792
+ }
1793
+ if (cds_update.common_tls_context.combined_validation_context
1794
+ .validation_context_certificate_provider_instance
1795
+ .instance_name.empty()) {
1796
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1797
+ "TLS configuration provided but no "
1798
+ "validation_context_certificate_provider_instance found.");
1799
+ }
1800
+ }
1801
+ }
1802
+ }
1813
1803
  // Record LRS server name (if any).
1814
1804
  const envoy_config_core_v3_ConfigSource* lrs_server =
1815
1805
  envoy_config_cluster_v3_Cluster_lrs_server(cluster);
@@ -1820,7 +1810,32 @@ grpc_error* CdsResponseParse(
1820
1810
  }
1821
1811
  cds_update.lrs_load_reporting_server_name.emplace("");
1822
1812
  }
1823
- cds_update_map->emplace(std::move(cluster_name), std::move(cds_update));
1813
+ // The Cluster resource encodes the circuit breaking parameters in a list of
1814
+ // Thresholds messages, where each message specifies the parameters for a
1815
+ // particular RoutingPriority. we will look only at the first entry in the
1816
+ // list for priority DEFAULT and default to 1024 if not found.
1817
+ if (envoy_config_cluster_v3_Cluster_has_circuit_breakers(cluster)) {
1818
+ const envoy_config_cluster_v3_CircuitBreakers* circuit_breakers =
1819
+ envoy_config_cluster_v3_Cluster_circuit_breakers(cluster);
1820
+ size_t num_thresholds;
1821
+ const envoy_config_cluster_v3_CircuitBreakers_Thresholds* const*
1822
+ thresholds = envoy_config_cluster_v3_CircuitBreakers_thresholds(
1823
+ circuit_breakers, &num_thresholds);
1824
+ for (size_t i = 0; i < num_thresholds; ++i) {
1825
+ const auto* threshold = thresholds[i];
1826
+ if (envoy_config_cluster_v3_CircuitBreakers_Thresholds_priority(
1827
+ threshold) == envoy_config_core_v3_DEFAULT) {
1828
+ const google_protobuf_UInt32Value* max_requests =
1829
+ envoy_config_cluster_v3_CircuitBreakers_Thresholds_max_requests(
1830
+ threshold);
1831
+ if (max_requests != nullptr) {
1832
+ cds_update.max_concurrent_requests =
1833
+ google_protobuf_UInt32Value_value(max_requests);
1834
+ }
1835
+ break;
1836
+ }
1837
+ }
1838
+ }
1824
1839
  }
1825
1840
  return GRPC_ERROR_NONE;
1826
1841
  }
@@ -1858,7 +1873,7 @@ grpc_error* ServerAddressParseAndAppend(
1858
1873
 
1859
1874
  grpc_error* LocalityParse(
1860
1875
  const envoy_config_endpoint_v3_LocalityLbEndpoints* locality_lb_endpoints,
1861
- XdsApi::PriorityListUpdate::LocalityMap::Locality* output_locality) {
1876
+ XdsApi::EdsUpdate::Priority::Locality* output_locality, size_t* priority) {
1862
1877
  // Parse LB weight.
1863
1878
  const google_protobuf_UInt32Value* lb_weight =
1864
1879
  envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
@@ -1888,25 +1903,24 @@ grpc_error* LocalityParse(
1888
1903
  locality_lb_endpoints, &size);
1889
1904
  for (size_t i = 0; i < size; ++i) {
1890
1905
  grpc_error* error = ServerAddressParseAndAppend(
1891
- lb_endpoints[i], &output_locality->serverlist);
1906
+ lb_endpoints[i], &output_locality->endpoints);
1892
1907
  if (error != GRPC_ERROR_NONE) return error;
1893
1908
  }
1894
1909
  // Parse the priority.
1895
- output_locality->priority =
1896
- envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1897
- locality_lb_endpoints);
1910
+ *priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1911
+ locality_lb_endpoints);
1898
1912
  return GRPC_ERROR_NONE;
1899
1913
  }
1900
1914
 
1901
1915
  grpc_error* DropParseAndAppend(
1902
1916
  const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload*
1903
1917
  drop_overload,
1904
- XdsApi::DropConfig* drop_config) {
1918
+ XdsApi::EdsUpdate::DropConfig* drop_config) {
1905
1919
  // Get the category.
1906
1920
  std::string category = UpbStringToStdString(
1907
1921
  envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
1908
1922
  drop_overload));
1909
- if (category.size() == 0) {
1923
+ if (category.empty()) {
1910
1924
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
1911
1925
  }
1912
1926
  // Get the drop rate (per million).
@@ -1938,7 +1952,7 @@ grpc_error* DropParseAndAppend(
1938
1952
  }
1939
1953
 
1940
1954
  grpc_error* EdsResponseParse(
1941
- XdsClient* client, TraceFlag* tracer,
1955
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1942
1956
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1943
1957
  const std::set<absl::string_view>& expected_eds_service_names,
1944
1958
  XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
@@ -1947,7 +1961,6 @@ grpc_error* EdsResponseParse(
1947
1961
  const google_protobuf_Any* const* resources =
1948
1962
  envoy_service_discovery_v3_DiscoveryResponse_resources(response, &size);
1949
1963
  for (size_t i = 0; i < size; ++i) {
1950
- XdsApi::EdsUpdate eds_update;
1951
1964
  // Check the type_url of the resource.
1952
1965
  absl::string_view type_url =
1953
1966
  UpbStringToAbsl(google_protobuf_Any_type_url(resources[i]));
@@ -1965,7 +1978,8 @@ grpc_error* EdsResponseParse(
1965
1978
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1966
1979
  "Can't parse cluster_load_assignment.");
1967
1980
  }
1968
- MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
1981
+ MaybeLogClusterLoadAssignment(client, tracer, symtab,
1982
+ cluster_load_assignment);
1969
1983
  // Check the EDS service name. Ignore unexpected names.
1970
1984
  std::string eds_service_name = UpbStringToStdString(
1971
1985
  envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
@@ -1980,29 +1994,36 @@ grpc_error* EdsResponseParse(
1980
1994
  absl::StrCat("duplicate resource name \"", eds_service_name, "\"")
1981
1995
  .c_str());
1982
1996
  }
1997
+ XdsApi::EdsUpdate& eds_update =
1998
+ (*eds_update_map)[std::move(eds_service_name)];
1983
1999
  // Get the endpoints.
1984
2000
  size_t locality_size;
1985
2001
  const envoy_config_endpoint_v3_LocalityLbEndpoints* const* endpoints =
1986
2002
  envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1987
2003
  cluster_load_assignment, &locality_size);
1988
2004
  for (size_t j = 0; j < locality_size; ++j) {
1989
- XdsApi::PriorityListUpdate::LocalityMap::Locality locality;
1990
- grpc_error* error = LocalityParse(endpoints[j], &locality);
2005
+ size_t priority;
2006
+ XdsApi::EdsUpdate::Priority::Locality locality;
2007
+ grpc_error* error = LocalityParse(endpoints[j], &locality, &priority);
1991
2008
  if (error != GRPC_ERROR_NONE) return error;
1992
2009
  // Filter out locality with weight 0.
1993
2010
  if (locality.lb_weight == 0) continue;
1994
- eds_update.priority_list_update.Add(locality);
2011
+ // Make sure prorities is big enough. Note that they might not
2012
+ // arrive in priority order.
2013
+ while (eds_update.priorities.size() < priority + 1) {
2014
+ eds_update.priorities.emplace_back();
2015
+ }
2016
+ eds_update.priorities[priority].localities.emplace(locality.name.get(),
2017
+ std::move(locality));
1995
2018
  }
1996
- for (uint32_t priority = 0;
1997
- priority < eds_update.priority_list_update.size(); ++priority) {
1998
- auto* locality_map = eds_update.priority_list_update.Find(priority);
1999
- if (locality_map == nullptr || locality_map->size() == 0) {
2019
+ for (const auto& priority : eds_update.priorities) {
2020
+ if (priority.localities.empty()) {
2000
2021
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2001
2022
  "EDS update includes sparse priority list");
2002
2023
  }
2003
2024
  }
2004
2025
  // Get the drop config.
2005
- eds_update.drop_config = MakeRefCounted<XdsApi::DropConfig>();
2026
+ eds_update.drop_config = MakeRefCounted<XdsApi::EdsUpdate::DropConfig>();
2006
2027
  const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
2007
2028
  envoy_config_endpoint_v3_ClusterLoadAssignment_policy(
2008
2029
  cluster_load_assignment);
@@ -2018,7 +2039,6 @@ grpc_error* EdsResponseParse(
2018
2039
  if (error != GRPC_ERROR_NONE) return error;
2019
2040
  }
2020
2041
  }
2021
- eds_update_map->emplace(std::move(eds_service_name), std::move(eds_update));
2022
2042
  }
2023
2043
  return GRPC_ERROR_NONE;
2024
2044
  }
@@ -2039,7 +2059,8 @@ std::string TypeUrlInternalToExternal(absl::string_view type_url) {
2039
2059
  } // namespace
2040
2060
 
2041
2061
  XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2042
- const grpc_slice& encoded_response, const std::string& expected_server_name,
2062
+ const grpc_slice& encoded_response,
2063
+ const std::set<absl::string_view>& expected_listener_names,
2043
2064
  const std::set<absl::string_view>& expected_route_configuration_names,
2044
2065
  const std::set<absl::string_view>& expected_cluster_names,
2045
2066
  const std::set<absl::string_view>& expected_eds_service_names) {
@@ -2056,7 +2077,7 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2056
2077
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
2057
2078
  return result;
2058
2079
  }
2059
- MaybeLogDiscoveryResponse(client_, tracer_, response);
2080
+ MaybeLogDiscoveryResponse(client_, tracer_, symtab_.ptr(), response);
2060
2081
  // Record the type_url, the version_info, and the nonce of the response.
2061
2082
  result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
2062
2083
  envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
@@ -2066,21 +2087,22 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2066
2087
  envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
2067
2088
  // Parse the response according to the resource type.
2068
2089
  if (IsLds(result.type_url)) {
2069
- result.parse_error =
2070
- LdsResponseParse(client_, tracer_, response, expected_server_name,
2071
- &result.lds_update, arena.ptr());
2090
+ result.parse_error = LdsResponseParse(client_, tracer_, symtab_.ptr(),
2091
+ response, expected_listener_names,
2092
+ &result.lds_update_map, arena.ptr());
2072
2093
  } 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
2094
  result.parse_error =
2078
- CdsResponseParse(client_, tracer_, response, expected_cluster_names,
2079
- &result.cds_update_map, arena.ptr());
2095
+ RdsResponseParse(client_, tracer_, symtab_.ptr(), response,
2096
+ expected_route_configuration_names,
2097
+ &result.rds_update_map, arena.ptr());
2098
+ } else if (IsCds(result.type_url)) {
2099
+ result.parse_error = CdsResponseParse(client_, tracer_, symtab_.ptr(),
2100
+ response, expected_cluster_names,
2101
+ &result.cds_update_map, arena.ptr());
2080
2102
  } 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());
2103
+ result.parse_error = EdsResponseParse(client_, tracer_, symtab_.ptr(),
2104
+ response, expected_eds_service_names,
2105
+ &result.eds_update_map, arena.ptr());
2084
2106
  }
2085
2107
  return result;
2086
2108
  }
@@ -2088,120 +2110,16 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2088
2110
  namespace {
2089
2111
 
2090
2112
  void MaybeLogLrsRequest(
2091
- XdsClient* client, TraceFlag* tracer,
2092
- const envoy_service_load_stats_v3_LoadStatsRequest* request,
2093
- const std::string& build_version) {
2113
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
2114
+ const envoy_service_load_stats_v3_LoadStatsRequest* request) {
2094
2115
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
2095
2116
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
2096
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
2097
- // the raw proto instead of doing this manually.
2098
- std::vector<std::string> fields;
2099
- // node
2100
- const auto* node =
2101
- envoy_service_load_stats_v3_LoadStatsRequest_node(request);
2102
- if (node != nullptr) {
2103
- AddNodeLogFields(node, build_version, &fields);
2104
- }
2105
- // cluster_stats
2106
- size_t num_cluster_stats;
2107
- const struct envoy_config_endpoint_v3_ClusterStats* const* cluster_stats =
2108
- envoy_service_load_stats_v3_LoadStatsRequest_cluster_stats(
2109
- request, &num_cluster_stats);
2110
- for (size_t i = 0; i < num_cluster_stats; ++i) {
2111
- const auto* cluster_stat = cluster_stats[i];
2112
- fields.emplace_back("cluster_stats {");
2113
- // cluster_name
2114
- AddStringField(
2115
- " cluster_name",
2116
- envoy_config_endpoint_v3_ClusterStats_cluster_name(cluster_stat),
2117
- &fields);
2118
- // cluster_service_name
2119
- AddStringField(" cluster_service_name",
2120
- envoy_config_endpoint_v3_ClusterStats_cluster_service_name(
2121
- cluster_stat),
2122
- &fields);
2123
- // upstream_locality_stats
2124
- size_t num_stats;
2125
- const envoy_config_endpoint_v3_UpstreamLocalityStats* const* stats =
2126
- envoy_config_endpoint_v3_ClusterStats_upstream_locality_stats(
2127
- cluster_stat, &num_stats);
2128
- for (size_t j = 0; j < num_stats; ++j) {
2129
- const auto* stat = stats[j];
2130
- fields.emplace_back(" upstream_locality_stats {");
2131
- // locality
2132
- const auto* locality =
2133
- envoy_config_endpoint_v3_UpstreamLocalityStats_locality(stat);
2134
- if (locality != nullptr) {
2135
- fields.emplace_back(" locality {");
2136
- AddLocalityField(3, locality, &fields);
2137
- fields.emplace_back(" }");
2138
- }
2139
- // total_successful_requests
2140
- fields.emplace_back(absl::StrCat(
2141
- " total_successful_requests: ",
2142
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_successful_requests(
2143
- stat)));
2144
- // total_requests_in_progress
2145
- fields.emplace_back(absl::StrCat(
2146
- " total_requests_in_progress: ",
2147
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_requests_in_progress(
2148
- stat)));
2149
- // total_error_requests
2150
- fields.emplace_back(absl::StrCat(
2151
- " total_error_requests: ",
2152
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_error_requests(
2153
- stat)));
2154
- // total_issued_requests
2155
- fields.emplace_back(absl::StrCat(
2156
- " total_issued_requests: ",
2157
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_issued_requests(
2158
- stat)));
2159
- fields.emplace_back(" }");
2160
- }
2161
- // total_dropped_requests
2162
- fields.emplace_back(absl::StrCat(
2163
- " total_dropped_requests: ",
2164
- envoy_config_endpoint_v3_ClusterStats_total_dropped_requests(
2165
- cluster_stat)));
2166
- // dropped_requests
2167
- size_t 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);
2171
- for (size_t j = 0; j < num_drops; ++j) {
2172
- const auto* drop = drops[j];
2173
- fields.emplace_back(" dropped_requests {");
2174
- // category
2175
- AddStringField(
2176
- " category",
2177
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_category(
2178
- drop),
2179
- &fields);
2180
- // dropped_count
2181
- fields.emplace_back(absl::StrCat(
2182
- " dropped_count: ",
2183
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_dropped_count(
2184
- drop)));
2185
- fields.emplace_back(" }");
2186
- }
2187
- // load_report_interval
2188
- const auto* load_report_interval =
2189
- envoy_config_endpoint_v3_ClusterStats_load_report_interval(
2190
- cluster_stat);
2191
- if (load_report_interval != nullptr) {
2192
- fields.emplace_back(" load_report_interval {");
2193
- fields.emplace_back(absl::StrCat(
2194
- " seconds: ",
2195
- google_protobuf_Duration_seconds(load_report_interval)));
2196
- fields.emplace_back(
2197
- absl::StrCat(" nanos: ",
2198
- google_protobuf_Duration_nanos(load_report_interval)));
2199
- fields.emplace_back(" }");
2200
- }
2201
- fields.emplace_back("}");
2202
- }
2117
+ const upb_msgdef* msg_type =
2118
+ envoy_service_load_stats_v3_LoadStatsRequest_getmsgdef(symtab);
2119
+ char buf[10240];
2120
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
2203
2121
  gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s", client,
2204
- absl::StrJoin(fields, "\n").c_str());
2122
+ buf);
2205
2123
  }
2206
2124
  }
2207
2125
 
@@ -2216,7 +2134,8 @@ grpc_slice SerializeLrsRequest(
2216
2134
 
2217
2135
  } // namespace
2218
2136
 
2219
- grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
2137
+ grpc_slice XdsApi::CreateLrsInitialRequest(
2138
+ const XdsBootstrap::XdsServer& server) {
2220
2139
  upb::Arena arena;
2221
2140
  // Create a request.
2222
2141
  envoy_service_load_stats_v3_LoadStatsRequest* request =
@@ -2225,12 +2144,12 @@ grpc_slice XdsApi::CreateLrsInitialRequest(const std::string& server_name) {
2225
2144
  envoy_config_core_v3_Node* node_msg =
2226
2145
  envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
2227
2146
  arena.ptr());
2228
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
2229
- server_name, node_msg);
2147
+ PopulateNode(arena.ptr(), node_, server.ShouldUseV3(), build_version_,
2148
+ user_agent_name_, node_msg);
2230
2149
  envoy_config_core_v3_Node_add_client_features(
2231
2150
  node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
2232
2151
  arena.ptr());
2233
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2152
+ MaybeLogLrsRequest(client_, tracer_, symtab_.ptr(), request);
2234
2153
  return SerializeLrsRequest(request, arena.ptr());
2235
2154
  }
2236
2155
 
@@ -2317,7 +2236,7 @@ grpc_slice XdsApi::CreateLrsRequest(
2317
2236
  }
2318
2237
  // Add dropped requests.
2319
2238
  uint64_t total_dropped_requests = 0;
2320
- for (const auto& p : load_report.dropped_requests) {
2239
+ for (const auto& p : load_report.dropped_requests.categorized_drops) {
2321
2240
  const std::string& category = p.first;
2322
2241
  const uint64_t count = p.second;
2323
2242
  envoy_config_endpoint_v3_ClusterStats_DroppedRequests* dropped_requests =
@@ -2329,6 +2248,7 @@ grpc_slice XdsApi::CreateLrsRequest(
2329
2248
  dropped_requests, count);
2330
2249
  total_dropped_requests += count;
2331
2250
  }
2251
+ total_dropped_requests += load_report.dropped_requests.uncategorized_drops;
2332
2252
  // Set total dropped requests.
2333
2253
  envoy_config_endpoint_v3_ClusterStats_set_total_dropped_requests(
2334
2254
  cluster_stats, total_dropped_requests);
@@ -2341,7 +2261,7 @@ grpc_slice XdsApi::CreateLrsRequest(
2341
2261
  google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
2342
2262
  google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
2343
2263
  }
2344
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2264
+ MaybeLogLrsRequest(client_, tracer_, symtab_.ptr(), request);
2345
2265
  return SerializeLrsRequest(request, arena.ptr());
2346
2266
  }
2347
2267