grpc 1.33.0.pre1 → 1.34.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 (533) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +342 -134
  3. data/include/grpc/grpc.h +1 -2
  4. data/include/grpc/grpc_security.h +149 -172
  5. data/include/grpc/impl/codegen/grpc_types.h +9 -2
  6. data/include/grpc/impl/codegen/port_platform.h +22 -55
  7. data/src/core/ext/filters/client_channel/client_channel.cc +11 -34
  8. data/src/core/ext/filters/client_channel/config_selector.h +2 -3
  9. data/src/core/ext/filters/client_channel/health/health_check_client.cc +4 -1
  10. data/src/core/ext/filters/client_channel/health/health_check_client.h +2 -2
  11. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +1 -1
  12. data/src/core/ext/filters/client_channel/lb_policy.cc +5 -1
  13. data/src/core/ext/filters/client_channel/lb_policy.h +3 -3
  14. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +1 -1
  15. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +1 -1
  16. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +80 -71
  17. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +3 -1
  18. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +2 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +47 -17
  20. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +2 -2
  21. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -5
  22. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +3 -3
  23. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +1 -1
  24. data/src/core/ext/filters/client_channel/lb_policy/xds/eds.cc +16 -243
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.h +53 -17
  26. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +809 -0
  27. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +20 -25
  28. data/src/core/ext/filters/client_channel/resolver.cc +3 -1
  29. data/src/core/ext/filters/client_channel/resolver.h +4 -1
  30. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  31. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +1 -1
  32. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
  33. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +1 -1
  34. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -1
  35. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +20 -0
  36. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +66 -7
  37. data/src/core/ext/filters/client_channel/resolver_registry.cc +4 -4
  38. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +13 -25
  39. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +1 -1
  40. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +2 -2
  41. data/src/core/ext/filters/client_channel/retry_throttle.h +1 -1
  42. data/src/core/ext/filters/client_channel/server_address.h +0 -4
  43. data/src/core/ext/filters/client_channel/service_config.cc +3 -1
  44. data/src/core/ext/filters/client_channel/service_config.h +1 -1
  45. data/src/core/ext/filters/client_channel/subchannel.cc +18 -15
  46. data/src/core/ext/filters/client_channel/subchannel.h +2 -2
  47. data/src/core/ext/filters/client_channel/subchannel_interface.h +7 -15
  48. data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +6 -2
  49. data/src/core/ext/filters/deadline/deadline_filter.cc +83 -77
  50. data/src/core/ext/filters/deadline/deadline_filter.h +7 -11
  51. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -1
  52. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -3
  53. data/src/core/ext/filters/max_age/max_age_filter.cc +1 -1
  54. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +1 -1
  55. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +17 -3
  56. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -7
  57. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +4 -24
  58. data/src/core/ext/transport/chttp2/transport/flow_control.h +2 -2
  59. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
  60. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +12 -8
  61. data/src/core/ext/transport/chttp2/transport/internal.h +0 -1
  62. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
  63. data/src/core/ext/transport/chttp2/transport/writing.cc +1 -2
  64. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.c +38 -0
  65. data/src/core/ext/upbdefs-generated/envoy/annotations/deprecation.upbdefs.h +30 -0
  66. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.c +41 -0
  67. data/src/core/ext/upbdefs-generated/envoy/annotations/resource.upbdefs.h +35 -0
  68. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.c +254 -0
  69. data/src/core/ext/upbdefs-generated/envoy/config/accesslog/v3/accesslog.upbdefs.h +105 -0
  70. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.c +100 -0
  71. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/circuit_breaker.upbdefs.h +45 -0
  72. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +558 -0
  73. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +145 -0
  74. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.c +53 -0
  75. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/filter.upbdefs.h +35 -0
  76. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.c +133 -0
  77. data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/outlier_detection.upbdefs.h +35 -0
  78. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.c +127 -0
  79. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/address.upbdefs.h +65 -0
  80. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.c +56 -0
  81. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/backoff.upbdefs.h +35 -0
  82. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +266 -0
  83. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +125 -0
  84. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.c +143 -0
  85. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/config_source.upbdefs.h +55 -0
  86. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.c +56 -0
  87. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/event_service_config.upbdefs.h +35 -0
  88. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.c +66 -0
  89. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/extension.upbdefs.h +40 -0
  90. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.c +263 -0
  91. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/grpc_service.upbdefs.h +100 -0
  92. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +233 -0
  93. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.h +70 -0
  94. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.c +56 -0
  95. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/http_uri.upbdefs.h +35 -0
  96. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +228 -0
  97. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.h +80 -0
  98. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.c +46 -0
  99. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/proxy_protocol.upbdefs.h +35 -0
  100. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.c +59 -0
  101. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/socket_option.upbdefs.h +35 -0
  102. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.c +55 -0
  103. data/src/core/ext/upbdefs-generated/envoy/config/core/v3/substitution_format_string.upbdefs.h +35 -0
  104. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.c +110 -0
  105. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint.upbdefs.h +50 -0
  106. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +113 -0
  107. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.h +50 -0
  108. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.c +146 -0
  109. data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/load_report.upbdefs.h +55 -0
  110. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.c +50 -0
  111. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/api_listener.upbdefs.h +35 -0
  112. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.c +190 -0
  113. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener.upbdefs.h +55 -0
  114. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.c +185 -0
  115. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/listener_components.upbdefs.h +65 -0
  116. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.c +62 -0
  117. data/src/core/ext/upbdefs-generated/envoy/config/listener/v3/udp_listener_config.upbdefs.h +40 -0
  118. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.c +97 -0
  119. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route.upbdefs.h +40 -0
  120. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +915 -0
  121. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.h +280 -0
  122. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.c +71 -0
  123. data/src/core/ext/upbdefs-generated/envoy/config/route/v3/scoped_route.upbdefs.h +45 -0
  124. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.c +64 -0
  125. data/src/core/ext/upbdefs-generated/envoy/config/trace/v3/http_tracer.upbdefs.h +40 -0
  126. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.c +511 -0
  127. data/src/core/ext/upbdefs-generated/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upbdefs.h +115 -0
  128. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.c +48 -0
  129. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/cert.upbdefs.h +30 -0
  130. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.c +166 -0
  131. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/common.upbdefs.h +55 -0
  132. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.c +105 -0
  133. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/secret.upbdefs.h +45 -0
  134. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.c +249 -0
  135. data/src/core/ext/upbdefs-generated/envoy/extensions/transport_sockets/tls/v3/tls.upbdefs.h +60 -0
  136. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.c +72 -0
  137. data/src/core/ext/upbdefs-generated/envoy/service/cluster/v3/cds.upbdefs.h +35 -0
  138. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.c +60 -0
  139. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/ads.upbdefs.h +35 -0
  140. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.c +152 -0
  141. data/src/core/ext/upbdefs-generated/envoy/service/discovery/v3/discovery.upbdefs.h +60 -0
  142. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.c +83 -0
  143. data/src/core/ext/upbdefs-generated/envoy/service/endpoint/v3/eds.upbdefs.h +35 -0
  144. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.c +82 -0
  145. data/src/core/ext/upbdefs-generated/envoy/service/listener/v3/lds.upbdefs.h +35 -0
  146. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.c +83 -0
  147. data/src/core/ext/upbdefs-generated/envoy/service/load_stats/v3/lrs.upbdefs.h +40 -0
  148. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.c +86 -0
  149. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/rds.upbdefs.h +35 -0
  150. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.c +74 -0
  151. data/src/core/ext/upbdefs-generated/envoy/service/route/v3/srds.upbdefs.h +35 -0
  152. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.c +64 -0
  153. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/metadata.upbdefs.h +40 -0
  154. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.c +54 -0
  155. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/number.upbdefs.h +35 -0
  156. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.c +53 -0
  157. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/path.upbdefs.h +35 -0
  158. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.c +73 -0
  159. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/regex.upbdefs.h +45 -0
  160. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.c +72 -0
  161. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/string.upbdefs.h +40 -0
  162. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.c +81 -0
  163. data/src/core/ext/upbdefs-generated/envoy/type/matcher/v3/value.upbdefs.h +45 -0
  164. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.c +92 -0
  165. data/src/core/ext/upbdefs-generated/envoy/type/metadata/v3/metadata.upbdefs.h +65 -0
  166. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.c +95 -0
  167. data/src/core/ext/upbdefs-generated/envoy/type/tracing/v3/custom_tag.upbdefs.h +55 -0
  168. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.c +34 -0
  169. data/src/core/ext/upbdefs-generated/envoy/type/v3/http.upbdefs.h +30 -0
  170. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.c +59 -0
  171. data/src/core/ext/upbdefs-generated/envoy/type/v3/percent.upbdefs.h +40 -0
  172. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.c +54 -0
  173. data/src/core/ext/upbdefs-generated/envoy/type/v3/range.upbdefs.h +45 -0
  174. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.c +47 -0
  175. data/src/core/ext/upbdefs-generated/envoy/type/v3/semantic_version.upbdefs.h +35 -0
  176. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.c +40 -0
  177. data/src/core/ext/upbdefs-generated/google/api/annotations.upbdefs.h +30 -0
  178. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.c +61 -0
  179. data/src/core/ext/upbdefs-generated/google/api/http.upbdefs.h +45 -0
  180. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.c +38 -0
  181. data/src/core/ext/upbdefs-generated/google/protobuf/any.upbdefs.h +35 -0
  182. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.c +386 -0
  183. data/src/core/ext/upbdefs-generated/google/protobuf/descriptor.upbdefs.h +165 -0
  184. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.c +39 -0
  185. data/src/core/ext/upbdefs-generated/google/protobuf/duration.upbdefs.h +35 -0
  186. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.c +37 -0
  187. data/src/core/ext/upbdefs-generated/google/protobuf/empty.upbdefs.h +35 -0
  188. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.c +65 -0
  189. data/src/core/ext/upbdefs-generated/google/protobuf/struct.upbdefs.h +50 -0
  190. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.c +39 -0
  191. data/src/core/ext/upbdefs-generated/google/protobuf/timestamp.upbdefs.h +35 -0
  192. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.c +66 -0
  193. data/src/core/ext/upbdefs-generated/google/protobuf/wrappers.upbdefs.h +75 -0
  194. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.c +42 -0
  195. data/src/core/ext/upbdefs-generated/google/rpc/status.upbdefs.h +35 -0
  196. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +70 -0
  197. data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.h +45 -0
  198. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +56 -0
  199. data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.h +35 -0
  200. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +33 -0
  201. data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.h +30 -0
  202. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +49 -0
  203. data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.h +35 -0
  204. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +43 -0
  205. data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.h +35 -0
  206. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.c +42 -0
  207. data/src/core/ext/upbdefs-generated/udpa/core/v1/authority.upbdefs.h +35 -0
  208. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.c +62 -0
  209. data/src/core/ext/upbdefs-generated/udpa/core/v1/collection_entry.upbdefs.h +40 -0
  210. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.c +45 -0
  211. data/src/core/ext/upbdefs-generated/udpa/core/v1/context_params.upbdefs.h +40 -0
  212. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.c +49 -0
  213. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource.upbdefs.h +35 -0
  214. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.c +68 -0
  215. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_locator.upbdefs.h +40 -0
  216. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.c +51 -0
  217. data/src/core/ext/upbdefs-generated/udpa/core/v1/resource_name.upbdefs.h +35 -0
  218. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.c +307 -0
  219. data/src/core/ext/upbdefs-generated/validate/validate.upbdefs.h +145 -0
  220. data/src/core/ext/xds/certificate_provider_factory.h +7 -5
  221. data/src/core/ext/xds/certificate_provider_store.cc +84 -0
  222. data/src/core/ext/xds/certificate_provider_store.h +65 -8
  223. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +119 -0
  224. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +72 -0
  225. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.cc +28 -140
  226. data/src/core/ext/xds/google_mesh_ca_certificate_provider_factory.h +6 -4
  227. data/src/core/ext/xds/xds_api.cc +241 -718
  228. data/src/core/ext/xds/xds_api.h +50 -9
  229. data/src/core/ext/xds/xds_bootstrap.cc +172 -25
  230. data/src/core/ext/xds/xds_bootstrap.h +23 -7
  231. data/src/core/ext/xds/xds_certificate_provider.cc +240 -0
  232. data/src/core/ext/xds/xds_certificate_provider.h +74 -0
  233. data/src/core/ext/xds/xds_client.cc +161 -128
  234. data/src/core/ext/xds/xds_client.h +12 -11
  235. data/src/core/ext/xds/xds_client_stats.cc +41 -4
  236. data/src/core/ext/xds/xds_client_stats.h +2 -2
  237. data/src/core/lib/channel/channel_args.cc +2 -1
  238. data/src/core/lib/channel/channel_trace.cc +4 -2
  239. data/src/core/lib/channel/channelz.h +2 -2
  240. data/src/core/lib/channel/handshaker.h +2 -2
  241. data/src/core/lib/compression/compression.cc +8 -4
  242. data/src/core/lib/compression/compression_internal.cc +10 -5
  243. data/src/core/lib/compression/compression_internal.h +2 -1
  244. data/src/core/lib/compression/stream_compression_identity.cc +1 -3
  245. data/src/core/lib/debug/stats_data.cc +1 -0
  246. data/src/core/lib/gpr/cpu_iphone.cc +10 -2
  247. data/src/core/lib/gpr/log_linux.cc +17 -3
  248. data/src/core/lib/gpr/log_posix.cc +13 -1
  249. data/src/core/lib/gpr/log_windows.cc +16 -4
  250. data/src/core/lib/gpr/murmur_hash.cc +1 -1
  251. data/src/core/lib/gpr/string.cc +1 -1
  252. data/src/core/lib/gpr/time_precise.cc +3 -2
  253. data/src/core/lib/gpr/tls.h +4 -0
  254. data/src/core/lib/gpr/tls_msvc.h +2 -0
  255. data/src/core/lib/gpr/tls_stdcpp.h +48 -0
  256. data/src/core/lib/gpr/useful.h +5 -4
  257. data/src/core/lib/gprpp/dual_ref_counted.h +44 -49
  258. data/src/core/lib/gprpp/examine_stack.cc +43 -0
  259. data/src/core/lib/gprpp/examine_stack.h +46 -0
  260. data/src/core/lib/gprpp/fork.cc +2 -2
  261. data/src/core/lib/gprpp/manual_constructor.h +1 -1
  262. data/src/core/lib/gprpp/orphanable.h +4 -8
  263. data/src/core/lib/gprpp/ref_counted.h +40 -46
  264. data/src/core/lib/gprpp/ref_counted_ptr.h +9 -11
  265. data/src/core/lib/{security/authorization/mock_cel/statusor.h → gprpp/stat.h} +13 -25
  266. data/src/core/lib/gprpp/stat_posix.cc +49 -0
  267. data/src/core/lib/gprpp/stat_windows.cc +48 -0
  268. data/src/core/lib/gprpp/thd.h +2 -2
  269. data/src/core/lib/gprpp/thd_posix.cc +36 -36
  270. data/src/core/lib/http/parser.cc +46 -25
  271. data/src/core/lib/iomgr/error.cc +2 -1
  272. data/src/core/lib/iomgr/ev_epollex_linux.cc +8 -4
  273. data/src/core/lib/iomgr/exec_ctx.cc +1 -1
  274. data/src/core/lib/iomgr/executor/mpmcqueue.h +5 -5
  275. data/src/core/lib/iomgr/executor/threadpool.h +3 -3
  276. data/src/core/lib/iomgr/parse_address.cc +84 -6
  277. data/src/core/lib/iomgr/parse_address.h +20 -0
  278. data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +2 -1
  279. data/src/core/lib/iomgr/python_util.h +3 -3
  280. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -5
  281. data/src/core/lib/iomgr/tcp_posix.cc +3 -2
  282. data/src/core/lib/iomgr/timer_custom.cc +2 -2
  283. data/src/core/lib/iomgr/unix_sockets_posix.cc +27 -15
  284. data/src/core/lib/iomgr/unix_sockets_posix.h +5 -0
  285. data/src/core/lib/iomgr/unix_sockets_posix_noop.cc +7 -0
  286. data/src/core/lib/iomgr/wakeup_fd_pipe.cc +2 -2
  287. data/src/core/lib/json/json.h +2 -2
  288. data/src/core/lib/json/json_reader.cc +8 -4
  289. data/src/core/lib/json/json_util.h +167 -0
  290. data/src/core/lib/json/json_writer.cc +2 -1
  291. data/src/core/lib/security/authorization/mock_cel/cel_expr_builder_factory.h +3 -1
  292. data/src/core/lib/security/authorization/mock_cel/cel_expression.h +5 -4
  293. data/src/core/lib/security/authorization/mock_cel/cel_value.h +4 -0
  294. data/src/core/lib/security/authorization/mock_cel/evaluator_core.h +6 -6
  295. data/src/core/lib/security/authorization/mock_cel/flat_expr_builder.h +10 -9
  296. data/src/core/lib/security/context/security_context.h +3 -1
  297. data/src/core/lib/security/credentials/credentials.cc +1 -1
  298. data/src/core/lib/security/credentials/credentials.h +3 -3
  299. data/src/core/lib/security/credentials/external/aws_request_signer.cc +208 -0
  300. data/src/core/lib/security/credentials/external/aws_request_signer.h +73 -0
  301. data/src/core/lib/security/credentials/external/external_account_credentials.cc +311 -0
  302. data/src/core/lib/security/credentials/external/external_account_credentials.h +118 -0
  303. data/src/core/lib/security/credentials/external/file_external_account_credentials.cc +136 -0
  304. data/src/core/lib/security/credentials/external/file_external_account_credentials.h +49 -0
  305. data/src/core/lib/security/credentials/external/url_external_account_credentials.cc +211 -0
  306. data/src/core/lib/security/credentials/external/url_external_account_credentials.h +59 -0
  307. data/src/core/lib/security/credentials/insecure/insecure_credentials.cc +51 -0
  308. data/src/core/lib/security/credentials/jwt/json_token.cc +5 -2
  309. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +4 -3
  310. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +5 -1
  311. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +2 -2
  312. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.cc +35 -5
  313. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_distributor.h +12 -8
  314. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +78 -0
  315. data/src/core/lib/security/{certificate_provider.h → credentials/tls/grpc_tls_certificate_provider.h} +32 -18
  316. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +77 -149
  317. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +58 -187
  318. data/src/core/lib/security/credentials/tls/tls_credentials.cc +16 -12
  319. data/src/core/lib/security/credentials/tls/tls_credentials.h +2 -2
  320. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +2 -2
  321. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.cc +88 -0
  322. data/src/core/lib/security/security_connector/insecure/insecure_security_connector.h +70 -0
  323. data/src/core/lib/security/security_connector/load_system_roots.h +4 -0
  324. data/src/core/lib/security/security_connector/load_system_roots_linux.h +2 -0
  325. data/src/core/lib/security/security_connector/local/local_security_connector.cc +2 -2
  326. data/src/core/lib/security/security_connector/security_connector.cc +1 -1
  327. data/src/core/lib/security/security_connector/security_connector.h +4 -2
  328. data/src/core/lib/security/security_connector/ssl_utils.h +4 -2
  329. data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +293 -275
  330. data/src/core/lib/security/security_connector/tls/tls_security_connector.h +106 -61
  331. data/src/core/lib/security/transport/security_handshaker.cc +1 -1
  332. data/src/core/lib/security/transport/server_auth_filter.cc +2 -1
  333. data/src/core/lib/security/util/json_util.h +1 -0
  334. data/src/core/lib/slice/slice.cc +7 -4
  335. data/src/core/lib/slice/slice_buffer.cc +2 -1
  336. data/src/core/lib/slice/slice_intern.cc +2 -2
  337. data/src/core/lib/surface/call.cc +9 -8
  338. data/src/core/lib/surface/completion_queue.cc +7 -6
  339. data/src/core/lib/surface/server.cc +4 -2
  340. data/src/core/lib/surface/server.h +2 -2
  341. data/src/core/lib/surface/validate_metadata.h +3 -0
  342. data/src/core/lib/surface/version.cc +2 -2
  343. data/src/core/lib/transport/authority_override.h +2 -0
  344. data/src/core/lib/transport/bdp_estimator.cc +1 -1
  345. data/src/core/lib/transport/byte_stream.h +3 -3
  346. data/src/core/lib/transport/connectivity_state.h +3 -3
  347. data/src/core/lib/transport/metadata.h +2 -2
  348. data/src/core/lib/transport/timeout_encoding.cc +4 -4
  349. data/src/core/lib/transport/transport.cc +5 -3
  350. data/src/core/lib/transport/transport.h +1 -1
  351. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -4
  352. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +4 -3
  353. data/src/core/tsi/fake_transport_security.cc +1 -0
  354. data/src/core/tsi/local_transport_security.cc +5 -1
  355. data/src/core/tsi/local_transport_security.h +6 -7
  356. data/src/core/tsi/ssl/session_cache/ssl_session.h +3 -0
  357. data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -1
  358. data/src/core/tsi/ssl_transport_security.cc +14 -7
  359. data/src/core/tsi/ssl_transport_security.h +3 -0
  360. data/src/core/tsi/transport_security.cc +4 -2
  361. data/src/ruby/ext/grpc/extconf.rb +1 -1
  362. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +22 -14
  363. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +36 -24
  364. data/src/ruby/lib/grpc/version.rb +1 -1
  365. data/third_party/abseil-cpp/absl/algorithm/container.h +59 -22
  366. data/third_party/abseil-cpp/absl/base/attributes.h +99 -38
  367. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  368. data/third_party/abseil-cpp/absl/base/casts.h +9 -6
  369. data/third_party/abseil-cpp/absl/base/config.h +60 -17
  370. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +428 -335
  371. data/third_party/abseil-cpp/absl/base/internal/bits.h +17 -16
  372. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +5 -0
  373. data/third_party/abseil-cpp/absl/base/internal/dynamic_annotations.h +398 -0
  374. data/third_party/abseil-cpp/absl/base/internal/invoke.h +4 -4
  375. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +1 -1
  376. data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +29 -1
  377. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +2 -2
  378. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +7 -5
  379. data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +25 -38
  380. data/third_party/abseil-cpp/absl/base/internal/spinlock.h +19 -25
  381. data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +8 -0
  382. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +28 -5
  383. data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +8 -0
  384. data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +3 -1
  385. data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +2 -2
  386. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +3 -3
  387. data/third_party/abseil-cpp/absl/base/macros.h +36 -109
  388. data/third_party/abseil-cpp/absl/base/optimization.h +61 -1
  389. data/third_party/abseil-cpp/absl/base/options.h +31 -4
  390. data/third_party/abseil-cpp/absl/base/policy_checks.h +1 -1
  391. data/third_party/abseil-cpp/absl/base/thread_annotations.h +94 -39
  392. data/third_party/abseil-cpp/absl/container/fixed_array.h +42 -25
  393. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +2 -1
  394. data/third_party/abseil-cpp/absl/container/inlined_vector.h +33 -36
  395. data/third_party/abseil-cpp/absl/container/internal/common.h +6 -2
  396. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +33 -8
  397. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +49 -29
  398. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +15 -0
  399. data/third_party/abseil-cpp/absl/container/internal/hash_policy_traits.h +24 -7
  400. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -1
  401. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.h +35 -11
  402. data/third_party/abseil-cpp/absl/container/internal/have_sse.h +10 -9
  403. data/third_party/abseil-cpp/absl/container/internal/layout.h +7 -5
  404. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +55 -34
  405. data/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +5 -4
  406. data/third_party/abseil-cpp/absl/debugging/internal/demangle.cc +66 -16
  407. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +4 -0
  408. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_arm-inl.inc +13 -4
  409. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h +43 -24
  410. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_generic-inl.inc +12 -3
  411. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_win32-inl.inc +10 -2
  412. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +22 -1
  413. data/third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc +0 -21
  414. data/third_party/abseil-cpp/absl/debugging/symbolize.cc +12 -1
  415. data/third_party/abseil-cpp/absl/debugging/symbolize_darwin.inc +101 -0
  416. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +100 -20
  417. data/third_party/abseil-cpp/absl/functional/bind_front.h +184 -0
  418. data/third_party/abseil-cpp/absl/functional/function_ref.h +1 -1
  419. data/third_party/abseil-cpp/absl/functional/internal/front_binder.h +95 -0
  420. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +2 -2
  421. data/third_party/abseil-cpp/absl/hash/hash.h +6 -5
  422. data/third_party/abseil-cpp/absl/hash/internal/hash.h +73 -65
  423. data/third_party/abseil-cpp/absl/memory/memory.h +4 -0
  424. data/third_party/abseil-cpp/absl/meta/type_traits.h +2 -8
  425. data/third_party/abseil-cpp/absl/numeric/int128.cc +13 -27
  426. data/third_party/abseil-cpp/absl/numeric/int128.h +16 -15
  427. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +51 -0
  428. data/third_party/abseil-cpp/absl/status/status.cc +4 -6
  429. data/third_party/abseil-cpp/absl/status/status.h +502 -113
  430. data/third_party/abseil-cpp/absl/status/status_payload_printer.cc +5 -10
  431. data/third_party/abseil-cpp/absl/strings/charconv.cc +2 -2
  432. data/third_party/abseil-cpp/absl/strings/cord.cc +91 -112
  433. data/third_party/abseil-cpp/absl/strings/cord.h +360 -205
  434. data/third_party/abseil-cpp/absl/strings/escaping.cc +9 -9
  435. data/third_party/abseil-cpp/absl/strings/internal/char_map.h +1 -1
  436. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +1 -1
  437. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +2 -2
  438. data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +2 -2
  439. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +45 -23
  440. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +222 -136
  441. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +136 -64
  442. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.cc +1 -1
  443. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +14 -21
  444. data/third_party/abseil-cpp/absl/strings/internal/str_format/checker.h +7 -14
  445. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.cc +31 -7
  446. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +147 -135
  447. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +999 -87
  448. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.h +3 -3
  449. data/third_party/abseil-cpp/absl/strings/internal/str_format/output.h +4 -12
  450. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.cc +8 -6
  451. data/third_party/abseil-cpp/absl/strings/internal/str_format/parser.h +13 -11
  452. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +2 -2
  453. data/third_party/abseil-cpp/absl/strings/str_cat.cc +4 -4
  454. data/third_party/abseil-cpp/absl/strings/str_cat.h +1 -1
  455. data/third_party/abseil-cpp/absl/strings/str_format.h +289 -13
  456. data/third_party/abseil-cpp/absl/strings/str_split.cc +2 -2
  457. data/third_party/abseil-cpp/absl/strings/str_split.h +1 -0
  458. data/third_party/abseil-cpp/absl/strings/string_view.h +26 -19
  459. data/third_party/abseil-cpp/absl/strings/substitute.cc +5 -5
  460. data/third_party/abseil-cpp/absl/strings/substitute.h +32 -29
  461. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +3 -3
  462. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +3 -3
  463. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +28 -28
  464. data/third_party/abseil-cpp/absl/synchronization/internal/mutex_nonprod.inc +4 -16
  465. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +1 -1
  466. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +8 -0
  467. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +2 -2
  468. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +75 -64
  469. data/third_party/abseil-cpp/absl/synchronization/mutex.h +15 -6
  470. data/third_party/abseil-cpp/absl/time/civil_time.cc +9 -9
  471. data/third_party/abseil-cpp/absl/time/clock.cc +3 -3
  472. data/third_party/abseil-cpp/absl/time/duration.cc +90 -59
  473. data/third_party/abseil-cpp/absl/time/format.cc +43 -36
  474. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/civil_time_detail.h +26 -16
  475. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +4 -2
  476. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/zone_info_source.h +1 -1
  477. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +136 -29
  478. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +13 -21
  479. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +1 -1
  480. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +136 -129
  481. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +4 -5
  482. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +8 -7
  483. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +6 -6
  484. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +2 -1
  485. data/third_party/abseil-cpp/absl/time/time.h +15 -16
  486. data/third_party/abseil-cpp/absl/types/internal/variant.h +4 -4
  487. data/third_party/abseil-cpp/absl/types/optional.h +9 -9
  488. data/third_party/abseil-cpp/absl/types/span.h +49 -36
  489. data/third_party/abseil-cpp/absl/utility/utility.h +2 -2
  490. data/third_party/address_sorting/include/address_sorting/address_sorting.h +2 -0
  491. data/third_party/boringssl-with-bazel/err_data.c +340 -336
  492. data/third_party/boringssl-with-bazel/src/crypto/bio/bio.c +2 -0
  493. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/cipher/e_aes.c +173 -35
  494. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/rsa/rsa_impl.c +46 -7
  495. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +8 -2
  496. data/third_party/boringssl-with-bazel/src/crypto/trust_token/internal.h +90 -63
  497. data/third_party/boringssl-with-bazel/src/crypto/trust_token/pmbtoken.c +60 -60
  498. data/third_party/boringssl-with-bazel/src/crypto/trust_token/trust_token.c +179 -47
  499. data/third_party/boringssl-with-bazel/src/crypto/trust_token/voprf.c +766 -0
  500. data/third_party/boringssl-with-bazel/src/crypto/x509/algorithm.c +10 -0
  501. data/third_party/boringssl-with-bazel/src/crypto/x509v3/pcy_data.c +5 -3
  502. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +14 -14
  503. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_prn.c +1 -1
  504. data/third_party/boringssl-with-bazel/src/include/openssl/aead.h +24 -0
  505. data/third_party/boringssl-with-bazel/src/include/openssl/arm_arch.h +7 -5
  506. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -2
  507. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +4 -0
  508. data/third_party/boringssl-with-bazel/src/include/openssl/des.h +6 -0
  509. data/third_party/boringssl-with-bazel/src/include/openssl/opensslconf.h +3 -0
  510. data/third_party/boringssl-with-bazel/src/include/openssl/pem.h +202 -134
  511. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +55 -1
  512. data/third_party/boringssl-with-bazel/src/include/openssl/tls1.h +4 -0
  513. data/third_party/boringssl-with-bazel/src/include/openssl/trust_token.h +31 -23
  514. data/third_party/boringssl-with-bazel/src/include/openssl/x509v3.h +435 -394
  515. data/third_party/boringssl-with-bazel/src/ssl/bio_ssl.cc +18 -5
  516. data/third_party/boringssl-with-bazel/src/ssl/handoff.cc +35 -0
  517. data/third_party/boringssl-with-bazel/src/ssl/internal.h +36 -1
  518. data/third_party/boringssl-with-bazel/src/ssl/ssl_asn1.cc +42 -1
  519. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +67 -0
  520. data/third_party/boringssl-with-bazel/src/ssl/ssl_session.cc +11 -14
  521. data/third_party/boringssl-with-bazel/src/ssl/t1_lib.cc +216 -11
  522. data/third_party/boringssl-with-bazel/src/ssl/tls13_client.cc +53 -11
  523. data/third_party/boringssl-with-bazel/src/ssl/tls13_server.cc +133 -39
  524. data/third_party/upb/upb/def.c +2169 -0
  525. data/third_party/upb/upb/def.h +330 -0
  526. data/third_party/upb/upb/def.hpp +525 -0
  527. data/third_party/upb/upb/reflection.c +391 -0
  528. data/third_party/upb/upb/reflection.h +168 -0
  529. data/third_party/upb/upb/text_encode.c +398 -0
  530. data/third_party/upb/upb/text_encode.h +35 -0
  531. metadata +227 -37
  532. data/src/core/ext/filters/client_channel/lb_policy/xds/eds_drop.cc +0 -571
  533. data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +0 -129
@@ -0,0 +1,72 @@
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
+ // TODO(yashykt) : To be implemented
66
+ return nullptr;
67
+ }
68
+ };
69
+
70
+ } // namespace grpc_core
71
+
72
+ #endif // GRPC_CORE_EXT_XDS_FILE_WATCHER_CERTIFICATE_PROVIDER_FACTORY_H
@@ -37,123 +37,6 @@ namespace {
37
37
 
38
38
  const char* kMeshCaPlugin = "meshCA";
39
39
 
40
- //
41
- // Helper functions for extracting types from JSON
42
- //
43
- template <typename NumericType, typename ErrorVectorType>
44
- bool ExtractJsonType(const Json& json, const std::string& field_name,
45
- NumericType* output, ErrorVectorType* error_list) {
46
- static_assert(std::is_integral<NumericType>::value, "Integral required");
47
- if (json.type() != Json::Type::NUMBER) {
48
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
49
- absl::StrCat("field:", field_name, " error:type should be NUMBER")
50
- .c_str()));
51
- return false;
52
- }
53
- std::istringstream ss(json.string_value());
54
- ss >> *output;
55
- // The JSON parsing API should have dealt with parsing errors, but check
56
- // anyway
57
- if (GPR_UNLIKELY(ss.bad())) {
58
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
59
- absl::StrCat("field:", field_name, " error:failed to parse.").c_str()));
60
- return false;
61
- }
62
- return true;
63
- }
64
-
65
- template <typename ErrorVectorType>
66
- bool ExtractJsonType(const Json& json, const std::string& field_name,
67
- bool* output, ErrorVectorType* error_list) {
68
- switch (json.type()) {
69
- case Json::Type::JSON_TRUE:
70
- *output = true;
71
- return true;
72
- case Json::Type::JSON_FALSE:
73
- *output = false;
74
- return true;
75
- default:
76
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
77
- absl::StrCat("field:", field_name, " error:type should be BOOLEAN")
78
- .c_str()));
79
- return false;
80
- }
81
- }
82
-
83
- template <typename ErrorVectorType>
84
- bool ExtractJsonType(const Json& json, const std::string& field_name,
85
- std::string* output, ErrorVectorType* error_list) {
86
- if (json.type() != Json::Type::STRING) {
87
- *output = "";
88
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
89
- absl::StrCat("field:", field_name, " error:type should be STRING")
90
- .c_str()));
91
- return false;
92
- }
93
- *output = json.string_value();
94
- return true;
95
- }
96
-
97
- template <typename ErrorVectorType>
98
- bool ExtractJsonType(const Json& json, const std::string& field_name,
99
- const Json::Array** output, ErrorVectorType* error_list) {
100
- if (json.type() != Json::Type::ARRAY) {
101
- *output = nullptr;
102
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
103
- absl::StrCat("field:", field_name, " error:type should be ARRAY")
104
- .c_str()));
105
- return false;
106
- }
107
- *output = &json.array_value();
108
- return true;
109
- }
110
-
111
- template <typename ErrorVectorType>
112
- bool ExtractJsonType(const Json& json, const std::string& field_name,
113
- const Json::Object** output, ErrorVectorType* error_list) {
114
- if (json.type() != Json::Type::OBJECT) {
115
- *output = nullptr;
116
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
117
- absl::StrCat("field:", field_name, " error:type should be OBJECT")
118
- .c_str()));
119
- return false;
120
- }
121
- *output = &json.object_value();
122
- return true;
123
- }
124
-
125
- template <typename ErrorVectorType>
126
- bool ExtractJsonType(const Json& json, const std::string& field_name,
127
- grpc_millis* output, ErrorVectorType* error_list) {
128
- if (!ParseDurationFromJson(json, output)) {
129
- *output = GRPC_MILLIS_INF_PAST;
130
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
131
- absl::StrCat("field:", field_name,
132
- " error:type should be STRING of the form given by "
133
- "google.proto.Duration.")
134
- .c_str()));
135
- return false;
136
- }
137
- return true;
138
- }
139
-
140
- template <typename T, typename ErrorVectorType>
141
- bool ParseJsonObjectField(const Json::Object& object,
142
- const std::string& field_name, T* output,
143
- ErrorVectorType* error_list, bool optional = false) {
144
- auto it = object.find(field_name);
145
- if (it == object.end()) {
146
- if (!optional) {
147
- error_list->push_back(GRPC_ERROR_CREATE_FROM_COPIED_STRING(
148
- absl::StrCat("field:", field_name, " error:does not exist.")
149
- .c_str()));
150
- }
151
- return false;
152
- }
153
- auto& child_object_json = it->second;
154
- return ExtractJsonType(child_object_json, field_name, output, error_list);
155
- }
156
-
157
40
  } // namespace
158
41
 
159
42
  //
@@ -164,28 +47,33 @@ const char* GoogleMeshCaCertificateProviderFactory::Config::name() const {
164
47
  return kMeshCaPlugin;
165
48
  }
166
49
 
50
+ std::string GoogleMeshCaCertificateProviderFactory::Config::ToString() const {
51
+ // TODO(yashykt): To be filled
52
+ return "{}";
53
+ }
54
+
167
55
  std::vector<grpc_error*>
168
56
  GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectStsService(
169
57
  const Json::Object& sts_service) {
170
58
  std::vector<grpc_error*> error_list_sts_service;
171
59
  if (!ParseJsonObjectField(sts_service, "token_exchange_service_uri",
172
60
  &sts_config_.token_exchange_service_uri,
173
- &error_list_sts_service, true)) {
61
+ &error_list_sts_service, false)) {
174
62
  sts_config_.token_exchange_service_uri =
175
63
  "securetoken.googleapis.com"; // default
176
64
  }
177
65
  ParseJsonObjectField(sts_service, "resource", &sts_config_.resource,
178
- &error_list_sts_service, true);
66
+ &error_list_sts_service, false);
179
67
  ParseJsonObjectField(sts_service, "audience", &sts_config_.audience,
180
- &error_list_sts_service, true);
68
+ &error_list_sts_service, false);
181
69
  if (!ParseJsonObjectField(sts_service, "scope", &sts_config_.scope,
182
- &error_list_sts_service, true)) {
70
+ &error_list_sts_service, false)) {
183
71
  sts_config_.scope =
184
72
  "https://www.googleapis.com/auth/cloud-platform"; // default
185
73
  }
186
74
  ParseJsonObjectField(sts_service, "requested_token_type",
187
75
  &sts_config_.requested_token_type,
188
- &error_list_sts_service, true);
76
+ &error_list_sts_service, false);
189
77
  ParseJsonObjectField(sts_service, "subject_token_path",
190
78
  &sts_config_.subject_token_path,
191
79
  &error_list_sts_service);
@@ -194,10 +82,10 @@ GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectStsService(
194
82
  &error_list_sts_service);
195
83
  ParseJsonObjectField(sts_service, "actor_token_path",
196
84
  &sts_config_.actor_token_path, &error_list_sts_service,
197
- true);
85
+ false);
198
86
  ParseJsonObjectField(sts_service, "actor_token_type",
199
87
  &sts_config_.actor_token_type, &error_list_sts_service,
200
- true);
88
+ false);
201
89
  return error_list_sts_service;
202
90
  }
203
91
 
@@ -223,7 +111,7 @@ GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectGoogleGrpc(
223
111
  const Json::Object& google_grpc) {
224
112
  std::vector<grpc_error*> error_list_google_grpc;
225
113
  if (!ParseJsonObjectField(google_grpc, "target_uri", &endpoint_,
226
- &error_list_google_grpc, true)) {
114
+ &error_list_google_grpc, false)) {
227
115
  endpoint_ = "meshca.googleapis.com"; // Default target
228
116
  }
229
117
  const Json::Array* call_credentials_array = nullptr;
@@ -263,8 +151,8 @@ GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectGrpcServices(
263
151
  "field:google_grpc", &error_list_google_grpc));
264
152
  }
265
153
  }
266
- if (!ParseJsonObjectField(grpc_service, "timeout", &timeout_,
267
- &error_list_grpc_services, true)) {
154
+ if (!ParseJsonObjectFieldAsDuration(grpc_service, "timeout", &timeout_,
155
+ &error_list_grpc_services, false)) {
268
156
  timeout_ = 10 * 1000; // 10sec default
269
157
  }
270
158
  return error_list_grpc_services;
@@ -276,7 +164,7 @@ GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectServer(
276
164
  std::vector<grpc_error*> error_list_server;
277
165
  std::string api_type;
278
166
  if (ParseJsonObjectField(server, "api_type", &api_type, &error_list_server,
279
- true)) {
167
+ false)) {
280
168
  if (api_type != "GRPC") {
281
169
  error_list_server.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
282
170
  "field:api_type error:Only GRPC is supported"));
@@ -304,11 +192,11 @@ GoogleMeshCaCertificateProviderFactory::Config::ParseJsonObjectServer(
304
192
  return error_list_server;
305
193
  }
306
194
 
307
- std::unique_ptr<GoogleMeshCaCertificateProviderFactory::Config>
195
+ RefCountedPtr<GoogleMeshCaCertificateProviderFactory::Config>
308
196
  GoogleMeshCaCertificateProviderFactory::Config::Parse(const Json& config_json,
309
197
  grpc_error** error) {
310
198
  auto config =
311
- absl::make_unique<GoogleMeshCaCertificateProviderFactory::Config>();
199
+ MakeRefCounted<GoogleMeshCaCertificateProviderFactory::Config>();
312
200
  if (config_json.type() != Json::Type::OBJECT) {
313
201
  *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING(
314
202
  "error:config type should be OBJECT.");
@@ -325,30 +213,30 @@ GoogleMeshCaCertificateProviderFactory::Config::Parse(const Json& config_json,
325
213
  GRPC_ERROR_CREATE_FROM_VECTOR("field:server", &error_list_server));
326
214
  }
327
215
  }
328
- if (!ParseJsonObjectField(config_json.object_value(), "certificate_lifetime",
329
- &config->certificate_lifetime_, &error_list,
330
- true)) {
216
+ if (!ParseJsonObjectFieldAsDuration(
217
+ config_json.object_value(), "certificate_lifetime",
218
+ &config->certificate_lifetime_, &error_list, false)) {
331
219
  config->certificate_lifetime_ = 24 * 60 * 60 * 1000; // 24hrs default
332
220
  }
333
- if (!ParseJsonObjectField(config_json.object_value(), "renewal_grace_period",
334
- &config->renewal_grace_period_, &error_list,
335
- true)) {
221
+ if (!ParseJsonObjectFieldAsDuration(
222
+ config_json.object_value(), "renewal_grace_period",
223
+ &config->renewal_grace_period_, &error_list, false)) {
336
224
  config->renewal_grace_period_ = 12 * 60 * 60 * 1000; // 12hrs default
337
225
  }
338
226
  std::string key_type;
339
227
  if (ParseJsonObjectField(config_json.object_value(), "key_type", &key_type,
340
- &error_list, true)) {
228
+ &error_list, false)) {
341
229
  if (key_type != "RSA") {
342
230
  error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
343
231
  "field:key_type error:Only RSA is supported."));
344
232
  }
345
233
  }
346
234
  if (!ParseJsonObjectField(config_json.object_value(), "key_size",
347
- &config->key_size_, &error_list, true)) {
235
+ &config->key_size_, &error_list, false)) {
348
236
  config->key_size_ = 2048; // default 2048 bit key size
349
237
  }
350
238
  if (!ParseJsonObjectField(config_json.object_value(), "location",
351
- &config->location_, &error_list, true)) {
239
+ &config->location_, &error_list, false)) {
352
240
  // GCE/GKE Metadata server needs to be contacted to get the value.
353
241
  }
354
242
  if (!error_list.empty()) {
@@ -367,7 +255,7 @@ const char* GoogleMeshCaCertificateProviderFactory::name() const {
367
255
  return kMeshCaPlugin;
368
256
  }
369
257
 
370
- std::unique_ptr<CertificateProviderFactory::Config>
258
+ RefCountedPtr<CertificateProviderFactory::Config>
371
259
  GoogleMeshCaCertificateProviderFactory::CreateCertificateProviderConfig(
372
260
  const Json& config_json, grpc_error** error) {
373
261
  return GoogleMeshCaCertificateProviderFactory::Config::Parse(config_json,
@@ -46,6 +46,8 @@ class GoogleMeshCaCertificateProviderFactory
46
46
 
47
47
  const char* name() const override;
48
48
 
49
+ std::string ToString() const override;
50
+
49
51
  const std::string& endpoint() const { return endpoint_; }
50
52
 
51
53
  const StsConfig& sts_config() const { return sts_config_; }
@@ -60,8 +62,8 @@ class GoogleMeshCaCertificateProviderFactory
60
62
 
61
63
  const std::string& location() const { return location_; }
62
64
 
63
- static std::unique_ptr<Config> Parse(const Json& config_json,
64
- grpc_error** error);
65
+ static RefCountedPtr<Config> Parse(const Json& config_json,
66
+ grpc_error** error);
65
67
 
66
68
  private:
67
69
  // Helpers for parsing the config
@@ -86,12 +88,12 @@ class GoogleMeshCaCertificateProviderFactory
86
88
 
87
89
  const char* name() const override;
88
90
 
89
- std::unique_ptr<CertificateProviderFactory::Config>
91
+ RefCountedPtr<CertificateProviderFactory::Config>
90
92
  CreateCertificateProviderConfig(const Json& config_json,
91
93
  grpc_error** error) override;
92
94
 
93
95
  RefCountedPtr<grpc_tls_certificate_provider> CreateCertificateProvider(
94
- std::unique_ptr<CertificateProviderFactory::Config> config) override {
96
+ RefCountedPtr<CertificateProviderFactory::Config> config) override {
95
97
  // TODO(yashykt) : To be implemented
96
98
  return nullptr;
97
99
  }
@@ -41,29 +41,39 @@
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
 
45
46
  #include "envoy/config/cluster/v3/circuit_breaker.upb.h"
46
47
  #include "envoy/config/cluster/v3/cluster.upb.h"
48
+ #include "envoy/config/cluster/v3/cluster.upbdefs.h"
47
49
  #include "envoy/config/core/v3/address.upb.h"
48
50
  #include "envoy/config/core/v3/base.upb.h"
49
51
  #include "envoy/config/core/v3/config_source.upb.h"
50
52
  #include "envoy/config/core/v3/health_check.upb.h"
53
+ #include "envoy/config/core/v3/protocol.upb.h"
51
54
  #include "envoy/config/endpoint/v3/endpoint.upb.h"
55
+ #include "envoy/config/endpoint/v3/endpoint.upbdefs.h"
52
56
  #include "envoy/config/endpoint/v3/endpoint_components.upb.h"
53
57
  #include "envoy/config/endpoint/v3/load_report.upb.h"
54
58
  #include "envoy/config/listener/v3/api_listener.upb.h"
55
59
  #include "envoy/config/listener/v3/listener.upb.h"
56
60
  #include "envoy/config/route/v3/route.upb.h"
61
+ #include "envoy/config/route/v3/route.upbdefs.h"
57
62
  #include "envoy/config/route/v3/route_components.upb.h"
58
63
  #include "envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.upb.h"
59
64
  #include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
60
65
  #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
61
66
  #include "envoy/service/cluster/v3/cds.upb.h"
67
+ #include "envoy/service/cluster/v3/cds.upbdefs.h"
62
68
  #include "envoy/service/discovery/v3/discovery.upb.h"
69
+ #include "envoy/service/discovery/v3/discovery.upbdefs.h"
63
70
  #include "envoy/service/endpoint/v3/eds.upb.h"
71
+ #include "envoy/service/endpoint/v3/eds.upbdefs.h"
64
72
  #include "envoy/service/listener/v3/lds.upb.h"
65
73
  #include "envoy/service/load_stats/v3/lrs.upb.h"
74
+ #include "envoy/service/load_stats/v3/lrs.upbdefs.h"
66
75
  #include "envoy/service/route/v3/rds.upb.h"
76
+ #include "envoy/service/route/v3/rds.upbdefs.h"
67
77
  #include "envoy/type/matcher/v3/regex.upb.h"
68
78
  #include "envoy/type/matcher/v3/string.upb.h"
69
79
  #include "envoy/type/v3/percent.upb.h"
@@ -73,18 +83,44 @@
73
83
  #include "google/protobuf/struct.upb.h"
74
84
  #include "google/protobuf/wrappers.upb.h"
75
85
  #include "google/rpc/status.upb.h"
86
+ #include "upb/text_encode.h"
76
87
  #include "upb/upb.h"
77
88
 
78
89
  namespace grpc_core {
79
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
+
80
113
  //
81
114
  // XdsApi::Route::Matchers::PathMatcher
82
115
  //
83
116
 
84
117
  XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
85
- : type(other.type) {
118
+ : type(other.type), case_sensitive(other.case_sensitive) {
86
119
  if (type == PathMatcherType::REGEX) {
87
- 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);
88
124
  } else {
89
125
  string_matcher = other.string_matcher;
90
126
  }
@@ -93,8 +129,12 @@ XdsApi::Route::Matchers::PathMatcher::PathMatcher(const PathMatcher& other)
93
129
  XdsApi::Route::Matchers::PathMatcher& XdsApi::Route::Matchers::PathMatcher::
94
130
  operator=(const PathMatcher& other) {
95
131
  type = other.type;
132
+ case_sensitive = other.case_sensitive;
96
133
  if (type == PathMatcherType::REGEX) {
97
- 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);
98
138
  } else {
99
139
  string_matcher = other.string_matcher;
100
140
  }
@@ -104,6 +144,7 @@ operator=(const PathMatcher& other) {
104
144
  bool XdsApi::Route::Matchers::PathMatcher::operator==(
105
145
  const PathMatcher& other) const {
106
146
  if (type != other.type) return false;
147
+ if (case_sensitive != other.case_sensitive) return false;
107
148
  if (type == PathMatcherType::REGEX) {
108
149
  // Should never be null.
109
150
  if (regex_matcher == nullptr || other.regex_matcher == nullptr) {
@@ -129,10 +170,11 @@ std::string XdsApi::Route::Matchers::PathMatcher::ToString() const {
129
170
  default:
130
171
  break;
131
172
  }
132
- return absl::StrFormat("Path %s:%s", path_type_string,
173
+ return absl::StrFormat("Path %s:%s%s", path_type_string,
133
174
  type == PathMatcherType::REGEX
134
175
  ? regex_matcher->pattern()
135
- : string_matcher);
176
+ : string_matcher,
177
+ case_sensitive ? "" : "[case_sensitive=false]");
136
178
  }
137
179
 
138
180
  //
@@ -255,6 +297,9 @@ std::string XdsApi::Route::ToString() const {
255
297
  for (const ClusterWeight& cluster_weight : weighted_clusters) {
256
298
  contents.push_back(cluster_weight.ToString());
257
299
  }
300
+ if (max_stream_duration.has_value()) {
301
+ contents.push_back(max_stream_duration->ToString());
302
+ }
258
303
  return absl::StrJoin(contents, "\n");
259
304
  }
260
305
 
@@ -294,9 +339,11 @@ enum MatchType {
294
339
  };
295
340
 
296
341
  // Returns true if match succeeds.
297
- bool DomainMatch(MatchType match_type, std::string domain_pattern,
298
- 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) {
299
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;
300
347
  std::transform(domain_pattern.begin(), domain_pattern.end(),
301
348
  domain_pattern.begin(),
302
349
  [](unsigned char c) { return std::tolower(c); });
@@ -527,11 +574,10 @@ bool IsEds(absl::string_view type_url) {
527
574
  } // namespace
528
575
 
529
576
  XdsApi::XdsApi(XdsClient* client, TraceFlag* tracer,
530
- const XdsBootstrap* bootstrap)
577
+ const XdsBootstrap::Node* node)
531
578
  : client_(client),
532
579
  tracer_(tracer),
533
- use_v3_(bootstrap != nullptr && bootstrap->server().ShouldUseV3()),
534
- bootstrap_(bootstrap),
580
+ node_(node),
535
581
  build_version_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING, " ",
536
582
  grpc_version_string())),
537
583
  user_agent_name_(absl::StrCat("gRPC C-core ", GPR_PLATFORM_STRING)) {}
@@ -632,11 +678,10 @@ void PopulateBuildVersion(upb_arena* arena, envoy_config_core_v3_Node* node_msg,
632
678
  encoded_build_version.size(), arena);
633
679
  }
634
680
 
635
- void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
681
+ void PopulateNode(upb_arena* arena, const XdsBootstrap::Node* node, bool use_v3,
636
682
  const std::string& build_version,
637
683
  const std::string& user_agent_name,
638
684
  envoy_config_core_v3_Node* node_msg) {
639
- const XdsBootstrap::Node* node = bootstrap->node();
640
685
  if (node != nullptr) {
641
686
  if (!node->id.empty()) {
642
687
  envoy_config_core_v3_Node_set_id(node_msg,
@@ -669,7 +714,7 @@ void PopulateNode(upb_arena* arena, const XdsBootstrap* bootstrap,
669
714
  }
670
715
  }
671
716
  }
672
- if (!bootstrap->server().ShouldUseV3()) {
717
+ if (!use_v3) {
673
718
  PopulateBuildVersion(arena, node_msg, build_version);
674
719
  }
675
720
  envoy_config_core_v3_Node_set_user_agent_name(
@@ -689,172 +734,17 @@ inline std::string UpbStringToStdString(const upb_strview& str) {
689
734
  return std::string(str.data, str.size);
690
735
  }
691
736
 
692
- inline void AddStringField(const char* name, const upb_strview& value,
693
- std::vector<std::string>* fields,
694
- bool add_if_empty = false) {
695
- if (value.size > 0 || add_if_empty) {
696
- fields->emplace_back(
697
- absl::StrCat(name, ": \"", UpbStringToAbsl(value), "\""));
698
- }
699
- }
700
-
701
- inline void AddUInt32ValueField(const char* name,
702
- const google_protobuf_UInt32Value* value,
703
- std::vector<std::string>* fields) {
704
- if (value != nullptr) {
705
- fields->emplace_back(absl::StrCat(
706
- name, " { value: ", google_protobuf_UInt32Value_value(value), " }"));
707
- }
708
- }
709
-
710
- inline void AddLocalityField(int indent_level,
711
- const envoy_config_core_v3_Locality* locality,
712
- std::vector<std::string>* fields) {
713
- std::string indent =
714
- absl::StrJoin(std::vector<std::string>(indent_level, " "), "");
715
- // region
716
- std::string field = absl::StrCat(indent, "region");
717
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_region(locality),
718
- fields);
719
- // zone
720
- field = absl::StrCat(indent, "zone");
721
- AddStringField(field.c_str(), envoy_config_core_v3_Locality_zone(locality),
722
- fields);
723
- // sub_zone
724
- field = absl::StrCat(indent, "sub_zone");
725
- AddStringField(field.c_str(),
726
- envoy_config_core_v3_Locality_sub_zone(locality), fields);
727
- }
728
-
729
- void AddNodeLogFields(const envoy_config_core_v3_Node* node,
730
- const std::string& build_version,
731
- std::vector<std::string>* fields) {
732
- fields->emplace_back("node {");
733
- // id
734
- AddStringField(" id", envoy_config_core_v3_Node_id(node), fields);
735
- // metadata
736
- const google_protobuf_Struct* metadata =
737
- envoy_config_core_v3_Node_metadata(node);
738
- if (metadata != nullptr) {
739
- fields->emplace_back(" metadata {");
740
- size_t entry_idx = UPB_MAP_BEGIN;
741
- while (true) {
742
- const google_protobuf_Struct_FieldsEntry* entry =
743
- google_protobuf_Struct_fields_next(metadata, &entry_idx);
744
- if (entry == nullptr) break;
745
- fields->emplace_back(" field {");
746
- // key
747
- AddStringField(" key", google_protobuf_Struct_FieldsEntry_key(entry),
748
- fields);
749
- // value
750
- const google_protobuf_Value* value =
751
- google_protobuf_Struct_FieldsEntry_value(entry);
752
- if (value != nullptr) {
753
- std::string value_str;
754
- if (google_protobuf_Value_has_string_value(value)) {
755
- value_str = absl::StrCat(
756
- "string_value: \"",
757
- UpbStringToAbsl(google_protobuf_Value_string_value(value)), "\"");
758
- } else if (google_protobuf_Value_has_null_value(value)) {
759
- value_str = "null_value: NULL_VALUE";
760
- } else if (google_protobuf_Value_has_number_value(value)) {
761
- value_str = absl::StrCat("double_value: ",
762
- google_protobuf_Value_number_value(value));
763
- } else if (google_protobuf_Value_has_bool_value(value)) {
764
- value_str = absl::StrCat("bool_value: ",
765
- google_protobuf_Value_bool_value(value));
766
- } else if (google_protobuf_Value_has_struct_value(value)) {
767
- value_str = "struct_value: <not printed>";
768
- } else if (google_protobuf_Value_has_list_value(value)) {
769
- value_str = "list_value: <not printed>";
770
- } else {
771
- value_str = "<unknown>";
772
- }
773
- fields->emplace_back(absl::StrCat(" value { ", value_str, " }"));
774
- }
775
- fields->emplace_back(" }");
776
- }
777
- fields->emplace_back(" }");
778
- }
779
- // locality
780
- const envoy_config_core_v3_Locality* locality =
781
- envoy_config_core_v3_Node_locality(node);
782
- if (locality != nullptr) {
783
- fields->emplace_back(" locality {");
784
- AddLocalityField(2, locality, fields);
785
- fields->emplace_back(" }");
786
- }
787
- // build_version (doesn't exist in v3 proto; this is a horrible hack)
788
- if (!build_version.empty()) {
789
- fields->emplace_back(
790
- absl::StrCat(" build_version: \"", build_version, "\""));
791
- }
792
- // user_agent_name
793
- AddStringField(" user_agent_name",
794
- envoy_config_core_v3_Node_user_agent_name(node), fields);
795
- // user_agent_version
796
- AddStringField(" user_agent_version",
797
- envoy_config_core_v3_Node_user_agent_version(node), fields);
798
- // client_features
799
- size_t num_client_features;
800
- const upb_strview* client_features =
801
- envoy_config_core_v3_Node_client_features(node, &num_client_features);
802
- for (size_t i = 0; i < num_client_features; ++i) {
803
- AddStringField(" client_features", client_features[i], fields);
804
- }
805
- fields->emplace_back("}");
806
- }
807
-
808
737
  void MaybeLogDiscoveryRequest(
809
- XdsClient* client, TraceFlag* tracer,
810
- const envoy_service_discovery_v3_DiscoveryRequest* request,
811
- const std::string& build_version) {
738
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
739
+ const envoy_service_discovery_v3_DiscoveryRequest* request) {
812
740
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
813
741
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
814
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
815
- // the raw proto instead of doing this manually.
816
- std::vector<std::string> fields;
817
- // version_info
818
- AddStringField(
819
- "version_info",
820
- envoy_service_discovery_v3_DiscoveryRequest_version_info(request),
821
- &fields);
822
- // node
823
- const envoy_config_core_v3_Node* node =
824
- envoy_service_discovery_v3_DiscoveryRequest_node(request);
825
- if (node != nullptr) AddNodeLogFields(node, build_version, &fields);
826
- // resource_names
827
- size_t num_resource_names;
828
- const upb_strview* resource_names =
829
- envoy_service_discovery_v3_DiscoveryRequest_resource_names(
830
- request, &num_resource_names);
831
- for (size_t i = 0; i < num_resource_names; ++i) {
832
- AddStringField("resource_names", resource_names[i], &fields);
833
- }
834
- // type_url
835
- AddStringField(
836
- "type_url",
837
- envoy_service_discovery_v3_DiscoveryRequest_type_url(request), &fields);
838
- // response_nonce
839
- AddStringField(
840
- "response_nonce",
841
- envoy_service_discovery_v3_DiscoveryRequest_response_nonce(request),
842
- &fields);
843
- // error_detail
844
- const struct google_rpc_Status* error_detail =
845
- envoy_service_discovery_v3_DiscoveryRequest_error_detail(request);
846
- if (error_detail != nullptr) {
847
- fields.emplace_back("error_detail {");
848
- // code
849
- int32_t code = google_rpc_Status_code(error_detail);
850
- if (code != 0) fields.emplace_back(absl::StrCat(" code: ", code));
851
- // message
852
- AddStringField(" message", google_rpc_Status_message(error_detail),
853
- &fields);
854
- fields.emplace_back("}");
855
- }
742
+ const upb_msgdef* msg_type =
743
+ envoy_service_discovery_v3_DiscoveryRequest_getmsgdef(symtab);
744
+ char buf[10240];
745
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
856
746
  gpr_log(GPR_DEBUG, "[xds_client %p] constructed ADS request: %s", client,
857
- absl::StrJoin(fields, "\n").c_str());
747
+ buf);
858
748
  }
859
749
  }
860
750
 
@@ -888,7 +778,7 @@ absl::string_view TypeUrlExternalToInternal(bool use_v3,
888
778
  } // namespace
889
779
 
890
780
  grpc_slice XdsApi::CreateAdsRequest(
891
- const std::string& type_url,
781
+ const XdsBootstrap::XdsServer& server, const std::string& type_url,
892
782
  const std::set<absl::string_view>& resource_names,
893
783
  const std::string& version, const std::string& nonce, grpc_error* error,
894
784
  bool populate_node) {
@@ -898,7 +788,7 @@ grpc_slice XdsApi::CreateAdsRequest(
898
788
  envoy_service_discovery_v3_DiscoveryRequest_new(arena.ptr());
899
789
  // Set type_url.
900
790
  absl::string_view real_type_url =
901
- TypeUrlExternalToInternal(use_v3_, type_url);
791
+ TypeUrlExternalToInternal(server.ShouldUseV3(), type_url);
902
792
  envoy_service_discovery_v3_DiscoveryRequest_set_type_url(
903
793
  request, StdStringToUpbString(real_type_url));
904
794
  // Set version_info.
@@ -913,16 +803,20 @@ grpc_slice XdsApi::CreateAdsRequest(
913
803
  }
914
804
  // Set error_detail if it's a NACK.
915
805
  if (error != GRPC_ERROR_NONE) {
806
+ google_rpc_Status* error_detail =
807
+ envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
808
+ request, arena.ptr());
809
+ // Hard-code INVALID_ARGUMENT as the status code.
810
+ // TODO(roth): If at some point we decide we care about this value,
811
+ // we could attach a status code to the individual errors where we
812
+ // generate them in the parsing code, and then use that here.
813
+ google_rpc_Status_set_code(error_detail, GRPC_STATUS_INVALID_ARGUMENT);
814
+ // Error description comes from the error that was passed in.
916
815
  grpc_slice error_description_slice;
917
816
  GPR_ASSERT(grpc_error_get_str(error, GRPC_ERROR_STR_DESCRIPTION,
918
817
  &error_description_slice));
919
818
  upb_strview error_description_strview =
920
- upb_strview_make(reinterpret_cast<const char*>(
921
- GPR_SLICE_START_PTR(error_description_slice)),
922
- GPR_SLICE_LENGTH(error_description_slice));
923
- google_rpc_Status* error_detail =
924
- envoy_service_discovery_v3_DiscoveryRequest_mutable_error_detail(
925
- request, arena.ptr());
819
+ StdStringToUpbString(StringViewFromSlice(error_description_slice));
926
820
  google_rpc_Status_set_message(error_detail, error_description_strview);
927
821
  GRPC_ERROR_UNREF(error);
928
822
  }
@@ -931,401 +825,84 @@ grpc_slice XdsApi::CreateAdsRequest(
931
825
  envoy_config_core_v3_Node* node_msg =
932
826
  envoy_service_discovery_v3_DiscoveryRequest_mutable_node(request,
933
827
  arena.ptr());
934
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
935
- node_msg);
828
+ PopulateNode(arena.ptr(), node_, server.ShouldUseV3(), build_version_,
829
+ user_agent_name_, node_msg);
936
830
  }
937
831
  // Add resource_names.
938
832
  for (const auto& resource_name : resource_names) {
939
833
  envoy_service_discovery_v3_DiscoveryRequest_add_resource_names(
940
834
  request, StdStringToUpbString(resource_name), arena.ptr());
941
835
  }
942
- MaybeLogDiscoveryRequest(client_, tracer_, request, build_version_);
836
+ MaybeLogDiscoveryRequest(client_, tracer_, symtab_.ptr(), request);
943
837
  return SerializeDiscoveryRequest(arena.ptr(), request);
944
838
  }
945
839
 
946
840
  namespace {
947
841
 
948
842
  void MaybeLogDiscoveryResponse(
949
- XdsClient* client, TraceFlag* tracer,
843
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
950
844
  const envoy_service_discovery_v3_DiscoveryResponse* response) {
951
845
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
952
846
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
953
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
954
- // the raw proto instead of doing this manually.
955
- std::vector<std::string> fields;
956
- // version_info
957
- AddStringField(
958
- "version_info",
959
- envoy_service_discovery_v3_DiscoveryResponse_version_info(response),
960
- &fields);
961
- // resources
962
- size_t num_resources;
963
- envoy_service_discovery_v3_DiscoveryResponse_resources(response,
964
- &num_resources);
965
- fields.emplace_back(
966
- absl::StrCat("resources: <", num_resources, " element(s)>"));
967
- // type_url
968
- AddStringField(
969
- "type_url",
970
- envoy_service_discovery_v3_DiscoveryResponse_type_url(response),
971
- &fields);
972
- // nonce
973
- AddStringField("nonce",
974
- envoy_service_discovery_v3_DiscoveryResponse_nonce(response),
975
- &fields);
976
- gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client,
977
- absl::StrJoin(fields, "\n").c_str());
847
+ const upb_msgdef* msg_type =
848
+ envoy_service_discovery_v3_DiscoveryResponse_getmsgdef(symtab);
849
+ char buf[10240];
850
+ upb_text_encode(response, msg_type, nullptr, 0, buf, sizeof(buf));
851
+ gpr_log(GPR_DEBUG, "[xds_client %p] received response: %s", client, buf);
978
852
  }
979
853
  }
980
854
 
981
855
  void MaybeLogRouteConfiguration(
982
- XdsClient* client, TraceFlag* tracer,
856
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
983
857
  const envoy_config_route_v3_RouteConfiguration* route_config) {
984
858
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
985
859
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
986
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
987
- // the raw proto instead of doing this manually.
988
- std::vector<std::string> fields;
989
- // name
990
- AddStringField("name",
991
- envoy_config_route_v3_RouteConfiguration_name(route_config),
992
- &fields);
993
- // virtual_hosts
994
- size_t num_virtual_hosts;
995
- const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
996
- envoy_config_route_v3_RouteConfiguration_virtual_hosts(
997
- route_config, &num_virtual_hosts);
998
- for (size_t i = 0; i < num_virtual_hosts; ++i) {
999
- const auto* virtual_host = virtual_hosts[i];
1000
- fields.push_back("virtual_hosts {");
1001
- // name
1002
- AddStringField(" name",
1003
- envoy_config_route_v3_VirtualHost_name(virtual_host),
1004
- &fields);
1005
- // domains
1006
- size_t num_domains;
1007
- const upb_strview* const domains =
1008
- envoy_config_route_v3_VirtualHost_domains(virtual_host, &num_domains);
1009
- for (size_t j = 0; j < num_domains; ++j) {
1010
- AddStringField(" domains", domains[j], &fields);
1011
- }
1012
- // routes
1013
- size_t num_routes;
1014
- const envoy_config_route_v3_Route* const* routes =
1015
- envoy_config_route_v3_VirtualHost_routes(virtual_host, &num_routes);
1016
- for (size_t j = 0; j < num_routes; ++j) {
1017
- const auto* route = routes[j];
1018
- fields.push_back(" route {");
1019
- // name
1020
- AddStringField(" name", envoy_config_route_v3_Route_name(route),
1021
- &fields);
1022
- // match
1023
- const envoy_config_route_v3_RouteMatch* match =
1024
- envoy_config_route_v3_Route_match(route);
1025
- if (match != nullptr) {
1026
- fields.emplace_back(" match {");
1027
- // path matching
1028
- if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1029
- AddStringField(" prefix",
1030
- envoy_config_route_v3_RouteMatch_prefix(match),
1031
- &fields,
1032
- /*add_if_empty=*/true);
1033
- } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1034
- AddStringField(" path",
1035
- envoy_config_route_v3_RouteMatch_path(match),
1036
- &fields,
1037
- /*add_if_empty=*/true);
1038
- } else if (envoy_config_route_v3_RouteMatch_has_safe_regex(match)) {
1039
- fields.emplace_back(" safe_regex: <not printed>");
1040
- } else {
1041
- fields.emplace_back(" <unknown path matching type>");
1042
- }
1043
- // header matching
1044
- size_t num_headers;
1045
- envoy_config_route_v3_RouteMatch_headers(match, &num_headers);
1046
- if (num_headers > 0) {
1047
- fields.emplace_back(
1048
- absl::StrCat(" headers: <", num_headers, " element(s)>"));
1049
- }
1050
- fields.emplace_back(" }");
1051
- }
1052
- // action
1053
- if (envoy_config_route_v3_Route_has_route(route)) {
1054
- const envoy_config_route_v3_RouteAction* action =
1055
- envoy_config_route_v3_Route_route(route);
1056
- fields.emplace_back(" route {");
1057
- if (envoy_config_route_v3_RouteAction_has_cluster(action)) {
1058
- AddStringField(" cluster",
1059
- envoy_config_route_v3_RouteAction_cluster(action),
1060
- &fields);
1061
- } else if (envoy_config_route_v3_RouteAction_has_cluster_header(
1062
- action)) {
1063
- AddStringField(
1064
- " cluster_header",
1065
- envoy_config_route_v3_RouteAction_cluster_header(action),
1066
- &fields);
1067
- } else if (envoy_config_route_v3_RouteAction_has_weighted_clusters(
1068
- action)) {
1069
- const envoy_config_route_v3_WeightedCluster* weighted_clusters =
1070
- envoy_config_route_v3_RouteAction_weighted_clusters(action);
1071
- fields.emplace_back(" weighted_clusters {");
1072
- size_t num_cluster_weights;
1073
- const envoy_config_route_v3_WeightedCluster_ClusterWeight* const*
1074
- cluster_weights =
1075
- envoy_config_route_v3_WeightedCluster_clusters(
1076
- weighted_clusters, &num_cluster_weights);
1077
- for (size_t i = 0; i < num_cluster_weights; ++i) {
1078
- const envoy_config_route_v3_WeightedCluster_ClusterWeight*
1079
- cluster_weight = cluster_weights[i];
1080
- fields.emplace_back(" clusters {");
1081
- AddStringField(
1082
- " name",
1083
- envoy_config_route_v3_WeightedCluster_ClusterWeight_name(
1084
- cluster_weight),
1085
- &fields);
1086
- AddUInt32ValueField(
1087
- " weight",
1088
- envoy_config_route_v3_WeightedCluster_ClusterWeight_weight(
1089
- cluster_weight),
1090
- &fields);
1091
- fields.emplace_back(" }");
1092
- }
1093
- AddUInt32ValueField(
1094
- " total_weight",
1095
- envoy_config_route_v3_WeightedCluster_total_weight(
1096
- weighted_clusters),
1097
- &fields);
1098
- fields.emplace_back(" }");
1099
- }
1100
- fields.emplace_back(" }");
1101
- } else if (envoy_config_route_v3_Route_has_redirect(route)) {
1102
- fields.emplace_back(" redirect: <not printed>");
1103
- } else if (envoy_config_route_v3_Route_has_direct_response(route)) {
1104
- fields.emplace_back(" direct_response: <not printed>");
1105
- } else if (envoy_config_route_v3_Route_has_filter_action(route)) {
1106
- fields.emplace_back(" filter_action: <not printed>");
1107
- }
1108
- fields.push_back(" }");
1109
- }
1110
- fields.push_back("}");
1111
- }
1112
- gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client,
1113
- absl::StrJoin(fields, "\n").c_str());
860
+ const upb_msgdef* msg_type =
861
+ envoy_config_route_v3_RouteConfiguration_getmsgdef(symtab);
862
+ char buf[10240];
863
+ upb_text_encode(route_config, msg_type, nullptr, 0, buf, sizeof(buf));
864
+ gpr_log(GPR_DEBUG, "[xds_client %p] RouteConfiguration: %s", client, buf);
1114
865
  }
1115
866
  }
1116
867
 
1117
- void MaybeLogCluster(XdsClient* client, TraceFlag* tracer,
868
+ void MaybeLogCluster(XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1118
869
  const envoy_config_cluster_v3_Cluster* cluster) {
1119
870
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1120
871
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1121
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1122
- // the raw proto instead of doing this manually.
1123
- std::vector<std::string> fields;
1124
- // name
1125
- AddStringField("name", envoy_config_cluster_v3_Cluster_name(cluster),
1126
- &fields);
1127
- // type
1128
- if (envoy_config_cluster_v3_Cluster_has_type(cluster)) {
1129
- fields.emplace_back(absl::StrCat(
1130
- "type: ", envoy_config_cluster_v3_Cluster_type(cluster)));
1131
- } else if (envoy_config_cluster_v3_Cluster_has_cluster_type(cluster)) {
1132
- fields.emplace_back("cluster_type: <not printed>");
1133
- } else {
1134
- fields.emplace_back("<unknown type>");
1135
- }
1136
- // eds_cluster_config
1137
- const envoy_config_cluster_v3_Cluster_EdsClusterConfig* eds_cluster_config =
1138
- envoy_config_cluster_v3_Cluster_eds_cluster_config(cluster);
1139
- if (eds_cluster_config != nullptr) {
1140
- fields.emplace_back("eds_cluster_config {");
1141
- // eds_config
1142
- const struct envoy_config_core_v3_ConfigSource* eds_config =
1143
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_eds_config(
1144
- eds_cluster_config);
1145
- if (eds_config != nullptr) {
1146
- if (envoy_config_core_v3_ConfigSource_has_ads(eds_config)) {
1147
- fields.emplace_back(" eds_config { ads {} }");
1148
- } else {
1149
- fields.emplace_back(" eds_config: <non-ADS type>");
1150
- }
1151
- }
1152
- // service_name
1153
- AddStringField(
1154
- " service_name",
1155
- envoy_config_cluster_v3_Cluster_EdsClusterConfig_service_name(
1156
- eds_cluster_config),
1157
- &fields);
1158
- fields.emplace_back("}");
1159
- }
1160
- // lb_policy
1161
- fields.emplace_back(absl::StrCat(
1162
- "lb_policy: ", envoy_config_cluster_v3_Cluster_lb_policy(cluster)));
1163
- // lrs_server
1164
- const envoy_config_core_v3_ConfigSource* lrs_server =
1165
- envoy_config_cluster_v3_Cluster_lrs_server(cluster);
1166
- if (lrs_server != nullptr) {
1167
- if (envoy_config_core_v3_ConfigSource_has_self(lrs_server)) {
1168
- fields.emplace_back("lrs_server { self {} }");
1169
- } else {
1170
- fields.emplace_back("lrs_server: <non-self type>");
1171
- }
1172
- }
1173
- gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client,
1174
- absl::StrJoin(fields, "\n").c_str());
872
+ const upb_msgdef* msg_type =
873
+ envoy_config_cluster_v3_Cluster_getmsgdef(symtab);
874
+ char buf[10240];
875
+ upb_text_encode(cluster, msg_type, nullptr, 0, buf, sizeof(buf));
876
+ gpr_log(GPR_DEBUG, "[xds_client %p] Cluster: %s", client, buf);
1175
877
  }
1176
878
  }
1177
879
 
1178
880
  void MaybeLogClusterLoadAssignment(
1179
- XdsClient* client, TraceFlag* tracer,
881
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1180
882
  const envoy_config_endpoint_v3_ClusterLoadAssignment* cla) {
1181
883
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
1182
884
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
1183
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
1184
- // the raw proto instead of doing this manually.
1185
- std::vector<std::string> fields;
1186
- // cluster_name
1187
- AddStringField(
1188
- "cluster_name",
1189
- envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(cla),
1190
- &fields);
1191
- // endpoints
1192
- size_t num_localities;
1193
- const struct envoy_config_endpoint_v3_LocalityLbEndpoints* const*
1194
- locality_endpoints =
1195
- envoy_config_endpoint_v3_ClusterLoadAssignment_endpoints(
1196
- cla, &num_localities);
1197
- for (size_t i = 0; i < num_localities; ++i) {
1198
- const auto* locality_endpoint = locality_endpoints[i];
1199
- fields.emplace_back("endpoints {");
1200
- // locality
1201
- const auto* locality =
1202
- envoy_config_endpoint_v3_LocalityLbEndpoints_locality(
1203
- locality_endpoint);
1204
- if (locality != nullptr) {
1205
- fields.emplace_back(" locality {");
1206
- AddLocalityField(2, locality, &fields);
1207
- fields.emplace_back(" }");
1208
- }
1209
- // lb_endpoints
1210
- size_t num_lb_endpoints;
1211
- const envoy_config_endpoint_v3_LbEndpoint* const* lb_endpoints =
1212
- envoy_config_endpoint_v3_LocalityLbEndpoints_lb_endpoints(
1213
- locality_endpoint, &num_lb_endpoints);
1214
- for (size_t j = 0; j < num_lb_endpoints; ++j) {
1215
- const auto* lb_endpoint = lb_endpoints[j];
1216
- fields.emplace_back(" lb_endpoints {");
1217
- // health_status
1218
- uint32_t health_status =
1219
- envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
1220
- if (health_status > 0) {
1221
- fields.emplace_back(
1222
- absl::StrCat(" health_status: ", health_status));
1223
- }
1224
- // endpoint
1225
- const envoy_config_endpoint_v3_Endpoint* endpoint =
1226
- envoy_config_endpoint_v3_LbEndpoint_endpoint(lb_endpoint);
1227
- if (endpoint != nullptr) {
1228
- fields.emplace_back(" endpoint {");
1229
- // address
1230
- const auto* address =
1231
- envoy_config_endpoint_v3_Endpoint_address(endpoint);
1232
- if (address != nullptr) {
1233
- fields.emplace_back(" address {");
1234
- // socket_address
1235
- const auto* socket_address =
1236
- envoy_config_core_v3_Address_socket_address(address);
1237
- if (socket_address != nullptr) {
1238
- fields.emplace_back(" socket_address {");
1239
- // address
1240
- AddStringField(
1241
- " address",
1242
- envoy_config_core_v3_SocketAddress_address(socket_address),
1243
- &fields);
1244
- // port_value
1245
- if (envoy_config_core_v3_SocketAddress_has_port_value(
1246
- socket_address)) {
1247
- fields.emplace_back(
1248
- absl::StrCat(" port_value: ",
1249
- envoy_config_core_v3_SocketAddress_port_value(
1250
- socket_address)));
1251
- } else {
1252
- fields.emplace_back(" <non-numeric port>");
1253
- }
1254
- fields.emplace_back(" }");
1255
- } else {
1256
- fields.emplace_back(" <non-socket address>");
1257
- }
1258
- fields.emplace_back(" }");
1259
- }
1260
- fields.emplace_back(" }");
1261
- }
1262
- fields.emplace_back(" }");
1263
- }
1264
- // load_balancing_weight
1265
- AddUInt32ValueField(
1266
- " load_balancing_weight",
1267
- envoy_config_endpoint_v3_LocalityLbEndpoints_load_balancing_weight(
1268
- locality_endpoint),
1269
- &fields);
1270
- // priority
1271
- uint32_t priority = envoy_config_endpoint_v3_LocalityLbEndpoints_priority(
1272
- locality_endpoint);
1273
- if (priority > 0) {
1274
- fields.emplace_back(absl::StrCat(" priority: ", priority));
1275
- }
1276
- fields.emplace_back("}");
1277
- }
1278
- // policy
1279
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy* policy =
1280
- envoy_config_endpoint_v3_ClusterLoadAssignment_policy(cla);
1281
- if (policy != nullptr) {
1282
- fields.emplace_back("policy {");
1283
- // drop_overloads
1284
- size_t num_drop_overloads;
1285
- const envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload* const*
1286
- drop_overloads =
1287
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_drop_overloads(
1288
- policy, &num_drop_overloads);
1289
- for (size_t i = 0; i < num_drop_overloads; ++i) {
1290
- auto* drop_overload = drop_overloads[i];
1291
- fields.emplace_back(" drop_overloads {");
1292
- // category
1293
- AddStringField(
1294
- " category",
1295
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
1296
- drop_overload),
1297
- &fields);
1298
- // drop_percentage
1299
- const auto* drop_percentage =
1300
- envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_drop_percentage(
1301
- drop_overload);
1302
- if (drop_percentage != nullptr) {
1303
- fields.emplace_back(" drop_percentage {");
1304
- fields.emplace_back(absl::StrCat(
1305
- " numerator: ",
1306
- envoy_type_v3_FractionalPercent_numerator(drop_percentage)));
1307
- fields.emplace_back(absl::StrCat(
1308
- " denominator: ",
1309
- envoy_type_v3_FractionalPercent_denominator(drop_percentage)));
1310
- fields.emplace_back(" }");
1311
- }
1312
- fields.emplace_back(" }");
1313
- }
1314
- // overprovisioning_factor
1315
- fields.emplace_back("}");
1316
- }
885
+ const upb_msgdef* msg_type =
886
+ envoy_config_endpoint_v3_ClusterLoadAssignment_getmsgdef(symtab);
887
+ char buf[10240];
888
+ upb_text_encode(cla, msg_type, nullptr, 0, buf, sizeof(buf));
1317
889
  gpr_log(GPR_DEBUG, "[xds_client %p] ClusterLoadAssignment: %s", client,
1318
- absl::StrJoin(fields, "\n").c_str());
890
+ buf);
1319
891
  }
1320
892
  }
1321
893
 
1322
894
  grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1323
895
  XdsApi::Route* route, bool* ignore_route) {
896
+ auto* case_sensitive = envoy_config_route_v3_RouteMatch_case_sensitive(match);
897
+ if (case_sensitive != nullptr) {
898
+ route->matchers.path_matcher.case_sensitive =
899
+ google_protobuf_BoolValue_value(case_sensitive);
900
+ }
1324
901
  if (envoy_config_route_v3_RouteMatch_has_prefix(match)) {
1325
902
  absl::string_view prefix =
1326
903
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_prefix(match));
1327
904
  // Empty prefix "" is accepted.
1328
- if (prefix.size() > 0) {
905
+ if (!prefix.empty()) {
1329
906
  // Prefix "/" is accepted.
1330
907
  if (prefix[0] != '/') {
1331
908
  // Prefix which does not start with a / will never match anything, so
@@ -1351,7 +928,7 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1351
928
  } else if (envoy_config_route_v3_RouteMatch_has_path(match)) {
1352
929
  absl::string_view path =
1353
930
  UpbStringToAbsl(envoy_config_route_v3_RouteMatch_path(match));
1354
- if (path.size() == 0) {
931
+ if (path.empty()) {
1355
932
  // Path that is empty will never match anything, so ignore this route.
1356
933
  *ignore_route = true;
1357
934
  return GRPC_ERROR_NONE;
@@ -1389,7 +966,9 @@ grpc_error* RoutePathMatchParse(const envoy_config_route_v3_RouteMatch* match,
1389
966
  GPR_ASSERT(regex_matcher != nullptr);
1390
967
  std::string matcher = UpbStringToStdString(
1391
968
  envoy_type_matcher_v3_RegexMatcher_regex(regex_matcher));
1392
- std::unique_ptr<RE2> regex = absl::make_unique<RE2>(std::move(matcher));
969
+ RE2::Options options;
970
+ options.set_case_sensitive(route->matchers.path_matcher.case_sensitive);
971
+ auto regex = absl::make_unique<RE2>(std::move(matcher), options);
1393
972
  if (!regex->ok()) {
1394
973
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1395
974
  "Invalid regex string specified in path matcher.");
@@ -1518,7 +1097,7 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1518
1097
  if (envoy_config_route_v3_RouteAction_has_cluster(route_action)) {
1519
1098
  route->cluster_name = UpbStringToStdString(
1520
1099
  envoy_config_route_v3_RouteAction_cluster(route_action));
1521
- if (route->cluster_name.size() == 0) {
1100
+ if (route->cluster_name.empty()) {
1522
1101
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1523
1102
  "RouteAction cluster contains empty cluster name.");
1524
1103
  }
@@ -1571,16 +1150,36 @@ grpc_error* RouteActionParse(const envoy_config_route_v3_Route* route_msg,
1571
1150
  } else {
1572
1151
  // No cluster or weighted_clusters found in RouteAction, ignore this route.
1573
1152
  *ignore_route = true;
1574
- return GRPC_ERROR_NONE;
1153
+ }
1154
+ if (XdsTimeoutEnabled() && !*ignore_route) {
1155
+ const envoy_config_route_v3_RouteAction_MaxStreamDuration*
1156
+ max_stream_duration =
1157
+ envoy_config_route_v3_RouteAction_max_stream_duration(route_action);
1158
+ if (max_stream_duration != nullptr) {
1159
+ const google_protobuf_Duration* duration =
1160
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_grpc_timeout_header_max(
1161
+ max_stream_duration);
1162
+ if (duration == nullptr) {
1163
+ duration =
1164
+ envoy_config_route_v3_RouteAction_MaxStreamDuration_max_stream_duration(
1165
+ max_stream_duration);
1166
+ }
1167
+ if (duration != nullptr) {
1168
+ XdsApi::Duration duration_in_route;
1169
+ duration_in_route.seconds = google_protobuf_Duration_seconds(duration);
1170
+ duration_in_route.nanos = google_protobuf_Duration_nanos(duration);
1171
+ route->max_stream_duration = duration_in_route;
1172
+ }
1173
+ }
1575
1174
  }
1576
1175
  return GRPC_ERROR_NONE;
1577
1176
  }
1578
1177
 
1579
1178
  grpc_error* RouteConfigParse(
1580
- XdsClient* client, TraceFlag* tracer,
1179
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1581
1180
  const envoy_config_route_v3_RouteConfiguration* route_config,
1582
1181
  XdsApi::RdsUpdate* rds_update) {
1583
- MaybeLogRouteConfiguration(client, tracer, route_config);
1182
+ MaybeLogRouteConfiguration(client, tracer, symtab, route_config);
1584
1183
  // Get the virtual hosts.
1585
1184
  size_t size;
1586
1185
  const envoy_config_route_v3_VirtualHost* const* virtual_hosts =
@@ -1636,13 +1235,6 @@ grpc_error* RouteConfigParse(
1636
1235
  error = RouteActionParse(routes[j], &route, &ignore_route);
1637
1236
  if (error != GRPC_ERROR_NONE) return error;
1638
1237
  if (ignore_route) continue;
1639
- const google_protobuf_BoolValue* case_sensitive =
1640
- envoy_config_route_v3_RouteMatch_case_sensitive(match);
1641
- if (case_sensitive != nullptr &&
1642
- !google_protobuf_BoolValue_value(case_sensitive)) {
1643
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1644
- "case_sensitive if set must be set to true.");
1645
- }
1646
1238
  vhost.routes.emplace_back(std::move(route));
1647
1239
  }
1648
1240
  if (vhost.routes.empty()) {
@@ -1653,7 +1245,7 @@ grpc_error* RouteConfigParse(
1653
1245
  }
1654
1246
 
1655
1247
  grpc_error* LdsResponseParse(
1656
- XdsClient* client, TraceFlag* tracer,
1248
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1657
1249
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1658
1250
  const std::set<absl::string_view>& expected_listener_names,
1659
1251
  XdsApi::LdsUpdateMap* lds_update_map, upb_arena* arena) {
@@ -1708,6 +1300,23 @@ grpc_error* LdsResponseParse(
1708
1300
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1709
1301
  "Could not parse HttpConnectionManager config from ApiListener");
1710
1302
  }
1303
+ if (XdsTimeoutEnabled()) {
1304
+ // Obtain max_stream_duration from Http Protocol Options.
1305
+ const envoy_config_core_v3_HttpProtocolOptions* options =
1306
+ envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_common_http_protocol_options(
1307
+ http_connection_manager);
1308
+ if (options != nullptr) {
1309
+ const google_protobuf_Duration* duration =
1310
+ envoy_config_core_v3_HttpProtocolOptions_max_stream_duration(
1311
+ options);
1312
+ if (duration != nullptr) {
1313
+ lds_update.http_max_stream_duration.seconds =
1314
+ google_protobuf_Duration_seconds(duration);
1315
+ lds_update.http_max_stream_duration.nanos =
1316
+ google_protobuf_Duration_nanos(duration);
1317
+ }
1318
+ }
1319
+ }
1711
1320
  // Found inlined route_config. Parse it to find the cluster_name.
1712
1321
  if (envoy_extensions_filters_network_http_connection_manager_v3_HttpConnectionManager_has_route_config(
1713
1322
  http_connection_manager)) {
@@ -1716,7 +1325,7 @@ grpc_error* LdsResponseParse(
1716
1325
  http_connection_manager);
1717
1326
  XdsApi::RdsUpdate rds_update;
1718
1327
  grpc_error* error =
1719
- RouteConfigParse(client, tracer, route_config, &rds_update);
1328
+ RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
1720
1329
  if (error != GRPC_ERROR_NONE) return error;
1721
1330
  lds_update.rds_update = std::move(rds_update);
1722
1331
  continue;
@@ -1751,7 +1360,7 @@ grpc_error* LdsResponseParse(
1751
1360
  }
1752
1361
 
1753
1362
  grpc_error* RdsResponseParse(
1754
- XdsClient* client, TraceFlag* tracer,
1363
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1755
1364
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1756
1365
  const std::set<absl::string_view>& expected_route_configuration_names,
1757
1366
  XdsApi::RdsUpdateMap* rds_update_map, upb_arena* arena) {
@@ -1793,12 +1402,25 @@ grpc_error* RdsResponseParse(
1793
1402
  XdsApi::RdsUpdate& rds_update =
1794
1403
  (*rds_update_map)[std::move(route_config_name)];
1795
1404
  grpc_error* error =
1796
- RouteConfigParse(client, tracer, route_config, &rds_update);
1405
+ RouteConfigParse(client, tracer, symtab, route_config, &rds_update);
1797
1406
  if (error != GRPC_ERROR_NONE) return error;
1798
1407
  }
1799
1408
  return GRPC_ERROR_NONE;
1800
1409
  }
1801
1410
 
1411
+ XdsApi::CommonTlsContext::CertificateProviderInstance
1412
+ CertificateProviderInstanceParse(
1413
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
1414
+ certificate_provider_instance_proto) {
1415
+ return {
1416
+ UpbStringToStdString(
1417
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1418
+ certificate_provider_instance_proto)),
1419
+ UpbStringToStdString(
1420
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
1421
+ certificate_provider_instance_proto))};
1422
+ }
1423
+
1802
1424
  grpc_error* CommonTlsContextParse(
1803
1425
  const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
1804
1426
  common_tls_context_proto,
@@ -1868,25 +1490,24 @@ grpc_error* CommonTlsContextParse(
1868
1490
  combined_validation_context);
1869
1491
  if (validation_context_certificate_provider_instance != nullptr) {
1870
1492
  common_tls_context->combined_validation_context
1871
- .validation_context_certificate_provider_instance = UpbStringToStdString(
1872
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1873
- validation_context_certificate_provider_instance));
1493
+ .validation_context_certificate_provider_instance =
1494
+ CertificateProviderInstanceParse(
1495
+ validation_context_certificate_provider_instance);
1874
1496
  }
1875
1497
  }
1876
1498
  auto* tls_certificate_certificate_provider_instance =
1877
1499
  envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
1878
1500
  common_tls_context_proto);
1879
1501
  if (tls_certificate_certificate_provider_instance != nullptr) {
1880
- common_tls_context
1881
- ->tls_certificate_certificate_provider_instance = UpbStringToStdString(
1882
- envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
1883
- tls_certificate_certificate_provider_instance));
1502
+ common_tls_context->tls_certificate_certificate_provider_instance =
1503
+ CertificateProviderInstanceParse(
1504
+ tls_certificate_certificate_provider_instance);
1884
1505
  }
1885
1506
  return GRPC_ERROR_NONE;
1886
1507
  }
1887
1508
 
1888
1509
  grpc_error* CdsResponseParse(
1889
- XdsClient* client, TraceFlag* tracer,
1510
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1890
1511
  const envoy_service_discovery_v3_DiscoveryResponse* response,
1891
1512
  const std::set<absl::string_view>& expected_cluster_names,
1892
1513
  XdsApi::CdsUpdateMap* cds_update_map, upb_arena* arena) {
@@ -1910,7 +1531,7 @@ grpc_error* CdsResponseParse(
1910
1531
  if (cluster == nullptr) {
1911
1532
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode cluster.");
1912
1533
  }
1913
- MaybeLogCluster(client, tracer, cluster);
1534
+ MaybeLogCluster(client, tracer, symtab, cluster);
1914
1535
  // Ignore unexpected cluster names.
1915
1536
  std::string cluster_name =
1916
1537
  UpbStringToStdString(envoy_config_cluster_v3_Cluster_name(cluster));
@@ -1956,33 +1577,36 @@ grpc_error* CdsResponseParse(
1956
1577
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1957
1578
  "LB policy is not ROUND_ROBIN.");
1958
1579
  }
1959
- // Record Upstream tls context
1960
- auto* transport_socket =
1961
- envoy_config_cluster_v3_Cluster_transport_socket(cluster);
1962
- if (transport_socket != nullptr) {
1963
- absl::string_view name = UpbStringToAbsl(
1964
- envoy_config_core_v3_TransportSocket_name(transport_socket));
1965
- if (name == "tls") {
1966
- auto* typed_config =
1967
- envoy_config_core_v3_TransportSocket_typed_config(transport_socket);
1968
- if (typed_config != nullptr) {
1969
- const upb_strview encoded_upstream_tls_context =
1970
- google_protobuf_Any_value(typed_config);
1971
- auto* upstream_tls_context =
1972
- envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
1973
- encoded_upstream_tls_context.data,
1974
- encoded_upstream_tls_context.size, arena);
1975
- if (upstream_tls_context == nullptr) {
1976
- return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1977
- "Can't decode upstream tls context.");
1978
- }
1979
- auto* common_tls_context =
1980
- envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
1981
- upstream_tls_context);
1982
- if (common_tls_context != nullptr) {
1983
- grpc_error* error = CommonTlsContextParse(
1984
- common_tls_context, &cds_update.common_tls_context);
1985
- if (error != GRPC_ERROR_NONE) return error;
1580
+ if (XdsSecurityEnabled()) {
1581
+ // Record Upstream tls context
1582
+ auto* transport_socket =
1583
+ envoy_config_cluster_v3_Cluster_transport_socket(cluster);
1584
+ if (transport_socket != nullptr) {
1585
+ absl::string_view name = UpbStringToAbsl(
1586
+ envoy_config_core_v3_TransportSocket_name(transport_socket));
1587
+ if (name == "envoy.transport_sockets.tls") {
1588
+ auto* typed_config =
1589
+ envoy_config_core_v3_TransportSocket_typed_config(
1590
+ transport_socket);
1591
+ if (typed_config != nullptr) {
1592
+ const upb_strview encoded_upstream_tls_context =
1593
+ google_protobuf_Any_value(typed_config);
1594
+ auto* upstream_tls_context =
1595
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_parse(
1596
+ encoded_upstream_tls_context.data,
1597
+ encoded_upstream_tls_context.size, arena);
1598
+ if (upstream_tls_context == nullptr) {
1599
+ return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
1600
+ "Can't decode upstream tls context.");
1601
+ }
1602
+ auto* common_tls_context =
1603
+ envoy_extensions_transport_sockets_tls_v3_UpstreamTlsContext_common_tls_context(
1604
+ upstream_tls_context);
1605
+ if (common_tls_context != nullptr) {
1606
+ grpc_error* error = CommonTlsContextParse(
1607
+ common_tls_context, &cds_update.common_tls_context);
1608
+ if (error != GRPC_ERROR_NONE) return error;
1609
+ }
1986
1610
  }
1987
1611
  }
1988
1612
  }
@@ -2107,7 +1731,7 @@ grpc_error* DropParseAndAppend(
2107
1731
  std::string category = UpbStringToStdString(
2108
1732
  envoy_config_endpoint_v3_ClusterLoadAssignment_Policy_DropOverload_category(
2109
1733
  drop_overload));
2110
- if (category.size() == 0) {
1734
+ if (category.empty()) {
2111
1735
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Empty drop category name");
2112
1736
  }
2113
1737
  // Get the drop rate (per million).
@@ -2139,7 +1763,7 @@ grpc_error* DropParseAndAppend(
2139
1763
  }
2140
1764
 
2141
1765
  grpc_error* EdsResponseParse(
2142
- XdsClient* client, TraceFlag* tracer,
1766
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
2143
1767
  const envoy_service_discovery_v3_DiscoveryResponse* response,
2144
1768
  const std::set<absl::string_view>& expected_eds_service_names,
2145
1769
  XdsApi::EdsUpdateMap* eds_update_map, upb_arena* arena) {
@@ -2165,7 +1789,8 @@ grpc_error* EdsResponseParse(
2165
1789
  return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
2166
1790
  "Can't parse cluster_load_assignment.");
2167
1791
  }
2168
- MaybeLogClusterLoadAssignment(client, tracer, cluster_load_assignment);
1792
+ MaybeLogClusterLoadAssignment(client, tracer, symtab,
1793
+ cluster_load_assignment);
2169
1794
  // Check the EDS service name. Ignore unexpected names.
2170
1795
  std::string eds_service_name = UpbStringToStdString(
2171
1796
  envoy_config_endpoint_v3_ClusterLoadAssignment_cluster_name(
@@ -2263,7 +1888,7 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2263
1888
  GRPC_ERROR_CREATE_FROM_STATIC_STRING("Can't decode DiscoveryResponse.");
2264
1889
  return result;
2265
1890
  }
2266
- MaybeLogDiscoveryResponse(client_, tracer_, response);
1891
+ MaybeLogDiscoveryResponse(client_, tracer_, symtab_.ptr(), response);
2267
1892
  // Record the type_url, the version_info, and the nonce of the response.
2268
1893
  result.type_url = TypeUrlInternalToExternal(UpbStringToAbsl(
2269
1894
  envoy_service_discovery_v3_DiscoveryResponse_type_url(response)));
@@ -2273,21 +1898,22 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2273
1898
  envoy_service_discovery_v3_DiscoveryResponse_nonce(response));
2274
1899
  // Parse the response according to the resource type.
2275
1900
  if (IsLds(result.type_url)) {
2276
- result.parse_error =
2277
- LdsResponseParse(client_, tracer_, response, expected_listener_names,
2278
- &result.lds_update_map, arena.ptr());
1901
+ result.parse_error = LdsResponseParse(client_, tracer_, symtab_.ptr(),
1902
+ response, expected_listener_names,
1903
+ &result.lds_update_map, arena.ptr());
2279
1904
  } else if (IsRds(result.type_url)) {
2280
- result.parse_error = RdsResponseParse(client_, tracer_, response,
2281
- expected_route_configuration_names,
2282
- &result.rds_update_map, arena.ptr());
2283
- } else if (IsCds(result.type_url)) {
2284
1905
  result.parse_error =
2285
- CdsResponseParse(client_, tracer_, response, expected_cluster_names,
2286
- &result.cds_update_map, arena.ptr());
1906
+ RdsResponseParse(client_, tracer_, symtab_.ptr(), response,
1907
+ expected_route_configuration_names,
1908
+ &result.rds_update_map, arena.ptr());
1909
+ } else if (IsCds(result.type_url)) {
1910
+ result.parse_error = CdsResponseParse(client_, tracer_, symtab_.ptr(),
1911
+ response, expected_cluster_names,
1912
+ &result.cds_update_map, arena.ptr());
2287
1913
  } else if (IsEds(result.type_url)) {
2288
- result.parse_error =
2289
- EdsResponseParse(client_, tracer_, response, expected_eds_service_names,
2290
- &result.eds_update_map, arena.ptr());
1914
+ result.parse_error = EdsResponseParse(client_, tracer_, symtab_.ptr(),
1915
+ response, expected_eds_service_names,
1916
+ &result.eds_update_map, arena.ptr());
2291
1917
  }
2292
1918
  return result;
2293
1919
  }
@@ -2295,120 +1921,16 @@ XdsApi::AdsParseResult XdsApi::ParseAdsResponse(
2295
1921
  namespace {
2296
1922
 
2297
1923
  void MaybeLogLrsRequest(
2298
- XdsClient* client, TraceFlag* tracer,
2299
- const envoy_service_load_stats_v3_LoadStatsRequest* request,
2300
- const std::string& build_version) {
1924
+ XdsClient* client, TraceFlag* tracer, upb_symtab* symtab,
1925
+ const envoy_service_load_stats_v3_LoadStatsRequest* request) {
2301
1926
  if (GRPC_TRACE_FLAG_ENABLED(*tracer) &&
2302
1927
  gpr_should_log(GPR_LOG_SEVERITY_DEBUG)) {
2303
- // TODO(roth): When we can upgrade upb, use upb textformat code to dump
2304
- // the raw proto instead of doing this manually.
2305
- std::vector<std::string> fields;
2306
- // node
2307
- const auto* node =
2308
- envoy_service_load_stats_v3_LoadStatsRequest_node(request);
2309
- if (node != nullptr) {
2310
- AddNodeLogFields(node, build_version, &fields);
2311
- }
2312
- // cluster_stats
2313
- size_t num_cluster_stats;
2314
- const struct envoy_config_endpoint_v3_ClusterStats* const* cluster_stats =
2315
- envoy_service_load_stats_v3_LoadStatsRequest_cluster_stats(
2316
- request, &num_cluster_stats);
2317
- for (size_t i = 0; i < num_cluster_stats; ++i) {
2318
- const auto* cluster_stat = cluster_stats[i];
2319
- fields.emplace_back("cluster_stats {");
2320
- // cluster_name
2321
- AddStringField(
2322
- " cluster_name",
2323
- envoy_config_endpoint_v3_ClusterStats_cluster_name(cluster_stat),
2324
- &fields);
2325
- // cluster_service_name
2326
- AddStringField(" cluster_service_name",
2327
- envoy_config_endpoint_v3_ClusterStats_cluster_service_name(
2328
- cluster_stat),
2329
- &fields);
2330
- // upstream_locality_stats
2331
- size_t num_stats;
2332
- const envoy_config_endpoint_v3_UpstreamLocalityStats* const* stats =
2333
- envoy_config_endpoint_v3_ClusterStats_upstream_locality_stats(
2334
- cluster_stat, &num_stats);
2335
- for (size_t j = 0; j < num_stats; ++j) {
2336
- const auto* stat = stats[j];
2337
- fields.emplace_back(" upstream_locality_stats {");
2338
- // locality
2339
- const auto* locality =
2340
- envoy_config_endpoint_v3_UpstreamLocalityStats_locality(stat);
2341
- if (locality != nullptr) {
2342
- fields.emplace_back(" locality {");
2343
- AddLocalityField(3, locality, &fields);
2344
- fields.emplace_back(" }");
2345
- }
2346
- // total_successful_requests
2347
- fields.emplace_back(absl::StrCat(
2348
- " total_successful_requests: ",
2349
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_successful_requests(
2350
- stat)));
2351
- // total_requests_in_progress
2352
- fields.emplace_back(absl::StrCat(
2353
- " total_requests_in_progress: ",
2354
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_requests_in_progress(
2355
- stat)));
2356
- // total_error_requests
2357
- fields.emplace_back(absl::StrCat(
2358
- " total_error_requests: ",
2359
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_error_requests(
2360
- stat)));
2361
- // total_issued_requests
2362
- fields.emplace_back(absl::StrCat(
2363
- " total_issued_requests: ",
2364
- envoy_config_endpoint_v3_UpstreamLocalityStats_total_issued_requests(
2365
- stat)));
2366
- fields.emplace_back(" }");
2367
- }
2368
- // total_dropped_requests
2369
- fields.emplace_back(absl::StrCat(
2370
- " total_dropped_requests: ",
2371
- envoy_config_endpoint_v3_ClusterStats_total_dropped_requests(
2372
- cluster_stat)));
2373
- // dropped_requests
2374
- size_t num_drops;
2375
- const envoy_config_endpoint_v3_ClusterStats_DroppedRequests* const*
2376
- drops = envoy_config_endpoint_v3_ClusterStats_dropped_requests(
2377
- cluster_stat, &num_drops);
2378
- for (size_t j = 0; j < num_drops; ++j) {
2379
- const auto* drop = drops[j];
2380
- fields.emplace_back(" dropped_requests {");
2381
- // category
2382
- AddStringField(
2383
- " category",
2384
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_category(
2385
- drop),
2386
- &fields);
2387
- // dropped_count
2388
- fields.emplace_back(absl::StrCat(
2389
- " dropped_count: ",
2390
- envoy_config_endpoint_v3_ClusterStats_DroppedRequests_dropped_count(
2391
- drop)));
2392
- fields.emplace_back(" }");
2393
- }
2394
- // load_report_interval
2395
- const auto* load_report_interval =
2396
- envoy_config_endpoint_v3_ClusterStats_load_report_interval(
2397
- cluster_stat);
2398
- if (load_report_interval != nullptr) {
2399
- fields.emplace_back(" load_report_interval {");
2400
- fields.emplace_back(absl::StrCat(
2401
- " seconds: ",
2402
- google_protobuf_Duration_seconds(load_report_interval)));
2403
- fields.emplace_back(
2404
- absl::StrCat(" nanos: ",
2405
- google_protobuf_Duration_nanos(load_report_interval)));
2406
- fields.emplace_back(" }");
2407
- }
2408
- fields.emplace_back("}");
2409
- }
1928
+ const upb_msgdef* msg_type =
1929
+ envoy_service_load_stats_v3_LoadStatsRequest_getmsgdef(symtab);
1930
+ char buf[10240];
1931
+ upb_text_encode(request, msg_type, nullptr, 0, buf, sizeof(buf));
2410
1932
  gpr_log(GPR_DEBUG, "[xds_client %p] constructed LRS request: %s", client,
2411
- absl::StrJoin(fields, "\n").c_str());
1933
+ buf);
2412
1934
  }
2413
1935
  }
2414
1936
 
@@ -2423,7 +1945,8 @@ grpc_slice SerializeLrsRequest(
2423
1945
 
2424
1946
  } // namespace
2425
1947
 
2426
- grpc_slice XdsApi::CreateLrsInitialRequest() {
1948
+ grpc_slice XdsApi::CreateLrsInitialRequest(
1949
+ const XdsBootstrap::XdsServer& server) {
2427
1950
  upb::Arena arena;
2428
1951
  // Create a request.
2429
1952
  envoy_service_load_stats_v3_LoadStatsRequest* request =
@@ -2432,12 +1955,12 @@ grpc_slice XdsApi::CreateLrsInitialRequest() {
2432
1955
  envoy_config_core_v3_Node* node_msg =
2433
1956
  envoy_service_load_stats_v3_LoadStatsRequest_mutable_node(request,
2434
1957
  arena.ptr());
2435
- PopulateNode(arena.ptr(), bootstrap_, build_version_, user_agent_name_,
2436
- node_msg);
1958
+ PopulateNode(arena.ptr(), node_, server.ShouldUseV3(), build_version_,
1959
+ user_agent_name_, node_msg);
2437
1960
  envoy_config_core_v3_Node_add_client_features(
2438
1961
  node_msg, upb_strview_makez("envoy.lrs.supports_send_all_clusters"),
2439
1962
  arena.ptr());
2440
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
1963
+ MaybeLogLrsRequest(client_, tracer_, symtab_.ptr(), request);
2441
1964
  return SerializeLrsRequest(request, arena.ptr());
2442
1965
  }
2443
1966
 
@@ -2549,7 +2072,7 @@ grpc_slice XdsApi::CreateLrsRequest(
2549
2072
  google_protobuf_Duration_set_seconds(load_report_interval, timespec.tv_sec);
2550
2073
  google_protobuf_Duration_set_nanos(load_report_interval, timespec.tv_nsec);
2551
2074
  }
2552
- MaybeLogLrsRequest(client_, tracer_, request, build_version_);
2075
+ MaybeLogLrsRequest(client_, tracer_, symtab_.ptr(), request);
2553
2076
  return SerializeLrsRequest(request, arena.ptr());
2554
2077
  }
2555
2078