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
@@ -356,9 +356,7 @@ void Call::HandleCompressionAlgorithmDisabled(
356
356
  std::string error_msg =
357
357
  absl::StrFormat("Compression algorithm '%s' is disabled.", algo_name);
358
358
  LOG(ERROR) << error_msg;
359
- CancelWithError(grpc_error_set_int(absl::UnimplementedError(error_msg),
360
- StatusIntProperty::kRpcStatus,
361
- GRPC_STATUS_UNIMPLEMENTED));
359
+ CancelWithError(absl::UnimplementedError(error_msg));
362
360
  }
363
361
 
364
362
  grpc_error_handle Call::UpdateDeadline(Timestamp deadline) {
@@ -369,9 +367,7 @@ grpc_error_handle Call::UpdateDeadline(Timestamp deadline) {
369
367
  if (deadline >= deadline_) return absl::OkStatus();
370
368
  if (deadline < Timestamp::Now()) {
371
369
  lock.Release();
372
- grpc_error_handle error = grpc_error_set_int(
373
- absl::DeadlineExceededError("Deadline Exceeded"),
374
- StatusIntProperty::kRpcStatus, GRPC_STATUS_DEADLINE_EXCEEDED);
370
+ grpc_error_handle error = absl::DeadlineExceededError("Deadline Exceeded");
375
371
  CancelWithError(error);
376
372
  return error;
377
373
  }
@@ -405,9 +401,7 @@ void Call::Run() {
405
401
  GRPC_TRACE_LOG(call, INFO)
406
402
  << "call deadline expired "
407
403
  << GRPC_DUMP_ARGS(Timestamp::Now(), send_deadline_);
408
- CancelWithError(grpc_error_set_int(
409
- absl::DeadlineExceededError("Deadline Exceeded"),
410
- StatusIntProperty::kRpcStatus, GRPC_STATUS_DEADLINE_EXCEEDED));
404
+ CancelWithError(absl::DeadlineExceededError("Deadline Exceeded"));
411
405
  InternalUnref("deadline[run]");
412
406
  }
413
407
 
@@ -58,6 +58,7 @@
58
58
  #include "src/core/lib/surface/completion_queue.h"
59
59
  #include "src/core/util/crash.h"
60
60
  #include "src/core/util/grpc_check.h"
61
+ #include "src/core/util/ref_counted_ptr.h"
61
62
  #include "src/core/util/upb_utils.h"
62
63
  #include "src/proto/grpc/channelz/v2/promise.upb.h"
63
64
  #include "upb/mem/arena.h"
@@ -584,6 +585,118 @@ class MessageReceiver {
584
585
  GRPC_COMPRESS_NONE;
585
586
  };
586
587
 
588
+ // Tracks and validates the state of operations on a call to ensure invariants.
589
+ //
590
+ // Invariants validated:
591
+ // 1. Intra-batch duplicates: A single batch cannot contain multiple operations
592
+ // of the same type.
593
+ // 2. Once-only operations: Operations like sending initial metadata or closing
594
+ // the call can only be performed once.
595
+ // 3. Concurrent operations: Operations like sending or receiving messages
596
+ // cannot run concurrently (i.e., a new one cannot start until the previous
597
+ // one completes).
598
+ //
599
+ // This class is thread-safe.
600
+ class CallOpInvariantsValidator {
601
+ public:
602
+ CallOpInvariantsValidator() = default;
603
+
604
+ // Validates a batch of operations against the current call state and commits
605
+ // them if valid.
606
+ //
607
+ // Returns GRPC_CALL_OK if the batch is valid and its operations are
608
+ // successfully committed to the active state.
609
+ // Returns GRPC_CALL_ERROR_TOO_MANY_OPERATIONS if:
610
+ // - The batch contains duplicate operations of the same type.
611
+ // - Any operation in the batch conflicts with the current state (either
612
+ // because a once-only operation has already been performed, or a
613
+ // concurrent operation is already active).
614
+ grpc_call_error ValidateAndCommit(const grpc_op* ops, size_t nops) {
615
+ if (!IsCallv3BatchValidationEnabled()) {
616
+ return GRPC_CALL_OK;
617
+ }
618
+
619
+ uint8_t batch_ops = 0;
620
+ for (size_t i = 0; i < nops; i++) {
621
+ uint8_t op_bit = OpBit(ops[i].op);
622
+ // Detect intra-batch duplicate operations!
623
+ if ((batch_ops & op_bit) != 0) {
624
+ return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
625
+ }
626
+ batch_ops |= op_bit;
627
+ }
628
+
629
+ uint8_t current_state = ops_state_.load(std::memory_order_relaxed);
630
+ while (true) {
631
+ if ((current_state & batch_ops) != 0) {
632
+ return GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
633
+ }
634
+ if (ops_state_.compare_exchange_weak(
635
+ current_state, current_state | batch_ops,
636
+ std::memory_order_relaxed, std::memory_order_relaxed)) {
637
+ return GRPC_CALL_OK;
638
+ }
639
+ }
640
+ }
641
+
642
+ // Resets the state of a concurrent operation, marking it as no longer active.
643
+ // This allows subsequent operations of the same type to be validated and
644
+ // committed. Should be called when the operation completes.
645
+ void ResetConcurrentOps(uint8_t ops_mask) {
646
+ if (ops_mask == 0 || !IsCallv3BatchValidationEnabled()) {
647
+ return;
648
+ }
649
+ GRPC_DCHECK((ops_mask & kConcurrentOpsMask) != 0);
650
+ GRPC_DCHECK((ops_mask & kOnceOpsMask) == 0);
651
+ ops_state_.fetch_and(~ops_mask, std::memory_order_relaxed);
652
+ }
653
+
654
+ static constexpr uint8_t OpBit(const grpc_op_type op) { return 1 << op; }
655
+
656
+ private:
657
+ static constexpr uint8_t kOnceOpsMask =
658
+ (1 << GRPC_OP_SEND_INITIAL_METADATA) |
659
+ (1 << GRPC_OP_SEND_CLOSE_FROM_CLIENT) |
660
+ (1 << GRPC_OP_SEND_STATUS_FROM_SERVER) |
661
+ (1 << GRPC_OP_RECV_INITIAL_METADATA) |
662
+ (1 << GRPC_OP_RECV_STATUS_ON_CLIENT) |
663
+ (1 << GRPC_OP_RECV_CLOSE_ON_SERVER);
664
+
665
+ static constexpr uint8_t kConcurrentOpsMask =
666
+ (1 << GRPC_OP_SEND_MESSAGE) | (1 << GRPC_OP_RECV_MESSAGE);
667
+
668
+ std::atomic<uint8_t> ops_state_{0};
669
+ };
670
+
671
+ // Helper class to perform cleanup of primary ops for both ClientCall and
672
+ // ServerCall.
673
+ template <typename CallType>
674
+ class PrimaryOpsCleanup {
675
+ public:
676
+ explicit PrimaryOpsCleanup(WeakRefCountedPtr<CallType> self,
677
+ uint8_t concurrent_ops_to_reset)
678
+ : self_(std::move(self)),
679
+ concurrent_ops_to_reset_(concurrent_ops_to_reset) {}
680
+
681
+ // PrimaryOpsCleanup is move only.
682
+ PrimaryOpsCleanup(const PrimaryOpsCleanup&) = delete;
683
+ PrimaryOpsCleanup& operator=(const PrimaryOpsCleanup&) = delete;
684
+ PrimaryOpsCleanup(PrimaryOpsCleanup&&) = default;
685
+ PrimaryOpsCleanup& operator=(PrimaryOpsCleanup&&) = default;
686
+
687
+ ~PrimaryOpsCleanup() {
688
+ if (concurrent_ops_to_reset_ == 0) return;
689
+ if (self_ != nullptr) {
690
+ self_->call_op_invariants_validator_.ResetConcurrentOps(
691
+ concurrent_ops_to_reset_);
692
+ }
693
+ }
694
+
695
+ private:
696
+ WeakRefCountedPtr<CallType> self_;
697
+ uint8_t concurrent_ops_to_reset_;
698
+ };
699
+
587
700
  std::string MakeErrorString(const ServerMetadata* trailing_metadata);
588
701
 
589
702
  } // namespace grpc_core
@@ -104,7 +104,7 @@ absl::StatusOr<RefCountedPtr<Channel>> ChannelCreate(
104
104
  case GRPC_CLIENT_CHANNEL:
105
105
  return ClientChannel::Create(std::move(target), std::move(args));
106
106
  case GRPC_CLIENT_DIRECT_CHANNEL:
107
- return DirectChannel::Create(std::move(target), args);
107
+ return DirectChannel::Create(std::move(target), std::move(args));
108
108
  default:
109
109
  Crash(absl::StrCat("Invalid channel stack type for ChannelCreate: ",
110
110
  grpc_channel_stack_type_string(channel_stack_type)));
@@ -26,8 +26,6 @@
26
26
  #include "src/core/lib/surface/channel_stack_type.h"
27
27
  #include "absl/status/statusor.h"
28
28
 
29
- #define GRPC_ARG_USE_V3_STACK "grpc.internal.use_v3_stack"
30
-
31
29
  namespace grpc_core {
32
30
 
33
31
  class Transport;
@@ -33,6 +33,7 @@
33
33
  #include "src/core/channelz/channelz.h"
34
34
  #include "src/core/channelz/property_list.h"
35
35
  #include "src/core/lib/debug/trace.h"
36
+ #include "src/core/lib/experiments/experiments.h"
36
37
  #include "src/core/lib/surface/channel_stack_type.h"
37
38
  #include "src/core/util/crash.h"
38
39
  #include "src/core/util/grpc_check.h"
@@ -48,13 +49,6 @@ namespace grpc_core {
48
49
  UniqueTypeName (*NameFromChannelFilter)(const grpc_channel_filter*);
49
50
 
50
51
  namespace {
51
- struct CompareChannelFiltersByName {
52
- bool operator()(UniqueTypeName a, UniqueTypeName b) const {
53
- // Compare lexicographically instead of by pointer value so that different
54
- // builds make the same choices.
55
- return a.name() < b.name();
56
- }
57
- };
58
52
 
59
53
  struct CompareFusedChannelFiltersByName {
60
54
  bool operator()(ChannelInit::FilterRegistration* a,
@@ -111,12 +105,12 @@ ChannelInit::FilterRegistration& ChannelInit::FilterRegistration::IfNot(
111
105
  }
112
106
 
113
107
  ChannelInit::FilterRegistration&
114
- ChannelInit::FilterRegistration::IfHasChannelArg(const char* arg) {
108
+ ChannelInit::FilterRegistration::IfHasChannelArg(absl::string_view arg) {
115
109
  return If([arg](const ChannelArgs& args) { return args.Contains(arg); });
116
110
  }
117
111
 
118
112
  ChannelInit::FilterRegistration& ChannelInit::FilterRegistration::IfChannelArg(
119
- const char* arg, bool default_value) {
113
+ absl::string_view arg, bool default_value) {
120
114
  return If([arg, default_value](const ChannelArgs& args) {
121
115
  return args.GetBool(arg).value_or(default_value);
122
116
  });
@@ -126,6 +120,12 @@ ChannelInit::FilterRegistration&
126
120
  ChannelInit::FilterRegistration::ExcludeFromMinimalStack() {
127
121
  return If([](const ChannelArgs& args) { return !args.WantMinimalStack(); });
128
122
  }
123
+ ChannelInit::Builder::Builder()
124
+ : fix_v3_filter_stack_server_side_ordering_(
125
+ IsFixV3FilterStackServerSideOrderingEnabled()) {}
126
+ ChannelInit::Builder::Builder(bool fix_v3_filter_stack_server_side_ordering)
127
+ : fix_v3_filter_stack_server_side_ordering_(
128
+ fix_v3_filter_stack_server_side_ordering) {}
129
129
 
130
130
  ChannelInit::FilterRegistration& ChannelInit::Builder::RegisterFilter(
131
131
  grpc_channel_stack_type type, UniqueTypeName name,
@@ -146,32 +146,23 @@ void ChannelInit::Builder::RegisterFusedFilter(
146
146
 
147
147
  class ChannelInit::DependencyTracker {
148
148
  public:
149
+ explicit DependencyTracker(bool reverse_ordering_)
150
+ : ready_dependencies_(ReadyDependency::Comparator{reverse_ordering_}),
151
+ reverse_ordering_(reverse_ordering_) {}
152
+
149
153
  // Declare that a filter exists.
150
154
  void Declare(FilterRegistration* registration) {
151
155
  nodes_.emplace(registration->name_, registration);
152
156
  }
153
157
  // Insert an edge from a to b
154
158
  // Both nodes must be declared.
159
+
155
160
  void InsertEdge(UniqueTypeName a, UniqueTypeName b) {
156
- auto it_a = nodes_.find(a);
157
- auto it_b = nodes_.find(b);
158
- if (it_a == nodes_.end()) {
159
- GRPC_TRACE_LOG(channel_stack, INFO)
160
- << "gRPC Filter " << a.name()
161
- << " was not declared before adding an edge to " << b.name();
162
- return;
163
- }
164
- if (it_b == nodes_.end()) {
165
- GRPC_TRACE_LOG(channel_stack, INFO)
166
- << "gRPC Filter " << b.name()
167
- << " was not declared before adding an edge from " << a.name();
168
- return;
161
+ if (!reverse_ordering_) {
162
+ InsertEdgeImpl(a, b);
163
+ } else {
164
+ InsertEdgeImpl(b, a);
169
165
  }
170
- auto& node_a = it_a->second;
171
- auto& node_b = it_b->second;
172
- node_a.dependents.push_back(&node_b);
173
- node_b.all_dependencies.push_back(a);
174
- ++node_b.waiting_dependencies;
175
166
  }
176
167
 
177
168
  // Finish the dependency graph and begin iteration.
@@ -247,21 +238,61 @@ class ChannelInit::DependencyTracker {
247
238
  Ordering ordering() const { return registration->ordering_; }
248
239
  absl::string_view name() const { return registration->name_.name(); }
249
240
  };
241
+
250
242
  struct ReadyDependency {
251
243
  explicit ReadyDependency(Node* node) : node(node) {}
252
244
  Node* node;
253
- bool operator<(const ReadyDependency& other) const {
245
+
246
+ struct Comparator {
254
247
  // Sort first on ordering, and then lexically on name.
255
248
  // The lexical sort means that the ordering is stable between builds
256
249
  // (UniqueTypeName ordering is not stable between builds).
257
- return node->ordering() > other.node->ordering() ||
258
- (node->ordering() == other.node->ordering() &&
259
- node->name() > other.node->name());
260
- }
250
+ bool operator()(const ReadyDependency& a,
251
+ const ReadyDependency& b) const {
252
+ if (!reverse_ordering) {
253
+ return a.node->ordering() > b.node->ordering() ||
254
+ (a.node->ordering() == b.node->ordering() &&
255
+ a.node->name() > b.node->name());
256
+ } else {
257
+ return a.node->ordering() < b.node->ordering() ||
258
+ (a.node->ordering() == b.node->ordering() &&
259
+ a.node->name() > b.node->name());
260
+ }
261
+ };
262
+ bool reverse_ordering = false;
263
+ };
261
264
  };
265
+
266
+ void InsertEdgeImpl(UniqueTypeName a, UniqueTypeName b) {
267
+ auto it_a = nodes_.find(a);
268
+ auto it_b = nodes_.find(b);
269
+ if (it_a == nodes_.end()) {
270
+ GRPC_TRACE_LOG(channel_stack, INFO)
271
+ << "gRPC Filter " << a.name()
272
+ << " was not declared before adding an edge to " << b.name();
273
+ return;
274
+ }
275
+ if (it_b == nodes_.end()) {
276
+ GRPC_TRACE_LOG(channel_stack, INFO)
277
+ << "gRPC Filter " << b.name()
278
+ << " was not declared before adding an edge from " << a.name();
279
+ return;
280
+ }
281
+ auto& node_a = it_a->second;
282
+ auto& node_b = it_b->second;
283
+ node_a.dependents.push_back(&node_b);
284
+ node_b.all_dependencies.push_back(a);
285
+ ++node_b.waiting_dependencies;
286
+ }
287
+
262
288
  absl::flat_hash_map<UniqueTypeName, Node> nodes_;
263
- std::priority_queue<ReadyDependency> ready_dependencies_;
289
+ std::priority_queue<ReadyDependency, std::vector<ReadyDependency>,
290
+ ReadyDependency::Comparator>
291
+ ready_dependencies_;
264
292
  size_t nodes_taken_ = 0;
293
+
294
+ // Whether to reverse the ordering for server side filters.
295
+ bool reverse_ordering_ = false;
265
296
  };
266
297
 
267
298
  template <bool is_terminal>
@@ -333,14 +364,17 @@ std::tuple<std::vector<ChannelInit::Filter>, std::vector<ChannelInit::Filter>>
333
364
  ChannelInit::SortFilterRegistrationsByDependencies(
334
365
  const std::vector<std::unique_ptr<ChannelInit::FilterRegistration>>&
335
366
  filter_registrations,
336
- grpc_channel_stack_type type, channelz::PropertyTable& filter_ordering) {
367
+ grpc_channel_stack_type type, channelz::PropertyTable& filter_ordering,
368
+ bool fix_v3_filter_stack_server_side_ordering) {
337
369
  // Phase 1: Build a map from filter to the set of filters that must be
338
370
  // initialized before it.
339
371
  // We order this map (and the set of dependent filters) by filter name to
340
372
  // ensure algorithm ordering stability is deterministic for a given build.
341
373
  // We should not require this, but at the time of writing it's expected that
342
374
  // this will help overall stability.
343
- DependencyTracker dependencies;
375
+ const bool reverse_ordering = !grpc_channel_stack_type_is_client(type) &&
376
+ fix_v3_filter_stack_server_side_ordering;
377
+ DependencyTracker dependencies{reverse_ordering};
344
378
  std::vector<Filter> terminal_filters;
345
379
  for (const auto& registration : filter_registrations) {
346
380
  if (registration->terminal_) {
@@ -432,7 +466,8 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
432
466
  filter_registrations,
433
467
  const std::vector<std::unique_ptr<ChannelInit::FilterRegistration>>&
434
468
  fused_filter_registrations,
435
- PostProcessor* post_processors, grpc_channel_stack_type type) {
469
+ PostProcessor* post_processors, grpc_channel_stack_type type,
470
+ bool fix_v3_filter_stack_server_side_ordering) {
436
471
  // Collect post processors that need to be applied.
437
472
  // We've already ensured the one-per-slot constraint, so now we can just
438
473
  // collect everything up into a vector and run it in order.
@@ -444,7 +479,8 @@ ChannelInit::StackConfig ChannelInit::BuildStackConfig(
444
479
  channelz::PropertyTable filter_ordering;
445
480
 
446
481
  auto sorted_filters = SortFilterRegistrationsByDependencies(
447
- filter_registrations, type, filter_ordering);
482
+ filter_registrations, type, filter_ordering,
483
+ fix_v3_filter_stack_server_side_ordering);
448
484
  std::vector<Filter> filters = std::move(std::get<0>(sorted_filters));
449
485
  std::vector<Filter> terminal_filters = std::move(std::get<1>(sorted_filters));
450
486
 
@@ -563,10 +599,13 @@ void ChannelInit::PrintChannelStackTrace(
563
599
 
564
600
  ChannelInit ChannelInit::Builder::Build() {
565
601
  ChannelInit result;
602
+ result.fix_v3_filter_stack_server_side_ordering_ =
603
+ fix_v3_filter_stack_server_side_ordering_;
566
604
  for (int i = 0; i < GRPC_NUM_CHANNEL_STACK_TYPES; i++) {
567
605
  result.stack_configs_[i] =
568
606
  BuildStackConfig(filters_[i], fused_filters_[i], post_processors_[i],
569
- static_cast<grpc_channel_stack_type>(i));
607
+ static_cast<grpc_channel_stack_type>(i),
608
+ fix_v3_filter_stack_server_side_ordering_);
570
609
  }
571
610
  return result;
572
611
  }
@@ -73,6 +73,7 @@ class ChannelInit {
73
73
  kV2,
74
74
  kV3,
75
75
  };
76
+
76
77
  static const char* VersionToString(Version version) {
77
78
  switch (version) {
78
79
  case Version::kAny:
@@ -127,6 +128,7 @@ class ChannelInit {
127
128
  kXdsChannelStackModifier,
128
129
  kCount
129
130
  };
131
+
130
132
  static const char* PostProcessorSlotName(PostProcessorSlot slot) {
131
133
  switch (slot) {
132
134
  case PostProcessorSlot::kAuthSubstitution:
@@ -224,10 +226,10 @@ class ChannelInit {
224
226
  FilterRegistration& IfNot(InclusionPredicate predicate);
225
227
  // Add a predicate that only includes this filter if a channel arg is
226
228
  // present.
227
- FilterRegistration& IfHasChannelArg(const char* arg);
229
+ FilterRegistration& IfHasChannelArg(absl::string_view arg);
228
230
  // Add a predicate that only includes this filter if a boolean channel arg
229
231
  // is true (with default_value being used if the argument is not present).
230
- FilterRegistration& IfChannelArg(const char* arg, bool default_value);
232
+ FilterRegistration& IfChannelArg(absl::string_view arg, bool default_value);
231
233
  // Mark this filter as being terminal.
232
234
  // Exactly one terminal filter will be added at the end of each filter
233
235
  // stack.
@@ -301,17 +303,10 @@ class ChannelInit {
301
303
 
302
304
  class Builder {
303
305
  public:
304
- // Register a builder in the normal filter registration pass.
305
- // This occurs first during channel build time.
306
- // The FilterRegistration methods can be called to declaratively define
307
- // properties of the filter being registered.
308
- // TODO(ctiller): remove in favor of the version that does not mention
309
- // grpc_channel_filter
310
- FilterRegistration& RegisterFilter(grpc_channel_stack_type type,
311
- UniqueTypeName name,
312
- const grpc_channel_filter* filter,
313
- FilterAdder filter_adder = nullptr,
314
- SourceLocation registration_source = {});
306
+ Builder();
307
+
308
+ // TEST ONLY.
309
+ explicit Builder(bool fix_v3_filter_stack_server_side_ordering);
315
310
  FilterRegistration& RegisterFilter(
316
311
  grpc_channel_stack_type type, const grpc_channel_filter* filter,
317
312
  SourceLocation registration_source = {}) {
@@ -319,6 +314,7 @@ class ChannelInit {
319
314
  return RegisterFilter(type, NameFromChannelFilter(filter), filter,
320
315
  nullptr, registration_source);
321
316
  }
317
+
322
318
  template <typename Filter>
323
319
  FilterRegistration& RegisterFilter(
324
320
  grpc_channel_stack_type type, SourceLocation registration_source = {}) {
@@ -383,12 +379,27 @@ class ChannelInit {
383
379
  ChannelInit Build();
384
380
 
385
381
  private:
382
+ // Register a builder in the normal filter registration pass.
383
+ // This occurs first during channel build time.
384
+ // The FilterRegistration methods can be called to declaratively define
385
+ // properties of the filter being registered.
386
+ // TODO(ctiller): remove in favor of the version that does not mention
387
+ // grpc_channel_filter
388
+ FilterRegistration& RegisterFilter(grpc_channel_stack_type type,
389
+ UniqueTypeName name,
390
+ const grpc_channel_filter* filter,
391
+ FilterAdder filter_adder = nullptr,
392
+ SourceLocation registration_source = {});
393
+
386
394
  std::vector<std::unique_ptr<FilterRegistration>>
387
395
  filters_[GRPC_NUM_CHANNEL_STACK_TYPES];
388
396
  std::vector<std::unique_ptr<FilterRegistration>>
389
397
  fused_filters_[GRPC_NUM_CHANNEL_STACK_TYPES];
390
398
  PostProcessor post_processors_[GRPC_NUM_CHANNEL_STACK_TYPES]
391
399
  [static_cast<int>(PostProcessorSlot::kCount)];
400
+ // TODO(weizheyuan): Remove this once the corresponding experiment
401
+ // `fix_v3_filter_stack_server_side_ordering` is deleted.
402
+ bool fix_v3_filter_stack_server_side_ordering_ = false;
392
403
  };
393
404
 
394
405
  /// Construct a channel stack of some sort: see channel_stack.h for details
@@ -445,19 +456,21 @@ class ChannelInit {
445
456
  };
446
457
 
447
458
  StackConfig stack_configs_[GRPC_NUM_CHANNEL_STACK_TYPES];
459
+ bool fix_v3_filter_stack_server_side_ordering_ = false;
448
460
 
449
461
  static std::tuple<std::vector<Filter>, std::vector<Filter>>
450
462
  SortFilterRegistrationsByDependencies(
451
463
  const std::vector<std::unique_ptr<FilterRegistration>>&
452
464
  filter_registrations,
453
- grpc_channel_stack_type type, channelz::PropertyTable& filter_ordering);
465
+ grpc_channel_stack_type type, channelz::PropertyTable& filter_ordering,
466
+ bool fix_v3_filter_stack_server_side_ordering);
454
467
 
455
468
  static std::vector<Filter> SortFusedFilterRegistrations(
456
469
  const std::vector<std::unique_ptr<FilterRegistration>>&
457
470
  filter_registrations);
458
471
 
459
472
  template <bool is_terminal>
460
- static std::vector<FilterNode> SelectFiltersByPredicate(
473
+ static std::vector<ChannelInit::FilterNode> SelectFiltersByPredicate(
461
474
  const std::vector<Filter>& filters, ChannelStackBuilder* builder);
462
475
 
463
476
  static void MergeFusedFilters(ChannelStackBuilder* builder,
@@ -471,7 +484,8 @@ class ChannelInit {
471
484
  filter_registrations,
472
485
  const std::vector<std::unique_ptr<FilterRegistration>>&
473
486
  fused_filter_registrations,
474
- PostProcessor* post_processors, grpc_channel_stack_type type);
487
+ PostProcessor* post_processors, grpc_channel_stack_type type,
488
+ bool fix_v3_filter_stack_server_side_ordering);
475
489
 
476
490
  static void PrintChannelStackTrace(
477
491
  grpc_channel_stack_type type,
@@ -137,8 +137,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
137
137
  GrpcRegisteredMethod(), reinterpret_cast<void*>(static_cast<uintptr_t>(
138
138
  args->registered_method)));
139
139
  if (parent != nullptr) {
140
- add_init_error(&error, absl_status_to_grpc_error(call->InitParent(
141
- parent, args->propagation_mask)));
140
+ add_init_error(&error, call->InitParent(parent, args->propagation_mask));
142
141
  }
143
142
  // Client call tracers should be created after propagating relevant
144
143
  // properties (tracing included) from the parent.
@@ -470,9 +469,7 @@ void FilterStackCall::RecvTrailingFilter(grpc_metadata_batch* b,
470
469
  SetFinalStatus(absl::OkStatus());
471
470
  } else {
472
471
  VLOG(2) << "Received trailing metadata with no error and no status";
473
- SetFinalStatus(grpc_error_set_int(GRPC_ERROR_CREATE("No status received"),
474
- StatusIntProperty::kRpcStatus,
475
- GRPC_STATUS_UNKNOWN));
472
+ SetFinalStatus(absl::UnknownError("No status received"));
476
473
  }
477
474
  }
478
475
  PublishAppMetadata(b, true);
@@ -899,11 +896,9 @@ grpc_call_error FilterStackCall::StartBatch(const grpc_op* ops, size_t nops,
899
896
  grpc_error_handle status_error =
900
897
  op->data.send_status_from_server.status == GRPC_STATUS_OK
901
898
  ? absl::OkStatus()
902
- : grpc_error_set_int(
903
- GRPC_ERROR_CREATE("Server returned error"),
904
- StatusIntProperty::kRpcStatus,
905
- static_cast<intptr_t>(
906
- op->data.send_status_from_server.status));
899
+ : absl::Status(static_cast<absl::StatusCode>(
900
+ op->data.send_status_from_server.status),
901
+ "Server returned error");
907
902
  if (op->data.send_status_from_server.status_details != nullptr) {
908
903
  send_trailing_metadata_.Set(
909
904
  GrpcMessageMetadata(),
@@ -46,14 +46,10 @@
46
46
  #include "src/core/util/thd.h"
47
47
  #include "absl/base/thread_annotations.h"
48
48
  #include "absl/log/log.h"
49
+ #include "absl/random/random.h"
49
50
  #include "absl/time/clock.h"
50
51
  #include "absl/time/time.h"
51
52
 
52
- // Remnants of the old plugin system
53
- void grpc_resolver_dns_ares_init(void);
54
- void grpc_resolver_dns_ares_shutdown(void);
55
- void grpc_resolver_dns_ares_reset_dns_resolver(void);
56
-
57
53
  extern absl::Status AresInit();
58
54
  extern void AresShutdown();
59
55
 
@@ -80,10 +76,15 @@ void RegisterSecurityFilters(CoreConfiguration::Builder* builder) {
80
76
  builder->channel_init()
81
77
  ->RegisterFilter<ServerAuthFilter>(GRPC_SERVER_CHANNEL)
82
78
  .IfHasChannelArg(GRPC_SERVER_CREDENTIALS_ARG);
83
- builder->channel_init()
84
- ->RegisterFilter<GrpcServerAuthzFilter>(GRPC_SERVER_CHANNEL)
85
- .IfHasChannelArg(GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER)
86
- .After<ServerAuthFilter>();
79
+ auto& authz_registration =
80
+ builder->channel_init()
81
+ ->RegisterFilter<GrpcServerAuthzFilter>(GRPC_SERVER_CHANNEL)
82
+ .IfHasChannelArg(GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER);
83
+ if (IsFixV3FilterStackServerSideOrderingEnabled()) {
84
+ authz_registration.Before<ServerAuthFilter>();
85
+ } else {
86
+ authz_registration.After<ServerAuthFilter>();
87
+ }
87
88
  }
88
89
  } // namespace grpc_core
89
90
 
@@ -102,6 +103,9 @@ static void do_basic_init(void) {
102
103
  grpc_fork_handlers_auto_register();
103
104
  grpc_tracer_init();
104
105
  grpc_client_channel_global_init_backup_polling();
106
+ // Pre-warm Abseil random entropy pool while file descriptors are available,
107
+ // preventing late-runtime SeedGenException crashes under FD exhaustion.
108
+ (void)absl::InsecureBitGen()();
105
109
  }
106
110
 
107
111
  void grpc_init(void) {
@@ -114,18 +118,6 @@ void grpc_init(void) {
114
118
  g_shutting_down_cv->SignalAll();
115
119
  }
116
120
  grpc_iomgr_init();
117
- if (grpc_core::IsEventEngineDnsEnabled()) {
118
- address_sorting_init();
119
- auto status = AresInit();
120
- if (!status.ok()) {
121
- VLOG(2) << "AresInit failed: " << status.message();
122
- } else {
123
- // TODO(yijiem): remove this once we remove the iomgr dns system.
124
- grpc_resolver_dns_ares_reset_dns_resolver();
125
- }
126
- } else {
127
- grpc_resolver_dns_ares_init();
128
- }
129
121
  grpc_iomgr_start();
130
122
  }
131
123
 
@@ -138,12 +130,6 @@ void grpc_shutdown_internal_locked(void)
138
130
  grpc_core::ExecCtx exec_ctx(0);
139
131
  grpc_iomgr_shutdown_background_closure();
140
132
  grpc_timer_manager_set_threading(false); // shutdown timer_manager thread
141
- if (grpc_core::IsEventEngineDnsEnabled()) {
142
- address_sorting_shutdown();
143
- AresShutdown();
144
- } else {
145
- grpc_resolver_dns_ares_shutdown();
146
- }
147
133
  grpc_iomgr_shutdown();
148
134
  }
149
135
  g_shutting_down = false;
@@ -24,4 +24,4 @@
24
24
 
25
25
  const char* grpc_version_string(void) { return "56.0.0"; }
26
26
 
27
- const char* grpc_g_stands_for(void) { return "garden"; }
27
+ const char* grpc_g_stands_for(void) { return "gimbal"; }
@@ -30,21 +30,6 @@
30
30
 
31
31
  using grpc_core::http2::Http2ErrorCode;
32
32
 
33
- static grpc_error_handle recursively_find_error_with_field(
34
- grpc_error_handle error, grpc_core::StatusIntProperty which) {
35
- intptr_t unused;
36
- // If the error itself has a status code, return it.
37
- if (grpc_error_get_int(error, which, &unused)) {
38
- return error;
39
- }
40
- std::vector<absl::Status> children = grpc_core::StatusGetChildren(error);
41
- for (const absl::Status& child : children) {
42
- grpc_error_handle result = recursively_find_error_with_field(child, which);
43
- if (!result.ok()) return result;
44
- }
45
- return absl::OkStatus();
46
- }
47
-
48
33
  namespace {
49
34
 
50
35
  std::optional<Http2ErrorCode> GetHttp2Error(const absl::Status& status) {
@@ -95,15 +80,3 @@ void grpc_error_get_status(grpc_error_handle error,
95
80
  }
96
81
  }
97
82
  }
98
-
99
- absl::Status grpc_error_to_absl_status(grpc_error_handle error) {
100
- return error;
101
- }
102
-
103
- grpc_error_handle absl_status_to_grpc_error(absl::Status status) {
104
- return status;
105
- }
106
-
107
- bool grpc_error_has_clear_grpc_status(grpc_error_handle error) {
108
- return error.code() != absl::StatusCode::kUnknown;
109
- }