From 3717ff04bafd18504d8613d753d4605927305de3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Jul 2023 09:19:35 -0700 Subject: [PATCH] [chttp2] Split ping policy from transport (#33703) Why: Cleanup for chttp2_transport ahead of promise conversion - lots of logic has become interleaved throughout chttp2, so some effort to isolate logic out is warranted ahead of that conversion. What: Split configuration and policy tracking for each of ping rate throttling and abuse detection into their own modules. Add tests for them. Incidentally: Split channel args into their own header so that we can split the policy stuff into separate build targets. --------- Co-authored-by: ctiller --- BUILD | 27 +- CMakeLists.txt | 107 +++++ Makefile | 6 + Package.swift | 5 + build_autogenerated.yaml | 81 ++++ config.m4 | 2 + config.w32 | 2 + gRPC-C++.podspec | 4 + gRPC-Core.podspec | 7 + grpc.gemspec | 5 + grpc.gyp | 4 + include/grpc/impl/channel_arg_names.h | 371 ++++++++++++++++++ include/grpc/impl/grpc_types.h | 354 +---------------- include/grpc/module.modulemap | 1 + package.xml | 5 + src/core/BUILD | 70 ++++ .../backend_metrics/backend_metric_filter.cc | 2 +- .../channel_idle/channel_idle_filter.cc | 2 +- .../filters/client_channel/client_channel.cc | 1 + .../ext/filters/client_channel/http_proxy.cc | 2 +- .../client_channel/lb_policy/grpclb/grpclb.cc | 1 + .../lb_policy/health_check_client.cc | 2 +- .../lb_policy/pick_first/pick_first.cc | 2 +- .../lb_policy/priority/priority.cc | 2 +- .../lb_policy/ring_hash/ring_hash.cc | 3 +- .../client_channel/lb_policy/rls/rls.cc | 1 + .../lb_policy/subchannel_list.h | 2 +- .../lb_policy/xds/xds_cluster_resolver.cc | 2 +- .../resolver/dns/c_ares/dns_resolver_ares.cc | 2 +- .../resolver/dns/c_ares/grpc_ares_wrapper.cc | 2 +- .../event_engine_client_channel_resolver.cc | 2 +- .../resolver/dns/native/dns_resolver.cc | 2 +- .../resolver/xds/xds_resolver.cc | 2 +- .../ext/filters/client_channel/retry_filter.h | 1 + .../client_channel/retry_service_config.cc | 2 +- .../service_config_channel_arg_filter.cc | 2 +- .../ext/filters/client_channel/subchannel.cc | 2 +- .../ext/filters/deadline/deadline_filter.cc | 2 +- .../filters/http/client/http_client_filter.cc | 1 + .../filters/http/client_authority_filter.cc | 2 +- .../message_compress/compression_filter.cc | 1 + .../filters/http/server/http_server_filter.cc | 2 +- .../server_load_reporting_filter.cc | 2 +- .../ext/filters/logging/logging_filter.cc | 2 +- .../message_size/message_size_filter.cc | 1 + .../chttp2/client/chttp2_connector.cc | 1 + .../transport/chttp2/server/chttp2_server.cc | 1 + .../chttp2/transport/chttp2_transport.cc | 86 ++-- .../transport/chttp2/transport/frame_ping.cc | 23 +- .../ext/transport/chttp2/transport/internal.h | 28 +- .../ext/transport/chttp2/transport/parsing.cc | 6 +- .../chttp2/transport/ping_abuse_policy.cc | 80 ++++ .../chttp2/transport/ping_abuse_policy.h | 55 +++ .../chttp2/transport/ping_rate_policy.cc | 98 +++++ .../chttp2/transport/ping_rate_policy.h | 73 ++++ .../ext/transport/chttp2/transport/writing.cc | 171 ++++---- .../client/secure/cronet_channel_create.cc | 1 + .../cronet/transport/cronet_transport.cc | 1 + .../ext/transport/inproc/inproc_transport.cc | 1 + src/core/ext/xds/xds_client_grpc.cc | 1 + src/core/ext/xds/xds_transport_grpc.cc | 1 + src/core/lib/channel/channel_args.cc | 1 + .../posix_engine/tcp_socket_utils.cc | 1 + .../lib/http/httpcli_security_connector.cc | 1 + src/core/lib/resource_quota/api.cc | 1 + src/core/lib/resource_quota/resource_quota.h | 1 + .../authorization_policy_provider.h | 2 +- .../google_default_credentials.cc | 1 + .../credentials/ssl/ssl_credentials.cc | 1 + .../credentials/tls/tls_credentials.cc | 1 + .../credentials/xds/xds_credentials.cc | 1 + .../alts/alts_security_connector.cc | 1 + .../fake/fake_security_connector.cc | 1 + .../security/security_connector/ssl_utils.cc | 1 + .../security/transport/security_handshaker.cc | 1 + src/core/lib/surface/channel.cc | 1 + src/core/lib/surface/init.cc | 1 + src/core/lib/surface/server.cc | 1 + src/cpp/common/channel_arguments.cc | 1 + src/cpp/common/secure_channel_arguments.cc | 1 + src/cpp/ext/gcp/BUILD | 1 + src/cpp/ext/gcp/observability_logging_sink.cc | 1 + ...reporting_service_server_builder_option.cc | 2 +- src/cpp/server/server_builder.cc | 1 + src/cpp/server/server_cc.cc | 1 + src/python/grpcio/grpc_core_dependencies.py | 2 + test/core/bad_connection/close_fd_test.cc | 1 + test/core/bad_ssl/bad_ssl_test.cc | 1 + test/core/channel/channel_args_test.cc | 1 + test/core/channel/channel_trace_test.cc | 1 + test/core/channel/channelz_test.cc | 1 + .../channel/minimal_stack_is_minimal_test.cc | 1 + .../client_channel/client_channel_test.cc | 2 +- .../client_channel/http_proxy_mapper_test.cc | 2 +- .../lb_policy/outlier_detection_test.cc | 1 + .../lb_policy/pick_first_test.cc | 1 + .../resolvers/dns_resolver_cooldown_test.cc | 1 + .../retry_service_config_test.cc | 1 + test/core/end2end/BUILD | 8 + test/core/end2end/connection_refused_test.cc | 1 + test/core/end2end/end2end_test_suites.cc | 1 + test/core/end2end/fixtures/h2_oauth2_common.h | 1 + .../fixtures/h2_ssl_cred_reload_fixture.h | 1 + .../core/end2end/fixtures/h2_ssl_tls_common.h | 1 + test/core/end2end/fixtures/h2_tls_common.h | 1 + test/core/end2end/fixtures/proxy.cc | 1 + test/core/end2end/fixtures/sockpair_fixture.h | 1 + test/core/end2end/fuzzers/client_fuzzer.cc | 1 + test/core/end2end/goaway_server_test.cc | 1 + test/core/end2end/h2_ssl_cert_test.cc | 1 + .../core/end2end/h2_ssl_session_reuse_test.cc | 1 + ...ls_peer_property_external_verifier_test.cc | 1 + test/core/end2end/tests/bad_ping.cc | 2 +- test/core/end2end/tests/binary_metadata.cc | 2 +- test/core/end2end/tests/call_host_override.cc | 2 +- .../core/end2end/tests/cancel_after_accept.cc | 2 +- .../end2end/tests/cancel_after_round_trip.cc | 2 +- test/core/end2end/tests/channelz.cc | 2 +- test/core/end2end/tests/compressed_payload.cc | 1 + test/core/end2end/tests/connectivity.cc | 1 + test/core/end2end/tests/grpc_authz.cc | 1 + test/core/end2end/tests/high_initial_seqno.cc | 2 +- test/core/end2end/tests/hpack_size.cc | 2 +- .../end2end/tests/invoke_large_request.cc | 2 +- test/core/end2end/tests/keepalive_timeout.cc | 2 +- test/core/end2end/tests/large_metadata.cc | 2 +- .../end2end/tests/max_concurrent_streams.cc | 2 +- test/core/end2end/tests/max_connection_age.cc | 2 +- .../core/end2end/tests/max_connection_idle.cc | 1 + test/core/end2end/tests/max_message_length.cc | 2 +- test/core/end2end/tests/ping.cc | 1 + .../end2end/tests/resource_quota_server.cc | 1 + test/core/end2end/tests/retry.cc | 2 +- ...retry_cancel_after_first_attempt_starts.cc | 2 +- .../tests/retry_cancel_during_delay.cc | 2 +- ...retry_cancel_with_multiple_send_batches.cc | 2 +- test/core/end2end/tests/retry_cancellation.cc | 2 +- test/core/end2end/tests/retry_disabled.cc | 2 +- .../retry_exceeds_buffer_size_in_delay.cc | 2 +- ...ry_exceeds_buffer_size_in_initial_batch.cc | 2 +- ...exceeds_buffer_size_in_subsequent_batch.cc | 2 +- test/core/end2end/tests/retry_lb_drop.cc | 1 + test/core/end2end/tests/retry_lb_fail.cc | 2 +- .../tests/retry_non_retriable_status.cc | 2 +- ...ry_non_retriable_status_before_trailers.cc | 2 +- .../tests/retry_per_attempt_recv_timeout.cc | 2 +- ...er_attempt_recv_timeout_on_last_attempt.cc | 2 +- .../tests/retry_recv_initial_metadata.cc | 2 +- test/core/end2end/tests/retry_recv_message.cc | 2 +- .../tests/retry_recv_message_replay.cc | 2 +- .../retry_recv_trailing_metadata_error.cc | 2 +- .../tests/retry_send_initial_metadata_refs.cc | 2 +- .../core/end2end/tests/retry_send_op_fails.cc | 2 +- .../end2end/tests/retry_send_recv_batch.cc | 2 +- .../tests/retry_server_pushback_delay.cc | 2 +- .../tests/retry_server_pushback_disabled.cc | 2 +- test/core/end2end/tests/retry_streaming.cc | 2 +- .../tests/retry_streaming_after_commit.cc | 2 +- ...reaming_succeeds_before_replay_finished.cc | 2 +- test/core/end2end/tests/retry_throttled.cc | 2 +- .../end2end/tests/retry_too_many_attempts.cc | 2 +- .../end2end/tests/retry_transparent_goaway.cc | 2 +- ...etry_transparent_max_concurrent_streams.cc | 1 + .../retry_transparent_not_sent_on_wire.cc | 2 +- .../tests/retry_unref_before_finish.cc | 2 +- .../end2end/tests/retry_unref_before_recv.cc | 2 +- .../end2end/tests/simple_delayed_request.cc | 1 + .../event_engine/posix/posix_endpoint_test.cc | 1 + .../posix/posix_event_engine_connect_test.cc | 1 + .../test_suite/tests/client_test.cc | 2 +- .../test_suite/tests/server_test.cc | 2 +- test/core/handshake/client_ssl.cc | 1 + test/core/http/httpscli_test.cc | 1 + test/core/memory_usage/callback_client.cc | 1 + test/core/memory_usage/client.cc | 1 + test/core/memory_usage/server.cc | 1 + ...num_external_connectivity_watchers_test.cc | 1 + .../surface/sequential_connectivity_test.cc | 1 + test/core/surface/server_chttp2_test.cc | 1 + test/core/surface/server_test.cc | 1 + test/core/transport/chttp2/BUILD | 28 ++ .../chttp2/graceful_shutdown_test.cc | 1 + .../chttp2/ping_abuse_policy_test.cc | 111 ++++++ .../chttp2/ping_configuration_test.cc | 30 +- .../transport/chttp2/ping_rate_policy_test.cc | 77 ++++ .../remove_stream_from_stalled_lists_test.cc | 1 + .../transport/chttp2/settings_timeout_test.cc | 1 + ...ak_with_queued_flow_control_update_test.cc | 1 + .../transport/chttp2/streams_not_seen_test.cc | 1 + .../transport/chttp2/too_many_pings_test.cc | 1 + tools/doxygen/Doxyfile.c++ | 1 + tools/doxygen/Doxyfile.c++.internal | 5 + tools/doxygen/Doxyfile.core | 1 + tools/doxygen/Doxyfile.core.internal | 5 + tools/run_tests/generated/tests.json | 48 +++ 195 files changed, 1593 insertions(+), 628 deletions(-) create mode 100644 include/grpc/impl/channel_arg_names.h create mode 100644 src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc create mode 100644 src/core/ext/transport/chttp2/transport/ping_abuse_policy.h create mode 100644 src/core/ext/transport/chttp2/transport/ping_rate_policy.cc create mode 100644 src/core/ext/transport/chttp2/transport/ping_rate_policy.h create mode 100644 test/core/transport/chttp2/ping_abuse_policy_test.cc create mode 100644 test/core/transport/chttp2/ping_rate_policy_test.cc diff --git a/BUILD b/BUILD index 68362ea3412..1b81c905824 100644 --- a/BUILD +++ b/BUILD @@ -552,6 +552,7 @@ grpc_cc_library( ], visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -624,6 +625,7 @@ grpc_cc_library( "@grpc:public", ], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -837,7 +839,10 @@ grpc_cc_library( "avoid_dep", "nofixdeps", ], - deps = ["gpr_public_hdrs"], + deps = [ + "channel_arg_names", + "gpr_public_hdrs", + ], ) grpc_cc_library( @@ -860,6 +865,11 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "channel_arg_names", + hdrs = ["include/grpc/impl/channel_arg_names.h"], +) + grpc_cc_library( name = "grpc++", hdrs = [ @@ -1258,6 +1268,7 @@ grpc_cc_library( "nofixdeps", ], deps = [ + "channel_arg_names", "gpr", ], ) @@ -1496,6 +1507,7 @@ grpc_cc_library( public_hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, visibility = ["@grpc:alt_grpc_base_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "config_vars", @@ -1659,6 +1671,7 @@ grpc_cc_library( ], tags = ["nofixdeps"], deps = [ + "channel_arg_names", "gpr", "gpr_platform", "grpc", @@ -1772,6 +1785,7 @@ grpc_cc_library( public_hdrs = GRPC_PUBLIC_HDRS, visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "config", "debug_location", "exec_ctx", @@ -1922,6 +1936,7 @@ grpc_cc_library( tags = ["nofixdeps"], visibility = ["@grpc:alt_grpc++_base_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -1997,6 +2012,7 @@ grpc_cc_library( ], visibility = ["@grpc:alt_grpc++_base_unsecure_legacy"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "exec_ctx", @@ -3008,6 +3024,7 @@ grpc_cc_library( visibility = ["@grpc:client_channel"], deps = [ "backoff", + "channel_arg_names", "channel_stack_builder", "config", "config_vars", @@ -3110,6 +3127,7 @@ grpc_cc_library( language = "c++", deps = [ "backoff", + "channel_arg_names", "config", "config_vars", "debug_location", @@ -3217,6 +3235,7 @@ grpc_cc_library( visibility = ["@grpc:public"], deps = [ "alts_util", + "channel_arg_names", "debug_location", "exec_ctx", "gpr", @@ -3479,6 +3498,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:public"], deps = [ + "channel_arg_names", "config_vars", "gpr", "grpc_base", @@ -3523,6 +3543,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:http"], deps = [ + "channel_arg_names", "channel_stack_builder", "config", "gpr", @@ -3912,6 +3933,7 @@ grpc_cc_library( language = "c++", visibility = ["@grpc:grpclb"], deps = [ + "channel_arg_names", "chttp2_context_list_entry", "chttp2_frame", "chttp2_varint", @@ -3943,7 +3965,10 @@ grpc_cc_library( "//src/core:init_internally", "//src/core:iomgr_fwd", "//src/core:iomgr_port", + "//src/core:match", "//src/core:memory_quota", + "//src/core:ping_abuse_policy", + "//src/core:ping_rate_policy", "//src/core:poll", "//src/core:ref_counted", "//src/core:resource_quota", diff --git a/CMakeLists.txt b/CMakeLists.txt index bb3a3756bdb..923aa95102f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1136,8 +1136,10 @@ if(gRPC_BUILD_TESTS) add_dependencies(buildtests_cxx periodic_update_test) add_dependencies(buildtests_cxx pick_first_test) add_dependencies(buildtests_cxx pid_controller_test) + add_dependencies(buildtests_cxx ping_abuse_policy_test) add_dependencies(buildtests_cxx ping_configuration_test) add_dependencies(buildtests_cxx ping_pong_streaming_test) + add_dependencies(buildtests_cxx ping_rate_policy_test) add_dependencies(buildtests_cxx ping_test) add_dependencies(buildtests_cxx pipe_test) add_dependencies(buildtests_cxx poll_test) @@ -1781,6 +1783,8 @@ add_library(grpc src/core/ext/transport/chttp2/transport/http_trace.cc src/core/ext/transport/chttp2/transport/huffsyms.cc src/core/ext/transport/chttp2/transport/parsing.cc + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc src/core/ext/transport/chttp2/transport/stream_lists.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc @@ -2529,6 +2533,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -2807,6 +2812,8 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/transport/http_trace.cc src/core/ext/transport/chttp2/transport/huffsyms.cc src/core/ext/transport/chttp2/transport/parsing.cc + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc src/core/ext/transport/chttp2/transport/stream_lists.cc src/core/ext/transport/chttp2/transport/varint.cc src/core/ext/transport/chttp2/transport/writing.cc @@ -3175,6 +3182,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -4694,6 +4702,7 @@ foreach(_hdr include/grpc/grpc_posix.h include/grpc/grpc_security.h include/grpc/grpc_security_constants.h + include/grpc/impl/channel_arg_names.h include/grpc/impl/codegen/atm.h include/grpc/impl/codegen/atm_gcc_atomic.h include/grpc/impl/codegen/atm_gcc_sync.h @@ -18224,6 +18233,55 @@ target_link_libraries(pid_controller_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(ping_abuse_policy_test + test/core/transport/chttp2/ping_abuse_policy_test.cc + test/core/util/cmdline.cc + test/core/util/fuzzer_util.cc + test/core/util/grpc_profiler.cc + test/core/util/histogram.cc + test/core/util/mock_endpoint.cc + test/core/util/parse_hexstring.cc + test/core/util/passthru_endpoint.cc + test/core/util/resolve_localhost_ip46.cc + test/core/util/slice_splitter.cc + test/core/util/subprocess_posix.cc + test/core/util/subprocess_windows.cc + test/core/util/tracer_util.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(ping_abuse_policy_test PUBLIC cxx_std_14) +target_include_directories(ping_abuse_policy_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(ping_abuse_policy_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) @@ -18321,6 +18379,55 @@ target_link_libraries(ping_pong_streaming_test ) +endif() +if(gRPC_BUILD_TESTS) + +add_executable(ping_rate_policy_test + test/core/transport/chttp2/ping_rate_policy_test.cc + test/core/util/cmdline.cc + test/core/util/fuzzer_util.cc + test/core/util/grpc_profiler.cc + test/core/util/histogram.cc + test/core/util/mock_endpoint.cc + test/core/util/parse_hexstring.cc + test/core/util/passthru_endpoint.cc + test/core/util/resolve_localhost_ip46.cc + test/core/util/slice_splitter.cc + test/core/util/subprocess_posix.cc + test/core/util/subprocess_windows.cc + test/core/util/tracer_util.cc + third_party/googletest/googletest/src/gtest-all.cc + third_party/googletest/googlemock/src/gmock-all.cc +) +target_compile_features(ping_rate_policy_test PUBLIC cxx_std_14) +target_include_directories(ping_rate_policy_test + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${_gRPC_ADDRESS_SORTING_INCLUDE_DIR} + ${_gRPC_RE2_INCLUDE_DIR} + ${_gRPC_SSL_INCLUDE_DIR} + ${_gRPC_UPB_GENERATED_DIR} + ${_gRPC_UPB_GRPC_GENERATED_DIR} + ${_gRPC_UPB_INCLUDE_DIR} + ${_gRPC_XXHASH_INCLUDE_DIR} + ${_gRPC_ZLIB_INCLUDE_DIR} + third_party/googletest/googletest/include + third_party/googletest/googletest + third_party/googletest/googlemock/include + third_party/googletest/googlemock + ${_gRPC_PROTO_GENS_DIR} +) + +target_link_libraries(ping_rate_policy_test + ${_gRPC_BASELIB_LIBRARIES} + ${_gRPC_PROTOBUF_LIBRARIES} + ${_gRPC_ZLIB_LIBRARIES} + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util +) + + endif() if(gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 3937fbc7a2a..f1a04b993b0 100644 --- a/Makefile +++ b/Makefile @@ -1065,6 +1065,8 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ @@ -1752,6 +1754,7 @@ PUBLIC_HEADERS_C += \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ + include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -1944,6 +1947,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ @@ -2252,6 +2257,7 @@ PUBLIC_HEADERS_C += \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ + include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ diff --git a/Package.swift b/Package.swift index a3d31ce6d56..62ca96e64a4 100644 --- a/Package.swift +++ b/Package.swift @@ -60,6 +60,7 @@ let package = Package( "include/grpc/grpc_posix.h", "include/grpc/grpc_security.h", "include/grpc/grpc_security_constants.h", + "include/grpc/impl/channel_arg_names.h", "include/grpc/impl/codegen/atm.h", "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", @@ -309,6 +310,10 @@ let package = Package( "src/core/ext/transport/chttp2/transport/huffsyms.h", "src/core/ext/transport/chttp2/transport/internal.h", "src/core/ext/transport/chttp2/transport/parsing.cc", + "src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc", + "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h", + "src/core/ext/transport/chttp2/transport/ping_rate_policy.cc", + "src/core/ext/transport/chttp2/transport/ping_rate_policy.h", "src/core/ext/transport/chttp2/transport/stream_lists.cc", "src/core/ext/transport/chttp2/transport/varint.cc", "src/core/ext/transport/chttp2/transport/varint.h", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 3b03656e521..d7a2af54dd2 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -161,6 +161,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -307,6 +308,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.h - src/core/ext/transport/chttp2/transport/huffsyms.h - src/core/ext/transport/chttp2/transport/internal.h + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.h + - src/core/ext/transport/chttp2/transport/ping_rate_policy.h - src/core/ext/transport/chttp2/transport/varint.h - src/core/ext/transport/inproc/inproc_transport.h - src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h @@ -1125,6 +1128,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.cc - src/core/ext/transport/chttp2/transport/huffsyms.cc - src/core/ext/transport/chttp2/transport/parsing.cc + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + - src/core/ext/transport/chttp2/transport/ping_rate_policy.cc - src/core/ext/transport/chttp2/transport/stream_lists.cc - src/core/ext/transport/chttp2/transport/varint.cc - src/core/ext/transport/chttp2/transport/writing.cc @@ -1891,6 +1896,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -2025,6 +2031,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.h - src/core/ext/transport/chttp2/transport/huffsyms.h - src/core/ext/transport/chttp2/transport/internal.h + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.h + - src/core/ext/transport/chttp2/transport/ping_rate_policy.h - src/core/ext/transport/chttp2/transport/varint.h - src/core/ext/transport/inproc/inproc_transport.h - src/core/ext/upb-generated/google/api/annotations.upb.h @@ -2446,6 +2454,8 @@ libs: - src/core/ext/transport/chttp2/transport/http_trace.cc - src/core/ext/transport/chttp2/transport/huffsyms.cc - src/core/ext/transport/chttp2/transport/parsing.cc + - src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc + - src/core/ext/transport/chttp2/transport/ping_rate_policy.cc - src/core/ext/transport/chttp2/transport/stream_lists.cc - src/core/ext/transport/chttp2/transport/varint.cc - src/core/ext/transport/chttp2/transport/writing.cc @@ -3497,6 +3507,7 @@ libs: - include/grpc/grpc_posix.h - include/grpc/grpc_security.h - include/grpc/grpc_security_constants.h + - include/grpc/impl/channel_arg_names.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h @@ -11258,6 +11269,41 @@ targets: - test/core/util/tracer_util.cc deps: - grpc_test_util +- name: ping_abuse_policy_test + gtest: true + build: test + language: c++ + headers: + - test/core/util/cmdline.h + - test/core/util/evaluate_args_test_util.h + - test/core/util/fuzzer_util.h + - test/core/util/grpc_profiler.h + - test/core/util/histogram.h + - test/core/util/mock_authorization_endpoint.h + - test/core/util/mock_endpoint.h + - test/core/util/parse_hexstring.h + - test/core/util/passthru_endpoint.h + - test/core/util/resolve_localhost_ip46.h + - test/core/util/slice_splitter.h + - test/core/util/subprocess.h + - test/core/util/tracer_util.h + src: + - test/core/transport/chttp2/ping_abuse_policy_test.cc + - test/core/util/cmdline.cc + - test/core/util/fuzzer_util.cc + - test/core/util/grpc_profiler.cc + - test/core/util/histogram.cc + - test/core/util/mock_endpoint.cc + - test/core/util/parse_hexstring.cc + - test/core/util/passthru_endpoint.cc + - test/core/util/resolve_localhost_ip46.cc + - test/core/util/slice_splitter.cc + - test/core/util/subprocess_posix.cc + - test/core/util/subprocess_windows.cc + - test/core/util/tracer_util.cc + deps: + - grpc_test_util + uses_polling: false - name: ping_configuration_test gtest: true build: test @@ -11328,6 +11374,41 @@ targets: - grpc_authorization_provider - grpc_unsecure - grpc_test_util +- name: ping_rate_policy_test + gtest: true + build: test + language: c++ + headers: + - test/core/util/cmdline.h + - test/core/util/evaluate_args_test_util.h + - test/core/util/fuzzer_util.h + - test/core/util/grpc_profiler.h + - test/core/util/histogram.h + - test/core/util/mock_authorization_endpoint.h + - test/core/util/mock_endpoint.h + - test/core/util/parse_hexstring.h + - test/core/util/passthru_endpoint.h + - test/core/util/resolve_localhost_ip46.h + - test/core/util/slice_splitter.h + - test/core/util/subprocess.h + - test/core/util/tracer_util.h + src: + - test/core/transport/chttp2/ping_rate_policy_test.cc + - test/core/util/cmdline.cc + - test/core/util/fuzzer_util.cc + - test/core/util/grpc_profiler.cc + - test/core/util/histogram.cc + - test/core/util/mock_endpoint.cc + - test/core/util/parse_hexstring.cc + - test/core/util/passthru_endpoint.cc + - test/core/util/resolve_localhost_ip46.cc + - test/core/util/slice_splitter.cc + - test/core/util/subprocess_posix.cc + - test/core/util/subprocess_windows.cc + - test/core/util/tracer_util.cc + deps: + - grpc_test_util + uses_polling: false - name: ping_test gtest: true build: test diff --git a/config.m4 b/config.m4 index 46102ab6576..7963168b683 100644 --- a/config.m4 +++ b/config.m4 @@ -144,6 +144,8 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/transport/http_trace.cc \ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/parsing.cc \ + src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ + src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/writing.cc \ diff --git a/config.w32 b/config.w32 index da44d20aedd..e8412bdeb19 100644 --- a/config.w32 +++ b/config.w32 @@ -109,6 +109,8 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\transport\\chttp2\\transport\\http_trace.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\huffsyms.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\parsing.cc " + + "src\\core\\ext\\transport\\chttp2\\transport\\ping_abuse_policy.cc " + + "src\\core\\ext\\transport\\chttp2\\transport\\ping_rate_policy.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\stream_lists.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\varint.cc " + "src\\core\\ext\\transport\\chttp2\\transport\\writing.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 80d676e5735..a32da715385 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -377,6 +377,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', @@ -1426,6 +1428,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 11debea0f5f..a2b15673bf4 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -126,6 +126,7 @@ Pod::Spec.new do |s| 'include/grpc/grpc_posix.h', 'include/grpc/grpc_security.h', 'include/grpc/grpc_security_constants.h', + 'include/grpc/impl/channel_arg_names.h', 'include/grpc/impl/codegen/atm.h', 'include/grpc/impl/codegen/atm_gcc_atomic.h', 'include/grpc/impl/codegen/atm_gcc_sync.h', @@ -410,6 +411,10 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/varint.h', @@ -2158,6 +2163,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/http_trace.h', 'src/core/ext/transport/chttp2/transport/huffsyms.h', 'src/core/ext/transport/chttp2/transport/internal.h', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.h', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/inproc/inproc_transport.h', 'src/core/ext/upb-generated/envoy/admin/v3/certs.upb.h', diff --git a/grpc.gemspec b/grpc.gemspec index 4e8db380142..67a4bfcf084 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -66,6 +66,7 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/grpc_posix.h ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/grpc_security_constants.h ) + s.files += %w( include/grpc/impl/channel_arg_names.h ) s.files += %w( include/grpc/impl/codegen/atm.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h ) @@ -315,6 +316,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/huffsyms.h ) s.files += %w( src/core/ext/transport/chttp2/transport/internal.h ) s.files += %w( src/core/ext/transport/chttp2/transport/parsing.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_abuse_policy.h ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_rate_policy.cc ) + s.files += %w( src/core/ext/transport/chttp2/transport/ping_rate_policy.h ) s.files += %w( src/core/ext/transport/chttp2/transport/stream_lists.cc ) s.files += %w( src/core/ext/transport/chttp2/transport/varint.cc ) s.files += %w( src/core/ext/transport/chttp2/transport/varint.h ) diff --git a/grpc.gyp b/grpc.gyp index d82377051ff..9a53deff7e9 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -369,6 +369,8 @@ 'src/core/ext/transport/chttp2/transport/http_trace.cc', 'src/core/ext/transport/chttp2/transport/huffsyms.cc', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/writing.cc', @@ -1188,6 +1190,8 @@ 'src/core/ext/transport/chttp2/transport/http_trace.cc', 'src/core/ext/transport/chttp2/transport/huffsyms.cc', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/writing.cc', diff --git a/include/grpc/impl/channel_arg_names.h b/include/grpc/impl/channel_arg_names.h new file mode 100644 index 00000000000..cf1f616c176 --- /dev/null +++ b/include/grpc/impl/channel_arg_names.h @@ -0,0 +1,371 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GRPC_IMPL_CHANNEL_ARG_NAMES_H +#define GRPC_IMPL_CHANNEL_ARG_NAMES_H + +/** \defgroup grpc_arg_keys + * Channel argument keys. + * \{ + */ +/** If non-zero, enable census for tracing and stats collection. */ +#define GRPC_ARG_ENABLE_CENSUS "grpc.census" +/** If non-zero, enable load reporting. */ +#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting" +/** If non-zero, call metric recording is enabled. */ +#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \ + "grpc.server_call_metric_recording" +/** Request that optional features default to off (regardless of what they + usually default to) - to enable tight control over what gets enabled */ +#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack" +/** Maximum number of concurrent incoming streams to allow on a http2 + connection. Int valued. */ +#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams" +/** Maximum message length that the channel can receive. Int valued, bytes. + -1 means unlimited. */ +#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length" +/** \deprecated For backward compatibility. + * Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */ +#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH +/** Maximum message length that the channel can send. Int valued, bytes. + -1 means unlimited. */ +#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" +/** Maximum time that a channel may have no outstanding rpcs, after which the + * server will close the connection. Int valued, milliseconds. INT_MAX means + * unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" +/** Maximum time that a channel may exist. Int valued, milliseconds. + * INT_MAX means unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms" +/** Grace period after the channel reaches its max age. Int valued, + milliseconds. INT_MAX means unlimited. */ +#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" +/** Timeout after the last RPC finishes on the client channel at which the + * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means + * unlimited. The default value is 30 minutes and the min value is 1 second. */ +#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" +/** Enable/disable support for per-message compression. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ +#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" +/** Experimental Arg. Enable/disable support for per-message decompression. + Defaults to 1. If disabled, decompression will not be performed and the + application will see the compressed message in the byte buffer. */ +#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \ + "grpc.per_message_decompression" +/** Enable/disable support for deadline checking. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */ +#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking" +/** Initial stream ID for http2 transports. Int valued. */ +#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ + "grpc.http2.initial_sequence_number" +/** Amount to read ahead on individual streams. Defaults to 64kb, larger + values can help throughput on high-latency connections. + NOTE: at some point we'd like to auto-tune this, and this parameter + will become a no-op. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes" +/** How much memory to use for hpack decoding. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \ + "grpc.http2.hpack_table_size.decoder" +/** How much memory to use for hpack encoding. Int valued, bytes. */ +#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ + "grpc.http2.hpack_table_size.encoder" +/** How big a frame are we willing to receive via HTTP2. + Min 16384, max 16777215. Larger values give lower CPU usage for large + messages, but more head of line blocking for small messages. */ +#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" +/** Should BDP probing be performed? */ +#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe" +/** (DEPRECATED) Does not have any effect. + Earlier, this arg configured the minimum time between successive ping frames + without receiving any data/header frame, Int valued, milliseconds. This put + unnecessary constraints on the configuration of keepalive pings, + requiring users to set this channel arg along with + GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other + source of pings in gRPC Core - BDP pings, but BDP pings are only sent when + there is receive-side data activity, making this arg unuseful for BDP pings + too. */ +#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \ + "grpc.http2.min_time_between_pings_ms" +/** Minimum allowed time between a server receiving successive ping frames + without sending any data/header frame. Int valued, milliseconds + */ +#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \ + "grpc.http2.min_ping_interval_without_data_ms" +/** Channel arg to override the http2 :scheme header */ +#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" +/** How many pings can the client send before needing to send a + data/header frame? (0 indicates that an infinite number of + pings can be sent without sending a data frame or header frame) */ +#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \ + "grpc.http2.max_pings_without_data" +/** How many misbehaving pings the server can bear before sending goaway and + closing the transport? (0 indicates that the server can bear an infinite + number of misbehaving pings) */ +#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes" +/** How much data are we willing to queue up per stream if + GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */ +#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size" +/** Should we allow receipt of true-binary data on http2 connections? + Defaults to on (1) */ +#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary" +/** An experimental channel arg which determines whether the preferred crypto + * frame size http2 setting sent to the peer at startup. If set to 0 (false + * - default), the preferred frame size is not sent to the peer. Otherwise it + * sends a default preferred crypto frame size value of 4GB to the peer at + * the startup of each connection. */ +#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \ + "grpc.experimental.http2.enable_preferred_frame_size" +/** After a duration of this time the client/server pings its peer to see if the + transport is still alive. Int valued, milliseconds. */ +#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms" +/** After waiting for a duration of this time, if the keepalive ping sender does + not receive the ping ack, it will close the transport. Int valued, + milliseconds. */ +#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms" +/** Is it permissible to send keepalive pings from the client without any + outstanding streams. Int valued, 0(false)/1(true). */ +#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \ + "grpc.keepalive_permit_without_calls" +/** Default authority to pass if none specified on call construction. A string. + * */ +#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" +/** Primary user agent: goes at the start of the user-agent metadata + sent on each request. A string. */ +#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent" +/** Secondary user agent: goes at the end of the user-agent metadata + sent on each request. A string. */ +#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" +/** The minimum time between subsequent connection attempts, in ms */ +#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms" +/** The maximum time between subsequent connection attempts, in ms */ +#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms" +/** The time between the first and second connection attempts, in ms */ +#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ + "grpc.initial_reconnect_backoff_ms" +/** Minimum amount of time between DNS resolutions, in ms */ +#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \ + "grpc.dns_min_time_between_resolutions_ms" +/** The timeout used on servers for finishing handshaking on an incoming + connection. Defaults to 120 seconds. */ +#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" +/** This *should* be used for testing only. + The caller of the secure_channel_create functions may override the target + name used for SSL host name checking using this channel argument which is of + type \a GRPC_ARG_STRING. If this argument is not specified, the name used + for SSL host name checking will be the target parameter (assuming that the + secure channel is an SSL channel). If this parameter is specified and the + underlying is not an SSL channel, it will just be ignored. */ +#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override" +/** If non-zero, a pointer to a session cache (a pointer of type + grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch + an appropriate pointer arg vtable) */ +#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" +/** If non-zero, it will determine the maximum frame size used by TSI's frame + * protector. + */ +#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" +/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the + max sum of all metadata key-value entries in a batch of headers. Some random + sample of requests between this limit and + `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum + of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set). + */ +#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" +/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the + max sum of all metadata key-value entries in a batch of headers. All requests + exceeding this limit will be rejected. Defaults to maximum of 16 KB and + `GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */ +#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size" +/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */ +#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport" +/** If non-zero, a pointer to a buffer pool (a pointer of type + * grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an + * appropriate pointer arg vtable) */ +#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota" +/** If non-zero, expand wildcard addresses to a list of local addresses. */ +#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs" +/** Service config data in JSON form. + This value will be ignored if the name resolver returns a service config. */ +#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config" +/** Disable looking up the service config via the name resolver. */ +#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \ + "grpc.service_config_disable_resolution" +/** LB policy name. */ +#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name" +/** Cap for ring size in the ring_hash LB policy. The min and max ring size + values set in the LB policy config will be capped to this value. + Default is 4096. */ +#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap" +/** The grpc_socket_mutator instance that set the socket options. A pointer. */ +#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" +/** The grpc_socket_factory instance to create and bind sockets. A pointer. */ +#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" +/** The maximum amount of memory used by trace events per channel trace node. + * Once the maximum is reached, subsequent events will evict the oldest events + * from the buffer. The unit for this knob is bytes. Setting it to zero causes + * channel tracing to be disabled. */ +#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \ + "grpc.max_channel_trace_event_memory_per_node" +/** If non-zero, gRPC library will track stats and information at at per channel + * level. Disabling channelz naturally disables channel tracing. The default + * is for channelz to be enabled. */ +#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz" +/** If non-zero, Cronet transport will coalesce packets to fewer frames + * when possible. */ +#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ + "grpc.use_cronet_packet_coalescing" +/** Channel arg (integer) setting how large a slice to try and read from the + wire each time recvmsg (or equivalent) is called **/ +#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size" +/** Note this is not a "channel arg" key. This is the default slice size to use + * when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE + * channel arg is unspecified. */ +#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 +#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \ + "grpc.experimental.tcp_min_read_chunk_size" +#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ + "grpc.experimental.tcp_max_read_chunk_size" +/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By + default, it is disabled. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \ + "grpc.experimental.tcp_tx_zerocopy_enabled" +/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By + default, this is set to 16KB. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \ + "grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold" +/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending + calls to tcp_write() using zerocopy. A tcp_write() is considered pending + until the kernel performs the zerocopy-done callback for all sendmsg() calls + issued by the tcp_write(). By default, this is set to 4. */ +#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \ + "grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends" +/* Overrides the TCP socket recieve buffer size, SO_RCVBUF. */ +#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size" +/* Timeout in milliseconds to use for calls to the grpclb load balancer. + If 0 or unset, the balancer calls will have no deadline. */ +#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms" +/* Specifies the xDS bootstrap config as a JSON string. + FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION. + This option allows controlling the bootstrap configuration on a + per-channel basis, which is useful in tests. However, this results + in having a separate xDS client instance per channel rather than + using the global instance, which is not the intended way to use xDS. + Currently, this will (a) add unnecessary load on the xDS server and + (b) break use of CSDS, and there may be additional side effects in + the future. */ +#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \ + "grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config" +/* Timeout in milliseconds to wait for the serverlist from the grpclb load + balancer before using fallback backend addresses from the resolver. + If 0, enter fallback mode immediately. Default value is 10000. */ +#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms" +/* Experimental Arg. Channel args to be used for the control-plane channel + * created to the grpclb load balancers. This is a pointer arg whose value is a + * grpc_channel_args object. If unset, most channel args from the parent channel + * will be propagated to the grpclb channel. */ +#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \ + "grpc.experimental.grpclb_channel_args" +/* Timeout in milliseconds to wait for the child of a specific priority to + complete its initial connection attempt before the priority LB policy fails + over to the next priority. Default value is 10 seconds. */ +#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \ + "grpc.priority_failover_timeout_ms" +/** If non-zero, grpc server's cronet compression workaround will be enabled */ +#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \ + "grpc.workaround.cronet_compression" +/** String defining the optimization target for a channel. + Can be: "latency" - attempt to minimize latency at the cost of throughput + "blend" - try to balance latency and throughput + "throughput" - attempt to maximize throughput at the expense of + latency + Defaults to "blend". In the current implementation "blend" is equivalent to + "latency". */ +#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target" +/** Enables retry functionality. Defaults to true. When enabled, + transparent retries will be performed as appropriate, and configurable + retries are enabled when they are configured via the service config. + For details, see: + https://github.com/grpc/proposal/blob/master/A6-client-retries.md + NOTE: Hedging functionality is not yet implemented, so those + fields in the service config will currently be ignored. See + also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below. + */ +#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries" +/** Enables hedging functionality, as described in: + https://github.com/grpc/proposal/blob/master/A6-client-retries.md + Default is currently false, since this functionality is not yet + fully implemented. + NOTE: This channel arg is experimental and will eventually be removed. + Once hedging functionality has been implemented and proves stable, + this arg will be removed, and the hedging functionality will + be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */ +#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging" +/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */ +#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" +/** Channel arg that carries the bridged objective c object for custom metrics + * logging filter. */ +#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context" +/** If non-zero, client authority filter is disabled for the channel */ +#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ + "grpc.disable_client_authority_filter" +/** If set to zero, disables use of http proxies. Enabled by default. */ +#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy" +/** Channel arg to set http proxy per channel. If set, the channel arg + * value will be preferred over the environment variable settings. */ +#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy" +/** If set to non zero, surfaces the user agent string to the server. User + agent is surfaced by default. */ +#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent" +/** If set, inhibits health checking (which may be enabled via the + * service config.) */ +#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking" +/** If enabled, the channel's DNS resolver queries for SRV records. + * This is useful only when using the "grpclb" load balancing policy, + * as described in the following documents: + * https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md + * https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md + * https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md + * Note that this works only with the "ares" DNS resolver; it isn't supported + * by the "native" DNS resolver. */ +#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" +/** If set, determines an upper bound on the number of milliseconds that the + * c-ares based DNS resolver will wait on queries before cancelling them. + * The default value is 120,000. Setting this to "0" will disable the + * overall timeout entirely. Note that this doesn't include internal c-ares + * timeouts/backoff/retry logic, and so the actual DNS resolution may time out + * sooner than the value specified here. */ +#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" +/** If set, uses a local subchannel pool within the channel. Otherwise, uses the + * global subchannel pool. */ +#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool" +/** gRPC Objective-C channel pooling domain string. */ +#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain" +/** gRPC Objective-C channel pooling id. */ +#define GRPC_ARG_CHANNEL_ID "grpc.channel_id" +/** Channel argument for grpc_authorization_policy_provider. If present, enables + gRPC authorization check. */ +#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \ + "grpc.authorization_policy_provider" +/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for + * example, listener updates from xDS) cause all older connections to be + * gracefully shut down (i.e., "drained") with a grace period configured by this + * channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/ +#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \ + "grpc.experimental.server_config_change_drain_grace_time_ms" +/** Configure the Differentiated Services Code Point used on outgoing packets. + * Integer value ranging from 0 to 63. */ +#define GRPC_ARG_DSCP "grpc.dscp" +/** \} */ + +#endif /* GRPC_IMPL_CHANNEL_ARG_NAMES_H */ diff --git a/include/grpc/impl/grpc_types.h b/include/grpc/impl/grpc_types.h index 425fe0b630b..9250ce8f6b6 100644 --- a/include/grpc/impl/grpc_types.h +++ b/include/grpc/impl/grpc_types.h @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -133,359 +134,6 @@ typedef struct { grpc_arg* args; } grpc_channel_args; -/** \defgroup grpc_arg_keys - * Channel argument keys. - * \{ - */ -/** If non-zero, enable census for tracing and stats collection. */ -#define GRPC_ARG_ENABLE_CENSUS "grpc.census" -/** If non-zero, enable load reporting. */ -#define GRPC_ARG_ENABLE_LOAD_REPORTING "grpc.loadreporting" -/** If non-zero, call metric recording is enabled. */ -#define GRPC_ARG_SERVER_CALL_METRIC_RECORDING \ - "grpc.server_call_metric_recording" -/** Request that optional features default to off (regardless of what they - usually default to) - to enable tight control over what gets enabled */ -#define GRPC_ARG_MINIMAL_STACK "grpc.minimal_stack" -/** Maximum number of concurrent incoming streams to allow on a http2 - connection. Int valued. */ -#define GRPC_ARG_MAX_CONCURRENT_STREAMS "grpc.max_concurrent_streams" -/** Maximum message length that the channel can receive. Int valued, bytes. - -1 means unlimited. */ -#define GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH "grpc.max_receive_message_length" -/** \deprecated For backward compatibility. - * Use GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH instead. */ -#define GRPC_ARG_MAX_MESSAGE_LENGTH GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH -/** Maximum message length that the channel can send. Int valued, bytes. - -1 means unlimited. */ -#define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" -/** Maximum time that a channel may have no outstanding rpcs, after which the - * server will close the connection. Int valued, milliseconds. INT_MAX means - * unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" -/** Maximum time that a channel may exist. Int valued, milliseconds. - * INT_MAX means unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_AGE_MS "grpc.max_connection_age_ms" -/** Grace period after the channel reaches its max age. Int valued, - milliseconds. INT_MAX means unlimited. */ -#define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" -/** Timeout after the last RPC finishes on the client channel at which the - * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means - * unlimited. The default value is 30 minutes and the min value is 1 second. */ -#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" -/** Enable/disable support for per-message compression. Defaults to 1, unless - GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ -#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" -/** Experimental Arg. Enable/disable support for per-message decompression. - Defaults to 1. If disabled, decompression will not be performed and the - application will see the compressed message in the byte buffer. */ -#define GRPC_ARG_ENABLE_PER_MESSAGE_DECOMPRESSION \ - "grpc.per_message_decompression" -/** Enable/disable support for deadline checking. Defaults to 1, unless - GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */ -#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking" -/** Initial stream ID for http2 transports. Int valued. */ -#define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ - "grpc.http2.initial_sequence_number" -/** Amount to read ahead on individual streams. Defaults to 64kb, larger - values can help throughput on high-latency connections. - NOTE: at some point we'd like to auto-tune this, and this parameter - will become a no-op. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES "grpc.http2.lookahead_bytes" -/** How much memory to use for hpack decoding. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER \ - "grpc.http2.hpack_table_size.decoder" -/** How much memory to use for hpack encoding. Int valued, bytes. */ -#define GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER \ - "grpc.http2.hpack_table_size.encoder" -/** How big a frame are we willing to receive via HTTP2. - Min 16384, max 16777215. Larger values give lower CPU usage for large - messages, but more head of line blocking for small messages. */ -#define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" -/** Should BDP probing be performed? */ -#define GRPC_ARG_HTTP2_BDP_PROBE "grpc.http2.bdp_probe" -/** (DEPRECATED) Does not have any effect. - Earlier, this arg configured the minimum time between successive ping frames - without receiving any data/header frame, Int valued, milliseconds. This put - unnecessary constraints on the configuration of keepalive pings, - requiring users to set this channel arg along with - GRPC_ARG_KEEPALIVE_TIME_MS. This arg also limited the activity of the other - source of pings in gRPC Core - BDP pings, but BDP pings are only sent when - there is receive-side data activity, making this arg unuseful for BDP pings - too. */ -#define GRPC_ARG_HTTP2_MIN_SENT_PING_INTERVAL_WITHOUT_DATA_MS \ - "grpc.http2.min_time_between_pings_ms" -/** Minimum allowed time between a server receiving successive ping frames - without sending any data/header frame. Int valued, milliseconds - */ -#define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \ - "grpc.http2.min_ping_interval_without_data_ms" -/** Channel arg to override the http2 :scheme header */ -#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" -/** How many pings can the client send before needing to send a - data/header frame? (0 indicates that an infinite number of - pings can be sent without sending a data frame or header frame) */ -#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \ - "grpc.http2.max_pings_without_data" -/** How many misbehaving pings the server can bear before sending goaway and - closing the transport? (0 indicates that the server can bear an infinite - number of misbehaving pings) */ -#define GRPC_ARG_HTTP2_MAX_PING_STRIKES "grpc.http2.max_ping_strikes" -/** How much data are we willing to queue up per stream if - GRPC_WRITE_BUFFER_HINT is set? This is an upper bound */ -#define GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE "grpc.http2.write_buffer_size" -/** Should we allow receipt of true-binary data on http2 connections? - Defaults to on (1) */ -#define GRPC_ARG_HTTP2_ENABLE_TRUE_BINARY "grpc.http2.true_binary" -/** An experimental channel arg which determines whether the preferred crypto - * frame size http2 setting sent to the peer at startup. If set to 0 (false - * - default), the preferred frame size is not sent to the peer. Otherwise it - * sends a default preferred crypto frame size value of 4GB to the peer at - * the startup of each connection. */ -#define GRPC_ARG_EXPERIMENTAL_HTTP2_PREFERRED_CRYPTO_FRAME_SIZE \ - "grpc.experimental.http2.enable_preferred_frame_size" -/** After a duration of this time the client/server pings its peer to see if the - transport is still alive. Int valued, milliseconds. */ -#define GRPC_ARG_KEEPALIVE_TIME_MS "grpc.keepalive_time_ms" -/** After waiting for a duration of this time, if the keepalive ping sender does - not receive the ping ack, it will close the transport. Int valued, - milliseconds. */ -#define GRPC_ARG_KEEPALIVE_TIMEOUT_MS "grpc.keepalive_timeout_ms" -/** Is it permissible to send keepalive pings from the client without any - outstanding streams. Int valued, 0(false)/1(true). */ -#define GRPC_ARG_KEEPALIVE_PERMIT_WITHOUT_CALLS \ - "grpc.keepalive_permit_without_calls" -/** Default authority to pass if none specified on call construction. A string. - * */ -#define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" -/** Primary user agent: goes at the start of the user-agent metadata - sent on each request. A string. */ -#define GRPC_ARG_PRIMARY_USER_AGENT_STRING "grpc.primary_user_agent" -/** Secondary user agent: goes at the end of the user-agent metadata - sent on each request. A string. */ -#define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" -/** The minimum time between subsequent connection attempts, in ms */ -#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms" -/** The maximum time between subsequent connection attempts, in ms */ -#define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms" -/** The time between the first and second connection attempts, in ms */ -#define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ - "grpc.initial_reconnect_backoff_ms" -/** Minimum amount of time between DNS resolutions, in ms */ -#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \ - "grpc.dns_min_time_between_resolutions_ms" -/** The timeout used on servers for finishing handshaking on an incoming - connection. Defaults to 120 seconds. */ -#define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" -/** This *should* be used for testing only. - The caller of the secure_channel_create functions may override the target - name used for SSL host name checking using this channel argument which is of - type \a GRPC_ARG_STRING. If this argument is not specified, the name used - for SSL host name checking will be the target parameter (assuming that the - secure channel is an SSL channel). If this parameter is specified and the - underlying is not an SSL channel, it will just be ignored. */ -#define GRPC_SSL_TARGET_NAME_OVERRIDE_ARG "grpc.ssl_target_name_override" -/** If non-zero, a pointer to a session cache (a pointer of type - grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch - an appropriate pointer arg vtable) */ -#define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" -/** If non-zero, it will determine the maximum frame size used by TSI's frame - * protector. - */ -#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" -/** Maximum metadata size (soft limit), in bytes. Note this limit applies to the - max sum of all metadata key-value entries in a batch of headers. Some random - sample of requests between this limit and - `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` will be rejected. Defaults to maximum - of 8 KB and `GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE` * 0.8 (if set). - */ -#define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" -/** Maximum metadata size (hard limit), in bytes. Note this limit applies to the - max sum of all metadata key-value entries in a batch of headers. All requests - exceeding this limit will be rejected. Defaults to maximum of 16 KB and - `GRPC_ARG_MAX_METADATA_SIZE` * 1.25 (if set). */ -#define GRPC_ARG_ABSOLUTE_MAX_METADATA_SIZE "grpc.absolute_max_metadata_size" -/** If non-zero, allow the use of SO_REUSEPORT if it's available (default 1) */ -#define GRPC_ARG_ALLOW_REUSEPORT "grpc.so_reuseport" -/** If non-zero, a pointer to a buffer pool (a pointer of type - * grpc_resource_quota*). (use grpc_resource_quota_arg_vtable() to fetch an - * appropriate pointer arg vtable) */ -#define GRPC_ARG_RESOURCE_QUOTA "grpc.resource_quota" -/** If non-zero, expand wildcard addresses to a list of local addresses. */ -#define GRPC_ARG_EXPAND_WILDCARD_ADDRS "grpc.expand_wildcard_addrs" -/** Service config data in JSON form. - This value will be ignored if the name resolver returns a service config. */ -#define GRPC_ARG_SERVICE_CONFIG "grpc.service_config" -/** Disable looking up the service config via the name resolver. */ -#define GRPC_ARG_SERVICE_CONFIG_DISABLE_RESOLUTION \ - "grpc.service_config_disable_resolution" -/** LB policy name. */ -#define GRPC_ARG_LB_POLICY_NAME "grpc.lb_policy_name" -/** Cap for ring size in the ring_hash LB policy. The min and max ring size - values set in the LB policy config will be capped to this value. - Default is 4096. */ -#define GRPC_ARG_RING_HASH_LB_RING_SIZE_CAP "grpc.lb.ring_hash.ring_size_cap" -/** The grpc_socket_mutator instance that set the socket options. A pointer. */ -#define GRPC_ARG_SOCKET_MUTATOR "grpc.socket_mutator" -/** The grpc_socket_factory instance to create and bind sockets. A pointer. */ -#define GRPC_ARG_SOCKET_FACTORY "grpc.socket_factory" -/** The maximum amount of memory used by trace events per channel trace node. - * Once the maximum is reached, subsequent events will evict the oldest events - * from the buffer. The unit for this knob is bytes. Setting it to zero causes - * channel tracing to be disabled. */ -#define GRPC_ARG_MAX_CHANNEL_TRACE_EVENT_MEMORY_PER_NODE \ - "grpc.max_channel_trace_event_memory_per_node" -/** If non-zero, gRPC library will track stats and information at at per channel - * level. Disabling channelz naturally disables channel tracing. The default - * is for channelz to be enabled. */ -#define GRPC_ARG_ENABLE_CHANNELZ "grpc.enable_channelz" -/** If non-zero, Cronet transport will coalesce packets to fewer frames - * when possible. */ -#define GRPC_ARG_USE_CRONET_PACKET_COALESCING \ - "grpc.use_cronet_packet_coalescing" -/** Channel arg (integer) setting how large a slice to try and read from the - wire each time recvmsg (or equivalent) is called **/ -#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size" -/** Note this is not a "channel arg" key. This is the default slice size to use - * when trying to read from the wire if the GRPC_ARG_TCP_READ_CHUNK_SIZE - * channel arg is unspecified. */ -#define GRPC_TCP_DEFAULT_READ_SLICE_SIZE 8192 -#define GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE \ - "grpc.experimental.tcp_min_read_chunk_size" -#define GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE \ - "grpc.experimental.tcp_max_read_chunk_size" -/* TCP TX Zerocopy enable state: zero is disabled, non-zero is enabled. By - default, it is disabled. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_ENABLED \ - "grpc.experimental.tcp_tx_zerocopy_enabled" -/* TCP TX Zerocopy send threshold: only zerocopy if >= this many bytes sent. By - default, this is set to 16KB. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_SEND_BYTES_THRESHOLD \ - "grpc.experimental.tcp_tx_zerocopy_send_bytes_threshold" -/* TCP TX Zerocopy max simultaneous sends: limit for maximum number of pending - calls to tcp_write() using zerocopy. A tcp_write() is considered pending - until the kernel performs the zerocopy-done callback for all sendmsg() calls - issued by the tcp_write(). By default, this is set to 4. */ -#define GRPC_ARG_TCP_TX_ZEROCOPY_MAX_SIMULT_SENDS \ - "grpc.experimental.tcp_tx_zerocopy_max_simultaneous_sends" -/* Overrides the TCP socket recieve buffer size, SO_RCVBUF. */ -#define GRPC_ARG_TCP_RECEIVE_BUFFER_SIZE "grpc.tcp_receive_buffer_size" -/* Timeout in milliseconds to use for calls to the grpclb load balancer. - If 0 or unset, the balancer calls will have no deadline. */ -#define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms" -/* Specifies the xDS bootstrap config as a JSON string. - FOR TESTING PURPOSES ONLY -- DO NOT USE IN PRODUCTION. - This option allows controlling the bootstrap configuration on a - per-channel basis, which is useful in tests. However, this results - in having a separate xDS client instance per channel rather than - using the global instance, which is not the intended way to use xDS. - Currently, this will (a) add unnecessary load on the xDS server and - (b) break use of CSDS, and there may be additional side effects in - the future. */ -#define GRPC_ARG_TEST_ONLY_DO_NOT_USE_IN_PROD_XDS_BOOTSTRAP_CONFIG \ - "grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_config" -/* Timeout in milliseconds to wait for the serverlist from the grpclb load - balancer before using fallback backend addresses from the resolver. - If 0, enter fallback mode immediately. Default value is 10000. */ -#define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms" -/* Experimental Arg. Channel args to be used for the control-plane channel - * created to the grpclb load balancers. This is a pointer arg whose value is a - * grpc_channel_args object. If unset, most channel args from the parent channel - * will be propagated to the grpclb channel. */ -#define GRPC_ARG_EXPERIMENTAL_GRPCLB_CHANNEL_ARGS \ - "grpc.experimental.grpclb_channel_args" -/* Timeout in milliseconds to wait for the child of a specific priority to - complete its initial connection attempt before the priority LB policy fails - over to the next priority. Default value is 10 seconds. */ -#define GRPC_ARG_PRIORITY_FAILOVER_TIMEOUT_MS \ - "grpc.priority_failover_timeout_ms" -/** If non-zero, grpc server's cronet compression workaround will be enabled */ -#define GRPC_ARG_WORKAROUND_CRONET_COMPRESSION \ - "grpc.workaround.cronet_compression" -/** String defining the optimization target for a channel. - Can be: "latency" - attempt to minimize latency at the cost of throughput - "blend" - try to balance latency and throughput - "throughput" - attempt to maximize throughput at the expense of - latency - Defaults to "blend". In the current implementation "blend" is equivalent to - "latency". */ -#define GRPC_ARG_OPTIMIZATION_TARGET "grpc.optimization_target" -/** Enables retry functionality. Defaults to true. When enabled, - transparent retries will be performed as appropriate, and configurable - retries are enabled when they are configured via the service config. - For details, see: - https://github.com/grpc/proposal/blob/master/A6-client-retries.md - NOTE: Hedging functionality is not yet implemented, so those - fields in the service config will currently be ignored. See - also the GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING arg below. - */ -#define GRPC_ARG_ENABLE_RETRIES "grpc.enable_retries" -/** Enables hedging functionality, as described in: - https://github.com/grpc/proposal/blob/master/A6-client-retries.md - Default is currently false, since this functionality is not yet - fully implemented. - NOTE: This channel arg is experimental and will eventually be removed. - Once hedging functionality has been implemented and proves stable, - this arg will be removed, and the hedging functionality will - be enabled via the GRPC_ARG_ENABLE_RETRIES arg above. */ -#define GRPC_ARG_EXPERIMENTAL_ENABLE_HEDGING "grpc.experimental.enable_hedging" -/** Per-RPC retry buffer size, in bytes. Default is 256 KiB. */ -#define GRPC_ARG_PER_RPC_RETRY_BUFFER_SIZE "grpc.per_rpc_retry_buffer_size" -/** Channel arg that carries the bridged objective c object for custom metrics - * logging filter. */ -#define GRPC_ARG_MOBILE_LOG_CONTEXT "grpc.mobile_log_context" -/** If non-zero, client authority filter is disabled for the channel */ -#define GRPC_ARG_DISABLE_CLIENT_AUTHORITY_FILTER \ - "grpc.disable_client_authority_filter" -/** If set to zero, disables use of http proxies. Enabled by default. */ -#define GRPC_ARG_ENABLE_HTTP_PROXY "grpc.enable_http_proxy" -/** Channel arg to set http proxy per channel. If set, the channel arg - * value will be preferred over the environment variable settings. */ -#define GRPC_ARG_HTTP_PROXY "grpc.http_proxy" -/** If set to non zero, surfaces the user agent string to the server. User - agent is surfaced by default. */ -#define GRPC_ARG_SURFACE_USER_AGENT "grpc.surface_user_agent" -/** If set, inhibits health checking (which may be enabled via the - * service config.) */ -#define GRPC_ARG_INHIBIT_HEALTH_CHECKING "grpc.inhibit_health_checking" -/** If enabled, the channel's DNS resolver queries for SRV records. - * This is useful only when using the "grpclb" load balancing policy, - * as described in the following documents: - * https://github.com/grpc/proposal/blob/master/A5-grpclb-in-dns.md - * https://github.com/grpc/proposal/blob/master/A24-lb-policy-config.md - * https://github.com/grpc/proposal/blob/master/A26-grpclb-selection.md - * Note that this works only with the "ares" DNS resolver; it isn't supported - * by the "native" DNS resolver. */ -#define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" -/** If set, determines an upper bound on the number of milliseconds that the - * c-ares based DNS resolver will wait on queries before cancelling them. - * The default value is 120,000. Setting this to "0" will disable the - * overall timeout entirely. Note that this doesn't include internal c-ares - * timeouts/backoff/retry logic, and so the actual DNS resolution may time out - * sooner than the value specified here. */ -#define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" -/** If set, uses a local subchannel pool within the channel. Otherwise, uses the - * global subchannel pool. */ -#define GRPC_ARG_USE_LOCAL_SUBCHANNEL_POOL "grpc.use_local_subchannel_pool" -/** gRPC Objective-C channel pooling domain string. */ -#define GRPC_ARG_CHANNEL_POOL_DOMAIN "grpc.channel_pooling_domain" -/** gRPC Objective-C channel pooling id. */ -#define GRPC_ARG_CHANNEL_ID "grpc.channel_id" -/** Channel argument for grpc_authorization_policy_provider. If present, enables - gRPC authorization check. */ -#define GRPC_ARG_AUTHORIZATION_POLICY_PROVIDER \ - "grpc.authorization_policy_provider" -/** EXPERIMENTAL. Updates to a server's configuration from a config fetcher (for - * example, listener updates from xDS) cause all older connections to be - * gracefully shut down (i.e., "drained") with a grace period configured by this - * channel arg. Int valued, milliseconds. Defaults to 10 minutes.*/ -#define GRPC_ARG_SERVER_CONFIG_CHANGE_DRAIN_GRACE_TIME_MS \ - "grpc.experimental.server_config_change_drain_grace_time_ms" -/** Configure the Differentiated Services Code Point used on outgoing packets. - * Integer value ranging from 0 to 63. */ -#define GRPC_ARG_DSCP "grpc.dscp" -/** \} */ - /** Result of a grpc call. If the caller satisfies the prerequisites of a particular operation, the grpc_call_error returned will be GRPC_CALL_OK. Receiving any other value listed here is an indication of a bug in the diff --git a/include/grpc/module.modulemap b/include/grpc/module.modulemap index 3f8840ccaff..a37f5dcaafc 100644 --- a/include/grpc/module.modulemap +++ b/include/grpc/module.modulemap @@ -12,6 +12,7 @@ header "byte_buffer.h" header "grpc_posix.h" header "grpc_security.h" header "grpc_security_constants.h" + header "impl/channel_arg_names.h" header "impl/codegen/atm.h" header "impl/codegen/byte_buffer.h" header "impl/codegen/byte_buffer_reader.h" diff --git a/package.xml b/package.xml index 5417e51fde0..7a21ab7ac7d 100644 --- a/package.xml +++ b/package.xml @@ -48,6 +48,7 @@ + @@ -297,6 +298,10 @@ + + + + diff --git a/src/core/BUILD b/src/core/BUILD index 5b05d7481b4..d3426517922 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -1187,6 +1187,7 @@ grpc_cc_library( "ref_counted", "thread_quota", "useful", + "//:channel_arg_names", "//:cpp_impl_of", "//:event_engine_base_hdrs", "//:gpr_platform", @@ -1894,6 +1895,7 @@ grpc_cc_library( "strerror", "time", "useful", + "//:channel_arg_names", "//:event_engine_base_hdrs", "//:gpr", "//:ref_counted_ptr", @@ -2634,6 +2636,7 @@ grpc_cc_library( "ref_counted", "time", "useful", + "//:channel_arg_names", "//:debug_location", "//:event_engine_base_hdrs", "//:gpr", @@ -2953,6 +2956,7 @@ grpc_cc_library( "resolved_address", "slice", "useful", + "//:channel_arg_names", "//:gpr", "//:grpc_base", "//:grpc_credentials_util", @@ -2993,6 +2997,7 @@ grpc_cc_library( "slice", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3127,6 +3132,7 @@ grpc_cc_library( "iomgr_fwd", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3178,6 +3184,7 @@ grpc_cc_library( "unique_type_name", "useful", "//:alts_util", + "//:channel_arg_names", "//:exec_ctx", "//:gpr", "//:grpc_alts_credentials", @@ -3247,6 +3254,7 @@ grpc_cc_library( "status_helper", "unique_type_name", "useful", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3412,6 +3420,7 @@ grpc_cc_library( "error", "iomgr_fwd", "unique_type_name", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -3640,6 +3649,7 @@ grpc_cc_library( "status_helper", "time", "try_seq", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -3678,6 +3688,7 @@ grpc_cc_library( "error", "status_helper", "time", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -3710,6 +3721,7 @@ grpc_cc_library( "channel_fwd", "channel_stack_type", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr_platform", @@ -3752,6 +3764,7 @@ grpc_cc_library( "slice", "slice_buffer", "validation_errors", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -3950,6 +3963,7 @@ grpc_cc_library( "useful", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:debug_location", @@ -4041,6 +4055,7 @@ grpc_cc_library( "time", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4238,6 +4253,7 @@ grpc_cc_library( "validation_errors", "xds_type_upb", "xds_type_upbdefs", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4438,6 +4454,7 @@ grpc_cc_library( "lb_policy_registry", "pollset_set", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -4623,6 +4640,7 @@ grpc_cc_library( "slice", "subchannel_interface", "unique_type_name", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -4655,6 +4673,7 @@ grpc_cc_library( "iomgr_fwd", "lb_policy", "subchannel_interface", + "//:channel_arg_names", "//:debug_location", "//:gpr", "//:grpc_base", @@ -4694,6 +4713,7 @@ grpc_cc_library( "lb_policy_factory", "subchannel_interface", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -4739,6 +4759,7 @@ grpc_cc_library( "subchannel_interface", "unique_type_name", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -4934,6 +4955,7 @@ grpc_cc_library( "pollset_set", "time", "validation_errors", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5070,6 +5092,7 @@ grpc_cc_library( "resolved_address", "seq", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -5109,6 +5132,7 @@ grpc_cc_library( "grpc_backend_metric_provider", "map", "slice", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", @@ -5197,6 +5221,7 @@ grpc_cc_library( "time", "validation_errors", "//:backoff", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -5257,6 +5282,7 @@ grpc_cc_library( "resolved_address", "time", "//:backoff", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -5369,6 +5395,7 @@ grpc_cc_library( "ref_counted", "slice", "time", + "//:channel_arg_names", "//:config", "//:debug_location", "//:gpr", @@ -5475,6 +5502,45 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "ping_abuse_policy", + srcs = [ + "ext/transport/chttp2/transport/ping_abuse_policy.cc", + ], + hdrs = [ + "ext/transport/chttp2/transport/ping_abuse_policy.h", + ], + external_deps = ["absl/types:optional"], + deps = [ + "channel_args", + "time", + "//:channel_arg_names", + "//:gpr_platform", + ], +) + +grpc_cc_library( + name = "ping_rate_policy", + srcs = [ + "ext/transport/chttp2/transport/ping_rate_policy.cc", + ], + hdrs = [ + "ext/transport/chttp2/transport/ping_rate_policy.h", + ], + external_deps = [ + "absl/strings", + "absl/types:optional", + "absl/types:variant", + ], + deps = [ + "channel_args", + "match", + "time", + "//:channel_arg_names", + "//:gpr_platform", + ], +) + grpc_cc_library( name = "huffsyms", srcs = [ @@ -5558,6 +5624,7 @@ grpc_cc_library( "time", "transport_fwd", "unique_type_name", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5609,6 +5676,7 @@ grpc_cc_library( "time", "transport_fwd", "unique_type_name", + "//:channel_arg_names", "//:chttp2_frame", "//:config", "//:debug_location", @@ -5655,6 +5723,7 @@ grpc_cc_library( "status_helper", "time", "transport_fwd", + "//:channel_arg_names", "//:config", "//:debug_location", "//:exec_ctx", @@ -5801,6 +5870,7 @@ grpc_cc_library( "slice", "slice_buffer", "time", + "//:channel_arg_names", "//:channel_stack_builder", "//:config", "//:gpr", diff --git a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc index e1eae2a62b3..61cd59b3932 100644 --- a/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +++ b/src/core/ext/filters/backend_metrics/backend_metric_filter.cc @@ -30,7 +30,7 @@ #include "upb/upb.hpp" #include "xds/data/orca/v3/orca_load_report.upb.h" -#include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/backend_metric_data.h" diff --git a/src/core/ext/filters/channel_idle/channel_idle_filter.cc b/src/core/ext/filters/channel_idle/channel_idle_filter.cc index e2a6c36bb2b..34601e5e3a0 100644 --- a/src/core/ext/filters/channel_idle/channel_idle_filter.cc +++ b/src/core/ext/filters/channel_idle/channel_idle_filter.cc @@ -26,7 +26,7 @@ #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/client_channel/client_channel.cc b/src/core/ext/filters/client_channel/client_channel.cc index d250c32102b..1bab8f80034 100644 --- a/src/core/ext/filters/client_channel/client_channel.cc +++ b/src/core/ext/filters/client_channel/client_channel.cc @@ -41,6 +41,7 @@ #include "absl/types/variant.h" #include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/http_proxy.cc b/src/core/ext/filters/client_channel/http_proxy.cc index 6eb61fce4fa..54dac2dbf43 100644 --- a/src/core/ext/filters/client_channel/http_proxy.cc +++ b/src/core/ext/filters/client_channel/http_proxy.cc @@ -39,7 +39,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc index 88afb0600b2..2d079ed2b7d 100644 --- a/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +++ b/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc @@ -54,6 +54,7 @@ #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h" #include +#include #include // IWYU pragma: no_include diff --git a/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc b/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc index f9b02cdfe53..859fc4b78bd 100644 --- a/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +++ b/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc @@ -33,7 +33,7 @@ #include "upb/base/string_view.h" #include "upb/upb.hpp" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc index 4b84091950c..c65edd910e9 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc @@ -33,7 +33,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc b/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc index b1b39dae5e7..fe22f3b9263 100644 --- a/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +++ b/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc @@ -35,7 +35,7 @@ #include "absl/types/optional.h" #include -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc b/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc index f5767e4679f..6cc1a948b34 100644 --- a/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +++ b/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc @@ -37,10 +37,11 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include + #define XXH_INLINE_ALL #include "xxhash.h" -#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc index de19ba71a51..7a23aa83084 100644 --- a/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +++ b/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h index 87072c7381c..4acd432d7eb 100644 --- a/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +++ b/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h @@ -30,7 +30,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc index b4db0dbec14..ca487ad5dc5 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc @@ -35,7 +35,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc index 1f609a8e2f0..47706e2cbb8 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc @@ -33,7 +33,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc index f8278cc6fc2..a088c114585 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc @@ -24,7 +24,7 @@ #include "absl/strings/string_view.h" -#include +#include #include "src/core/lib/gprpp/status_helper.h" #include "src/core/lib/iomgr/sockaddr.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc index b2b03cf5a40..8d5566677ae 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc @@ -35,7 +35,7 @@ #include "absl/types/optional.h" #include -#include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h" diff --git a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc index 019ce8706a8..4de874fccc1 100644 --- a/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc @@ -30,7 +30,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/ext/filters/client_channel/resolver/polling_resolver.h" diff --git a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc index 43af7b0adec..04b76b7f731 100644 --- a/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +++ b/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc @@ -44,7 +44,7 @@ #include "absl/types/variant.h" #include "re2/re2.h" -#include +#include #include "src/core/lib/slice/slice.h" diff --git a/src/core/ext/filters/client_channel/retry_filter.h b/src/core/ext/filters/client_channel/retry_filter.h index fbaf6ce336f..c5d713f5fa9 100644 --- a/src/core/ext/filters/client_channel/retry_filter.h +++ b/src/core/ext/filters/client_channel/retry_filter.h @@ -28,6 +28,7 @@ #include #include +#include #include #include "src/core/ext/filters/client_channel/client_channel.h" diff --git a/src/core/ext/filters/client_channel/retry_service_config.cc b/src/core/ext/filters/client_channel/retry_service_config.cc index 9743d000142..db8ee915791 100644 --- a/src/core/ext/filters/client_channel/retry_service_config.cc +++ b/src/core/ext/filters/client_channel/retry_service_config.cc @@ -27,7 +27,7 @@ #include "absl/strings/str_cat.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc index 81ef16ee58f..077e69f8579 100644 --- a/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +++ b/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc @@ -28,7 +28,7 @@ #include "absl/status/statusor.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/client_channel/subchannel.cc b/src/core/ext/filters/client_channel/subchannel.cc index 3f7599e9a36..85da64014fa 100644 --- a/src/core/ext/filters/client_channel/subchannel.cc +++ b/src/core/ext/filters/client_channel/subchannel.cc @@ -33,7 +33,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/deadline/deadline_filter.cc b/src/core/ext/filters/deadline/deadline_filter.cc index bd2f290ca73..4562e45c612 100644 --- a/src/core/ext/filters/deadline/deadline_filter.cc +++ b/src/core/ext/filters/deadline/deadline_filter.cc @@ -26,7 +26,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include diff --git a/src/core/ext/filters/http/client/http_client_filter.cc b/src/core/ext/filters/http/client/http_client_filter.cc index 89ff0356cce..6ed05d95186 100644 --- a/src/core/ext/filters/http/client/http_client_filter.cc +++ b/src/core/ext/filters/http/client/http_client_filter.cc @@ -35,6 +35,7 @@ #include "absl/types/optional.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/http/client_authority_filter.cc b/src/core/ext/filters/http/client_authority_filter.cc index 9e15fa18da6..6350788b403 100644 --- a/src/core/ext/filters/http/client_authority_filter.cc +++ b/src/core/ext/filters/http/client_authority_filter.cc @@ -29,7 +29,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" -#include +#include #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder.h" diff --git a/src/core/ext/filters/http/message_compress/compression_filter.cc b/src/core/ext/filters/http/message_compress/compression_filter.cc index 26868c51ef1..2fefd04bb66 100644 --- a/src/core/ext/filters/http/message_compress/compression_filter.cc +++ b/src/core/ext/filters/http/message_compress/compression_filter.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 8ec0e54df0b..6b7648ddb88 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -30,7 +30,7 @@ #include "absl/status/status.h" #include "absl/types/optional.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc index 29d2a2cf6a4..77575cddf1f 100644 --- a/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc @@ -40,8 +40,8 @@ #include "opencensus/stats/stats.h" #include "opencensus/tags/tag_key.h" -#include #include +#include #include #include #include diff --git a/src/core/ext/filters/logging/logging_filter.cc b/src/core/ext/filters/logging/logging_filter.cc index 37e5450bb08..561e4718ab3 100644 --- a/src/core/ext/filters/logging/logging_filter.cc +++ b/src/core/ext/filters/logging/logging_filter.cc @@ -43,7 +43,7 @@ #include "absl/strings/strip.h" #include "absl/types/optional.h" -#include +#include #include #include #include diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index 6143239c0c0..be5505cf05a 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -28,6 +28,7 @@ #include "absl/strings/str_format.h" #include +#include #include #include diff --git a/src/core/ext/transport/chttp2/client/chttp2_connector.cc b/src/core/ext/transport/chttp2/client/chttp2_connector.cc index f4e716c9265..e720ce52ddb 100644 --- a/src/core/ext/transport/chttp2/client/chttp2_connector.cc +++ b/src/core/ext/transport/chttp2/client/chttp2_connector.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.cc b/src/core/ext/transport/chttp2/server/chttp2_server.cc index 7b4143bfb54..a4718fc769a 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.cc +++ b/src/core/ext/transport/chttp2/server/chttp2_server.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index fb1903a256c..06f9d90478d 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -44,6 +44,7 @@ #include #include +#include #include #include #include @@ -61,6 +62,8 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/ext/transport/chttp2/transport/varint.h" #include "src/core/lib/channel/call_tracer.h" #include "src/core/lib/channel/channel_args.h" @@ -123,11 +126,6 @@ static grpc_core::Duration g_default_server_keepalive_timeout = static bool g_default_client_keepalive_permit_without_calls = false; static bool g_default_server_keepalive_permit_without_calls = false; -static grpc_core::Duration g_default_min_recv_ping_interval_without_data = - grpc_core::Duration::Minutes(5); -static int g_default_max_pings_without_data = 2; -static int g_default_max_ping_strikes = 2; - #define MAX_CLIENT_STREAM_ID 0x7fffffffu grpc_core::TraceFlag grpc_keepalive_trace(false, "http_keepalive"); grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount(false, @@ -346,18 +344,6 @@ static void read_channel_args(grpc_chttp2_transport* t, t->hpack_compressor.SetMaxUsableSize(max_hpack_table_size); } - t->ping_policy.max_pings_without_data = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) - .value_or(g_default_max_pings_without_data)); - t->ping_policy.max_ping_strikes = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) - .value_or(g_default_max_ping_strikes)); - t->ping_policy.min_recv_ping_interval_without_data = - std::max(grpc_core::Duration::Zero(), - channel_args - .GetDurationFromIntMillis( - GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) - .value_or(g_default_min_recv_ping_interval_without_data)); t->write_buffer_size = std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE) .value_or(grpc_core::chttp2::kDefaultWindow)); @@ -546,6 +532,8 @@ grpc_chttp2_transport::grpc_chttp2_transport( GRPC_CHANNEL_READY), is_client(is_client), next_stream_id(is_client ? 1 : 2), + ping_abuse_policy(channel_args), + ping_rate_policy(channel_args, is_client), flow_control( peer_string.as_string_view(), channel_args.GetBool(GRPC_ARG_HTTP2_BDP_PROBE).value_or(true), @@ -588,13 +576,6 @@ grpc_chttp2_transport::grpc_chttp2_transport( read_channel_args(this, channel_args, is_client); - // No pings allowed before receiving a header or data frame. - ping_state.pings_before_data_required = 0; - ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); - - ping_recv_state.last_ping_recv_time = grpc_core::Timestamp::InfPast(); - ping_recv_state.ping_strikes = 0; - grpc_core::ExecCtx exec_ctx; combiner->Run( GRPC_CLOSURE_INIT(&init_keepalive_ping_locked, @@ -663,10 +644,10 @@ static void close_transport_locked(grpc_chttp2_transport* t, t->closed_with_error = error; connectivity_state_set(t, GRPC_CHANNEL_SHUTDOWN, absl::Status(), "close_transport"); - if (t->ping_state.delayed_ping_timer_handle.has_value()) { - if (t->event_engine->Cancel(*t->ping_state.delayed_ping_timer_handle)) { + if (t->delayed_ping_timer_handle.has_value()) { + if (t->event_engine->Cancel(*t->delayed_ping_timer_handle)) { GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked"); - t->ping_state.delayed_ping_timer_handle.reset(); + t->delayed_ping_timer_handle.reset(); } } if (t->next_bdp_ping_timer_handle.has_value()) { @@ -1673,8 +1654,8 @@ static void retry_initiate_ping_locked(void* tp, GRPC_UNUSED grpc_error_handle error) { GPR_DEBUG_ASSERT(error.ok()); grpc_chttp2_transport* t = static_cast(tp); - GPR_ASSERT(t->ping_state.delayed_ping_timer_handle.has_value()); - t->ping_state.delayed_ping_timer_handle.reset(); + GPR_ASSERT(t->delayed_ping_timer_handle.has_value()); + t->delayed_ping_timer_handle.reset(); grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_RETRY_SEND_PING); GRPC_CHTTP2_UNREF_TRANSPORT(t, "retry_initiate_ping_locked"); } @@ -1825,29 +1806,24 @@ static void send_goaway(grpc_chttp2_transport* t, grpc_error_handle error, grpc_chttp2_initiate_write(t, GRPC_CHTTP2_INITIATE_WRITE_GOAWAY_SENT); } -void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t) { - if (++t->ping_recv_state.ping_strikes > t->ping_policy.max_ping_strikes && - t->ping_policy.max_ping_strikes != 0) { - send_goaway(t, - grpc_error_set_int(GRPC_ERROR_CREATE("too_many_pings"), - grpc_core::StatusIntProperty::kHttp2Error, - GRPC_HTTP2_ENHANCE_YOUR_CALM), - /*immediate_disconnect_hint=*/true); - // The transport will be closed after the write is done - close_transport_locked( - t, grpc_error_set_int(GRPC_ERROR_CREATE("Too many pings"), - grpc_core::StatusIntProperty::kRpcStatus, - GRPC_STATUS_UNAVAILABLE)); - } +void grpc_chttp2_exceeded_ping_strikes(grpc_chttp2_transport* t) { + send_goaway(t, + grpc_error_set_int(GRPC_ERROR_CREATE("too_many_pings"), + grpc_core::StatusIntProperty::kHttp2Error, + GRPC_HTTP2_ENHANCE_YOUR_CALM), + /*immediate_disconnect_hint=*/true); + // The transport will be closed after the write is done + close_transport_locked( + t, grpc_error_set_int(GRPC_ERROR_CREATE("Too many pings"), + grpc_core::StatusIntProperty::kRpcStatus, + GRPC_STATUS_UNAVAILABLE)); } void grpc_chttp2_reset_ping_clock(grpc_chttp2_transport* t) { if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = grpc_core::Timestamp::InfPast(); - t->ping_recv_state.ping_strikes = 0; + t->ping_abuse_policy.ResetPingStrikes(); } - t->ping_state.pings_before_data_required = - t->ping_policy.max_pings_without_data; + t->ping_rate_policy.ResetPingsBeforeDataRequired(); } static void perform_transport_op_locked(void* stream_op, @@ -2736,20 +2712,8 @@ void grpc_chttp2_config_default_keepalive_args( keepalive_permit_without_calls; } - g_default_max_ping_strikes = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) - .value_or(g_default_max_ping_strikes)); - - g_default_max_pings_without_data = - std::max(0, channel_args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) - .value_or(g_default_max_pings_without_data)); - - g_default_min_recv_ping_interval_without_data = - std::max(grpc_core::Duration::Zero(), - channel_args - .GetDurationFromIntMillis( - GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) - .value_or(g_default_min_recv_ping_interval_without_data)); + grpc_core::Chttp2PingAbusePolicy::SetDefaults(channel_args); + grpc_core::Chttp2PingRatePolicy::SetDefaults(channel_args); } static void init_keepalive_ping(grpc_chttp2_transport* t) { diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.cc b/src/core/ext/transport/chttp2/transport/frame_ping.cc index 8cf45a59dcf..18a73a3cab2 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.cc +++ b/src/core/ext/transport/chttp2/transport/frame_ping.cc @@ -33,7 +33,7 @@ #include #include "src/core/ext/transport/chttp2/transport/internal.h" -#include "src/core/lib/gprpp/time.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) { grpc_slice slice = GRPC_SLICE_MALLOC(9 + 8); @@ -94,24 +94,11 @@ grpc_error_handle grpc_chttp2_ping_parser_parse(void* parser, grpc_chttp2_ack_ping(t, p->opaque_8bytes); } else { if (!t->is_client) { - grpc_core::Timestamp now = grpc_core::Timestamp::Now(); - grpc_core::Timestamp next_allowed_ping = - t->ping_recv_state.last_ping_recv_time + - t->ping_policy.min_recv_ping_interval_without_data; - - if (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) { - // According to RFC1122, the interval of TCP Keep-Alive is default to - // no less than two hours. When there is no outstanding streams, we - // restrict the number of PINGS equivalent to TCP Keep-Alive. - next_allowed_ping = t->ping_recv_state.last_ping_recv_time + - grpc_core::Duration::Hours(2); - } - - if (next_allowed_ping > now) { - grpc_chttp2_add_ping_strike(t); + const bool transport_idle = + t->keepalive_permit_without_calls == 0 && t->stream_map.empty(); + if (t->ping_abuse_policy.ReceivedOnePing(transport_idle)) { + grpc_chttp2_exceeded_ping_strikes(t); } - - t->ping_recv_state.last_ping_recv_time = now; } if (t->ack_pings) { if (t->ping_ack_count == t->ping_ack_capacity) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 479c7518e2e..807a105ebda 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -48,6 +48,8 @@ #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" @@ -146,21 +148,14 @@ struct grpc_chttp2_ping_queue { grpc_closure_list lists[GRPC_CHTTP2_PCL_COUNT] = {}; uint64_t inflight_id = 0; }; -struct grpc_chttp2_repeated_ping_policy { - int max_pings_without_data; - int max_ping_strikes; - grpc_core::Duration min_recv_ping_interval_without_data; -}; + struct grpc_chttp2_repeated_ping_state { grpc_core::Timestamp last_ping_sent_time; int pings_before_data_required; absl::optional delayed_ping_timer_handle; }; -struct grpc_chttp2_server_ping_recv_state { - grpc_core::Timestamp last_ping_recv_time; - int ping_strikes; -}; + // deframer state for the overall http2 stream of bytes typedef enum { // prefix: one entry per http2 connection prefix byte @@ -343,8 +338,10 @@ struct grpc_chttp2_transport : public grpc_core::KeepsGrpcInitialized { /// ping queues for various ping insertion points grpc_chttp2_ping_queue ping_queue = grpc_chttp2_ping_queue(); - grpc_chttp2_repeated_ping_policy ping_policy; - grpc_chttp2_repeated_ping_state ping_state; + grpc_core::Chttp2PingAbusePolicy ping_abuse_policy; + grpc_core::Chttp2PingRatePolicy ping_rate_policy; + absl::optional + delayed_ping_timer_handle; uint64_t ping_ctr = 0; // unique id for pings grpc_closure retry_initiate_ping_locked; @@ -352,7 +349,6 @@ struct grpc_chttp2_transport : public grpc_core::KeepsGrpcInitialized { size_t ping_ack_count = 0; size_t ping_ack_capacity = 0; uint64_t* ping_acks = nullptr; - grpc_chttp2_server_ping_recv_state ping_recv_state; /// parser for headers grpc_core::HPackParser hpack_parser; @@ -772,11 +768,9 @@ inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id); -/// Add a new ping strike to ping_recv_state.ping_strikes. If -/// ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY -/// with error code ENHANCE_YOUR_CALM and additional debug data resembling -/// "too_many_pings" followed by immediately closing the connection. -void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t); +/// Sends GOAWAY with error code ENHANCE_YOUR_CALM and additional debug data +/// resembling "too_many_pings" followed by immediately closing the connection. +void grpc_chttp2_exceeded_ping_strikes(grpc_chttp2_transport* t); /// Resets ping clock. Should be called when flushing window updates, /// initial/trailing metadata or data frames. For a server, it resets the number diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index 9fd94629721..f5ed79108e9 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -47,11 +47,11 @@ #include "src/core/ext/transport/chttp2/transport/http2_settings.h" #include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/status_helper.h" -#include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/endpoint.h" @@ -549,7 +549,7 @@ error_handler: t->incoming_stream = s; t->parser = grpc_chttp2_transport::Parser{ "data", grpc_chttp2_data_parser_parse, nullptr}; - t->ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); + t->ping_rate_policy.ReceivedDataFrame(); return absl::OkStatus(); } else if (s != nullptr) { // handle stream errors by closing the stream @@ -588,7 +588,7 @@ static grpc_error_handle init_header_frame_parser(grpc_chttp2_transport* t, ? HPackParser::Priority::Included : HPackParser::Priority::None; - t->ping_state.last_ping_sent_time = grpc_core::Timestamp::InfPast(); + t->ping_rate_policy.ReceivedDataFrame(); // could be a new grpc_chttp2_stream or an existing grpc_chttp2_stream s = grpc_chttp2_parsing_lookup_stream(t, t->incoming_stream_id); diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc new file mode 100644 index 00000000000..1ace22dd9a8 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc @@ -0,0 +1,80 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" + +#include + +#include "absl/types/optional.h" + +#include + +namespace grpc_core { + +namespace { +Duration g_default_min_recv_ping_interval_without_data = Duration::Minutes(5); +int g_default_max_ping_strikes = 2; +} // namespace + +Chttp2PingAbusePolicy::Chttp2PingAbusePolicy(const ChannelArgs& args) + : min_recv_ping_interval_without_data_(std::max( + Duration::Zero(), + args.GetDurationFromIntMillis( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) + .value_or(g_default_min_recv_ping_interval_without_data))), + max_ping_strikes_( + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) + .value_or(g_default_max_ping_strikes))) {} + +void Chttp2PingAbusePolicy::SetDefaults(const ChannelArgs& args) { + g_default_max_ping_strikes = + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PING_STRIKES) + .value_or(g_default_max_ping_strikes)); + g_default_min_recv_ping_interval_without_data = + std::max(Duration::Zero(), + args.GetDurationFromIntMillis( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS) + .value_or(g_default_min_recv_ping_interval_without_data)); +} + +bool Chttp2PingAbusePolicy::ReceivedOnePing(bool transport_idle) { + const Timestamp now = Timestamp::Now(); + const Timestamp next_allowed_ping = + last_ping_recv_time_ + RecvPingIntervalWithoutData(transport_idle); + last_ping_recv_time_ = now; + if (next_allowed_ping <= now) return false; + // Received ping too soon: increment strike count. + ++ping_strikes_; + return ping_strikes_ > max_ping_strikes_ && max_ping_strikes_ != 0; +} + +Duration Chttp2PingAbusePolicy::RecvPingIntervalWithoutData( + bool transport_idle) const { + if (transport_idle) { + // According to RFC1122, the interval of TCP Keep-Alive is default to + // no less than two hours. When there is no outstanding streams, we + // restrict the number of PINGS equivalent to TCP Keep-Alive. + return Duration::Hours(2); + } + return min_recv_ping_interval_without_data_; +} + +void Chttp2PingAbusePolicy::ResetPingStrikes() { + last_ping_recv_time_ = Timestamp::InfPast(); + ping_strikes_ = 0; +} + +} // namespace grpc_core diff --git a/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h new file mode 100644 index 00000000000..adc5cb79699 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h @@ -0,0 +1,55 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H + +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/time.h" + +namespace grpc_core { + +class Chttp2PingAbusePolicy { + public: + explicit Chttp2PingAbusePolicy(const ChannelArgs& args); + + static void SetDefaults(const ChannelArgs& args); + + // Record one received ping; returns true if the connection should be closed. + // If transport_idle is true, we increase the allowed time between pings up to + // TCP keep-alive check time. + GRPC_MUST_USE_RESULT bool ReceivedOnePing(bool transport_idle); + + // Reset the ping clock, strike count. + void ResetPingStrikes(); + + int TestOnlyMaxPingStrikes() const { return max_ping_strikes_; } + Duration TestOnlyMinPingIntervalWithoutData() const { + return min_recv_ping_interval_without_data_; + } + + private: + Duration RecvPingIntervalWithoutData(bool transport_idle) const; + + Timestamp last_ping_recv_time_ = Timestamp::InfPast(); + const Duration min_recv_ping_interval_without_data_; + int ping_strikes_ = 0; + const int max_ping_strikes_; +}; + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_ABUSE_POLICY_H diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc new file mode 100644 index 00000000000..51b7b38d578 --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc @@ -0,0 +1,98 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" + +#include +#include +#include + +#include "absl/strings/str_cat.h" +#include "absl/types/optional.h" + +#include + +#include "src/core/lib/gprpp/match.h" + +namespace grpc_core { + +namespace { +int g_default_max_pings_without_data = 2; +} // namespace + +Chttp2PingRatePolicy::Chttp2PingRatePolicy(const ChannelArgs& args, + bool is_client) + : max_pings_without_data_( + is_client + ? std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) + .value_or(g_default_max_pings_without_data)) + : 0) {} + +void Chttp2PingRatePolicy::SetDefaults(const ChannelArgs& args) { + g_default_max_pings_without_data = + std::max(0, args.GetInt(GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA) + .value_or(g_default_max_pings_without_data)); +} + +Chttp2PingRatePolicy::RequestSendPingResult +Chttp2PingRatePolicy::RequestSendPing(Duration next_allowed_ping_interval) { + if (max_pings_without_data_ != 0 && pings_before_data_required_ == 0) { + return TooManyRecentPings{}; + } + const Timestamp next_allowed_ping = + last_ping_sent_time_ + next_allowed_ping_interval; + const Timestamp now = Timestamp::Now(); + if (next_allowed_ping > now) { + return TooSoon{next_allowed_ping_interval, last_ping_sent_time_, + next_allowed_ping - now}; + } + last_ping_sent_time_ = now; + if (pings_before_data_required_) --pings_before_data_required_; + return SendGranted{}; +} + +void Chttp2PingRatePolicy::ReceivedDataFrame() { + last_ping_sent_time_ = Timestamp::InfPast(); +} + +void Chttp2PingRatePolicy::ResetPingsBeforeDataRequired() { + pings_before_data_required_ = max_pings_without_data_; +} + +std::string Chttp2PingRatePolicy::GetDebugString() const { + return absl::StrCat( + "max_pings_without_data: ", max_pings_without_data_, + ", pings_before_data_required: ", pings_before_data_required_, + ", last_ping_sent_time_: ", last_ping_sent_time_.ToString()); +} + +std::ostream& operator<<(std::ostream& out, + const Chttp2PingRatePolicy::RequestSendPingResult& r) { + Match( + r, [&out](Chttp2PingRatePolicy::SendGranted) { out << "SendGranted"; }, + [&out](Chttp2PingRatePolicy::TooManyRecentPings) { + out << "TooManyRecentPings"; + }, + [&out](Chttp2PingRatePolicy::TooSoon r) { + out << "TooSoon: next_allowed=" + << r.next_allowed_ping_interval.ToString() + << " last_ping_sent_time=" << r.last_ping.ToString() + << " wait=" << r.wait.ToString(); + }); + return out; +} + +} // namespace grpc_core diff --git a/src/core/ext/transport/chttp2/transport/ping_rate_policy.h b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h new file mode 100644 index 00000000000..7363259fb8b --- /dev/null +++ b/src/core/ext/transport/chttp2/transport/ping_rate_policy.h @@ -0,0 +1,73 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H +#define GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H + +#include + +#include +#include + +#include "absl/types/variant.h" + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/gprpp/time.h" + +namespace grpc_core { + +class Chttp2PingRatePolicy { + public: + explicit Chttp2PingRatePolicy(const ChannelArgs& args, bool is_client); + + static void SetDefaults(const ChannelArgs& args); + + struct SendGranted { + bool operator==(const SendGranted&) const { return true; } + }; + struct TooManyRecentPings { + bool operator==(const TooManyRecentPings&) const { return true; } + }; + struct TooSoon { + Duration next_allowed_ping_interval; + Timestamp last_ping; + Duration wait; + bool operator==(const TooSoon& other) const { + return next_allowed_ping_interval == other.next_allowed_ping_interval && + last_ping == other.last_ping && wait == other.wait; + } + }; + using RequestSendPingResult = + absl::variant; + + RequestSendPingResult RequestSendPing(Duration next_allowed_ping_interval); + void ResetPingsBeforeDataRequired(); + void ReceivedDataFrame(); + std::string GetDebugString() const; + + int TestOnlyMaxPingsWithoutData() const { return max_pings_without_data_; } + + private: + const int max_pings_without_data_; + // No pings allowed before receiving a header or data frame. + int pings_before_data_required_ = 0; + Timestamp last_ping_sent_time_ = Timestamp::InfPast(); +}; + +std::ostream& operator<<(std::ostream& out, + const Chttp2PingRatePolicy::RequestSendPingResult& r); + +} // namespace grpc_core + +#endif // GRPC_SRC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_PING_RATE_POLICY_H diff --git a/src/core/ext/transport/chttp2/transport/writing.cc b/src/core/ext/transport/chttp2/transport/writing.cc index f24c852d73a..e949f410246 100644 --- a/src/core/ext/transport/chttp2/transport/writing.cc +++ b/src/core/ext/transport/chttp2/transport/writing.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include "absl/container/flat_hash_map.h" #include "absl/status/status.h" @@ -35,10 +36,6 @@ #include #include -#include "src/core/ext/transport/chttp2/transport/http_trace.h" - -// IWYU pragma: no_include "src/core/lib/gprpp/orphanable.h" - #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/context_list_entry.h" #include "src/core/ext/transport/chttp2/transport/flow_control.h" @@ -50,12 +47,15 @@ #include "src/core/ext/transport/chttp2/transport/frame_window_update.h" #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" +#include "src/core/ext/transport/chttp2/transport/http_trace.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/stats.h" #include "src/core/lib/debug/stats_data.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/debug_location.h" +#include "src/core/lib/gprpp/match.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" @@ -69,6 +69,8 @@ #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" +// IWYU pragma: no_include "src/core/lib/gprpp/orphanable.h" + static void add_to_write_list(grpc_chttp2_write_cb** list, grpc_chttp2_write_cb* cb) { cb->next = *list; @@ -83,6 +85,25 @@ static void finish_write_cb(grpc_chttp2_transport* t, grpc_chttp2_stream* s, t->write_cb_pool = cb; } +static grpc_core::Duration NextAllowedPingInterval(grpc_chttp2_transport* t) { + if (t->is_client) { + return (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) + ? grpc_core::Duration::Hours(2) + : grpc_core::Duration::Seconds( + 1); // A second is added to deal with + // network delays and timing imprecision + } + if (t->sent_goaway_state != GRPC_CHTTP2_GRACEFUL_GOAWAY) { + // The gRPC keepalive spec doesn't call for any throttling on the server + // side, but we are adding some throttling for protection anyway, unless + // we are doing a graceful GOAWAY in which case we don't want to wait. + return t->keepalive_time == grpc_core::Duration::Infinity() + ? grpc_core::Duration::Seconds(20) + : t->keepalive_time / 2; + } + return grpc_core::Duration::Zero(); +} + static void maybe_initiate_ping(grpc_chttp2_transport* t) { grpc_chttp2_ping_queue* pq = &t->ping_queue; if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) { @@ -100,95 +121,67 @@ static void maybe_initiate_ping(grpc_chttp2_transport* t) { } return; } - if (t->is_client && t->ping_state.pings_before_data_required == 0 && - t->ping_policy.max_pings_without_data != 0) { - // need to receive something of substance before sending a ping again - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log(GPR_INFO, - "CLIENT: Ping delayed [%s]: too many recent pings: %d/%d", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.pings_before_data_required, - t->ping_policy.max_pings_without_data); - } - return; - } // InvalidateNow to avoid getting stuck re-initializing the ping timer // in a loop while draining the currently-held combiner. Also see // https://github.com/grpc/grpc/issues/26079. grpc_core::ExecCtx::Get()->InvalidateNow(); - grpc_core::Timestamp now = grpc_core::Timestamp::Now(); - - grpc_core::Duration next_allowed_ping_interval = grpc_core::Duration::Zero(); - if (t->is_client) { - next_allowed_ping_interval = - (t->keepalive_permit_without_calls == 0 && t->stream_map.empty()) - ? grpc_core::Duration::Hours(2) - : grpc_core::Duration::Seconds( - 1); // A second is added to deal with - // network delays and timing imprecision - } else if (t->sent_goaway_state != GRPC_CHTTP2_GRACEFUL_GOAWAY) { - // The gRPC keepalive spec doesn't call for any throttling on the server - // side, but we are adding some throttling for protection anyway, unless - // we are doing a graceful GOAWAY in which case we don't want to wait. - next_allowed_ping_interval = - t->keepalive_time == grpc_core::Duration::Infinity() - ? grpc_core::Duration::Seconds(20) - : t->keepalive_time / 2; - } - grpc_core::Timestamp next_allowed_ping = - t->ping_state.last_ping_sent_time + next_allowed_ping_interval; - - if (next_allowed_ping > now) { - // not enough elapsed time between successive pings - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log( - GPR_INFO, - "%s: Ping delayed [%s]: not enough time elapsed since last " - "ping. " - " Last ping %" PRId64 ": Next ping %" PRId64 ": Now %" PRId64, - t->is_client ? "CLIENT" : "SERVER", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.last_ping_sent_time.milliseconds_after_process_epoch(), - next_allowed_ping.milliseconds_after_process_epoch(), - now.milliseconds_after_process_epoch()); - } - if (!t->ping_state.delayed_ping_timer_handle.has_value()) { - GRPC_CHTTP2_REF_TRANSPORT(t, "retry_initiate_ping_locked"); - t->ping_state.delayed_ping_timer_handle = - t->event_engine->RunAfter(next_allowed_ping - now, [t] { - grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; - grpc_core::ExecCtx exec_ctx; - grpc_chttp2_retry_initiate_ping(t); - }); - } - return; - } - t->ping_state.last_ping_sent_time = now; - - pq->inflight_id = t->ping_ctr; - t->ping_ctr++; - grpc_core::ExecCtx::RunList(DEBUG_LOCATION, - &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); - grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], - &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(false, pq->inflight_id)); - grpc_core::global_stats().IncrementHttp2PingsSent(); - if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || - GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { - gpr_log(GPR_INFO, "%s: Ping sent [%s]: %d/%d", - t->is_client ? "CLIENT" : "SERVER", - std::string(t->peer_string.as_string_view()).c_str(), - t->ping_state.pings_before_data_required, - t->ping_policy.max_pings_without_data); - } - t->ping_state.pings_before_data_required -= - (t->ping_state.pings_before_data_required != 0); + Match( + t->ping_rate_policy.RequestSendPing(NextAllowedPingInterval(t)), + [pq, t](grpc_core::Chttp2PingRatePolicy::SendGranted) { + pq->inflight_id = t->ping_ctr; + t->ping_ctr++; + grpc_core::ExecCtx::RunList(DEBUG_LOCATION, + &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); + grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], + &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(false, pq->inflight_id)); + grpc_core::global_stats().IncrementHttp2PingsSent(); + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, "%s: Ping sent [%s]: %s", + t->is_client ? "CLIENT" : "SERVER", + std::string(t->peer_string.as_string_view()).c_str(), + t->ping_rate_policy.GetDebugString().c_str()); + } + }, + [t](grpc_core::Chttp2PingRatePolicy::TooManyRecentPings) { + // need to receive something of substance before sending a ping again + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, + "CLIENT: Ping delayed [%s]: too many recent pings: %s", + std::string(t->peer_string.as_string_view()).c_str(), + t->ping_rate_policy.GetDebugString().c_str()); + } + }, + [t](grpc_core::Chttp2PingRatePolicy::TooSoon too_soon) { + // not enough elapsed time between successive pings + if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_bdp_estimator_trace) || + GRPC_TRACE_FLAG_ENABLED(grpc_keepalive_trace)) { + gpr_log(GPR_INFO, + "%s: Ping delayed [%s]: not enough time elapsed since last " + "ping. " + " Last ping:%s, minimum wait:%s need to wait:%s", + t->is_client ? "CLIENT" : "SERVER", + std::string(t->peer_string.as_string_view()).c_str(), + too_soon.last_ping.ToString().c_str(), + too_soon.next_allowed_ping_interval.ToString().c_str(), + too_soon.wait.ToString().c_str()); + } + if (!t->delayed_ping_timer_handle.has_value()) { + GRPC_CHTTP2_REF_TRANSPORT(t, "retry_initiate_ping_locked"); + t->delayed_ping_timer_handle = + t->event_engine->RunAfter(too_soon.wait, [t] { + grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; + grpc_core::ExecCtx exec_ctx; + grpc_chttp2_retry_initiate_ping(t); + }); + } + }); } static bool update_list(grpc_chttp2_transport* t, grpc_chttp2_stream* s, diff --git a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc index f5e602fc89c..5cc1d5b554c 100644 --- a/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc +++ b/src/core/ext/transport/cronet/client/secure/cronet_channel_create.cc @@ -22,6 +22,7 @@ #include "absl/status/statusor.h" +#include #include #include "src/core/ext/transport/cronet/transport/cronet_transport.h" diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index e1dfbb33b71..270639362a0 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -37,6 +37,7 @@ #include "absl/types/optional.h" #include "third_party/objective_c/Cronet/bidirectional_stream_c.h" +#include #include #include #include diff --git a/src/core/ext/transport/inproc/inproc_transport.cc b/src/core/ext/transport/inproc/inproc_transport.cc index b4185e454c0..fb9bd9d6fe9 100644 --- a/src/core/ext/transport/inproc/inproc_transport.cc +++ b/src/core/ext/transport/inproc/inproc_transport.cc @@ -35,6 +35,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/src/core/ext/xds/xds_client_grpc.cc b/src/core/ext/xds/xds_client_grpc.cc index ca14f536266..7df4c36a5b2 100644 --- a/src/core/ext/xds/xds_client_grpc.cc +++ b/src/core/ext/xds/xds_client_grpc.cc @@ -30,6 +30,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/src/core/ext/xds/xds_transport_grpc.cc b/src/core/ext/xds/xds_transport_grpc.cc index 9c0cc48cf13..1a012416106 100644 --- a/src/core/ext/xds/xds_transport_grpc.cc +++ b/src/core/ext/xds/xds_transport_grpc.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/lib/channel/channel_args.cc b/src/core/lib/channel/channel_args.cc index fe8c4761c6c..1e76d6dca6d 100644 --- a/src/core/lib/channel/channel_args.cc +++ b/src/core/lib/channel/channel_args.cc @@ -34,6 +34,7 @@ #include "absl/strings/str_format.h" #include "absl/strings/str_join.h" +#include #include #include #include diff --git a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc index 1841212d58a..326248cb846 100644 --- a/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +++ b/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc @@ -27,6 +27,7 @@ #include "absl/types/optional.h" #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/crash.h" // IWYU pragma: keep diff --git a/src/core/lib/http/httpcli_security_connector.cc b/src/core/lib/http/httpcli_security_connector.cc index d99befef099..22efdc30034 100644 --- a/src/core/lib/http/httpcli_security_connector.cc +++ b/src/core/lib/http/httpcli_security_connector.cc @@ -29,6 +29,7 @@ #include #include +#include #include #include #include diff --git a/src/core/lib/resource_quota/api.cc b/src/core/lib/resource_quota/api.cc index 5c5a4dd6978..302b5d1a86e 100644 --- a/src/core/lib/resource_quota/api.cc +++ b/src/core/lib/resource_quota/api.cc @@ -26,6 +26,7 @@ #include "absl/strings/str_cat.h" #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" diff --git a/src/core/lib/resource_quota/resource_quota.h b/src/core/lib/resource_quota/resource_quota.h index 25da8218dbd..f6dde768daa 100644 --- a/src/core/lib/resource_quota/resource_quota.h +++ b/src/core/lib/resource_quota/resource_quota.h @@ -23,6 +23,7 @@ #include "absl/strings/string_view.h" #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/cpp_impl_of.h" diff --git a/src/core/lib/security/authorization/authorization_policy_provider.h b/src/core/lib/security/authorization/authorization_policy_provider.h index 6f93c7fb964..e5bee1a5e0c 100644 --- a/src/core/lib/security/authorization/authorization_policy_provider.h +++ b/src/core/lib/security/authorization/authorization_policy_provider.h @@ -19,8 +19,8 @@ #include "absl/strings/string_view.h" -#include #include +#include #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/dual_ref_counted.h" diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.cc b/src/core/lib/security/credentials/google_default/google_default_credentials.cc index 6d2eb20cda3..3601adae6a2 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.cc +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.cc @@ -32,6 +32,7 @@ #include // IWYU pragma: keep #include +#include #include #include #include diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.cc b/src/core/lib/security/credentials/ssl/ssl_credentials.cc index 86a220bf795..e31225e82ff 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.cc +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.cc @@ -28,6 +28,7 @@ #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include #include #include #include diff --git a/src/core/lib/security/credentials/tls/tls_credentials.cc b/src/core/lib/security/credentials/tls/tls_credentials.cc index 7548121ee13..34f27c0d593 100644 --- a/src/core/lib/security/credentials/tls/tls_credentials.cc +++ b/src/core/lib/security/credentials/tls/tls_credentials.cc @@ -28,6 +28,7 @@ #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/src/core/lib/security/credentials/xds/xds_credentials.cc b/src/core/lib/security/credentials/xds/xds_credentials.cc index 7d0035a988a..9d9fe3df2a7 100644 --- a/src/core/lib/security/credentials/xds/xds_credentials.cc +++ b/src/core/lib/security/credentials/xds/xds_credentials.cc @@ -24,6 +24,7 @@ #include "absl/types/optional.h" #include +#include #include #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h" diff --git a/src/core/lib/security/security_connector/alts/alts_security_connector.cc b/src/core/lib/security/security_connector/alts/alts_security_connector.cc index 5f6c7a738d8..5e64e8d49d3 100644 --- a/src/core/lib/security/security_connector/alts/alts_security_connector.cc +++ b/src/core/lib/security/security_connector/alts/alts_security_connector.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/src/core/lib/security/security_connector/fake/fake_security_connector.cc b/src/core/lib/security/security_connector/fake/fake_security_connector.cc index d316face739..384da2cd480 100644 --- a/src/core/lib/security/security_connector/fake/fake_security_connector.cc +++ b/src/core/lib/security/security_connector/fake/fake_security_connector.cc @@ -34,6 +34,7 @@ #include "absl/types/optional.h" #include +#include #include #include #include diff --git a/src/core/lib/security/security_connector/ssl_utils.cc b/src/core/lib/security/security_connector/ssl_utils.cc index fc51a6f57a6..230be953dcc 100644 --- a/src/core/lib/security/security_connector/ssl_utils.cc +++ b/src/core/lib/security/security_connector/ssl_utils.cc @@ -30,6 +30,7 @@ #include "absl/strings/str_split.h" #include +#include #include #include #include diff --git a/src/core/lib/security/transport/security_handshaker.cc b/src/core/lib/security/transport/security_handshaker.cc index 21227d65687..3f629517ef0 100644 --- a/src/core/lib/security/transport/security_handshaker.cc +++ b/src/core/lib/security/transport/security_handshaker.cc @@ -36,6 +36,7 @@ #include #include +#include #include #include #include diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 0448134a04a..2d47449c02e 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -32,6 +32,7 @@ #include #include +#include #include #include #include diff --git a/src/core/lib/surface/init.cc b/src/core/lib/surface/init.cc index 32d72fb2ae2..e5ff4f88657 100644 --- a/src/core/lib/surface/init.cc +++ b/src/core/lib/surface/init.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 9c67a82cfe6..e2a2bbca1f7 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -40,6 +40,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/common/channel_arguments.cc b/src/cpp/common/channel_arguments.cc index d593b271db2..b975b2e4edd 100644 --- a/src/cpp/common/channel_arguments.cc +++ b/src/cpp/common/channel_arguments.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/common/secure_channel_arguments.cc b/src/cpp/common/secure_channel_arguments.cc index 3ad0ff9fb7d..66e34506ffb 100644 --- a/src/cpp/common/secure_channel_arguments.cc +++ b/src/cpp/common/secure_channel_arguments.cc @@ -20,6 +20,7 @@ #include #include +#include #include namespace grpc { diff --git a/src/cpp/ext/gcp/BUILD b/src/cpp/ext/gcp/BUILD index cc49fecb1cf..41c9878390d 100644 --- a/src/cpp/ext/gcp/BUILD +++ b/src/cpp/ext/gcp/BUILD @@ -126,6 +126,7 @@ grpc_cc_library( deps = [ "environment_autodetect", "observability_config", + "//:channel_arg_names", "//:event_engine_base_hdrs", "//:gpr", "//:gpr_platform", diff --git a/src/cpp/ext/gcp/observability_logging_sink.cc b/src/cpp/ext/gcp/observability_logging_sink.cc index 84ea2127ed6..2ae582fa54e 100644 --- a/src/cpp/ext/gcp/observability_logging_sink.cc +++ b/src/cpp/ext/gcp/observability_logging_sink.cc @@ -36,6 +36,7 @@ #include "google/logging/v2/logging.pb.h" #include "google/protobuf/text_format.h" +#include #include #include #include diff --git a/src/cpp/server/load_reporter/load_reporting_service_server_builder_option.cc b/src/cpp/server/load_reporter/load_reporting_service_server_builder_option.cc index a9405254301..30f86b06e05 100644 --- a/src/cpp/server/load_reporter/load_reporting_service_server_builder_option.cc +++ b/src/cpp/server/load_reporter/load_reporting_service_server_builder_option.cc @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index efa813af2ba..6f42aaa46bb 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include #include diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 343fb424665..ad40fb29eeb 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 468e401a36a..3a03e18ac08 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -118,6 +118,8 @@ CORE_SOURCE_FILES = [ 'src/core/ext/transport/chttp2/transport/http_trace.cc', 'src/core/ext/transport/chttp2/transport/huffsyms.cc', 'src/core/ext/transport/chttp2/transport/parsing.cc', + 'src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc', + 'src/core/ext/transport/chttp2/transport/ping_rate_policy.cc', 'src/core/ext/transport/chttp2/transport/stream_lists.cc', 'src/core/ext/transport/chttp2/transport/varint.cc', 'src/core/ext/transport/chttp2/transport/writing.cc', diff --git a/test/core/bad_connection/close_fd_test.cc b/test/core/bad_connection/close_fd_test.cc index 6ffc08eaefa..06a68a8478a 100644 --- a/test/core/bad_connection/close_fd_test.cc +++ b/test/core/bad_connection/close_fd_test.cc @@ -28,6 +28,7 @@ #include "absl/status/statusor.h" #include "absl/strings/str_format.h" +#include #include #include #include diff --git a/test/core/bad_ssl/bad_ssl_test.cc b/test/core/bad_ssl/bad_ssl_test.cc index 0b313383663..51d5a95b63f 100644 --- a/test/core/bad_ssl/bad_ssl_test.cc +++ b/test/core/bad_ssl/bad_ssl_test.cc @@ -23,6 +23,7 @@ #include #include +#include #include #include #include diff --git a/test/core/channel/channel_args_test.cc b/test/core/channel/channel_args_test.cc index a7e55f9724a..10a05d35e26 100644 --- a/test/core/channel/channel_args_test.cc +++ b/test/core/channel/channel_args_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/test/core/channel/channel_trace_test.cc b/test/core/channel/channel_trace_test.cc index 5aae3bbcff0..1a346f3da6c 100644 --- a/test/core/channel/channel_trace_test.cc +++ b/test/core/channel/channel_trace_test.cc @@ -26,6 +26,7 @@ #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channelz.h" diff --git a/test/core/channel/channelz_test.cc b/test/core/channel/channelz_test.cc index f9f4ac828dd..5a3750c3e0f 100644 --- a/test/core/channel/channelz_test.cc +++ b/test/core/channel/channelz_test.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/test/core/channel/minimal_stack_is_minimal_test.cc b/test/core/channel/minimal_stack_is_minimal_test.cc index cbdb10b4bb6..7f9fc905af7 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.cc +++ b/test/core/channel/minimal_stack_is_minimal_test.cc @@ -38,6 +38,7 @@ #include "gtest/gtest.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/client_channel/client_channel_test.cc b/test/core/client_channel/client_channel_test.cc index 58f16e2166e..475fd8433eb 100644 --- a/test/core/client_channel/client_channel_test.cc +++ b/test/core/client_channel/client_channel_test.cc @@ -21,7 +21,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include "src/core/ext/filters/client_channel/subchannel_pool_interface.h" #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/client_channel/http_proxy_mapper_test.cc b/test/core/client_channel/http_proxy_mapper_test.cc index a8086cafef8..460a10ef65f 100644 --- a/test/core/client_channel/http_proxy_mapper_test.cc +++ b/test/core/client_channel/http_proxy_mapper_test.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include "src/core/ext/filters/client_channel/http_proxy.h" #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/client_channel/lb_policy/outlier_detection_test.cc b/test/core/client_channel/lb_policy/outlier_detection_test.cc index 907db1b4d19..440b117f2cb 100644 --- a/test/core/client_channel/lb_policy/outlier_detection_test.cc +++ b/test/core/client_channel/lb_policy/outlier_detection_test.cc @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/test/core/client_channel/lb_policy/pick_first_test.cc b/test/core/client_channel/lb_policy/pick_first_test.cc index 46d833d99c2..d9d81ce22d9 100644 --- a/test/core/client_channel/lb_policy/pick_first_test.cc +++ b/test/core/client_channel/lb_policy/pick_first_test.cc @@ -31,6 +31,7 @@ #include "gtest/gtest.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc index 5c00a0755de..998f77398e6 100644 --- a/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc +++ b/test/core/client_channel/resolvers/dns_resolver_cooldown_test.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/test/core/client_channel/retry_service_config_test.cc b/test/core/client_channel/retry_service_config_test.cc index 4ce8d0cf037..b161b6091e8 100644 --- a/test/core/client_channel/retry_service_config_test.cc +++ b/test/core/client_channel/retry_service_config_test.cc @@ -21,6 +21,7 @@ #include "gtest/gtest.h" #include +#include #include #include diff --git a/test/core/end2end/BUILD b/test/core/end2end/BUILD index 29cace309e8..3118dc39520 100644 --- a/test/core/end2end/BUILD +++ b/test/core/end2end/BUILD @@ -95,6 +95,7 @@ grpc_cc_library( hdrs = ["fixtures/proxy.h"], language = "C++", deps = [ + "//:channel_arg_names", "//:gpr", "//:grpc", "//:grpc_public_hdrs", @@ -164,6 +165,7 @@ grpc_cc_library( language = "C++", deps = [ "end2end_test_lib", + "//:channel_arg_names", "//:config", "//:exec_ctx", "//:gpr", @@ -204,6 +206,7 @@ grpc_cc_library( "fixture_support", "http_proxy", "proxy", + "//:channel_arg_names", "//:exec_ctx", "//:gpr", "//:grpc", @@ -472,6 +475,7 @@ grpc_cc_test( language = "C++", deps = [ "cq_verifier", + "//:channel_arg_names", "//:exec_ctx", "//:gpr", "//:grpc_public_hdrs", @@ -514,6 +518,7 @@ grpc_cc_test( language = "C++", deps = [ "cq_verifier", + "//:channel_arg_names", "//:debug_location", "//:exec_ctx", "//:gpr", @@ -595,6 +600,7 @@ grpc_cc_test( "end2end_test_lib", "fixture_support", "ssl_test_data", + "//:channel_arg_names", "//:config_vars", "//:debug_location", "//:gpr", @@ -627,6 +633,7 @@ grpc_cc_test( language = "C++", deps = [ "cq_verifier", + "//:channel_arg_names", "//:config_vars", "//:exec_ctx", "//:gpr", @@ -656,6 +663,7 @@ grpc_cc_test( language = "C++", deps = [ "cq_verifier", + "//:channel_arg_names", "//:config_vars", "//:exec_ctx", "//:gpr", diff --git a/test/core/end2end/connection_refused_test.cc b/test/core/end2end/connection_refused_test.cc index c7f52366af3..a670f4ece5d 100644 --- a/test/core/end2end/connection_refused_test.cc +++ b/test/core/end2end/connection_refused_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/end2end_test_suites.cc b/test/core/end2end/end2end_test_suites.cc index 4a7c133f850..76b0644657e 100644 --- a/test/core/end2end/end2end_test_suites.cc +++ b/test/core/end2end/end2end_test_suites.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_oauth2_common.h b/test/core/end2end/fixtures/h2_oauth2_common.h index bd54b59095c..76e246b0821 100644 --- a/test/core/end2end/fixtures/h2_oauth2_common.h +++ b/test/core/end2end/fixtures/h2_oauth2_common.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h index 2cafcdc8956..1e52f14b02f 100644 --- a/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h +++ b/test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_ssl_tls_common.h b/test/core/end2end/fixtures/h2_ssl_tls_common.h index d8fcf984637..2337dd89ac6 100644 --- a/test/core/end2end/fixtures/h2_ssl_tls_common.h +++ b/test/core/end2end/fixtures/h2_ssl_tls_common.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/h2_tls_common.h b/test/core/end2end/fixtures/h2_tls_common.h index 8854436885f..c9fe5b4925f 100644 --- a/test/core/end2end/fixtures/h2_tls_common.h +++ b/test/core/end2end/fixtures/h2_tls_common.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/proxy.cc b/test/core/end2end/fixtures/proxy.cc index 8e99c5b73a7..ddd96a2138f 100644 --- a/test/core/end2end/fixtures/proxy.cc +++ b/test/core/end2end/fixtures/proxy.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/fixtures/sockpair_fixture.h b/test/core/end2end/fixtures/sockpair_fixture.h index 4c74a6b9b5f..8aa1f715c2e 100644 --- a/test/core/end2end/fixtures/sockpair_fixture.h +++ b/test/core/end2end/fixtures/sockpair_fixture.h @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include +#include #include #include diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index a3f554c7f4d..04766c7ac00 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/end2end/goaway_server_test.cc b/test/core/end2end/goaway_server_test.cc index a876b9a8710..ed64801cdb7 100644 --- a/test/core/end2end/goaway_server_test.cc +++ b/test/core/end2end/goaway_server_test.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/h2_ssl_cert_test.cc b/test/core/end2end/h2_ssl_cert_test.cc index 98501b319dd..aa7a5299be9 100644 --- a/test/core/end2end/h2_ssl_cert_test.cc +++ b/test/core/end2end/h2_ssl_cert_test.cc @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/h2_ssl_session_reuse_test.cc b/test/core/end2end/h2_ssl_session_reuse_test.cc index 1aac4dfd8ff..30c1640c08b 100644 --- a/test/core/end2end/h2_ssl_session_reuse_test.cc +++ b/test/core/end2end/h2_ssl_session_reuse_test.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc index 1a367aa9b3b..9093b8d979c 100644 --- a/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc +++ b/test/core/end2end/h2_tls_peer_property_external_verifier_test.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/end2end/tests/bad_ping.cc b/test/core/end2end/tests/bad_ping.cc index 50759b5bc23..d13a19605b2 100644 --- a/test/core/end2end/tests/bad_ping.cc +++ b/test/core/end2end/tests/bad_ping.cc @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/binary_metadata.cc b/test/core/end2end/tests/binary_metadata.cc index bf0bc83c014..77c1692ff4c 100644 --- a/test/core/end2end/tests/binary_metadata.cc +++ b/test/core/end2end/tests/binary_metadata.cc @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/call_host_override.cc b/test/core/end2end/tests/call_host_override.cc index 9847497bdbc..678e5080373 100644 --- a/test/core/end2end/tests/call_host_override.cc +++ b/test/core/end2end/tests/call_host_override.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/cancel_after_accept.cc b/test/core/end2end/tests/cancel_after_accept.cc index 6abce4a2274..d56272eab0c 100644 --- a/test/core/end2end/tests/cancel_after_accept.cc +++ b/test/core/end2end/tests/cancel_after_accept.cc @@ -21,7 +21,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/cancel_after_round_trip.cc b/test/core/end2end/tests/cancel_after_round_trip.cc index 11c1ed9a105..2e63182a5f7 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.cc +++ b/test/core/end2end/tests/cancel_after_round_trip.cc @@ -21,7 +21,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/channelz.cc b/test/core/end2end/tests/channelz.cc index 8f3b198266f..66c35f5928e 100644 --- a/test/core/end2end/tests/channelz.cc +++ b/test/core/end2end/tests/channelz.cc @@ -23,7 +23,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/compressed_payload.cc b/test/core/end2end/tests/compressed_payload.cc index 50786307ed1..bb8cfe68148 100644 --- a/test/core/end2end/tests/compressed_payload.cc +++ b/test/core/end2end/tests/compressed_payload.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/connectivity.cc b/test/core/end2end/tests/connectivity.cc index 7d527b6dab0..043cbbf103d 100644 --- a/test/core/end2end/tests/connectivity.cc +++ b/test/core/end2end/tests/connectivity.cc @@ -20,6 +20,7 @@ #include "gtest/gtest.h" #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" diff --git a/test/core/end2end/tests/grpc_authz.cc b/test/core/end2end/tests/grpc_authz.cc index e5c307d571c..0de07397ed8 100644 --- a/test/core/end2end/tests/grpc_authz.cc +++ b/test/core/end2end/tests/grpc_authz.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include diff --git a/test/core/end2end/tests/high_initial_seqno.cc b/test/core/end2end/tests/high_initial_seqno.cc index 31c000dd3d9..e891d25ad11 100644 --- a/test/core/end2end/tests/high_initial_seqno.cc +++ b/test/core/end2end/tests/high_initial_seqno.cc @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/hpack_size.cc b/test/core/end2end/tests/hpack_size.cc index fb2e39097db..465de045e03 100644 --- a/test/core/end2end/tests/hpack_size.cc +++ b/test/core/end2end/tests/hpack_size.cc @@ -25,7 +25,7 @@ #include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/invoke_large_request.cc b/test/core/end2end/tests/invoke_large_request.cc index 5a0e83a4fcb..9ea09ab0420 100644 --- a/test/core/end2end/tests/invoke_large_request.cc +++ b/test/core/end2end/tests/invoke_large_request.cc @@ -20,7 +20,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/keepalive_timeout.cc b/test/core/end2end/tests/keepalive_timeout.cc index 1b8e7bb5162..751ca3cb00d 100644 --- a/test/core/end2end/tests/keepalive_timeout.cc +++ b/test/core/end2end/tests/keepalive_timeout.cc @@ -19,7 +19,7 @@ #include "absl/strings/string_view.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/large_metadata.cc b/test/core/end2end/tests/large_metadata.cc index ff2e09d4e4c..d44f5e725ba 100644 --- a/test/core/end2end/tests/large_metadata.cc +++ b/test/core/end2end/tests/large_metadata.cc @@ -24,7 +24,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/max_concurrent_streams.cc b/test/core/end2end/tests/max_concurrent_streams.cc index ff7b609fd35..b8aa9898249 100644 --- a/test/core/end2end/tests/max_concurrent_streams.cc +++ b/test/core/end2end/tests/max_concurrent_streams.cc @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/max_connection_age.cc b/test/core/end2end/tests/max_connection_age.cc index 680b2630882..9a1a47cea03 100644 --- a/test/core/end2end/tests/max_connection_age.cc +++ b/test/core/end2end/tests/max_connection_age.cc @@ -20,7 +20,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/max_connection_idle.cc b/test/core/end2end/tests/max_connection_idle.cc index fea7e0075d9..3c8332f2e33 100644 --- a/test/core/end2end/tests/max_connection_idle.cc +++ b/test/core/end2end/tests/max_connection_idle.cc @@ -21,6 +21,7 @@ #include "gtest/gtest.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/max_message_length.cc b/test/core/end2end/tests/max_message_length.cc index a296aee7871..83c53f01b86 100644 --- a/test/core/end2end/tests/max_message_length.cc +++ b/test/core/end2end/tests/max_message_length.cc @@ -22,7 +22,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/ping.cc b/test/core/end2end/tests/ping.cc index 572696f19d7..61eb6fbeef7 100644 --- a/test/core/end2end/tests/ping.cc +++ b/test/core/end2end/tests/ping.cc @@ -20,6 +20,7 @@ #include "gtest/gtest.h" #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" diff --git a/test/core/end2end/tests/resource_quota_server.cc b/test/core/end2end/tests/resource_quota_server.cc index 64fbbf697e1..680106cd1a1 100644 --- a/test/core/end2end/tests/resource_quota_server.cc +++ b/test/core/end2end/tests/resource_quota_server.cc @@ -26,6 +26,7 @@ #include "gtest/gtest.h" #include +#include #include #include diff --git a/test/core/end2end/tests/retry.cc b/test/core/end2end/tests/retry.cc index 845d4579757..84991d0e42d 100644 --- a/test/core/end2end/tests/retry.cc +++ b/test/core/end2end/tests/retry.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_cancel_after_first_attempt_starts.cc b/test/core/end2end/tests/retry_cancel_after_first_attempt_starts.cc index 48a6c40a2cc..cbe7dcd517d 100644 --- a/test/core/end2end/tests/retry_cancel_after_first_attempt_starts.cc +++ b/test/core/end2end/tests/retry_cancel_after_first_attempt_starts.cc @@ -16,7 +16,7 @@ #include "absl/types/optional.h" -#include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/time.h" diff --git a/test/core/end2end/tests/retry_cancel_during_delay.cc b/test/core/end2end/tests/retry_cancel_during_delay.cc index 41da4a604ee..a45d84293d0 100644 --- a/test/core/end2end/tests/retry_cancel_during_delay.cc +++ b/test/core/end2end/tests/retry_cancel_during_delay.cc @@ -21,7 +21,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc b/test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc index cf73f5e7a62..28b3f04d4a2 100644 --- a/test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc +++ b/test/core/end2end/tests/retry_cancel_with_multiple_send_batches.cc @@ -25,7 +25,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_cancellation.cc b/test/core/end2end/tests/retry_cancellation.cc index bc9b9d8dde2..5944f2b8b70 100644 --- a/test/core/end2end/tests/retry_cancellation.cc +++ b/test/core/end2end/tests/retry_cancellation.cc @@ -21,7 +21,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_disabled.cc b/test/core/end2end/tests/retry_disabled.cc index f7b61ef2fe7..f16295d9475 100644 --- a/test/core/end2end/tests/retry_disabled.cc +++ b/test/core/end2end/tests/retry_disabled.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_exceeds_buffer_size_in_delay.cc b/test/core/end2end/tests/retry_exceeds_buffer_size_in_delay.cc index 5b4b3a32d5c..3a0b681d198 100644 --- a/test/core/end2end/tests/retry_exceeds_buffer_size_in_delay.cc +++ b/test/core/end2end/tests/retry_exceeds_buffer_size_in_delay.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc b/test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc index 7a038020fcb..47476a023b3 100644 --- a/test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc +++ b/test/core/end2end/tests/retry_exceeds_buffer_size_in_initial_batch.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc b/test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc index 65aed1db8d6..1d6669c1121 100644 --- a/test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc +++ b/test/core/end2end/tests/retry_exceeds_buffer_size_in_subsequent_batch.cc @@ -21,7 +21,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_lb_drop.cc b/test/core/end2end/tests/retry_lb_drop.cc index 70a593342b2..b711a9aa0b1 100644 --- a/test/core/end2end/tests/retry_lb_drop.cc +++ b/test/core/end2end/tests/retry_lb_drop.cc @@ -25,6 +25,7 @@ #include "gtest/gtest.h" #include +#include #include #include diff --git a/test/core/end2end/tests/retry_lb_fail.cc b/test/core/end2end/tests/retry_lb_fail.cc index ce3d765b715..75d8dca976e 100644 --- a/test/core/end2end/tests/retry_lb_fail.cc +++ b/test/core/end2end/tests/retry_lb_fail.cc @@ -19,7 +19,7 @@ #include "absl/status/status.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_non_retriable_status.cc b/test/core/end2end/tests/retry_non_retriable_status.cc index b4cfbae34ce..45e8b923461 100644 --- a/test/core/end2end/tests/retry_non_retriable_status.cc +++ b/test/core/end2end/tests/retry_non_retriable_status.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_non_retriable_status_before_trailers.cc b/test/core/end2end/tests/retry_non_retriable_status_before_trailers.cc index e54d24466eb..b4a083d687b 100644 --- a/test/core/end2end/tests/retry_non_retriable_status_before_trailers.cc +++ b/test/core/end2end/tests/retry_non_retriable_status_before_trailers.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_per_attempt_recv_timeout.cc b/test/core/end2end/tests/retry_per_attempt_recv_timeout.cc index 97687c16441..20103656be4 100644 --- a/test/core/end2end/tests/retry_per_attempt_recv_timeout.cc +++ b/test/core/end2end/tests/retry_per_attempt_recv_timeout.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_per_attempt_recv_timeout_on_last_attempt.cc b/test/core/end2end/tests/retry_per_attempt_recv_timeout_on_last_attempt.cc index f051f37ea28..45e4ae87058 100644 --- a/test/core/end2end/tests/retry_per_attempt_recv_timeout_on_last_attempt.cc +++ b/test/core/end2end/tests/retry_per_attempt_recv_timeout_on_last_attempt.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_recv_initial_metadata.cc b/test/core/end2end/tests/retry_recv_initial_metadata.cc index 7460caf9e1f..1d7f514fb5f 100644 --- a/test/core/end2end/tests/retry_recv_initial_metadata.cc +++ b/test/core/end2end/tests/retry_recv_initial_metadata.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_recv_message.cc b/test/core/end2end/tests/retry_recv_message.cc index 6b0a586404f..cee5ddfa81d 100644 --- a/test/core/end2end/tests/retry_recv_message.cc +++ b/test/core/end2end/tests/retry_recv_message.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_recv_message_replay.cc b/test/core/end2end/tests/retry_recv_message_replay.cc index 2f7450f6815..ba3000afa14 100644 --- a/test/core/end2end/tests/retry_recv_message_replay.cc +++ b/test/core/end2end/tests/retry_recv_message_replay.cc @@ -22,7 +22,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_recv_trailing_metadata_error.cc b/test/core/end2end/tests/retry_recv_trailing_metadata_error.cc index 886aaa9af57..8f0ddeb2ab1 100644 --- a/test/core/end2end/tests/retry_recv_trailing_metadata_error.cc +++ b/test/core/end2end/tests/retry_recv_trailing_metadata_error.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_send_initial_metadata_refs.cc b/test/core/end2end/tests/retry_send_initial_metadata_refs.cc index 9348801424c..676efd1543c 100644 --- a/test/core/end2end/tests/retry_send_initial_metadata_refs.cc +++ b/test/core/end2end/tests/retry_send_initial_metadata_refs.cc @@ -22,7 +22,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include diff --git a/test/core/end2end/tests/retry_send_op_fails.cc b/test/core/end2end/tests/retry_send_op_fails.cc index a4ca292c143..cc45fe051ac 100644 --- a/test/core/end2end/tests/retry_send_op_fails.cc +++ b/test/core/end2end/tests/retry_send_op_fails.cc @@ -22,7 +22,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_send_recv_batch.cc b/test/core/end2end/tests/retry_send_recv_batch.cc index 3d6e018b7de..95ede4b54cc 100644 --- a/test/core/end2end/tests/retry_send_recv_batch.cc +++ b/test/core/end2end/tests/retry_send_recv_batch.cc @@ -16,7 +16,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_server_pushback_delay.cc b/test/core/end2end/tests/retry_server_pushback_delay.cc index 4039a526bbe..4eacd99fdbb 100644 --- a/test/core/end2end/tests/retry_server_pushback_delay.cc +++ b/test/core/end2end/tests/retry_server_pushback_delay.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_server_pushback_disabled.cc b/test/core/end2end/tests/retry_server_pushback_disabled.cc index e59772fd06c..268bb6a041d 100644 --- a/test/core/end2end/tests/retry_server_pushback_disabled.cc +++ b/test/core/end2end/tests/retry_server_pushback_disabled.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_streaming.cc b/test/core/end2end/tests/retry_streaming.cc index d900c1c44db..d21dd512444 100644 --- a/test/core/end2end/tests/retry_streaming.cc +++ b/test/core/end2end/tests/retry_streaming.cc @@ -22,7 +22,7 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_streaming_after_commit.cc b/test/core/end2end/tests/retry_streaming_after_commit.cc index 2195c5549f4..6a669c46350 100644 --- a/test/core/end2end/tests/retry_streaming_after_commit.cc +++ b/test/core/end2end/tests/retry_streaming_after_commit.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc b/test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc index 63cb8e444a9..f9621b84a24 100644 --- a/test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc +++ b/test/core/end2end/tests/retry_streaming_succeeds_before_replay_finished.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_throttled.cc b/test/core/end2end/tests/retry_throttled.cc index db9789d0c92..3dba07c026b 100644 --- a/test/core/end2end/tests/retry_throttled.cc +++ b/test/core/end2end/tests/retry_throttled.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_too_many_attempts.cc b/test/core/end2end/tests/retry_too_many_attempts.cc index 742db131f64..43c4e82d9c6 100644 --- a/test/core/end2end/tests/retry_too_many_attempts.cc +++ b/test/core/end2end/tests/retry_too_many_attempts.cc @@ -19,7 +19,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_transparent_goaway.cc b/test/core/end2end/tests/retry_transparent_goaway.cc index 631f1954535..a10490df99d 100644 --- a/test/core/end2end/tests/retry_transparent_goaway.cc +++ b/test/core/end2end/tests/retry_transparent_goaway.cc @@ -20,7 +20,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_transparent_max_concurrent_streams.cc b/test/core/end2end/tests/retry_transparent_max_concurrent_streams.cc index 52ba8b809c3..335d934423e 100644 --- a/test/core/end2end/tests/retry_transparent_max_concurrent_streams.cc +++ b/test/core/end2end/tests/retry_transparent_max_concurrent_streams.cc @@ -18,6 +18,7 @@ #include "gtest/gtest.h" #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_transparent_not_sent_on_wire.cc b/test/core/end2end/tests/retry_transparent_not_sent_on_wire.cc index bb808f65aaf..b5766886874 100644 --- a/test/core/end2end/tests/retry_transparent_not_sent_on_wire.cc +++ b/test/core/end2end/tests/retry_transparent_not_sent_on_wire.cc @@ -22,7 +22,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_unref_before_finish.cc b/test/core/end2end/tests/retry_unref_before_finish.cc index 49937bd808c..ceff069e9ce 100644 --- a/test/core/end2end/tests/retry_unref_before_finish.cc +++ b/test/core/end2end/tests/retry_unref_before_finish.cc @@ -16,7 +16,7 @@ #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/retry_unref_before_recv.cc b/test/core/end2end/tests/retry_unref_before_recv.cc index d2a926ec6cf..a11c3c5bc4f 100644 --- a/test/core/end2end/tests/retry_unref_before_recv.cc +++ b/test/core/end2end/tests/retry_unref_before_recv.cc @@ -17,7 +17,7 @@ #include "absl/types/optional.h" #include "gtest/gtest.h" -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/end2end/tests/simple_delayed_request.cc b/test/core/end2end/tests/simple_delayed_request.cc index 495cc649ddc..5758fbe299e 100644 --- a/test/core/end2end/tests/simple_delayed_request.cc +++ b/test/core/end2end/tests/simple_delayed_request.cc @@ -19,6 +19,7 @@ #include "gtest/gtest.h" #include +#include #include #include diff --git a/test/core/event_engine/posix/posix_endpoint_test.cc b/test/core/event_engine/posix/posix_endpoint_test.cc index 265b3c9ddcb..e58bd84bf3e 100644 --- a/test/core/event_engine/posix/posix_endpoint_test.cc +++ b/test/core/event_engine/posix/posix_endpoint_test.cc @@ -32,6 +32,7 @@ #include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/config/config_vars.h" diff --git a/test/core/event_engine/posix/posix_event_engine_connect_test.cc b/test/core/event_engine/posix/posix_event_engine_connect_test.cc index 4d0294b030c..9d988259ee9 100644 --- a/test/core/event_engine/posix/posix_event_engine_connect_test.cc +++ b/test/core/event_engine/posix/posix_event_engine_connect_test.cc @@ -38,6 +38,7 @@ #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/event_engine/test_suite/tests/client_test.cc b/test/core/event_engine/test_suite/tests/client_test.cc index b06f89308b7..47bcf4236f4 100644 --- a/test/core/event_engine/test_suite/tests/client_test.cc +++ b/test/core/event_engine/test_suite/tests/client_test.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/event_engine/test_suite/tests/server_test.cc b/test/core/event_engine/test_suite/tests/server_test.cc index 320ebe6e04c..bbcba7e9352 100644 --- a/test/core/event_engine/test_suite/tests/server_test.cc +++ b/test/core/event_engine/test_suite/tests/server_test.cc @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/handshake/client_ssl.cc b/test/core/handshake/client_ssl.cc index 69f14d17217..bcdc8743d5c 100644 --- a/test/core/handshake/client_ssl.cc +++ b/test/core/handshake/client_ssl.cc @@ -26,6 +26,7 @@ #include "absl/base/thread_annotations.h" #include "gtest/gtest.h" +#include #include #include diff --git a/test/core/http/httpscli_test.cc b/test/core/http/httpscli_test.cc index a4aa918f1df..281ccda4269 100644 --- a/test/core/http/httpscli_test.cc +++ b/test/core/http/httpscli_test.cc @@ -35,6 +35,7 @@ #include "absl/time/time.h" #include +#include #include #include #include diff --git a/test/core/memory_usage/callback_client.cc b/test/core/memory_usage/callback_client.cc index f460ff460f8..59d3ec96dc0 100644 --- a/test/core/memory_usage/callback_client.cc +++ b/test/core/memory_usage/callback_client.cc @@ -29,6 +29,7 @@ #include "absl/flags/parse.h" #include "absl/strings/string_view.h" +#include #include #include #include diff --git a/test/core/memory_usage/client.cc b/test/core/memory_usage/client.cc index 43bcf44b2ec..c7c73b4ad96 100644 --- a/test/core/memory_usage/client.cc +++ b/test/core/memory_usage/client.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/memory_usage/server.cc b/test/core/memory_usage/server.cc index 23eb9ee8659..9ccab48de9c 100644 --- a/test/core/memory_usage/server.cc +++ b/test/core/memory_usage/server.cc @@ -33,6 +33,7 @@ #include #include #include +#include #include #include diff --git a/test/core/surface/num_external_connectivity_watchers_test.cc b/test/core/surface/num_external_connectivity_watchers_test.cc index a276cbc1991..5917330aaa0 100644 --- a/test/core/surface/num_external_connectivity_watchers_test.cc +++ b/test/core/surface/num_external_connectivity_watchers_test.cc @@ -24,6 +24,7 @@ #include #include +#include #include #include #include diff --git a/test/core/surface/sequential_connectivity_test.cc b/test/core/surface/sequential_connectivity_test.cc index ab76f57217c..d9623f22cee 100644 --- a/test/core/surface/sequential_connectivity_test.cc +++ b/test/core/surface/sequential_connectivity_test.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include #include diff --git a/test/core/surface/server_chttp2_test.cc b/test/core/surface/server_chttp2_test.cc index e350676fe7d..3c211a9dd81 100644 --- a/test/core/surface/server_chttp2_test.cc +++ b/test/core/surface/server_chttp2_test.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include "src/core/lib/channel/channel_args.h" diff --git a/test/core/surface/server_test.cc b/test/core/surface/server_test.cc index c1c0535f5b4..9e7d35d3130 100644 --- a/test/core/surface/server_test.cc +++ b/test/core/surface/server_test.cc @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/test/core/transport/chttp2/BUILD b/test/core/transport/chttp2/BUILD index 37ad1c24f44..fff43730be9 100644 --- a/test/core/transport/chttp2/BUILD +++ b/test/core/transport/chttp2/BUILD @@ -160,6 +160,34 @@ grpc_cc_test( ], ) +grpc_cc_test( + name = "ping_abuse_policy_test", + srcs = ["ping_abuse_policy_test.cc"], + external_deps = ["gtest"], + language = "C++", + uses_polling = False, + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + "//test/core/util:grpc_test_util_base", + ], +) + +grpc_cc_test( + name = "ping_rate_policy_test", + srcs = ["ping_rate_policy_test.cc"], + external_deps = ["gtest"], + language = "C++", + uses_polling = False, + deps = [ + "//:gpr", + "//:grpc", + "//test/core/util:grpc_test_util", + "//test/core/util:grpc_test_util_base", + ], +) + grpc_cc_test( name = "ping_configuration_test", srcs = ["ping_configuration_test.cc"], diff --git a/test/core/transport/chttp2/graceful_shutdown_test.cc b/test/core/transport/chttp2/graceful_shutdown_test.cc index e68cb105660..ca6aaa48cf3 100644 --- a/test/core/transport/chttp2/graceful_shutdown_test.cc +++ b/test/core/transport/chttp2/graceful_shutdown_test.cc @@ -38,6 +38,7 @@ #include "gtest/gtest.h" #include +#include #include #include #include diff --git a/test/core/transport/chttp2/ping_abuse_policy_test.cc b/test/core/transport/chttp2/ping_abuse_policy_test.cc new file mode 100644 index 00000000000..279158fb370 --- /dev/null +++ b/test/core/transport/chttp2/ping_abuse_policy_test.cc @@ -0,0 +1,111 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" + +#include +#include + +#include "gtest/gtest.h" + +#include + +namespace grpc_core { +namespace { + +TEST(PingAbusePolicy, NoOp) { + Chttp2PingAbusePolicy policy{ChannelArgs()}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 2); + EXPECT_EQ(policy.TestOnlyMinPingIntervalWithoutData(), Duration::Minutes(5)); +} + +TEST(PingAbusePolicy, WithChannelArgs) { + Chttp2PingAbusePolicy policy{ + ChannelArgs() + .Set(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 100) + .Set(GRPC_ARG_HTTP2_MAX_PING_STRIKES, 42)}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 42); + EXPECT_EQ(policy.TestOnlyMinPingIntervalWithoutData(), + Duration::Milliseconds(100)); +} + +TEST(PingAbusePolicy, ChannelArgsRangeCheck) { + Chttp2PingAbusePolicy policy{ + ChannelArgs() + .Set(GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, -1000) + .Set(GRPC_ARG_HTTP2_MAX_PING_STRIKES, -100)}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 0); + EXPECT_EQ(policy.TestOnlyMinPingIntervalWithoutData(), Duration::Zero()); +} + +TEST(PingAbusePolicy, BasicOut) { + Chttp2PingAbusePolicy policy{ChannelArgs()}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 2); + // First ping ok + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Strike 1... too soon + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Strike 2... too soon + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Strike 3... you're out! + EXPECT_TRUE(policy.ReceivedOnePing(false)); +} + +TEST(PingAbusePolicy, TimePreventsOut) { + Chttp2PingAbusePolicy policy{ChannelArgs().Set( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 1000)}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 2); + // First ping ok + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Strike 1... too soon + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Strike 2... too soon + EXPECT_FALSE(policy.ReceivedOnePing(false)); + // Sleep a bit, allowed + std::this_thread::sleep_for(std::chrono::seconds(2)); + EXPECT_FALSE(policy.ReceivedOnePing(false)); +} + +TEST(PingAbusePolicy, TimerSustains) { + Chttp2PingAbusePolicy policy{ChannelArgs().Set( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 10)}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 2); + for (int i = 0; i < 100; i++) { + EXPECT_FALSE(policy.ReceivedOnePing(false)); + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + } +} + +TEST(PingAbusePolicy, IdleIncreasesTimeout) { + Chttp2PingAbusePolicy policy{ChannelArgs().Set( + GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS, 1000)}; + EXPECT_EQ(policy.TestOnlyMaxPingStrikes(), 2); + // First ping ok + EXPECT_FALSE(policy.ReceivedOnePing(true)); + // Strike 1... too soon + EXPECT_FALSE(policy.ReceivedOnePing(true)); + // Strike 2... too soon + EXPECT_FALSE(policy.ReceivedOnePing(true)); + // Sleep a bit, allowed + std::this_thread::sleep_for(std::chrono::seconds(2)); + EXPECT_TRUE(policy.ReceivedOnePing(true)); +} + +} // namespace +} // namespace grpc_core + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/transport/chttp2/ping_configuration_test.cc b/test/core/transport/chttp2/ping_configuration_test.cc index bac71bc9efe..5bc12bddaa0 100644 --- a/test/core/transport/chttp2/ping_configuration_test.cc +++ b/test/core/transport/chttp2/ping_configuration_test.cc @@ -15,11 +15,14 @@ #include "gtest/gtest.h" #include +#include #include #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/ext/transport/chttp2/transport/ping_abuse_policy.h" +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/event_engine/default_event_engine.h" #include "src/core/lib/experiments/config.h" @@ -57,7 +60,7 @@ TEST_F(ConfigurationTest, ClientKeepaliveDefaults) { EXPECT_EQ(t->keepalive_time, Duration::Infinity()); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_permit_without_calls, false); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 2); + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 2); grpc_transport_destroy(&t->base); } @@ -72,7 +75,7 @@ TEST_F(ConfigurationTest, ClientKeepaliveExplicitArgs) { EXPECT_EQ(t->keepalive_time, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(10)); EXPECT_EQ(t->keepalive_permit_without_calls, true); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 3); + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 3); grpc_transport_destroy(&t->base); } @@ -83,10 +86,11 @@ TEST_F(ConfigurationTest, ServerKeepaliveDefaults) { EXPECT_EQ(t->keepalive_time, Duration::Hours(2)); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_permit_without_calls, false); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 2); - EXPECT_EQ(t->ping_policy.min_recv_ping_interval_without_data, + // Server never limits based on number of pings without data. + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 0); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMinPingIntervalWithoutData(), Duration::Minutes(5)); - EXPECT_EQ(t->ping_policy.max_ping_strikes, 2); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMaxPingStrikes(), 2); grpc_transport_destroy(&t->base); } @@ -104,10 +108,11 @@ TEST_F(ConfigurationTest, ServerKeepaliveExplicitArgs) { EXPECT_EQ(t->keepalive_time, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(10)); EXPECT_EQ(t->keepalive_permit_without_calls, true); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 3); - EXPECT_EQ(t->ping_policy.min_recv_ping_interval_without_data, + // Server never limits based on number of pings without data. + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 0); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMinPingIntervalWithoutData(), Duration::Seconds(20)); - EXPECT_EQ(t->ping_policy.max_ping_strikes, 0); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMaxPingStrikes(), 0); grpc_transport_destroy(&t->base); } @@ -130,7 +135,7 @@ TEST_F(ConfigurationTest, ModifyClientDefaults) { EXPECT_EQ(t->keepalive_time, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(10)); EXPECT_EQ(t->keepalive_permit_without_calls, true); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 3); + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 3); grpc_transport_destroy(&t->base); } @@ -155,10 +160,11 @@ TEST_F(ConfigurationTest, ModifyServerDefaults) { EXPECT_EQ(t->keepalive_time, Duration::Seconds(20)); EXPECT_EQ(t->keepalive_timeout, Duration::Seconds(10)); EXPECT_EQ(t->keepalive_permit_without_calls, true); - EXPECT_EQ(t->ping_policy.max_pings_without_data, 3); - EXPECT_EQ(t->ping_policy.min_recv_ping_interval_without_data, + // Server never limits based on number of pings without data. + EXPECT_EQ(t->ping_rate_policy.TestOnlyMaxPingsWithoutData(), 0); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMinPingIntervalWithoutData(), Duration::Seconds(20)); - EXPECT_EQ(t->ping_policy.max_ping_strikes, 0); + EXPECT_EQ(t->ping_abuse_policy.TestOnlyMaxPingStrikes(), 0); grpc_transport_destroy(&t->base); } diff --git a/test/core/transport/chttp2/ping_rate_policy_test.cc b/test/core/transport/chttp2/ping_rate_policy_test.cc new file mode 100644 index 00000000000..cbe05cd4f22 --- /dev/null +++ b/test/core/transport/chttp2/ping_rate_policy_test.cc @@ -0,0 +1,77 @@ +// Copyright 2023 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/core/ext/transport/chttp2/transport/ping_rate_policy.h" + +#include +#include + +#include "gtest/gtest.h" + +namespace grpc_core { +namespace { + +Chttp2PingRatePolicy::RequestSendPingResult SendGranted() { + return Chttp2PingRatePolicy::SendGranted{}; +} + +Chttp2PingRatePolicy::RequestSendPingResult TooManyRecentPings() { + return Chttp2PingRatePolicy::TooManyRecentPings{}; +} + +TEST(PingRatePolicy, NoOpClient) { + Chttp2PingRatePolicy policy{ChannelArgs(), true}; + EXPECT_EQ(policy.TestOnlyMaxPingsWithoutData(), 2); +} + +TEST(PingRatePolicy, NoOpServer) { + Chttp2PingRatePolicy policy{ChannelArgs(), false}; + EXPECT_EQ(policy.TestOnlyMaxPingsWithoutData(), 0); +} + +TEST(PingRatePolicy, ServerCanSendAtStart) { + Chttp2PingRatePolicy policy{ChannelArgs(), false}; + EXPECT_EQ(policy.RequestSendPing(Duration::Milliseconds(100)), SendGranted()); +} + +TEST(PingRatePolicy, ClientBlockedUntilDataSent) { + Chttp2PingRatePolicy policy{ChannelArgs(), true}; + EXPECT_EQ(policy.RequestSendPing(Duration::Milliseconds(10)), + TooManyRecentPings()); + policy.ResetPingsBeforeDataRequired(); + EXPECT_EQ(policy.RequestSendPing(Duration::Milliseconds(10)), SendGranted()); + EXPECT_EQ(policy.RequestSendPing(Duration::Zero()), SendGranted()); + EXPECT_EQ(policy.RequestSendPing(Duration::Zero()), TooManyRecentPings()); +} + +TEST(PingRatePolicy, RateThrottlingWorks) { + Chttp2PingRatePolicy policy{ChannelArgs(), false}; + // Observe that we can fail if we send in a tight loop + while (policy.RequestSendPing(Duration::Milliseconds(10)) == SendGranted()) { + } + // Observe that we can succeed if we wait a bit between pings + for (int i = 0; i < 100; i++) { + std::this_thread::sleep_for(std::chrono::milliseconds(20)); + EXPECT_EQ(policy.RequestSendPing(Duration::Milliseconds(10)), + SendGranted()); + } +} + +} // namespace +} // namespace grpc_core + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc index b1fc3b3a4f2..95092f9ff8a 100644 --- a/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc +++ b/test/core/transport/chttp2/remove_stream_from_stalled_lists_test.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/transport/chttp2/settings_timeout_test.cc b/test/core/transport/chttp2/settings_timeout_test.cc index ddeef1d64df..58f1869f0f7 100644 --- a/test/core/transport/chttp2/settings_timeout_test.cc +++ b/test/core/transport/chttp2/settings_timeout_test.cc @@ -31,6 +31,7 @@ #include #include +#include #include #include #include diff --git a/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc b/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc index 2ab3b4fb63d..0c3aed882cf 100644 --- a/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc +++ b/test/core/transport/chttp2/stream_leak_with_queued_flow_control_update_test.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include diff --git a/test/core/transport/chttp2/streams_not_seen_test.cc b/test/core/transport/chttp2/streams_not_seen_test.cc index 1d7ebfd3353..a67c5ccbc2c 100644 --- a/test/core/transport/chttp2/streams_not_seen_test.cc +++ b/test/core/transport/chttp2/streams_not_seen_test.cc @@ -42,6 +42,7 @@ #include #include +#include #include #include #include diff --git a/test/core/transport/chttp2/too_many_pings_test.cc b/test/core/transport/chttp2/too_many_pings_test.cc index 2858e74a216..d888f9a1aab 100644 --- a/test/core/transport/chttp2/too_many_pings_test.cc +++ b/test/core/transport/chttp2/too_many_pings_test.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 292bfaa66a3..80e284fc7cf 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -895,6 +895,7 @@ include/grpc/grpc_audit_logging.h \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ +include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 0482efeb35d..4e3efe3e044 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -895,6 +895,7 @@ include/grpc/grpc_audit_logging.h \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ +include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -1312,6 +1313,10 @@ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/huffsyms.h \ src/core/ext/transport/chttp2/transport/internal.h \ src/core/ext/transport/chttp2/transport/parsing.cc \ +src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ +src/core/ext/transport/chttp2/transport/ping_abuse_policy.h \ +src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ +src/core/ext/transport/chttp2/transport/ping_rate_policy.h \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/varint.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 41008ce4415..89dabe26317 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -828,6 +828,7 @@ include/grpc/grpc_audit_logging.h \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ +include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e1778392a62..e778bb99a8e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -828,6 +828,7 @@ include/grpc/grpc_audit_logging.h \ include/grpc/grpc_posix.h \ include/grpc/grpc_security.h \ include/grpc/grpc_security_constants.h \ +include/grpc/impl/channel_arg_names.h \ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ @@ -1088,6 +1089,10 @@ src/core/ext/transport/chttp2/transport/huffsyms.cc \ src/core/ext/transport/chttp2/transport/huffsyms.h \ src/core/ext/transport/chttp2/transport/internal.h \ src/core/ext/transport/chttp2/transport/parsing.cc \ +src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc \ +src/core/ext/transport/chttp2/transport/ping_abuse_policy.h \ +src/core/ext/transport/chttp2/transport/ping_rate_policy.cc \ +src/core/ext/transport/chttp2/transport/ping_rate_policy.h \ src/core/ext/transport/chttp2/transport/stream_lists.cc \ src/core/ext/transport/chttp2/transport/varint.cc \ src/core/ext/transport/chttp2/transport/varint.h \ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index c96618b14d9..04210d5b1c9 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -6339,6 +6339,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "ping_abuse_policy_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false, @@ -6387,6 +6411,30 @@ ], "uses_polling": true }, + { + "args": [], + "benchmark": false, + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": true, + "language": "c++", + "name": "ping_rate_policy_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "uses_polling": false + }, { "args": [], "benchmark": false,