grpc 1.83.1 → 1.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +21 -17
  3. data/include/grpc/credentials.h +10 -0
  4. data/include/grpc/grpc_security_constants.h +2 -0
  5. data/include/grpc/impl/channel_arg_names.h +9 -0
  6. data/src/core/call/call_filters.h +4 -2
  7. data/src/core/call/client_call.cc +20 -8
  8. data/src/core/call/client_call.h +4 -0
  9. data/src/core/call/interception_chain.cc +2 -0
  10. data/src/core/call/interception_chain.h +14 -1
  11. data/src/core/call/metadata.cc +1 -3
  12. data/src/core/call/metadata_batch.h +13 -5
  13. data/src/core/call/server_call.cc +31 -14
  14. data/src/core/call/server_call.h +4 -0
  15. data/src/core/channelz/text_encode.cc +9 -4
  16. data/src/core/channelz/v2tov1/convert.cc +2 -2
  17. data/src/core/client_channel/backup_poller.cc +1 -2
  18. data/src/core/client_channel/client_channel.cc +6 -33
  19. data/src/core/client_channel/client_channel_filter.cc +22 -55
  20. data/src/core/client_channel/client_channel_filter.h +2 -2
  21. data/src/core/client_channel/client_channel_service_config.cc +3 -19
  22. data/src/core/client_channel/direct_channel.cc +7 -1
  23. data/src/core/client_channel/direct_channel.h +2 -2
  24. data/src/core/client_channel/load_balanced_call_destination.cc +5 -3
  25. data/src/core/client_channel/retry_filter_legacy_call_data.cc +5 -12
  26. data/src/core/client_channel/subchannel.cc +310 -1058
  27. data/src/core/client_channel/subchannel.h +44 -329
  28. data/src/core/client_channel/subchannel_metrics.cc +48 -0
  29. data/src/core/client_channel/subchannel_metrics.h +60 -0
  30. data/src/core/credentials/call/external/file_external_account_credentials.cc +1 -1
  31. data/src/core/credentials/call/external/url_external_account_credentials.cc +2 -3
  32. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.cc +8 -24
  33. data/src/core/credentials/call/gcp_service_account_identity/gcp_service_account_identity_credentials.h +3 -6
  34. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.cc +525 -0
  35. data/src/core/credentials/call/gdch_service_account/gdch_service_account_credentials.h +138 -0
  36. data/src/core/credentials/call/json_util.h +1 -0
  37. data/src/core/credentials/call/jwt/json_token.cc +10 -2
  38. data/src/core/credentials/call/jwt/jwt_verifier.cc +15 -1
  39. data/src/core/credentials/call/jwt_token_file/jwt_token_file_call_credentials.cc +1 -1
  40. data/src/core/credentials/call/oauth2/oauth2_credentials.cc +42 -79
  41. data/src/core/credentials/call/oauth2/oauth2_credentials.h +2 -5
  42. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.cc +52 -31
  43. data/src/core/credentials/call/token_fetcher/token_fetcher_credentials.h +21 -8
  44. data/src/core/credentials/transport/google_default/google_default_credentials.cc +3 -4
  45. data/src/core/credentials/transport/ssl/ssl_credentials.cc +59 -72
  46. data/src/core/credentials/transport/ssl/ssl_credentials.h +9 -8
  47. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +12 -6
  48. data/src/core/credentials/transport/ssl/ssl_security_connector.h +4 -4
  49. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -18
  50. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +9 -6
  51. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +45 -56
  52. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +5 -4
  53. data/src/core/credentials/transport/tls/grpc_tls_certificate_selector.h +26 -0
  54. data/src/core/credentials/transport/tls/grpc_tls_crl_provider.cc +1 -1
  55. data/src/core/credentials/transport/tls/load_system_roots.h +2 -6
  56. data/src/core/credentials/transport/tls/load_system_roots_fallback.cc +2 -4
  57. data/src/core/credentials/transport/tls/load_system_roots_supported.cc +13 -15
  58. data/src/core/credentials/transport/tls/load_system_roots_supported.h +3 -2
  59. data/src/core/credentials/transport/tls/load_system_roots_windows.cc +5 -8
  60. data/src/core/credentials/transport/tls/spiffe_utils.cc +1 -1
  61. data/src/core/credentials/transport/tls/ssl_utils.cc +39 -28
  62. data/src/core/credentials/transport/tls/ssl_utils.h +12 -49
  63. data/src/core/credentials/transport/tls/tls_security_connector.cc +48 -33
  64. data/src/core/credentials/transport/tls/tls_security_connector.h +31 -10
  65. data/src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc +15 -11
  66. data/src/core/ext/filters/http/http_filters_plugin.cc +20 -9
  67. data/src/core/ext/filters/rbac/rbac_filter.cc +43 -21
  68. data/src/core/ext/filters/rbac/rbac_filter.h +21 -3
  69. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +2 -2
  70. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -1
  71. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +6 -20
  72. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +32 -67
  73. data/src/core/ext/transport/chttp2/transport/flow_control.cc +2 -0
  74. data/src/core/ext/transport/chttp2/transport/flow_control.h +78 -4
  75. data/src/core/ext/transport/chttp2/transport/frame.h +2 -0
  76. data/src/core/ext/transport/chttp2/transport/frame_data.cc +3 -4
  77. data/src/core/ext/transport/chttp2/transport/goaway.h +7 -0
  78. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +5 -3
  79. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +3 -1
  80. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +141 -130
  81. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +22 -22
  82. data/src/core/ext/transport/chttp2/transport/http2_server_transport.cc +402 -269
  83. data/src/core/ext/transport/chttp2/transport/http2_server_transport.h +80 -49
  84. data/src/core/ext/transport/chttp2/transport/http2_settings_promises.h +1 -2
  85. data/src/core/ext/transport/chttp2/transport/http2_status.h +38 -37
  86. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +178 -5
  87. data/src/core/ext/transport/chttp2/transport/http2_transport.h +345 -5
  88. data/src/core/ext/transport/chttp2/transport/parsing.cc +5 -5
  89. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +3 -2
  90. data/src/core/ext/transport/chttp2/transport/ping_promise.h +25 -5
  91. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +3 -4
  92. data/src/core/ext/transport/chttp2/transport/read_context.h +30 -3
  93. data/src/core/ext/transport/chttp2/transport/stream.h +65 -23
  94. data/src/core/ext/transport/chttp2/transport/writing.cc +0 -3
  95. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -5
  96. data/src/core/ext/transport/inproc/legacy_inproc_transport.cc +4 -17
  97. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb.h +1912 -0
  98. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.c +300 -0
  99. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upb_minitable.h +37 -0
  100. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb.h +187 -0
  101. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.c +64 -0
  102. data/src/core/ext/upb-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upb_minitable.h +31 -0
  103. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb.h +2362 -0
  104. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.c +556 -0
  105. data/src/core/ext/upb-gen/envoy/service/ext_proc/v3/external_processor.upb_minitable.h +47 -0
  106. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb.h +5 -5
  107. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.c +3 -3
  108. data/src/core/ext/upb-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upb_minitable.h +5 -5
  109. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.c +453 -0
  110. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/ext_proc.upbdefs.h +67 -0
  111. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.c +142 -0
  112. data/src/core/ext/upbdefs-gen/envoy/extensions/filters/http/ext_proc/v3/processing_mode.upbdefs.h +37 -0
  113. data/src/core/ext/upbdefs-gen/grpc/channelz/v1/channelz.upbdefs.c +715 -0
  114. data/src/core/ext/upbdefs-gen/{src/proto/grpc/channelz → grpc/channelz/v1}/channelz.upbdefs.h +44 -44
  115. data/src/core/filter/auth/server_auth_filter.cc +2 -3
  116. data/src/core/filter/composite/composite_filter.cc +45 -33
  117. data/src/core/filter/composite/composite_filter.h +5 -4
  118. data/src/core/filter/ext_proc/ext_proc_filter.cc +224 -0
  119. data/src/core/filter/ext_proc/ext_proc_filter.h +155 -0
  120. data/src/core/filter/ext_proc/ext_proc_messages.cc +701 -0
  121. data/src/core/filter/ext_proc/ext_proc_messages.h +297 -0
  122. data/src/core/filter/filter_args.h +13 -2
  123. data/src/core/handshaker/http_connect/http_proxy_mapper.cc +30 -3
  124. data/src/core/handshaker/security/security_handshaker.cc +9 -6
  125. data/src/core/lib/channel/channel_stack.cc +3 -0
  126. data/src/core/lib/channel/channel_stack.h +2 -0
  127. data/src/core/lib/channel/channel_stack_builder_impl.cc +1 -2
  128. data/src/core/lib/channel/promise_based_filter.cc +132 -20
  129. data/src/core/lib/channel/promise_based_filter.h +42 -12
  130. data/src/core/lib/compression/compression_internal.cc +4 -5
  131. data/src/core/lib/debug/trace_flags.cc +8 -0
  132. data/src/core/lib/debug/trace_flags.h +3 -0
  133. data/src/core/lib/event_engine/ares_resolver.cc +54 -50
  134. data/src/core/lib/event_engine/ares_resolver.h +3 -2
  135. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +3 -3
  136. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +4 -10
  137. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +74 -33
  138. data/src/core/lib/event_engine/posix_engine/posix_endpoint.h +4 -4
  139. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +6 -2
  140. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +3 -0
  141. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +3 -0
  142. data/src/core/lib/event_engine/windows/windows_endpoint.cc +1 -3
  143. data/src/core/lib/experiments/experiments.cc +60 -96
  144. data/src/core/lib/experiments/experiments.h +34 -50
  145. data/src/core/lib/iomgr/cfstream_handle.cc +2 -6
  146. data/src/core/lib/iomgr/endpoint_cfstream.cc +3 -10
  147. data/src/core/lib/iomgr/error.cc +2 -6
  148. data/src/core/lib/iomgr/error_cfstream.cc +1 -1
  149. data/src/core/lib/iomgr/ev_poll_posix.cc +5 -9
  150. data/src/core/lib/iomgr/event_engine_shims/closure.cc +1 -1
  151. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +1 -2
  152. data/src/core/lib/iomgr/event_engine_shims/tcp_client.cc +1 -2
  153. data/src/core/lib/iomgr/iomgr_posix.cc +0 -4
  154. data/src/core/lib/iomgr/iomgr_posix_cfstream.cc +0 -4
  155. data/src/core/lib/iomgr/iomgr_windows.cc +0 -4
  156. data/src/core/lib/iomgr/socket_factory_posix.h +1 -1
  157. data/src/core/lib/iomgr/socket_utils_posix.cc +3 -0
  158. data/src/core/lib/iomgr/socket_utils_posix.h +3 -0
  159. data/src/core/lib/iomgr/systemd_utils.cc +0 -1
  160. data/src/core/lib/iomgr/tcp_client.h +1 -1
  161. data/src/core/lib/iomgr/tcp_posix.cc +23 -15
  162. data/src/core/lib/iomgr/tcp_server.h +1 -1
  163. data/src/core/lib/iomgr/tcp_server_posix.cc +2 -3
  164. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -1
  165. data/src/core/lib/iomgr/tcp_server_windows.cc +0 -1
  166. data/src/core/lib/iomgr/tcp_windows.cc +5 -10
  167. data/src/core/lib/iomgr/unix_sockets_posix.cc +2 -4
  168. data/src/core/lib/iomgr/unix_sockets_posix.h +3 -1
  169. data/src/core/lib/iomgr/vsock.h +3 -1
  170. data/src/core/lib/resource_quota/memory_quota.cc +1 -1
  171. data/src/core/lib/security/authorization/rbac_policy.cc +139 -56
  172. data/src/core/lib/security/authorization/rbac_policy.h +21 -3
  173. data/src/core/lib/surface/call.cc +3 -9
  174. data/src/core/lib/surface/call_utils.h +113 -0
  175. data/src/core/lib/surface/channel_create.cc +1 -1
  176. data/src/core/lib/surface/channel_create.h +0 -2
  177. data/src/core/lib/surface/channel_init.cc +77 -38
  178. data/src/core/lib/surface/channel_init.h +30 -16
  179. data/src/core/lib/surface/filter_stack_call.cc +5 -10
  180. data/src/core/lib/surface/init.cc +13 -27
  181. data/src/core/lib/surface/version.cc +1 -1
  182. data/src/core/lib/transport/error_utils.cc +0 -27
  183. data/src/core/lib/transport/error_utils.h +0 -16
  184. data/src/core/lib/transport/transport.h +7 -5
  185. data/src/core/load_balancing/pick_first/pick_first.cc +2 -0
  186. data/src/core/load_balancing/rls/rls.cc +28 -11
  187. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc +33 -42
  188. data/src/core/load_balancing/weighted_round_robin/weighted_round_robin.h +0 -2
  189. data/src/core/load_balancing/xds/cds.cc +3 -1
  190. data/src/core/load_balancing/xds/xds_cluster_impl.cc +0 -1
  191. data/src/core/mitigation_engine/mitigation.h +14 -5
  192. data/src/core/mitigation_engine/mitigation_engine.h +7 -3
  193. data/src/core/mitigation_engine/mitigation_provider.h +2 -1
  194. data/src/core/plugin_registry/grpc_plugin_registry.cc +39 -8
  195. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.cc → dns_resolver.cc} +42 -41
  196. data/src/core/resolver/dns/{event_engine/event_engine_client_channel_resolver.h → dns_resolver.h} +8 -5
  197. data/src/core/resolver/dns/{event_engine/service_config_helper.cc → service_config_helper.cc} +1 -1
  198. data/src/core/resolver/dns/{event_engine/service_config_helper.h → service_config_helper.h} +3 -3
  199. data/src/core/resolver/endpoint_addresses.h +3 -0
  200. data/src/core/resolver/google_c2p/google_c2p_resolver.cc +2 -1
  201. data/src/core/resolver/xds/xds_resolver.cc +35 -9
  202. data/src/core/server/server.cc +2 -6
  203. data/src/core/server/server_config_selector.h +18 -3
  204. data/src/core/server/server_config_selector_filter.cc +178 -91
  205. data/src/core/server/server_config_selector_filter.h +58 -3
  206. data/src/core/server/xds_server_config_fetcher.cc +196 -129
  207. data/src/core/server/xds_server_config_fetcher.h +49 -0
  208. data/src/core/server/xds_server_config_fetcher_legacy.cc +41 -37
  209. data/src/core/telemetry/histogram.h +94 -14
  210. data/src/core/telemetry/instrument.cc +179 -74
  211. data/src/core/telemetry/instrument.h +78 -30
  212. data/src/core/telemetry/metrics.h +5 -0
  213. data/src/core/{resolver/dns/dns_resolver_plugin.h → telemetry/telemetry_label.h} +12 -8
  214. data/src/core/tsi/alts/crypt/aes_gcm.cc +10 -13
  215. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +2 -2
  216. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +3 -1
  217. data/src/core/tsi/ssl_telemetry_utils.cc +216 -259
  218. data/src/core/tsi/ssl_telemetry_utils.h +12 -2
  219. data/src/core/tsi/ssl_transport_security.cc +238 -80
  220. data/src/core/tsi/ssl_transport_security.h +63 -33
  221. data/src/core/tsi/tls_telemetry.cc +31 -0
  222. data/src/core/tsi/tls_telemetry.h +47 -0
  223. data/src/core/tsi/transport_security.cc +2 -2
  224. data/src/core/tsi/transport_security.h +1 -1
  225. data/src/core/tsi/transport_security_interface.h +1 -1
  226. data/src/core/{resolver/dns/native/dns_resolver.h → util/address_sorting_init.cc} +21 -8
  227. data/src/core/{resolver/dns/c_ares/grpc_ares_wrapper_posix.cc → util/address_sorting_init.h} +7 -8
  228. data/src/core/util/http_client/httpcli.cc +16 -53
  229. data/src/core/util/http_client/httpcli.h +0 -7
  230. data/src/core/util/http_client/httpcli_security_connector.cc +13 -8
  231. data/src/core/util/linux/cpu.cc +1 -1
  232. data/src/core/util/load_file.cc +3 -9
  233. data/src/core/util/load_file.h +3 -4
  234. data/src/core/util/matchers.h +8 -0
  235. data/src/core/util/posix/cpu.cc +1 -1
  236. data/src/core/util/status_helper.cc +0 -20
  237. data/src/core/util/status_helper.h +3 -14
  238. data/src/core/xds/grpc/xds_audit_logger_registry.cc +51 -31
  239. data/src/core/xds/grpc/xds_audit_logger_registry.h +17 -3
  240. data/src/core/xds/grpc/xds_bootstrap_grpc.cc +2 -10
  241. data/src/core/xds/grpc/xds_bootstrap_grpc.h +8 -6
  242. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.cc +488 -0
  243. data/src/core/xds/grpc/xds_bootstrap_grpc_builder.h +97 -0
  244. data/src/core/xds/grpc/xds_certificate_provider.cc +7 -7
  245. data/src/core/xds/grpc/xds_client_grpc.cc +4 -8
  246. data/src/core/xds/grpc/xds_client_grpc.h +0 -4
  247. data/src/core/xds/grpc/xds_cluster.h +1 -0
  248. data/src/core/xds/grpc/xds_cluster_parser.cc +1 -5
  249. data/src/core/xds/grpc/xds_cluster_parser.h +0 -2
  250. data/src/core/xds/grpc/xds_cluster_specifier_plugin.cc +0 -2
  251. data/src/core/xds/grpc/xds_cluster_specifier_plugin.h +0 -2
  252. data/src/core/xds/grpc/xds_common_types.cc +0 -91
  253. data/src/core/xds/grpc/xds_common_types.h +1 -47
  254. data/src/core/xds/grpc/xds_common_types_parser.cc +84 -378
  255. data/src/core/xds/grpc/xds_common_types_parser.h +9 -11
  256. data/src/core/xds/grpc/xds_endpoint_parser.cc +0 -2
  257. data/src/core/xds/grpc/xds_grpc_service_parser.cc +177 -0
  258. data/src/core/{resolver/dns/c_ares/dns_resolver_ares.h → xds/grpc/xds_grpc_service_parser.h} +14 -9
  259. data/src/core/xds/grpc/xds_http_composite_filter.cc +26 -21
  260. data/src/core/xds/grpc/xds_http_composite_filter.h +4 -3
  261. data/src/core/xds/grpc/xds_http_ext_proc_filter.cc +418 -0
  262. data/src/core/xds/grpc/xds_http_ext_proc_filter.h +89 -0
  263. data/src/core/xds/grpc/xds_http_fault_filter.cc +9 -12
  264. data/src/core/xds/grpc/xds_http_fault_filter.h +1 -4
  265. data/src/core/xds/grpc/xds_http_filter.cc +2 -1
  266. data/src/core/xds/grpc/xds_http_filter.h +6 -5
  267. data/src/core/xds/grpc/xds_http_filter_registry.cc +10 -127
  268. data/src/core/xds/grpc/xds_http_filter_registry.h +7 -59
  269. data/src/core/xds/grpc/xds_http_gcp_authn_filter.cc +13 -14
  270. data/src/core/xds/grpc/xds_http_gcp_authn_filter.h +3 -2
  271. data/src/core/xds/grpc/xds_http_rbac_filter.cc +403 -25
  272. data/src/core/xds/grpc/xds_http_rbac_filter.h +1 -3
  273. data/src/core/xds/grpc/xds_http_stateful_session_filter.cc +8 -13
  274. data/src/core/xds/grpc/xds_http_stateful_session_filter.h +1 -4
  275. data/src/core/xds/grpc/xds_lb_policy_registry.cc +0 -292
  276. data/src/core/xds/grpc/xds_lb_policy_registry.h +7 -3
  277. data/src/core/xds/grpc/xds_listener.cc +2 -0
  278. data/src/core/xds/grpc/xds_listener.h +5 -0
  279. data/src/core/xds/grpc/xds_listener_parser.cc +16 -11
  280. data/src/core/xds/grpc/xds_matcher_parse.h +3 -1
  281. data/src/core/xds/grpc/xds_metadata_parser.cc +6 -1
  282. data/src/core/xds/grpc/xds_metadata_parser.h +2 -0
  283. data/src/core/xds/grpc/xds_route_config.cc +2 -0
  284. data/src/core/xds/grpc/xds_route_config.h +3 -1
  285. data/src/core/xds/grpc/xds_route_config_parser.cc +13 -79
  286. data/src/core/xds/grpc/xds_route_config_parser.h +0 -3
  287. data/src/core/xds/grpc/xds_routing.cc +116 -69
  288. data/src/core/xds/grpc/xds_routing.h +19 -8
  289. data/src/core/xds/grpc/xds_tls_context.cc +117 -0
  290. data/src/core/xds/grpc/xds_tls_context.h +76 -0
  291. data/src/core/xds/grpc/xds_tls_context_parser.cc +275 -0
  292. data/src/core/xds/grpc/xds_tls_context_parser.h +35 -0
  293. data/src/core/xds/grpc/xds_transport_grpc.cc +41 -38
  294. data/src/core/xds/grpc/xds_transport_grpc.h +4 -2
  295. data/src/ruby/ext/grpc/rb_call.c +26 -15
  296. data/src/ruby/ext/grpc/rb_completion_queue.c +6 -5
  297. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
  298. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +3 -0
  299. data/src/ruby/lib/grpc/version.rb +1 -1
  300. data/src/ruby/pb/test/client.rb +5 -4
  301. data/src/ruby/spec/call_spec.rb +14 -0
  302. data/src/ruby/spec/generic/server_interceptors_spec.rb +3 -6
  303. metadata +50 -35
  304. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +0 -716
  305. data/src/core/lib/iomgr/resolve_address.cc +0 -59
  306. data/src/core/lib/iomgr/resolve_address.h +0 -125
  307. data/src/core/lib/iomgr/resolve_address_impl.h +0 -58
  308. data/src/core/lib/iomgr/resolve_address_posix.cc +0 -184
  309. data/src/core/lib/iomgr/resolve_address_posix.h +0 -78
  310. data/src/core/lib/iomgr/resolve_address_windows.cc +0 -169
  311. data/src/core/lib/iomgr/resolve_address_windows.h +0 -76
  312. data/src/core/resolver/dns/c_ares/dns_resolver_ares.cc +0 -781
  313. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +0 -93
  314. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +0 -203
  315. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +0 -838
  316. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +0 -1237
  317. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +0 -130
  318. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper_windows.cc +0 -35
  319. data/src/core/resolver/dns/dns_resolver_plugin.cc +0 -64
  320. data/src/core/resolver/dns/native/dns_resolver.cc +0 -173
  321. data/src/core/util/json/json_util.cc +0 -101
  322. data/src/core/util/json/json_util.h +0 -163
@@ -0,0 +1,117 @@
1
+ //
2
+ // Copyright 2018 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #include "src/core/xds/grpc/xds_tls_context.h"
18
+
19
+ #include <string>
20
+ #include <variant>
21
+
22
+ #include "src/core/util/match.h"
23
+ #include "src/core/util/string.h"
24
+
25
+ namespace grpc_core {
26
+
27
+ //
28
+ // CommonTlsContext::CertificateProviderPluginInstance
29
+ //
30
+
31
+ std::string CommonTlsContext::CertificateProviderPluginInstance::ToString()
32
+ const {
33
+ std::string result = "{";
34
+ bool is_first = true;
35
+ if (!instance_name.empty()) {
36
+ StrAppend(result, "instance_name=");
37
+ StrAppend(result, instance_name);
38
+ is_first = false;
39
+ }
40
+ if (!certificate_name.empty()) {
41
+ if (!is_first) StrAppend(result, ", ");
42
+ StrAppend(result, "certificate_name=");
43
+ StrAppend(result, certificate_name);
44
+ }
45
+ StrAppend(result, "}");
46
+ return result;
47
+ }
48
+
49
+ bool CommonTlsContext::CertificateProviderPluginInstance::Empty() const {
50
+ return instance_name.empty() && certificate_name.empty();
51
+ }
52
+
53
+ //
54
+ // CommonTlsContext::CertificateValidationContext
55
+ //
56
+
57
+ std::string CommonTlsContext::CertificateValidationContext::ToString() const {
58
+ std::string result = "{";
59
+ bool is_first = true;
60
+ Match(
61
+ ca_certs, [](const std::monostate&) {},
62
+ [&](const CertificateProviderPluginInstance& cert_provider) {
63
+ StrAppend(result, "ca_certs=cert_provider");
64
+ StrAppend(result, cert_provider.ToString());
65
+ is_first = false;
66
+ },
67
+ [&](const SystemRootCerts&) {
68
+ StrAppend(result, "ca_certs=system_root_certs{}");
69
+ is_first = false;
70
+ });
71
+ if (!match_subject_alt_names.empty()) {
72
+ if (!is_first) StrAppend(result, ", ");
73
+ StrAppend(result, "match_subject_alt_names=[");
74
+ bool is_first_san = true;
75
+ for (const auto& match : match_subject_alt_names) {
76
+ if (!is_first_san) StrAppend(result, ", ");
77
+ StrAppend(result, match.ToString());
78
+ is_first_san = false;
79
+ }
80
+ StrAppend(result, "]");
81
+ }
82
+ StrAppend(result, "}");
83
+ return result;
84
+ }
85
+
86
+ bool CommonTlsContext::CertificateValidationContext::Empty() const {
87
+ return std::holds_alternative<std::monostate>(ca_certs) &&
88
+ match_subject_alt_names.empty();
89
+ }
90
+
91
+ //
92
+ // CommonTlsContext
93
+ //
94
+
95
+ std::string CommonTlsContext::ToString() const {
96
+ std::string result = "{";
97
+ bool is_first = true;
98
+ if (!tls_certificate_provider_instance.Empty()) {
99
+ StrAppend(result, "tls_certificate_provider_instance=");
100
+ StrAppend(result, tls_certificate_provider_instance.ToString());
101
+ is_first = false;
102
+ }
103
+ if (!certificate_validation_context.Empty()) {
104
+ if (!is_first) StrAppend(result, ", ");
105
+ StrAppend(result, "certificate_validation_context=");
106
+ StrAppend(result, certificate_validation_context.ToString());
107
+ }
108
+ StrAppend(result, "}");
109
+ return result;
110
+ }
111
+
112
+ bool CommonTlsContext::Empty() const {
113
+ return tls_certificate_provider_instance.Empty() &&
114
+ certificate_validation_context.Empty();
115
+ }
116
+
117
+ } // namespace grpc_core
@@ -0,0 +1,76 @@
1
+ //
2
+ // Copyright 2018 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_H
18
+ #define GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_H
19
+
20
+ #include <string>
21
+ #include <variant>
22
+ #include <vector>
23
+
24
+ #include "src/core/util/matchers.h"
25
+
26
+ namespace grpc_core {
27
+
28
+ struct CommonTlsContext {
29
+ struct CertificateProviderPluginInstance {
30
+ std::string instance_name;
31
+ std::string certificate_name;
32
+
33
+ bool operator==(const CertificateProviderPluginInstance& other) const {
34
+ return instance_name == other.instance_name &&
35
+ certificate_name == other.certificate_name;
36
+ }
37
+
38
+ std::string ToString() const;
39
+ bool Empty() const;
40
+ };
41
+
42
+ struct CertificateValidationContext {
43
+ struct SystemRootCerts {
44
+ bool operator==(const SystemRootCerts&) const { return true; }
45
+ };
46
+ std::variant<std::monostate, CertificateProviderPluginInstance,
47
+ SystemRootCerts>
48
+ ca_certs;
49
+ std::vector<StringMatcher> match_subject_alt_names;
50
+
51
+ bool operator==(const CertificateValidationContext& other) const {
52
+ return ca_certs == other.ca_certs &&
53
+ match_subject_alt_names == other.match_subject_alt_names;
54
+ }
55
+
56
+ std::string ToString() const;
57
+ bool Empty() const;
58
+ };
59
+
60
+ CertificateValidationContext certificate_validation_context;
61
+ CertificateProviderPluginInstance tls_certificate_provider_instance;
62
+
63
+ bool operator==(const CommonTlsContext& other) const {
64
+ return certificate_validation_context ==
65
+ other.certificate_validation_context &&
66
+ tls_certificate_provider_instance ==
67
+ other.tls_certificate_provider_instance;
68
+ }
69
+
70
+ std::string ToString() const;
71
+ bool Empty() const;
72
+ };
73
+
74
+ } // namespace grpc_core
75
+
76
+ #endif // GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_H
@@ -0,0 +1,275 @@
1
+ //
2
+ // Copyright 2018 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #include "src/core/xds/grpc/xds_tls_context_parser.h"
18
+
19
+ #include <utility>
20
+ #include <variant>
21
+
22
+ #include "envoy/extensions/transport_sockets/tls/v3/common.upb.h"
23
+ #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
24
+ #include "src/core/util/down_cast.h"
25
+ #include "src/core/util/upb_utils.h"
26
+ #include "src/core/util/validation_errors.h"
27
+ #include "src/core/xds/grpc/xds_bootstrap_grpc.h"
28
+ #include "src/core/xds/grpc/xds_common_types.h"
29
+ #include "src/core/xds/grpc/xds_common_types_parser.h"
30
+ #include "src/core/xds/xds_client/xds_client.h"
31
+ #include "absl/strings/str_cat.h"
32
+
33
+ namespace grpc_core {
34
+
35
+ namespace {
36
+
37
+ // CertificateProviderInstance is deprecated but we are still supporting it for
38
+ // backward compatibility reasons. Note that we still parse the data into the
39
+ // same CertificateProviderPluginInstance struct since the fields are the same.
40
+ // TODO(yashykt): Remove this once we stop supporting the old way of fetching
41
+ // certificate provider instances.
42
+ CommonTlsContext::CertificateProviderPluginInstance
43
+ CertificateProviderInstanceParse(
44
+ const XdsResourceType::DecodeContext& context,
45
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance*
46
+ certificate_provider_instance_proto,
47
+ ValidationErrors* errors) {
48
+ CommonTlsContext::CertificateProviderPluginInstance cert_provider;
49
+ cert_provider.instance_name = UpbStringToStdString(
50
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_instance_name(
51
+ certificate_provider_instance_proto));
52
+ const auto& bootstrap =
53
+ DownCast<const GrpcXdsBootstrap&>(context.client->bootstrap());
54
+ if (bootstrap.certificate_providers().find(cert_provider.instance_name) ==
55
+ bootstrap.certificate_providers().end()) {
56
+ ValidationErrors::ScopedField field(errors, ".instance_name");
57
+ errors->AddError(
58
+ absl::StrCat("unrecognized certificate provider instance name: ",
59
+ cert_provider.instance_name));
60
+ }
61
+ cert_provider.certificate_name = UpbStringToStdString(
62
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CertificateProviderInstance_certificate_name(
63
+ certificate_provider_instance_proto));
64
+ return cert_provider;
65
+ }
66
+
67
+ CommonTlsContext::CertificateProviderPluginInstance
68
+ CertificateProviderPluginInstanceParse(
69
+ const XdsResourceType::DecodeContext& context,
70
+ const envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance*
71
+ certificate_provider_plugin_instance_proto,
72
+ ValidationErrors* errors) {
73
+ CommonTlsContext::CertificateProviderPluginInstance cert_provider;
74
+ cert_provider.instance_name = UpbStringToStdString(
75
+ envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_instance_name(
76
+ certificate_provider_plugin_instance_proto));
77
+ const auto& bootstrap =
78
+ DownCast<const GrpcXdsBootstrap&>(context.client->bootstrap());
79
+ if (bootstrap.certificate_providers().find(cert_provider.instance_name) ==
80
+ bootstrap.certificate_providers().end()) {
81
+ ValidationErrors::ScopedField field(errors, ".instance_name");
82
+ errors->AddError(
83
+ absl::StrCat("unrecognized certificate provider instance name: ",
84
+ cert_provider.instance_name));
85
+ }
86
+ cert_provider.certificate_name = UpbStringToStdString(
87
+ envoy_extensions_transport_sockets_tls_v3_CertificateProviderPluginInstance_certificate_name(
88
+ certificate_provider_plugin_instance_proto));
89
+ return cert_provider;
90
+ }
91
+
92
+ CommonTlsContext::CertificateValidationContext
93
+ CertificateValidationContextParse(
94
+ const XdsResourceType::DecodeContext& context,
95
+ const envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext*
96
+ certificate_validation_context_proto,
97
+ ValidationErrors* errors) {
98
+ CommonTlsContext::CertificateValidationContext certificate_validation_context;
99
+ size_t len = 0;
100
+ auto* subject_alt_names_matchers =
101
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_match_subject_alt_names(
102
+ certificate_validation_context_proto, &len);
103
+ for (size_t i = 0; i < len; ++i) {
104
+ ValidationErrors::ScopedField field(
105
+ errors, absl::StrCat(".match_subject_alt_names[", i, "]"));
106
+ auto string_matcher =
107
+ StringMatcherParse(context, subject_alt_names_matchers[i], errors);
108
+ certificate_validation_context.match_subject_alt_names.push_back(
109
+ std::move(string_matcher));
110
+ }
111
+ auto* ca_certificate_provider_instance =
112
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_ca_certificate_provider_instance(
113
+ certificate_validation_context_proto);
114
+ if (ca_certificate_provider_instance != nullptr) {
115
+ ValidationErrors::ScopedField field(errors,
116
+ ".ca_certificate_provider_instance");
117
+ certificate_validation_context.ca_certs =
118
+ CertificateProviderPluginInstanceParse(
119
+ context, ca_certificate_provider_instance, errors);
120
+ } else {
121
+ auto* system_root_certs =
122
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_system_root_certs(
123
+ certificate_validation_context_proto);
124
+ if (system_root_certs != nullptr) {
125
+ certificate_validation_context.ca_certs =
126
+ CommonTlsContext::CertificateValidationContext::SystemRootCerts();
127
+ }
128
+ }
129
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_spki(
130
+ certificate_validation_context_proto, nullptr) != nullptr) {
131
+ ValidationErrors::ScopedField field(errors, ".verify_certificate_spki");
132
+ errors->AddError("feature unsupported");
133
+ }
134
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_verify_certificate_hash(
135
+ certificate_validation_context_proto, nullptr) != nullptr) {
136
+ ValidationErrors::ScopedField field(errors, ".verify_certificate_hash");
137
+ errors->AddError("feature unsupported");
138
+ }
139
+ if (ParseBoolValue(
140
+ envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_require_signed_certificate_timestamp(
141
+ certificate_validation_context_proto))) {
142
+ ValidationErrors::ScopedField field(
143
+ errors, ".require_signed_certificate_timestamp");
144
+ errors->AddError("feature unsupported");
145
+ }
146
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_crl(
147
+ certificate_validation_context_proto)) {
148
+ ValidationErrors::ScopedField field(errors, ".crl");
149
+ errors->AddError("feature unsupported");
150
+ }
151
+ if (envoy_extensions_transport_sockets_tls_v3_CertificateValidationContext_has_custom_validator_config(
152
+ certificate_validation_context_proto)) {
153
+ ValidationErrors::ScopedField field(errors, ".custom_validator_config");
154
+ errors->AddError("feature unsupported");
155
+ }
156
+ return certificate_validation_context;
157
+ }
158
+
159
+ } // namespace
160
+
161
+ CommonTlsContext CommonTlsContextParse(
162
+ const XdsResourceType::DecodeContext& context,
163
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
164
+ common_tls_context_proto,
165
+ ValidationErrors* errors) {
166
+ CommonTlsContext common_tls_context;
167
+ // The validation context is derived from the oneof in
168
+ // 'validation_context_type'. 'validation_context_sds_secret_config' is not
169
+ // supported.
170
+ auto* combined_validation_context =
171
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_combined_validation_context(
172
+ common_tls_context_proto);
173
+ if (combined_validation_context != nullptr) {
174
+ ValidationErrors::ScopedField field(errors, ".combined_validation_context");
175
+ auto* default_validation_context =
176
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_default_validation_context(
177
+ combined_validation_context);
178
+ if (default_validation_context != nullptr) {
179
+ ValidationErrors::ScopedField field(errors,
180
+ ".default_validation_context");
181
+ common_tls_context.certificate_validation_context =
182
+ CertificateValidationContextParse(context, default_validation_context,
183
+ errors);
184
+ }
185
+ // If after parsing default_validation_context,
186
+ // common_tls_context->certificate_validation_context.ca_certs does not
187
+ // contain a cert provider, fall back onto
188
+ // 'validation_context_certificate_provider_instance' inside
189
+ // 'combined_validation_context'. Note that this way of fetching root
190
+ // certificates is deprecated and will be removed in the future.
191
+ // TODO(yashykt): Remove this once it's no longer needed.
192
+ if (!std::holds_alternative<
193
+ CommonTlsContext::CertificateProviderPluginInstance>(
194
+ common_tls_context.certificate_validation_context.ca_certs)) {
195
+ const auto* validation_context_certificate_provider_instance =
196
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_CombinedCertificateValidationContext_validation_context_certificate_provider_instance(
197
+ combined_validation_context);
198
+ if (validation_context_certificate_provider_instance != nullptr) {
199
+ ValidationErrors::ScopedField field(
200
+ errors, ".validation_context_certificate_provider_instance");
201
+ common_tls_context.certificate_validation_context.ca_certs =
202
+ CertificateProviderInstanceParse(
203
+ context, validation_context_certificate_provider_instance,
204
+ errors);
205
+ }
206
+ }
207
+ } else if (
208
+ auto* validation_context =
209
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_validation_context(
210
+ common_tls_context_proto);
211
+ validation_context != nullptr) {
212
+ ValidationErrors::ScopedField field(errors, ".validation_context");
213
+ common_tls_context.certificate_validation_context =
214
+ CertificateValidationContextParse(context, validation_context, errors);
215
+ } else if (
216
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_validation_context_sds_secret_config(
217
+ common_tls_context_proto)) {
218
+ ValidationErrors::ScopedField field(
219
+ errors, ".validation_context_sds_secret_config");
220
+ errors->AddError("feature unsupported");
221
+ }
222
+ auto* tls_certificate_provider_instance =
223
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_provider_instance(
224
+ common_tls_context_proto);
225
+ if (tls_certificate_provider_instance != nullptr) {
226
+ ValidationErrors::ScopedField field(errors,
227
+ ".tls_certificate_provider_instance");
228
+ common_tls_context.tls_certificate_provider_instance =
229
+ CertificateProviderPluginInstanceParse(
230
+ context, tls_certificate_provider_instance, errors);
231
+ } else {
232
+ // Fall back onto 'tls_certificate_certificate_provider_instance'. Note that
233
+ // this way of fetching identity certificates is deprecated and will be
234
+ // removed in the future.
235
+ // TODO(yashykt): Remove this once it's no longer needed.
236
+ auto* tls_certificate_certificate_provider_instance =
237
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_certificate_provider_instance(
238
+ common_tls_context_proto);
239
+ if (tls_certificate_certificate_provider_instance != nullptr) {
240
+ ValidationErrors::ScopedField field(
241
+ errors, ".tls_certificate_certificate_provider_instance");
242
+ common_tls_context.tls_certificate_provider_instance =
243
+ CertificateProviderInstanceParse(
244
+ context, tls_certificate_certificate_provider_instance, errors);
245
+ } else {
246
+ size_t size;
247
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificates(
248
+ common_tls_context_proto, &size);
249
+ if (size != 0) {
250
+ ValidationErrors::ScopedField field(errors, ".tls_certificates");
251
+ errors->AddError("feature unsupported");
252
+ }
253
+ envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_tls_certificate_sds_secret_configs(
254
+ common_tls_context_proto, &size);
255
+ if (size != 0) {
256
+ ValidationErrors::ScopedField field(
257
+ errors, ".tls_certificate_sds_secret_configs");
258
+ errors->AddError("feature unsupported");
259
+ }
260
+ }
261
+ }
262
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_tls_params(
263
+ common_tls_context_proto)) {
264
+ ValidationErrors::ScopedField field(errors, ".tls_params");
265
+ errors->AddError("feature unsupported");
266
+ }
267
+ if (envoy_extensions_transport_sockets_tls_v3_CommonTlsContext_has_custom_handshaker(
268
+ common_tls_context_proto)) {
269
+ ValidationErrors::ScopedField field(errors, ".custom_handshaker");
270
+ errors->AddError("feature unsupported");
271
+ }
272
+ return common_tls_context;
273
+ }
274
+
275
+ } // namespace grpc_core
@@ -0,0 +1,35 @@
1
+ //
2
+ // Copyright 2018 gRPC authors.
3
+ //
4
+ // Licensed under the Apache License, Version 2.0 (the "License");
5
+ // you may not use this file except in compliance with the License.
6
+ // You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ //
16
+
17
+ #ifndef GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_PARSER_H
18
+ #define GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_PARSER_H
19
+
20
+ #include "envoy/extensions/transport_sockets/tls/v3/tls.upb.h"
21
+ #include "src/core/util/validation_errors.h"
22
+ #include "src/core/xds/grpc/xds_tls_context.h"
23
+ #include "src/core/xds/xds_client/xds_resource_type.h"
24
+
25
+ namespace grpc_core {
26
+
27
+ CommonTlsContext CommonTlsContextParse(
28
+ const XdsResourceType::DecodeContext& context,
29
+ const envoy_extensions_transport_sockets_tls_v3_CommonTlsContext*
30
+ common_tls_context_proto,
31
+ ValidationErrors* errors);
32
+
33
+ } // namespace grpc_core
34
+
35
+ #endif // GRPC_SRC_CORE_XDS_GRPC_XDS_TLS_CONTEXT_PARSER_H
@@ -78,6 +78,7 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
78
78
  WeakRefCountedPtr<GrpcXdsTransportFactory> factory, Channel* channel,
79
79
  const char* method,
80
80
  std::unique_ptr<StreamingCall::EventHandler> event_handler,
81
+ grpc_call_credentials* call_creds,
81
82
  const std::vector<std::pair<std::string, std::string>>& initial_metadata,
82
83
  Duration timeout)
83
84
  : factory_(std::move(factory)), event_handler_(std::move(event_handler)) {
@@ -91,6 +92,8 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
91
92
  /*authority=*/std::nullopt, deadline,
92
93
  /*registered_method=*/true, /*arena_init_function=*/std::nullopt);
93
94
  GRPC_CHECK_NE(call_, nullptr);
95
+ // Set call creds, if any.
96
+ if (call_creds != nullptr) grpc_call_set_credentials(call_, call_creds);
94
97
  // Init data associated with the call.
95
98
  grpc_metadata_array_init(&initial_metadata_recv_);
96
99
  grpc_metadata_array_init(&trailing_metadata_recv_);
@@ -141,10 +144,10 @@ GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::GrpcStreamingCall(
141
144
  op->flags = 0;
142
145
  op->reserved = nullptr;
143
146
  ++op;
144
- // This callback signals the end of the call, so it relies on the initial
145
- // ref instead of a new ref. When it's invoked, it's the initial ref that is
146
- // unreffed.
147
- GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived, this, nullptr);
147
+ // Ref will be released in the callback.
148
+ GRPC_CLOSURE_INIT(&on_status_received_, OnStatusReceived,
149
+ this->Ref(DEBUG_LOCATION, "OnStatusReceived").release(),
150
+ nullptr);
148
151
  call_error = grpc_call_start_batch_and_execute(
149
152
  call_, ops, static_cast<size_t>(op - ops), &on_status_received_);
150
153
  GRPC_CHECK_EQ(call_error, GRPC_CALL_OK);
@@ -172,8 +175,7 @@ void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::Orphan() {
172
175
  // Otherwise, we are here because xds_client has to orphan a failed call,
173
176
  // in which case the following cancellation will be a no-op.
174
177
  grpc_call_cancel_internal(call_);
175
- // Note that the initial ref is held by OnStatusReceived(), so the
176
- // corresponding unref happens there instead of here.
178
+ Unref(DEBUG_LOCATION, "Orphan");
177
179
  }
178
180
 
179
181
  void GrpcXdsTransportFactory::GrpcXdsTransport::GrpcStreamingCall::SendMessage(
@@ -301,22 +303,6 @@ RefCountedPtr<Channel> CreateXdsChannel(
301
303
  RefCountedPtr<grpc_channel_credentials> channel_creds =
302
304
  CoreConfiguration::Get().channel_creds_registry().CreateChannelCreds(
303
305
  server.channel_creds_config(), certificate_provider_store);
304
- RefCountedPtr<grpc_call_credentials> call_creds;
305
- for (const auto& call_creds_config : server.call_creds_configs()) {
306
- RefCountedPtr<grpc_call_credentials> creds =
307
- CoreConfiguration::Get().call_creds_registry().CreateCallCreds(
308
- call_creds_config);
309
- if (call_creds == nullptr) {
310
- call_creds = std::move(creds);
311
- } else {
312
- call_creds = MakeRefCounted<grpc_composite_call_credentials>(
313
- std::move(call_creds), std::move(creds));
314
- }
315
- }
316
- if (call_creds != nullptr) {
317
- channel_creds = MakeRefCounted<grpc_composite_channel_credentials>(
318
- std::move(channel_creds), std::move(call_creds));
319
- }
320
306
  return RefCountedPtr<Channel>(Channel::FromC(grpc_channel_create(
321
307
  server.server_uri().c_str(), channel_creds.get(), args.ToC().get())));
322
308
  }
@@ -330,14 +316,27 @@ std::string GetChannelKey(const GrpcXdsServerInterface& server) {
330
316
  ", channel_creds={type=", server.channel_creds_config()->type(),
331
317
  ", config=", server.channel_creds_config()->ToString(), "}");
332
318
  }
333
- for (const auto& call_creds_config : server.call_creds_configs()) {
334
- absl::StrAppend(&result, ", call_creds={type=", call_creds_config->type(),
335
- ", config=", call_creds_config->ToString(), "}");
336
- }
337
319
  absl::StrAppend(&result, "}");
338
320
  return result;
339
321
  }
340
322
 
323
+ RefCountedPtr<grpc_call_credentials> GetCallCredsForTransport(
324
+ const GrpcXdsServerInterface& server) {
325
+ RefCountedPtr<grpc_call_credentials> call_creds;
326
+ for (const auto& call_creds_config : server.call_creds_configs()) {
327
+ RefCountedPtr<grpc_call_credentials> creds =
328
+ CoreConfiguration::Get().call_creds_registry().CreateCallCreds(
329
+ call_creds_config);
330
+ if (call_creds == nullptr) {
331
+ call_creds = std::move(creds);
332
+ } else {
333
+ call_creds = MakeRefCounted<grpc_composite_call_credentials>(
334
+ std::move(call_creds), std::move(creds));
335
+ }
336
+ }
337
+ return call_creds;
338
+ }
339
+
341
340
  } // namespace
342
341
 
343
342
  class GrpcXdsTransportFactory::SharedChannel final
@@ -367,19 +366,19 @@ class GrpcXdsTransportFactory::SharedChannel final
367
366
 
368
367
  GrpcXdsTransportFactory::GrpcXdsTransport::GrpcXdsTransport(
369
368
  WeakRefCountedPtr<GrpcXdsTransportFactory> factory,
370
- RefCountedPtr<SharedChannel> channel,
371
- const XdsBootstrap::XdsServerTarget& server, absl::Status* status)
369
+ RefCountedPtr<SharedChannel> channel, const GrpcXdsServerInterface& server,
370
+ absl::Status* status)
372
371
  : XdsTransport(GRPC_TRACE_FLAG_ENABLED(xds_client_refcount)
373
372
  ? "GrpcXdsTransport"
374
373
  : nullptr),
375
374
  factory_(std::move(factory)),
376
375
  key_(server.Key()),
377
- channel_(std::move(channel)) {
376
+ channel_(std::move(channel)),
377
+ call_creds_(GetCallCredsForTransport(server)),
378
+ initial_metadata_(server.initial_metadata()),
379
+ timeout_(server.timeout()) {
378
380
  GRPC_TRACE_LOG(xds_client, INFO)
379
381
  << "[GrpcXdsTransport " << this << "] created";
380
- const auto& grpc_server = DownCast<const GrpcXdsServerInterface&>(server);
381
- initial_metadata_ = grpc_server.initial_metadata();
382
- timeout_ = grpc_server.timeout();
383
382
  if (channel_->channel()->IsLame()) {
384
383
  *status = absl::UnavailableError("xds client has a lame channel");
385
384
  }
@@ -443,7 +442,8 @@ GrpcXdsTransportFactory::GrpcXdsTransport::CreateStreamingCall(
443
442
  std::unique_ptr<StreamingCall::EventHandler> event_handler) {
444
443
  return MakeOrphanable<GrpcStreamingCall>(
445
444
  factory_.WeakRef(DEBUG_LOCATION, "StreamingCall"), channel_->channel(),
446
- method, std::move(event_handler), initial_metadata_, timeout_);
445
+ method, std::move(event_handler), call_creds_.get(), initial_metadata_,
446
+ timeout_);
447
447
  }
448
448
 
449
449
  void GrpcXdsTransportFactory::GrpcXdsTransport::ResetBackoff() {
@@ -500,20 +500,23 @@ GrpcXdsTransportFactory::GetTransport(
500
500
  auto channel_it = channels_.find(channel_key);
501
501
  RefCountedPtr<SharedChannel> channel;
502
502
  if (channel_it != channels_.end()) {
503
- channel = channel_it->second->Ref();
504
- } else {
503
+ GRPC_TRACE_LOG(xds_client, INFO) << "[GrpcXdsTransportFactory " << this
504
+ << "] found cached SharedChannel";
505
+ channel = channel_it->second->RefIfNonZero();
506
+ }
507
+ if (channel == nullptr) {
505
508
  RefCountedPtr<Channel> raw_channel =
506
509
  CreateXdsChannel(args_, *certificate_provider_store_, grpc_server);
507
510
  GRPC_CHECK(raw_channel != nullptr);
508
511
  channel = MakeRefCounted<SharedChannel>(
509
512
  channel_key, std::move(raw_channel),
510
513
  WeakRefAsSubclass<GrpcXdsTransportFactory>());
511
- channels_.emplace(channel_key, channel.get());
514
+ channels_[channel_key] = channel.get();
512
515
  }
513
516
  transport = MakeRefCounted<GrpcXdsTransport>(
514
517
  WeakRefAsSubclass<GrpcXdsTransportFactory>(), std::move(channel),
515
- server, status);
516
- transports_.emplace(std::move(key), transport.get());
518
+ grpc_server, status);
519
+ transports_[std::move(key)] = transport.get();
517
520
  }
518
521
  return transport;
519
522
  }