grpc 1.74.1 → 1.75.0.pre1

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 (368) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +83 -41
  3. data/include/grpc/credentials.h +7 -1
  4. data/src/core/call/client_call.cc +4 -4
  5. data/src/core/call/filter_fusion.h +1230 -0
  6. data/src/core/call/metadata.cc +22 -0
  7. data/src/core/call/metadata.h +24 -2
  8. data/src/core/channelz/channelz.cc +10 -17
  9. data/src/core/channelz/channelz.h +58 -19
  10. data/src/core/channelz/channelz_registry.cc +0 -162
  11. data/src/core/channelz/channelz_registry.h +14 -7
  12. data/src/core/channelz/property_list.cc +19 -23
  13. data/src/core/channelz/property_list.h +3 -1
  14. data/src/core/channelz/v2tov1/convert.cc +683 -0
  15. data/src/core/channelz/v2tov1/convert.h +58 -0
  16. data/src/core/channelz/v2tov1/legacy_api.cc +425 -0
  17. data/src/core/channelz/v2tov1/legacy_api.h +32 -0
  18. data/src/core/channelz/v2tov1/property_list.cc +118 -0
  19. data/src/core/channelz/v2tov1/property_list.h +52 -0
  20. data/src/core/client_channel/client_channel_filter.cc +5 -4
  21. data/src/core/client_channel/client_channel_filter.h +2 -2
  22. data/src/core/client_channel/client_channel_internal.h +2 -1
  23. data/src/core/client_channel/load_balanced_call_destination.cc +6 -5
  24. data/src/core/client_channel/subchannel.cc +14 -6
  25. data/src/core/client_channel/subchannel.h +2 -0
  26. data/src/core/config/core_configuration.cc +3 -1
  27. data/src/core/config/core_configuration.h +12 -0
  28. data/src/core/credentials/transport/alts/alts_credentials.cc +5 -0
  29. data/src/core/credentials/transport/alts/check_gcp_environment_windows.cc +2 -0
  30. data/src/core/credentials/transport/channel_creds_registry_init.cc +3 -1
  31. data/src/core/credentials/transport/ssl/ssl_credentials.cc +1 -1
  32. data/src/core/credentials/transport/ssl/ssl_security_connector.cc +8 -3
  33. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.cc +29 -24
  34. data/src/core/credentials/transport/tls/grpc_tls_certificate_distributor.h +19 -8
  35. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.cc +96 -54
  36. data/src/core/credentials/transport/tls/grpc_tls_certificate_provider.h +15 -2
  37. data/src/core/credentials/transport/tls/spiffe_utils.cc +371 -0
  38. data/src/core/credentials/transport/tls/spiffe_utils.h +171 -0
  39. data/src/core/credentials/transport/tls/ssl_utils.cc +11 -10
  40. data/src/core/credentials/transport/tls/ssl_utils.h +4 -2
  41. data/src/core/credentials/transport/tls/tls_credentials.cc +2 -0
  42. data/src/core/credentials/transport/tls/tls_security_connector.cc +11 -26
  43. data/src/core/credentials/transport/tls/tls_security_connector.h +12 -12
  44. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -2
  45. data/src/core/ext/filters/http/client/http_client_filter.cc +3 -6
  46. data/src/core/ext/filters/http/client_authority_filter.cc +1 -2
  47. data/src/core/ext/filters/http/message_compress/compression_filter.cc +8 -8
  48. data/src/core/ext/filters/http/server/http_server_filter.cc +3 -6
  49. data/src/core/ext/filters/message_size/message_size_filter.cc +4 -4
  50. data/src/core/ext/filters/rbac/rbac_filter.cc +1 -1
  51. data/src/core/ext/filters/stateful_session/stateful_session_filter.cc +3 -5
  52. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +3 -2
  53. data/src/core/ext/transport/chttp2/transport/flow_control.cc +1 -0
  54. data/src/core/ext/transport/chttp2/transport/flow_control.h +1 -0
  55. data/src/core/ext/transport/chttp2/transport/frame.cc +89 -6
  56. data/src/core/ext/transport/chttp2/transport/frame.h +38 -0
  57. data/src/core/ext/transport/chttp2/transport/header_assembler.h +5 -14
  58. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +4 -1
  59. data/src/core/ext/transport/chttp2/transport/http2_client_transport.cc +294 -78
  60. data/src/core/ext/transport/chttp2/transport/http2_client_transport.h +128 -9
  61. data/src/core/ext/transport/chttp2/transport/http2_settings.cc +11 -38
  62. data/src/core/ext/transport/chttp2/transport/http2_settings.h +52 -35
  63. data/src/core/ext/transport/chttp2/transport/http2_settings_manager.cc +61 -0
  64. data/src/core/ext/transport/chttp2/transport/http2_settings_manager.h +142 -0
  65. data/src/core/ext/transport/chttp2/transport/http2_transport.cc +81 -3
  66. data/src/core/ext/transport/chttp2/transport/http2_transport.h +12 -1
  67. data/src/core/ext/transport/chttp2/transport/message_assembler.h +2 -2
  68. data/src/core/ext/transport/chttp2/transport/parsing.cc +2 -1
  69. data/src/core/ext/transport/chttp2/transport/ping_promise.cc +2 -1
  70. data/src/core/ext/transport/chttp2/transport/ping_promise.h +22 -5
  71. data/src/core/ext/transport/chttp2/transport/stream_data_queue.h +607 -0
  72. data/src/core/ext/transport/chttp2/transport/writable_streams.h +254 -0
  73. data/src/core/ext/transport/chttp2/transport/writing.cc +6 -4
  74. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb.h +4959 -0
  75. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.c +1111 -0
  76. data/src/core/ext/upb-gen/src/proto/grpc/channelz/channelz.upb_minitable.h +108 -0
  77. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb.h +142 -54
  78. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.c +18 -14
  79. data/src/core/ext/upb-gen/src/proto/grpc/channelz/v2/property_list.upb_minitable.h +2 -2
  80. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.c +716 -0
  81. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/channelz.upbdefs.h +227 -0
  82. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.c +86 -88
  83. data/src/core/ext/upbdefs-gen/src/proto/grpc/channelz/v2/property_list.upbdefs.h +2 -2
  84. data/src/core/filter/auth/auth_filters.h +2 -2
  85. data/src/core/filter/fused_filters.cc +154 -0
  86. data/src/core/handshaker/security/legacy_secure_endpoint.cc +1 -1
  87. data/src/core/handshaker/security/pipelined_secure_endpoint.cc +965 -0
  88. data/src/core/handshaker/security/secure_endpoint.cc +28 -13
  89. data/src/core/handshaker/security/secure_endpoint.h +8 -0
  90. data/src/core/lib/channel/promise_based_filter.cc +15 -25
  91. data/src/core/lib/channel/promise_based_filter.h +6 -5
  92. data/src/core/lib/event_engine/ares_resolver.h +3 -1
  93. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -5
  94. data/src/core/lib/event_engine/cf_engine/cf_engine.h +2 -1
  95. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.cc +263 -0
  96. data/src/core/lib/event_engine/cf_engine/cfsocket_listener.h +107 -0
  97. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +31 -3
  98. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.h +12 -0
  99. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.cc +12 -10
  100. data/src/core/lib/event_engine/posix_engine/ev_epoll1_linux.h +6 -4
  101. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +15 -14
  102. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +7 -5
  103. data/src/core/lib/event_engine/posix_engine/event_poller.h +0 -8
  104. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.cc +11 -5
  105. data/src/core/lib/event_engine/posix_engine/event_poller_posix_default.h +3 -2
  106. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +1 -0
  107. data/src/core/lib/event_engine/posix_engine/lockfree_event.cc +4 -4
  108. data/src/core/lib/event_engine/posix_engine/lockfree_event.h +3 -4
  109. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +2 -2
  110. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +188 -199
  111. data/src/core/lib/event_engine/posix_engine/posix_engine.h +30 -45
  112. data/src/core/lib/event_engine/posix_engine/posix_engine_listener.cc +1 -1
  113. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.h +1 -1
  114. data/src/core/lib/event_engine/windows/grpc_polled_fd_windows.cc +2 -1
  115. data/src/core/lib/experiments/experiments.cc +120 -6
  116. data/src/core/lib/experiments/experiments.h +46 -3
  117. data/src/core/lib/iomgr/combiner.cc +1 -1
  118. data/src/core/lib/iomgr/exec_ctx.h +3 -9
  119. data/src/core/lib/iomgr/socket_mutator.cc +1 -1
  120. data/src/core/lib/iomgr/socket_utils_posix.cc +1 -1
  121. data/src/core/lib/iomgr/socket_utils_posix.h +1 -1
  122. data/src/core/lib/iomgr/tcp_client_posix.cc +1 -1
  123. data/src/core/lib/iomgr/tcp_posix.cc +3 -3
  124. data/src/core/lib/promise/activity.h +2 -2
  125. data/src/core/lib/promise/mpsc.cc +8 -8
  126. data/src/core/lib/promise/party.cc +7 -7
  127. data/src/core/lib/promise/party.h +4 -4
  128. data/src/core/lib/promise/poll.h +10 -0
  129. data/src/core/lib/resource_quota/memory_quota.cc +90 -3
  130. data/src/core/lib/resource_quota/memory_quota.h +20 -9
  131. data/src/core/lib/resource_quota/periodic_update.cc +14 -0
  132. data/src/core/lib/resource_quota/periodic_update.h +8 -0
  133. data/src/core/lib/resource_quota/resource_quota.cc +15 -4
  134. data/src/core/lib/resource_quota/resource_quota.h +3 -0
  135. data/src/core/lib/security/authorization/grpc_server_authz_filter.cc +1 -2
  136. data/src/core/lib/surface/call.cc +5 -5
  137. data/src/core/lib/surface/call.h +6 -5
  138. data/src/core/lib/surface/completion_queue.cc +2 -4
  139. data/src/core/lib/surface/filter_stack_call.cc +1 -1
  140. data/src/core/lib/surface/version.cc +2 -2
  141. data/src/core/lib/transport/promise_endpoint.cc +2 -2
  142. data/src/core/lib/transport/promise_endpoint.h +3 -3
  143. data/src/core/load_balancing/endpoint_list.cc +29 -2
  144. data/src/core/load_balancing/grpclb/client_load_reporting_filter.cc +3 -3
  145. data/src/core/load_balancing/grpclb/client_load_reporting_filter.h +1 -1
  146. data/src/core/load_balancing/pick_first/pick_first.cc +12 -5
  147. data/src/core/load_balancing/xds/xds_cluster_impl.cc +5 -3
  148. data/src/core/net/socket_mutator.cc +19 -0
  149. data/src/core/net/socket_mutator.h +25 -0
  150. data/src/core/plugin_registry/grpc_plugin_registry.cc +6 -0
  151. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver.h +6 -1
  152. data/src/core/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +2 -1
  153. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc +8 -5
  154. data/src/core/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
  155. data/src/core/resolver/xds/xds_dependency_manager.cc +1 -1
  156. data/src/core/server/server.cc +1 -1
  157. data/src/core/server/server_call_tracer_filter.cc +0 -66
  158. data/src/core/server/server_call_tracer_filter.h +64 -0
  159. data/src/core/server/server_config_selector_filter.cc +1 -1
  160. data/src/core/service_config/service_config_channel_arg_filter.cc +3 -60
  161. data/src/core/service_config/service_config_channel_arg_filter.h +82 -0
  162. data/src/core/telemetry/call_tracer.cc +20 -14
  163. data/src/core/telemetry/call_tracer.h +22 -17
  164. data/src/core/telemetry/metrics.h +8 -8
  165. data/src/core/telemetry/stats_data.cc +151 -151
  166. data/src/core/telemetry/stats_data.h +87 -87
  167. data/src/core/transport/auth_context.cc +20 -0
  168. data/src/core/transport/auth_context.h +4 -0
  169. data/src/core/transport/auth_context_comparator_registry.h +69 -0
  170. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +2 -3
  171. data/src/core/tsi/ssl_transport_security.cc +202 -32
  172. data/src/core/tsi/ssl_transport_security.h +19 -10
  173. data/src/core/tsi/ssl_transport_security_utils.cc +21 -0
  174. data/src/core/tsi/ssl_transport_security_utils.h +4 -0
  175. data/src/core/util/http_client/httpcli_security_connector.cc +3 -1
  176. data/src/core/util/latent_see.cc +178 -146
  177. data/src/core/util/latent_see.h +245 -188
  178. data/src/core/util/single_set_ptr.h +5 -2
  179. data/src/core/util/useful.h +91 -0
  180. data/src/core/util/windows/directory_reader.cc +1 -0
  181. data/src/core/util/windows/thd.cc +1 -3
  182. data/src/core/util/work_serializer.cc +1 -1
  183. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.cc +32 -5
  184. data/src/core/xds/grpc/file_watcher_certificate_provider_factory.h +5 -0
  185. data/src/core/xds/grpc/xds_certificate_provider.cc +5 -6
  186. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +1 -1
  187. data/src/ruby/lib/grpc/version.rb +1 -1
  188. data/third_party/cares/cares/include/ares.h +925 -460
  189. data/third_party/cares/cares/include/ares_dns.h +86 -71
  190. data/third_party/cares/cares/include/ares_dns_record.h +1118 -0
  191. data/third_party/cares/cares/include/ares_nameser.h +215 -189
  192. data/third_party/cares/cares/include/ares_version.h +37 -14
  193. data/third_party/cares/cares/src/lib/ares_addrinfo2hostent.c +305 -0
  194. data/third_party/cares/cares/src/lib/ares_addrinfo_localhost.c +245 -0
  195. data/third_party/cares/cares/src/lib/ares_android.c +216 -164
  196. data/third_party/cares/cares/src/lib/ares_android.h +25 -14
  197. data/third_party/cares/cares/src/lib/ares_cancel.c +68 -44
  198. data/third_party/cares/cares/src/lib/ares_close_sockets.c +137 -0
  199. data/third_party/cares/cares/src/lib/ares_conn.c +511 -0
  200. data/third_party/cares/cares/src/lib/ares_conn.h +196 -0
  201. data/third_party/cares/cares/src/lib/ares_cookie.c +461 -0
  202. data/third_party/cares/cares/src/lib/ares_data.c +93 -181
  203. data/third_party/cares/cares/src/lib/ares_data.h +50 -39
  204. data/third_party/cares/cares/src/lib/ares_destroy.c +127 -89
  205. data/third_party/cares/cares/src/lib/ares_free_hostent.c +35 -24
  206. data/third_party/cares/cares/src/lib/ares_free_string.c +24 -16
  207. data/third_party/cares/cares/src/lib/ares_freeaddrinfo.c +45 -38
  208. data/third_party/cares/cares/src/lib/ares_getaddrinfo.c +549 -663
  209. data/third_party/cares/cares/src/lib/ares_getenv.c +25 -15
  210. data/third_party/cares/cares/src/lib/ares_getenv.h +26 -18
  211. data/third_party/cares/cares/src/lib/ares_gethostbyaddr.c +163 -221
  212. data/third_party/cares/cares/src/lib/ares_gethostbyname.c +222 -223
  213. data/third_party/cares/cares/src/lib/ares_getnameinfo.c +328 -338
  214. data/third_party/cares/cares/src/lib/ares_hosts_file.c +952 -0
  215. data/third_party/cares/cares/src/lib/ares_inet_net_pton.h +25 -19
  216. data/third_party/cares/cares/src/lib/ares_init.c +425 -2091
  217. data/third_party/cares/cares/src/lib/ares_ipv6.h +63 -33
  218. data/third_party/cares/cares/src/lib/ares_library_init.c +110 -54
  219. data/third_party/cares/cares/src/lib/ares_metrics.c +261 -0
  220. data/third_party/cares/cares/src/lib/ares_options.c +418 -332
  221. data/third_party/cares/cares/src/lib/ares_parse_into_addrinfo.c +179 -0
  222. data/third_party/cares/cares/src/lib/ares_private.h +558 -356
  223. data/third_party/cares/cares/src/lib/ares_process.c +1224 -1369
  224. data/third_party/cares/cares/src/lib/ares_qcache.c +430 -0
  225. data/third_party/cares/cares/src/lib/ares_query.c +126 -121
  226. data/third_party/cares/cares/src/lib/ares_search.c +564 -262
  227. data/third_party/cares/cares/src/lib/ares_send.c +264 -93
  228. data/third_party/cares/cares/src/lib/ares_set_socket_functions.c +588 -0
  229. data/third_party/cares/cares/src/lib/ares_setup.h +115 -111
  230. data/third_party/cares/cares/src/lib/ares_socket.c +425 -0
  231. data/third_party/cares/cares/src/lib/ares_socket.h +163 -0
  232. data/third_party/cares/cares/src/lib/ares_sortaddrinfo.c +447 -0
  233. data/third_party/cares/cares/src/lib/ares_strerror.c +83 -48
  234. data/third_party/cares/cares/src/lib/ares_sysconfig.c +639 -0
  235. data/third_party/cares/cares/src/lib/ares_sysconfig_files.c +839 -0
  236. data/third_party/cares/cares/src/lib/ares_sysconfig_mac.c +373 -0
  237. data/third_party/cares/cares/src/lib/ares_sysconfig_win.c +621 -0
  238. data/third_party/cares/cares/src/lib/ares_timeout.c +136 -73
  239. data/third_party/cares/cares/src/lib/ares_update_servers.c +1362 -0
  240. data/third_party/cares/cares/src/lib/ares_version.c +29 -4
  241. data/third_party/cares/cares/src/lib/config-dos.h +88 -89
  242. data/third_party/cares/cares/src/lib/config-win32.h +122 -77
  243. data/third_party/cares/cares/src/lib/dsa/ares_array.c +394 -0
  244. data/third_party/cares/cares/src/lib/dsa/ares_htable.c +447 -0
  245. data/third_party/cares/cares/src/lib/dsa/ares_htable.h +174 -0
  246. data/third_party/cares/cares/src/lib/dsa/ares_htable_asvp.c +224 -0
  247. data/third_party/cares/cares/src/lib/dsa/ares_htable_dict.c +228 -0
  248. data/third_party/cares/cares/src/lib/dsa/ares_htable_strvp.c +210 -0
  249. data/third_party/cares/cares/src/lib/dsa/ares_htable_szvp.c +188 -0
  250. data/third_party/cares/cares/src/lib/dsa/ares_htable_vpstr.c +186 -0
  251. data/third_party/cares/cares/src/lib/dsa/ares_htable_vpvp.c +194 -0
  252. data/third_party/cares/cares/src/lib/dsa/ares_llist.c +382 -0
  253. data/third_party/cares/cares/src/lib/dsa/ares_slist.c +479 -0
  254. data/third_party/cares/cares/src/lib/dsa/ares_slist.h +207 -0
  255. data/third_party/cares/cares/src/lib/event/ares_event.h +191 -0
  256. data/third_party/cares/cares/src/lib/event/ares_event_configchg.c +743 -0
  257. data/third_party/cares/cares/src/lib/event/ares_event_epoll.c +192 -0
  258. data/third_party/cares/cares/src/lib/event/ares_event_kqueue.c +248 -0
  259. data/third_party/cares/cares/src/lib/event/ares_event_poll.c +140 -0
  260. data/third_party/cares/cares/src/lib/event/ares_event_select.c +159 -0
  261. data/third_party/cares/cares/src/lib/event/ares_event_thread.c +567 -0
  262. data/third_party/cares/cares/src/lib/event/ares_event_wake_pipe.c +166 -0
  263. data/third_party/cares/cares/src/lib/event/ares_event_win32.c +978 -0
  264. data/third_party/cares/cares/src/lib/event/ares_event_win32.h +161 -0
  265. data/third_party/cares/cares/src/lib/include/ares_array.h +276 -0
  266. data/third_party/cares/cares/src/lib/include/ares_buf.h +732 -0
  267. data/third_party/cares/cares/src/lib/include/ares_htable_asvp.h +130 -0
  268. data/third_party/cares/cares/src/lib/include/ares_htable_dict.h +123 -0
  269. data/third_party/cares/cares/src/lib/include/ares_htable_strvp.h +130 -0
  270. data/third_party/cares/cares/src/lib/include/ares_htable_szvp.h +118 -0
  271. data/third_party/cares/cares/src/lib/include/ares_htable_vpstr.h +111 -0
  272. data/third_party/cares/cares/src/lib/include/ares_htable_vpvp.h +128 -0
  273. data/third_party/cares/cares/src/lib/include/ares_llist.h +239 -0
  274. data/third_party/cares/cares/src/lib/include/ares_mem.h +38 -0
  275. data/third_party/cares/cares/src/lib/include/ares_str.h +244 -0
  276. data/third_party/cares/cares/src/lib/inet_net_pton.c +202 -157
  277. data/third_party/cares/cares/src/lib/inet_ntop.c +87 -69
  278. data/third_party/cares/cares/src/lib/legacy/ares_create_query.c +78 -0
  279. data/third_party/cares/cares/src/lib/legacy/ares_expand_name.c +99 -0
  280. data/third_party/cares/cares/src/lib/legacy/ares_expand_string.c +107 -0
  281. data/third_party/cares/cares/src/lib/legacy/ares_fds.c +80 -0
  282. data/third_party/cares/cares/src/lib/legacy/ares_getsock.c +85 -0
  283. data/third_party/cares/cares/src/lib/legacy/ares_parse_a_reply.c +107 -0
  284. data/third_party/cares/cares/src/lib/legacy/ares_parse_aaaa_reply.c +109 -0
  285. data/third_party/cares/cares/src/lib/legacy/ares_parse_caa_reply.c +137 -0
  286. data/third_party/cares/cares/src/lib/legacy/ares_parse_mx_reply.c +110 -0
  287. data/third_party/cares/cares/src/lib/legacy/ares_parse_naptr_reply.c +132 -0
  288. data/third_party/cares/cares/src/lib/legacy/ares_parse_ns_reply.c +154 -0
  289. data/third_party/cares/cares/src/lib/legacy/ares_parse_ptr_reply.c +213 -0
  290. data/third_party/cares/cares/src/lib/legacy/ares_parse_soa_reply.c +115 -0
  291. data/third_party/cares/cares/src/lib/legacy/ares_parse_srv_reply.c +114 -0
  292. data/third_party/cares/cares/src/lib/legacy/ares_parse_txt_reply.c +144 -0
  293. data/third_party/cares/cares/src/lib/legacy/ares_parse_uri_reply.c +113 -0
  294. data/third_party/cares/cares/src/lib/record/ares_dns_mapping.c +982 -0
  295. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.c +307 -0
  296. data/third_party/cares/cares/src/lib/record/ares_dns_multistring.h +72 -0
  297. data/third_party/cares/cares/src/lib/record/ares_dns_name.c +673 -0
  298. data/third_party/cares/cares/src/lib/record/ares_dns_parse.c +1329 -0
  299. data/third_party/cares/cares/src/lib/record/ares_dns_private.h +273 -0
  300. data/third_party/cares/cares/src/lib/record/ares_dns_record.c +1661 -0
  301. data/third_party/cares/cares/src/lib/record/ares_dns_write.c +1229 -0
  302. data/third_party/cares/cares/src/lib/str/ares_buf.c +1498 -0
  303. data/third_party/cares/cares/src/lib/str/ares_str.c +508 -0
  304. data/third_party/cares/cares/src/lib/str/ares_strsplit.c +90 -0
  305. data/third_party/cares/cares/src/lib/str/ares_strsplit.h +51 -0
  306. data/third_party/cares/cares/src/lib/thirdparty/apple/dnsinfo.h +122 -0
  307. data/third_party/cares/cares/src/lib/util/ares_iface_ips.c +628 -0
  308. data/third_party/cares/cares/src/lib/util/ares_iface_ips.h +139 -0
  309. data/third_party/cares/cares/src/lib/util/ares_math.c +158 -0
  310. data/third_party/cares/cares/src/lib/util/ares_math.h +45 -0
  311. data/third_party/cares/cares/src/lib/util/ares_rand.c +389 -0
  312. data/third_party/cares/cares/src/lib/util/ares_rand.h +36 -0
  313. data/third_party/cares/cares/src/lib/util/ares_threads.c +614 -0
  314. data/third_party/cares/cares/src/lib/util/ares_threads.h +60 -0
  315. data/third_party/cares/cares/src/lib/util/ares_time.h +48 -0
  316. data/third_party/cares/cares/src/lib/util/ares_timeval.c +95 -0
  317. data/third_party/cares/cares/src/lib/util/ares_uri.c +1626 -0
  318. data/third_party/cares/cares/src/lib/util/ares_uri.h +252 -0
  319. data/third_party/cares/cares/src/lib/windows_port.c +16 -9
  320. metadata +121 -49
  321. data/src/core/util/ring_buffer.h +0 -122
  322. data/third_party/cares/cares/include/ares_rules.h +0 -125
  323. data/third_party/cares/cares/src/lib/ares__addrinfo2hostent.c +0 -266
  324. data/third_party/cares/cares/src/lib/ares__addrinfo_localhost.c +0 -240
  325. data/third_party/cares/cares/src/lib/ares__close_sockets.c +0 -61
  326. data/third_party/cares/cares/src/lib/ares__get_hostent.c +0 -260
  327. data/third_party/cares/cares/src/lib/ares__parse_into_addrinfo.c +0 -229
  328. data/third_party/cares/cares/src/lib/ares__read_line.c +0 -73
  329. data/third_party/cares/cares/src/lib/ares__readaddrinfo.c +0 -258
  330. data/third_party/cares/cares/src/lib/ares__sortaddrinfo.c +0 -507
  331. data/third_party/cares/cares/src/lib/ares__timeval.c +0 -111
  332. data/third_party/cares/cares/src/lib/ares_create_query.c +0 -197
  333. data/third_party/cares/cares/src/lib/ares_expand_name.c +0 -311
  334. data/third_party/cares/cares/src/lib/ares_expand_string.c +0 -67
  335. data/third_party/cares/cares/src/lib/ares_fds.c +0 -59
  336. data/third_party/cares/cares/src/lib/ares_getsock.c +0 -66
  337. data/third_party/cares/cares/src/lib/ares_iphlpapi.h +0 -221
  338. data/third_party/cares/cares/src/lib/ares_llist.c +0 -63
  339. data/third_party/cares/cares/src/lib/ares_llist.h +0 -39
  340. data/third_party/cares/cares/src/lib/ares_mkquery.c +0 -24
  341. data/third_party/cares/cares/src/lib/ares_nowarn.c +0 -260
  342. data/third_party/cares/cares/src/lib/ares_nowarn.h +0 -61
  343. data/third_party/cares/cares/src/lib/ares_parse_a_reply.c +0 -90
  344. data/third_party/cares/cares/src/lib/ares_parse_aaaa_reply.c +0 -92
  345. data/third_party/cares/cares/src/lib/ares_parse_caa_reply.c +0 -199
  346. data/third_party/cares/cares/src/lib/ares_parse_mx_reply.c +0 -164
  347. data/third_party/cares/cares/src/lib/ares_parse_naptr_reply.c +0 -183
  348. data/third_party/cares/cares/src/lib/ares_parse_ns_reply.c +0 -177
  349. data/third_party/cares/cares/src/lib/ares_parse_ptr_reply.c +0 -228
  350. data/third_party/cares/cares/src/lib/ares_parse_soa_reply.c +0 -179
  351. data/third_party/cares/cares/src/lib/ares_parse_srv_reply.c +0 -168
  352. data/third_party/cares/cares/src/lib/ares_parse_txt_reply.c +0 -214
  353. data/third_party/cares/cares/src/lib/ares_parse_uri_reply.c +0 -184
  354. data/third_party/cares/cares/src/lib/ares_platform.c +0 -11042
  355. data/third_party/cares/cares/src/lib/ares_platform.h +0 -43
  356. data/third_party/cares/cares/src/lib/ares_rand.c +0 -279
  357. data/third_party/cares/cares/src/lib/ares_strcasecmp.c +0 -66
  358. data/third_party/cares/cares/src/lib/ares_strcasecmp.h +0 -30
  359. data/third_party/cares/cares/src/lib/ares_strdup.c +0 -42
  360. data/third_party/cares/cares/src/lib/ares_strdup.h +0 -24
  361. data/third_party/cares/cares/src/lib/ares_strsplit.c +0 -94
  362. data/third_party/cares/cares/src/lib/ares_strsplit.h +0 -42
  363. data/third_party/cares/cares/src/lib/ares_writev.c +0 -79
  364. data/third_party/cares/cares/src/lib/ares_writev.h +0 -36
  365. data/third_party/cares/cares/src/lib/bitncmp.c +0 -59
  366. data/third_party/cares/cares/src/lib/bitncmp.h +0 -26
  367. data/third_party/cares/cares/src/lib/setup_once.h +0 -554
  368. data/third_party/cares/cares/src/tools/ares_getopt.h +0 -53
@@ -27,13 +27,16 @@
27
27
  #include "src/core/ext/transport/chttp2/transport/header_assembler.h"
28
28
  #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
29
29
  #include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
30
- #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
30
+ #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h"
31
31
  #include "src/core/ext/transport/chttp2/transport/http2_status.h"
32
32
  #include "src/core/ext/transport/chttp2/transport/http2_transport.h"
33
33
  #include "src/core/ext/transport/chttp2/transport/keepalive.h"
34
34
  #include "src/core/ext/transport/chttp2/transport/message_assembler.h"
35
35
  #include "src/core/ext/transport/chttp2/transport/ping_promise.h"
36
+ #include "src/core/ext/transport/chttp2/transport/stream_data_queue.h"
37
+ #include "src/core/ext/transport/chttp2/transport/writable_streams.h"
36
38
  #include "src/core/lib/promise/inter_activity_mutex.h"
39
+ #include "src/core/lib/promise/loop.h"
37
40
  #include "src/core/lib/promise/mpsc.h"
38
41
  #include "src/core/lib/promise/party.h"
39
42
  #include "src/core/lib/transport/connectivity_state.h"
@@ -69,10 +72,11 @@ namespace http2 {
69
72
  // |---------------------|--------------|-----------------------|------------|
70
73
  // | Endpoint Read Loop | Infinite | On transport close | One |
71
74
  // | Endpoint Write Loop | Infinite | On transport close | One |
75
+ // | Stream Multiplexer | Infinite | On transport close | One |
72
76
  // | Close Transport | CloseTimeout | On transport close | One |
73
77
 
74
- // Max Party Slots (Always): 2
75
- // Max Promise Slots (Worst Case): 3
78
+ // Max Party Slots (Always): 3
79
+ // Max Promise Slots (Worst Case): 4
76
80
 
77
81
  // Experimental : This is just the initial skeleton of class
78
82
  // and it is functions. The code will be written iteratively.
@@ -137,8 +141,9 @@ class Http2ClientTransport final : public ClientTransport {
137
141
  }));
138
142
  }
139
143
 
140
- auto TestOnlySendPing(absl::AnyInvocable<void()> on_initiate) {
141
- return ping_manager_.RequestPing(std::move(on_initiate));
144
+ auto TestOnlySendPing(absl::AnyInvocable<void()> on_initiate,
145
+ bool important = false) {
146
+ return ping_manager_.RequestPing(std::move(on_initiate), important);
142
147
  }
143
148
 
144
149
  template <typename Factory>
@@ -189,6 +194,15 @@ class Http2ClientTransport final : public ClientTransport {
189
194
  // Returns a promise that will do the cleanup after the WriteLoop ends.
190
195
  auto OnWriteLoopEnded();
191
196
 
197
+ // Returns a promise to keep draining data and control frames from all the
198
+ // active streams. This includes all stream specific frames like data, header,
199
+ // continuation and reset stream frames.
200
+ auto StreamMultiplexerLoop();
201
+
202
+ // Returns a promise that will do the cleanup after the StreamMultiplexerLoop
203
+ // ends.
204
+ auto OnStreamMultiplexerLoopEnded();
205
+
192
206
  // Returns a promise to fetch data from the callhandler and pass it further
193
207
  // down towards the endpoint.
194
208
  auto CallOutboundLoop(CallHandler call_handler, uint32_t stream_id,
@@ -219,6 +233,7 @@ class Http2ClientTransport final : public ClientTransport {
219
233
 
220
234
  PromiseEndpoint endpoint_;
221
235
  Http2SettingsManager settings_;
236
+ Duration settings_timeout_;
222
237
 
223
238
  Http2FrameHeader current_frame_header_;
224
239
 
@@ -230,7 +245,59 @@ class Http2ClientTransport final : public ClientTransport {
230
245
  stream_id(stream_id1),
231
246
  header_assembler(stream_id1),
232
247
  did_push_initial_metadata(false),
233
- did_push_trailing_metadata(false) {}
248
+ did_push_trailing_metadata(false),
249
+ data_queue(MakeRefCounted<StreamDataQueue<ClientMetadataHandle>>(
250
+ /*is_client*/ true, /*stream_id*/ stream_id1,
251
+ /*queue_size*/ kStreamQueueSize)) {}
252
+
253
+ ////////////////////////////////////////////////////////////////////////////
254
+ // Data Queue Helpers
255
+
256
+ auto EnqueueInitialMetadata(ClientMetadataHandle&& metadata) {
257
+ GRPC_HTTP2_CLIENT_DLOG
258
+ << "Http2ClientTransport::Stream::EnqueueInitialMetadata stream_id="
259
+ << stream_id;
260
+ return data_queue->EnqueueInitialMetadata(std::move(metadata));
261
+ }
262
+
263
+ auto EnqueueTrailingMetadata(ClientMetadataHandle&& metadata) {
264
+ GRPC_HTTP2_CLIENT_DLOG
265
+ << "Http2ClientTransport::Stream::EnqueueTrailingMetadata stream_id="
266
+ << stream_id;
267
+ return data_queue->EnqueueTrailingMetadata(std::move(metadata));
268
+ }
269
+
270
+ auto EnqueueMessage(MessageHandle&& message) {
271
+ GRPC_HTTP2_CLIENT_DLOG
272
+ << "Http2ClientTransport::Stream::EnqueueMessage stream_id="
273
+ << stream_id
274
+ << " with payload size = " << message->payload()->Length();
275
+ return data_queue->EnqueueMessage(std::move(message));
276
+ }
277
+
278
+ auto EnqueueHalfClosed() {
279
+ GRPC_HTTP2_CLIENT_DLOG
280
+ << "Http2ClientTransport::Stream::EnqueueHalfClosed stream_id="
281
+ << stream_id;
282
+ return data_queue->EnqueueHalfClosed();
283
+ }
284
+
285
+ auto EnqueueResetStream(const uint32_t error_code) {
286
+ GRPC_HTTP2_CLIENT_DLOG
287
+ << "Http2ClientTransport::Stream::EnqueueResetStream stream_id="
288
+ << stream_id << " with error_code = " << error_code;
289
+ return data_queue->EnqueueResetStream(error_code);
290
+ }
291
+
292
+ auto DequeueFrames(const uint32_t transport_tokens,
293
+ const uint32_t max_frame_length,
294
+ HPackCompressor& encoder) {
295
+ return data_queue->DequeueFrames(transport_tokens, max_frame_length,
296
+ encoder);
297
+ }
298
+
299
+ ////////////////////////////////////////////////////////////////////////////
300
+ // Stream State Management
234
301
 
235
302
  // Modify the stream state
236
303
  // The possible stream transitions are as follows:
@@ -257,6 +324,7 @@ class Http2ClientTransport final : public ClientTransport {
257
324
  case HttpStreamState::kHalfClosedLocal:
258
325
  break;
259
326
  case HttpStreamState::kClosed:
327
+ DCHECK(false) << "MarkHalfClosedLocal called for a closed stream";
260
328
  break;
261
329
  }
262
330
  }
@@ -275,10 +343,13 @@ class Http2ClientTransport final : public ClientTransport {
275
343
  case HttpStreamState::kHalfClosedRemote:
276
344
  break;
277
345
  case HttpStreamState::kClosed:
346
+ DCHECK(false) << "MarkHalfClosedRemote called for a closed stream";
278
347
  break;
279
348
  }
280
349
  }
281
350
 
351
+ HttpStreamState GetStreamState() const { return stream_state; }
352
+
282
353
  inline bool IsClosed() const {
283
354
  return stream_state == HttpStreamState::kClosed;
284
355
  }
@@ -287,7 +358,6 @@ class Http2ClientTransport final : public ClientTransport {
287
358
  // TODO(akshitpatel) : [PH2][P3] : Investigate if this needs to be atomic.
288
359
  HttpStreamState stream_state;
289
360
  const uint32_t stream_id;
290
- TransportSendQeueue send_queue;
291
361
  GrpcMessageAssembler assembler;
292
362
  HeaderAssembler header_assembler;
293
363
  // TODO(akshitpatel) : [PH2][P2] : StreamQ should maintain a flag that
@@ -300,6 +370,7 @@ class Http2ClientTransport final : public ClientTransport {
300
370
  // transition to HalfClosedLocal till the end_stream frame is sent.
301
371
  bool did_push_initial_metadata;
302
372
  bool did_push_trailing_metadata;
373
+ RefCountedPtr<StreamDataQueue<ClientMetadataHandle>> data_queue;
303
374
  };
304
375
 
305
376
  uint32_t NextStreamId(
@@ -430,6 +501,8 @@ class Http2ClientTransport final : public ClientTransport {
430
501
  uint32_t incoming_header_stream_id_;
431
502
  grpc_closure* on_receive_settings_;
432
503
 
504
+ uint32_t max_header_list_size_soft_limit_;
505
+
433
506
  // Ping related members
434
507
  // TODO(akshitpatel) : [PH2][P2] : Consider removing the timeout related
435
508
  // members.
@@ -447,8 +520,8 @@ class Http2ClientTransport final : public ClientTransport {
447
520
  // Flags
448
521
  bool keepalive_permit_without_calls_;
449
522
 
450
- auto SendPing(absl::AnyInvocable<void()> on_initiate) {
451
- return ping_manager_.RequestPing(std::move(on_initiate));
523
+ auto SendPing(absl::AnyInvocable<void()> on_initiate, bool important) {
524
+ return ping_manager_.RequestPing(std::move(on_initiate), important);
452
525
  }
453
526
  auto WaitForPingAck() { return ping_manager_.WaitForPingAck(); }
454
527
 
@@ -490,6 +563,33 @@ class Http2ClientTransport final : public ClientTransport {
490
563
  }));
491
564
  }
492
565
 
566
+ auto AckPing(uint64_t opaque_data) {
567
+ bool valid_ping_ack_received = true;
568
+
569
+ if (!ping_manager_.AckPing(opaque_data)) {
570
+ GRPC_HTTP2_CLIENT_DLOG << "Unknown ping response received for ping id="
571
+ << opaque_data;
572
+ valid_ping_ack_received = false;
573
+ }
574
+
575
+ return If(
576
+ // It is possible that the PingRatePolicy may decide to not send a ping
577
+ // request (in cases like the number of inflight pings is too high).
578
+ // When this happens, it becomes important to ensure that if a ping ack
579
+ // is received and there is an "important" outstanding ping request, we
580
+ // should retry to send it out now.
581
+ valid_ping_ack_received && ping_manager_.ImportantPingRequested(),
582
+ [self = RefAsSubclass<Http2ClientTransport>()] {
583
+ return Map(self->TriggerWriteCycle(), [](const absl::Status status) {
584
+ return (status.ok())
585
+ ? Http2Status::Ok()
586
+ : Http2Status::AbslConnectionError(
587
+ status.code(), std::string(status.message()));
588
+ });
589
+ },
590
+ [] { return Immediate(Http2Status::Ok()); });
591
+ }
592
+
493
593
  class PingSystemInterfaceImpl : public PingInterface {
494
594
  public:
495
595
  static std::unique_ptr<PingInterface> Make(
@@ -579,6 +679,25 @@ class Http2ClientTransport final : public ClientTransport {
579
679
  // transport and greatly simpilfy the cleanup path.
580
680
  Http2ClientTransport* transport_;
581
681
  };
682
+
683
+ WritableStreams writable_stream_list_;
684
+
685
+ auto MaybeAddStreamToWritableStreamList(const uint32_t stream_id,
686
+ const bool became_writable) {
687
+ if (became_writable) {
688
+ GRPC_HTTP2_CLIENT_DLOG
689
+ << "Http2ClientTransport MaybeAddStreamToWritableStreamList "
690
+ " Stream id: "
691
+ << stream_id << " became writable";
692
+ absl::Status status = writable_stream_list_.Enqueue(
693
+ stream_id, WritableStreams::StreamPriority::kDefault);
694
+ if (!status.ok()) {
695
+ return HandleError(Http2Status::Http2ConnectionError(
696
+ Http2ErrorCode::kProtocolError, "Failed to enqueue stream"));
697
+ }
698
+ }
699
+ return absl::OkStatus();
700
+ }
582
701
  };
583
702
 
584
703
  // Since the corresponding class in CHTTP2 is about 3.9KB, our goal is to
@@ -23,7 +23,6 @@
23
23
  #include <grpc/support/port_platform.h>
24
24
 
25
25
  #include "absl/strings/str_cat.h"
26
- #include "src/core/ext/transport/chttp2/transport/frame.h"
27
26
  #include "src/core/ext/transport/chttp2/transport/http2_status.h"
28
27
  #include "src/core/util/useful.h"
29
28
 
@@ -32,35 +31,36 @@ using grpc_core::http2::Http2ErrorCode;
32
31
  namespace grpc_core {
33
32
 
34
33
  void Http2Settings::Diff(
35
- bool is_first_send, const Http2Settings& old,
34
+ bool is_first_send, const Http2Settings& old_setting,
36
35
  absl::FunctionRef<void(uint16_t key, uint32_t value)> cb) const {
37
- if (header_table_size_ != old.header_table_size_) {
36
+ if (header_table_size_ != old_setting.header_table_size_) {
38
37
  cb(kHeaderTableSizeWireId, header_table_size_);
39
38
  }
40
- if (enable_push_ != old.enable_push_) {
39
+ if (enable_push_ != old_setting.enable_push_) {
41
40
  cb(kEnablePushWireId, enable_push_);
42
41
  }
43
- if (max_concurrent_streams_ != old.max_concurrent_streams_) {
42
+ if (max_concurrent_streams_ != old_setting.max_concurrent_streams_) {
44
43
  cb(kMaxConcurrentStreamsWireId, max_concurrent_streams_);
45
44
  }
46
- if (is_first_send || initial_window_size_ != old.initial_window_size_) {
45
+ if (is_first_send ||
46
+ initial_window_size_ != old_setting.initial_window_size_) {
47
47
  cb(kInitialWindowSizeWireId, initial_window_size_);
48
48
  }
49
- if (max_frame_size_ != old.max_frame_size_) {
49
+ if (max_frame_size_ != old_setting.max_frame_size_) {
50
50
  cb(kMaxFrameSizeWireId, max_frame_size_);
51
51
  }
52
- if (max_header_list_size_ != old.max_header_list_size_) {
52
+ if (max_header_list_size_ != old_setting.max_header_list_size_) {
53
53
  cb(kMaxHeaderListSizeWireId, max_header_list_size_);
54
54
  }
55
- if (allow_true_binary_metadata_ != old.allow_true_binary_metadata_) {
55
+ if (allow_true_binary_metadata_ != old_setting.allow_true_binary_metadata_) {
56
56
  cb(kGrpcAllowTrueBinaryMetadataWireId, allow_true_binary_metadata_);
57
57
  }
58
58
  if (preferred_receive_crypto_message_size_ !=
59
- old.preferred_receive_crypto_message_size_) {
59
+ old_setting.preferred_receive_crypto_message_size_) {
60
60
  cb(kGrpcPreferredReceiveCryptoFrameSizeWireId,
61
61
  preferred_receive_crypto_message_size_);
62
62
  }
63
- if (allow_security_frame_ != old.allow_security_frame_) {
63
+ if (allow_security_frame_ != old_setting.allow_security_frame_) {
64
64
  cb(kGrpcAllowSecurityFrameWireId, allow_security_frame_);
65
65
  }
66
66
  }
@@ -134,31 +134,4 @@ Http2ErrorCode Http2Settings::Apply(uint16_t key, uint32_t value) {
134
134
  return Http2ErrorCode::kNoError;
135
135
  }
136
136
 
137
- std::optional<Http2SettingsFrame> Http2SettingsManager::MaybeSendUpdate() {
138
- switch (update_state_) {
139
- case UpdateState::kSending:
140
- return std::nullopt;
141
- case UpdateState::kIdle:
142
- if (local_ == sent_) return std::nullopt;
143
- break;
144
- case UpdateState::kFirst:
145
- break;
146
- }
147
- Http2SettingsFrame frame;
148
- local_.Diff(update_state_ == UpdateState::kFirst, sent_,
149
- [&frame](uint16_t key, uint32_t value) {
150
- frame.settings.emplace_back(key, value);
151
- });
152
- sent_ = local_;
153
- update_state_ = UpdateState::kSending;
154
- return frame;
155
- }
156
-
157
- bool Http2SettingsManager::AckLastSend() {
158
- if (update_state_ != UpdateState::kSending) return false;
159
- update_state_ = UpdateState::kIdle;
160
- acked_ = sent_;
161
- return true;
162
- }
163
-
164
137
  } // namespace grpc_core
@@ -26,7 +26,6 @@
26
26
  #include "absl/functional/function_ref.h"
27
27
  #include "absl/strings/string_view.h"
28
28
  #include "src/core/channelz/property_list.h"
29
- #include "src/core/ext/transport/chttp2/transport/frame.h"
30
29
  #include "src/core/ext/transport/chttp2/transport/http2_status.h"
31
30
  #include "src/core/util/useful.h"
32
31
 
@@ -35,18 +34,21 @@ namespace grpc_core {
35
34
  class Http2Settings {
36
35
  public:
37
36
  enum : uint16_t {
37
+ // These values are as defined in RFC9113
38
+ // https://www.rfc-editor.org/rfc/rfc9113.html#name-defined-settings
38
39
  kHeaderTableSizeWireId = 1,
39
40
  kEnablePushWireId = 2,
40
41
  kMaxConcurrentStreamsWireId = 3,
41
42
  kInitialWindowSizeWireId = 4,
42
43
  kMaxFrameSizeWireId = 5,
43
44
  kMaxHeaderListSizeWireId = 6,
45
+ // gRPC specific settings
44
46
  kGrpcAllowTrueBinaryMetadataWireId = 65027,
45
47
  kGrpcPreferredReceiveCryptoFrameSizeWireId = 65028,
46
48
  kGrpcAllowSecurityFrameWireId = 65029,
47
49
  };
48
50
 
49
- void Diff(bool is_first_send, const Http2Settings& old,
51
+ void Diff(bool is_first_send, const Http2Settings& old_setting,
50
52
  absl::FunctionRef<void(uint16_t key, uint32_t value)> cb) const;
51
53
  GRPC_MUST_USE_RESULT http2::Http2ErrorCode Apply(uint16_t key,
52
54
  uint32_t value);
@@ -148,47 +150,62 @@ class Http2Settings {
148
150
  }
149
151
 
150
152
  private:
151
- uint32_t header_table_size_ = 4096;
153
+ // RFC9113 states the default value for SETTINGS_HEADER_TABLE_SIZE
154
+ // Currently this is set only once in the lifetime of a transport.
155
+ // We plan to change that in the future.
156
+ uint32_t header_table_size_ = 4096u;
157
+
158
+ // TODO(tjagtap) [PH2][P4] : Get the history of why this default was decided
159
+ // and write it here.
160
+ // CLIENT : Set only once in the lifetime of a client transport. This is set
161
+ // to 0 for client.
162
+ // SERVER : This setting can change for the server. This is usually changed to
163
+ // handle memory pressure.
152
164
  uint32_t max_concurrent_streams_ = 4294967295u;
165
+
166
+ // RFC9113 states the default for SETTINGS_INITIAL_WINDOW_SIZE
167
+ // Both client and servers can change this setting. This is usually changed to
168
+ // handle memory pressure.
153
169
  uint32_t initial_window_size_ = 65535u;
170
+
171
+ // RFC9113 states the default for SETTINGS_MAX_FRAME_SIZE
172
+ // Both client and servers can change this setting. This is usually changed to
173
+ // handle memory pressure.
154
174
  uint32_t max_frame_size_ = 16384u;
175
+
176
+ // TODO(tjagtap) [PH2][P4] : Get the history of why this default was decided
177
+ // and write it here.
178
+ // This is an advisory but we currently enforce it.
179
+ // Set only once in the lifetime of a transport currently.
180
+ // When a peer that updates this more than once, that may indicate either an
181
+ // underlying issue or a malicious peer.
155
182
  uint32_t max_header_list_size_ = 16777216u;
156
- uint32_t preferred_receive_crypto_message_size_ = 0u;
157
- bool enable_push_ = true;
158
- bool allow_true_binary_metadata_ = false;
159
- bool allow_security_frame_ = false;
160
- };
161
183
 
162
- class Http2SettingsManager {
163
- public:
164
- Http2Settings& mutable_local() { return local_; }
165
- const Http2Settings& local() const { return local_; }
166
- const Http2Settings& acked() const { return acked_; }
167
- Http2Settings& mutable_peer() { return peer_; }
168
- const Http2Settings& peer() const { return peer_; }
184
+ // gRPC defined setting
185
+ // Both client and servers can change this setting. This is usually changed to
186
+ // handle memory pressure.
187
+ uint32_t preferred_receive_crypto_message_size_ = 0u;
169
188
 
170
- channelz::PropertyGrid ChannelzProperties() const {
171
- return channelz::PropertyGrid()
172
- .SetColumn("local", local_.ChannelzProperties())
173
- .SetColumn("sent", sent_.ChannelzProperties())
174
- .SetColumn("peer", peer_.ChannelzProperties())
175
- .SetColumn("acked", acked_.ChannelzProperties());
176
- }
189
+ // RFC9113 defined default is true. However, for gRPC we always then set it to
190
+ // false via the SetEnablePush function
191
+ // Currently this is set only once in the lifetime of a transport.
192
+ // We have no plans to support this in the future.
193
+ bool enable_push_ = true;
177
194
 
178
- std::optional<Http2SettingsFrame> MaybeSendUpdate();
179
- GRPC_MUST_USE_RESULT bool AckLastSend();
195
+ // gRPC defined setting
196
+ // Unlike most other SETTINGS, this setting is negotiated between the client
197
+ // and the server.
198
+ // Currently this is set only once in the lifetime of a transport.
199
+ // Disconnect if it is received more than once from the peer.
200
+ bool allow_true_binary_metadata_ = false;
180
201
 
181
- private:
182
- enum class UpdateState : uint8_t {
183
- kFirst,
184
- kSending,
185
- kIdle,
186
- };
187
- UpdateState update_state_ = UpdateState::kFirst;
188
- Http2Settings local_;
189
- Http2Settings sent_;
190
- Http2Settings peer_;
191
- Http2Settings acked_;
202
+ // gRPC defined setting
203
+ // Unlike most other SETTINGS, this setting is negotiated between the client
204
+ // and the server. Both have to set it to true for the system to successfully
205
+ // apply the custom SECURITY frame.
206
+ // Currently this is set only once in the lifetime of a transport.
207
+ // Disconnect if it is received more than once from the peer.
208
+ bool allow_security_frame_ = false;
192
209
  };
193
210
 
194
211
  } // namespace grpc_core
@@ -0,0 +1,61 @@
1
+ //
2
+ // Copyright 2017 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
+ //
18
+ // Automatically generated by tools/codegen/core/gen_settings_ids.py
19
+ //
20
+
21
+ #include "src/core/ext/transport/chttp2/transport/http2_settings_manager.h"
22
+
23
+ #include <grpc/support/port_platform.h>
24
+
25
+ #include "absl/strings/str_cat.h"
26
+ #include "src/core/ext/transport/chttp2/transport/frame.h"
27
+ #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
28
+ #include "src/core/ext/transport/chttp2/transport/http2_status.h"
29
+ #include "src/core/util/useful.h"
30
+
31
+ namespace grpc_core {
32
+
33
+ std::optional<Http2SettingsFrame> Http2SettingsManager::MaybeSendUpdate() {
34
+ switch (update_state_) {
35
+ case UpdateState::kSending:
36
+ return std::nullopt;
37
+ case UpdateState::kIdle:
38
+ if (local_ == sent_) return std::nullopt;
39
+ break;
40
+ case UpdateState::kFirst:
41
+ break;
42
+ }
43
+ Http2SettingsFrame frame;
44
+ local_.Diff(/*is_first_send=*/update_state_ == UpdateState::kFirst,
45
+ /*old_setting=*/sent_,
46
+ /*cb=*/[&frame](uint16_t key, uint32_t value) {
47
+ frame.settings.emplace_back(key, value);
48
+ });
49
+ sent_ = local_;
50
+ update_state_ = UpdateState::kSending;
51
+ return frame;
52
+ }
53
+
54
+ bool Http2SettingsManager::AckLastSend() {
55
+ if (update_state_ != UpdateState::kSending) return false;
56
+ update_state_ = UpdateState::kIdle;
57
+ acked_ = sent_;
58
+ return true;
59
+ }
60
+
61
+ } // namespace grpc_core
@@ -0,0 +1,142 @@
1
+ //
2
+ // Copyright 2017 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_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_MANAGER_H
18
+ #define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_MANAGER_H
19
+
20
+ #include <grpc/support/port_platform.h>
21
+ #include <stdint.h>
22
+
23
+ #include <cstdint>
24
+ #include <optional>
25
+
26
+ #include "absl/functional/function_ref.h"
27
+ #include "absl/strings/string_view.h"
28
+ #include "src/core/channelz/property_list.h"
29
+ #include "src/core/ext/transport/chttp2/transport/frame.h"
30
+ #include "src/core/ext/transport/chttp2/transport/http2_settings.h"
31
+ #include "src/core/ext/transport/chttp2/transport/http2_status.h"
32
+ #include "src/core/util/useful.h"
33
+
34
+ namespace grpc_core {
35
+
36
+ class Http2SettingsManager {
37
+ public:
38
+ // Only local and peer settings can be edited by the transport.
39
+ Http2Settings& mutable_local() { return local_; }
40
+ Http2Settings& mutable_peer() { return peer_; }
41
+
42
+ const Http2Settings& local() const { return local_; }
43
+ // Before the first SETTINGS ACK frame is received acked_ will hold the
44
+ // default values.
45
+ const Http2Settings& acked() const { return acked_; }
46
+ const Http2Settings& peer() const { return peer_; }
47
+
48
+ channelz::PropertyGrid ChannelzProperties() const {
49
+ return channelz::PropertyGrid()
50
+ .SetColumn("local", local_.ChannelzProperties())
51
+ .SetColumn("sent", sent_.ChannelzProperties())
52
+ .SetColumn("peer", peer_.ChannelzProperties())
53
+ .SetColumn("acked", acked_.ChannelzProperties());
54
+ }
55
+
56
+ // Returns nullopt if we don't need to send a SETTINGS frame to the peer.
57
+ // Returns Http2SettingsFrame if we need to send a SETTINGS frame to the
58
+ // peer. Transport MUST send a frame returned by this function to the peer.
59
+ // This function is not idempotent.
60
+ std::optional<Http2SettingsFrame> MaybeSendUpdate();
61
+
62
+ // To be called from a promise based HTTP2 transport only
63
+ http2::Http2ErrorCode ApplyIncomingSettings(
64
+ std::vector<Http2SettingsFrame::Setting>& settings) {
65
+ for (const auto& setting : settings) {
66
+ http2::Http2ErrorCode error1 =
67
+ count_updates_.IsUpdatePermitted(setting.id, setting.value, peer_);
68
+ if (GPR_UNLIKELY(error1 != http2::Http2ErrorCode::kNoError)) {
69
+ return error1;
70
+ }
71
+ http2::Http2ErrorCode error = peer_.Apply(setting.id, setting.value);
72
+ if (GPR_UNLIKELY(error != http2::Http2ErrorCode::kNoError)) {
73
+ return error;
74
+ }
75
+ }
76
+ return http2::Http2ErrorCode::kNoError;
77
+ }
78
+
79
+ // Call when we receive an ACK from our peer.
80
+ // This function is not idempotent.
81
+ GRPC_MUST_USE_RESULT bool AckLastSend();
82
+
83
+ private:
84
+ struct CountUpdates {
85
+ http2::Http2ErrorCode IsUpdatePermitted(const uint16_t setting_id,
86
+ const uint32_t value,
87
+ const Http2Settings& peer) {
88
+ switch (setting_id) {
89
+ case Http2Settings::kGrpcAllowTrueBinaryMetadataWireId:
90
+ // These settings must not change more than once. This is a gRPC
91
+ // defined settings.
92
+ if (allow_true_binary_metadata_update &&
93
+ peer.allow_true_binary_metadata() != static_cast<bool>(value)) {
94
+ return http2::Http2ErrorCode::kConnectError;
95
+ }
96
+ allow_true_binary_metadata_update = true;
97
+ break;
98
+ case Http2Settings::kGrpcAllowSecurityFrameWireId:
99
+ // These settings must not change more than once. This is a gRPC
100
+ // defined settings.
101
+ if (allow_security_frame_update &&
102
+ peer.allow_security_frame() != static_cast<bool>(value)) {
103
+ return http2::Http2ErrorCode::kConnectError;
104
+ }
105
+ allow_security_frame_update = true;
106
+ break;
107
+ default:
108
+ break;
109
+ }
110
+ return http2::Http2ErrorCode::kNoError;
111
+ }
112
+ bool allow_true_binary_metadata_update = false;
113
+ bool allow_security_frame_update = false;
114
+ };
115
+ CountUpdates count_updates_;
116
+
117
+ enum class UpdateState : uint8_t {
118
+ kFirst,
119
+ kSending,
120
+ kIdle,
121
+ };
122
+ UpdateState update_state_ = UpdateState::kFirst;
123
+
124
+ // This holds a copy of the peers settings.
125
+ Http2Settings peer_;
126
+
127
+ // These are different sets of our settings.
128
+ // local_ : Setting that has been changed inside our transport,
129
+ // but not yet sent to the peer.
130
+ // sent_ : New settings frame is sent to the peer but we have not yet
131
+ // received the ACK from the peer.
132
+ // acked_ : The settings that have already been ACKed by the peer. These
133
+ // settings can be enforced and any violation of these settings by a
134
+ // peer may cause an error.
135
+ Http2Settings local_;
136
+ Http2Settings sent_;
137
+ Http2Settings acked_;
138
+ };
139
+
140
+ } // namespace grpc_core
141
+
142
+ #endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HTTP2_SETTINGS_MANAGER_H