grpc 1.41.1 → 1.42.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +55 -43
- data/include/grpc/event_engine/event_engine.h +82 -42
- data/include/grpc/event_engine/internal/memory_allocator_impl.h +98 -0
- data/include/grpc/event_engine/memory_allocator.h +210 -0
- data/include/grpc/grpc.h +4 -0
- data/include/grpc/grpc_security.h +18 -0
- data/include/grpc/grpc_security_constants.h +1 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/src/core/ext/filters/client_channel/backend_metric.cc +18 -19
- data/src/core/ext/filters/client_channel/backup_poller.cc +2 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +71 -89
- data/src/core/ext/filters/client_channel/client_channel.cc +187 -252
- data/src/core/ext/filters/client_channel/client_channel.h +74 -27
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_factory.h +17 -19
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +8 -14
- data/src/core/ext/filters/client_channel/config_selector.cc +1 -1
- data/src/core/ext/filters/client_channel/config_selector.h +4 -5
- data/src/core/ext/filters/client_channel/connector.h +18 -18
- data/src/core/ext/filters/client_channel/dynamic_filters.cc +1 -1
- data/src/core/ext/filters/client_channel/global_subchannel_pool.h +0 -1
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +12 -11
- data/src/core/ext/filters/client_channel/http_connect_handshaker.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +4 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +6 -15
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +166 -82
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +4 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +2 -4
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +23 -7
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +15 -10
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -3
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +2502 -0
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +6 -1
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +7 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +6 -2
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +5 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +8 -1
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +7 -16
- data/src/core/ext/filters/client_channel/lb_policy.h +11 -1
- data/src/core/ext/filters/client_channel/lb_policy_factory.h +1 -0
- data/src/core/ext/filters/client_channel/resolver/binder/binder_resolver.cc +139 -0
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +11 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +3 -3
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +12 -39
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +21 -1
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +6 -2
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +3 -1
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +77 -68
- data/src/core/ext/filters/client_channel/resolver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +2 -0
- data/src/core/ext/filters/client_channel/resolver_registry.cc +6 -8
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +1 -1
- data/src/core/ext/filters/client_channel/retry_filter.cc +48 -86
- data/src/core/ext/filters/client_channel/retry_service_config.h +1 -1
- data/src/core/ext/filters/client_channel/retry_throttle.cc +17 -48
- data/src/core/ext/filters/client_channel/server_address.h +1 -1
- data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +49 -36
- data/src/core/ext/filters/client_channel/subchannel.cc +85 -143
- data/src/core/ext/filters/client_channel/subchannel.h +29 -49
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.cc +22 -7
- data/src/core/ext/filters/client_channel/subchannel_pool_interface.h +11 -2
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +27 -210
- data/src/core/ext/filters/client_idle/idle_filter_state.cc +96 -0
- data/src/core/ext/filters/client_idle/idle_filter_state.h +66 -0
- data/src/core/ext/filters/deadline/deadline_filter.cc +23 -26
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +19 -19
- data/src/core/ext/filters/fault_injection/service_config_parser.cc +0 -1
- data/src/core/ext/filters/fault_injection/service_config_parser.h +1 -1
- data/src/core/ext/filters/http/client/http_client_filter.cc +41 -44
- data/src/core/ext/filters/http/client_authority_filter.cc +14 -15
- data/src/core/ext/filters/http/http_filters_plugin.cc +53 -71
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +17 -12
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +1 -1
- data/src/core/ext/filters/http/server/http_server_filter.cc +72 -69
- data/src/core/ext/filters/max_age/max_age_filter.cc +24 -26
- data/src/core/ext/filters/message_size/message_size_filter.cc +19 -16
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/{filters/client_channel → service_config}/service_config.cc +2 -2
- data/src/core/ext/{filters/client_channel → service_config}/service_config.h +4 -4
- data/src/core/ext/service_config/service_config_call_data.h +72 -0
- data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.cc +3 -3
- data/src/core/ext/{filters/client_channel → service_config}/service_config_parser.h +8 -6
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +2 -5
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +19 -24
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +27 -50
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +14 -16
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +59 -58
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +19 -16
- data/src/core/ext/transport/chttp2/transport/flow_control.h +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +2 -1
- data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/hpack_constants.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +41 -1
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +8 -4
- data/src/core/ext/transport/chttp2/transport/hpack_encoder_index.h +1 -1
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +136 -98
- data/src/core/ext/transport/chttp2/transport/hpack_parser.h +27 -8
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +12 -25
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +37 -30
- data/src/core/ext/transport/chttp2/transport/internal.h +4 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +30 -173
- data/src/core/ext/transport/chttp2/transport/popularity_count.h +1 -1
- data/src/core/ext/transport/chttp2/transport/writing.cc +29 -22
- data/src/core/ext/transport/inproc/inproc_transport.cc +105 -109
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.c +68 -34
- data/src/core/ext/upb-generated/envoy/config/cluster/v3/cluster.upb.h +139 -1
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.c +16 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/base.upb.h +53 -4
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.c +3 -2
- data/src/core/ext/upb-generated/envoy/config/core/v3/health_check.upb.h +15 -0
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.c +13 -8
- data/src/core/ext/upb-generated/envoy/config/core/v3/protocol.upb.h +23 -0
- data/src/core/ext/upb-generated/envoy/config/endpoint/v3/endpoint_components.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.c +14 -11
- data/src/core/ext/upb-generated/envoy/config/rbac/v3/rbac.upb.h +17 -0
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.c +15 -12
- data/src/core/ext/upb-generated/envoy/config/route/v3/route_components.upb.h +49 -19
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.c +55 -0
- data/src/core/ext/upb-generated/src/proto/grpc/lookup/v1/rls.upb.h +154 -0
- data/src/core/ext/upb-generated/udpa/annotations/security.upb.c +0 -2
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.c +58 -0
- data/src/core/ext/upb-generated/xds/annotations/v3/status.upb.h +182 -0
- data/src/core/ext/upb-generated/xds/core/v3/authority.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/core/v3/collection_entry.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/core/v3/context_params.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/core/v3/resource.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/core/v3/resource_locator.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/core/v3/resource_name.upb.c +1 -1
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.c +58 -0
- data/src/core/ext/upb-generated/xds/data/orca/v3/orca_load_report.upb.h +130 -0
- data/src/core/ext/upb-generated/{udpa/type/v1 → xds/type/v3}/typed_struct.upb.c +7 -7
- data/src/core/ext/upb-generated/xds/type/v3/typed_struct.upb.h +83 -0
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.c +310 -286
- data/src/core/ext/upbdefs-generated/envoy/config/cluster/v3/cluster.upbdefs.h +10 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.c +101 -88
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/base.upbdefs.h +5 -0
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/health_check.upbdefs.c +59 -56
- data/src/core/ext/upbdefs-generated/envoy/config/core/v3/protocol.upbdefs.c +59 -46
- data/src/core/ext/upbdefs-generated/envoy/config/endpoint/v3/endpoint_components.upbdefs.c +78 -82
- data/src/core/ext/upbdefs-generated/envoy/config/route/v3/route_components.upbdefs.c +323 -316
- data/src/core/ext/upbdefs-generated/udpa/annotations/migrate.upbdefs.c +5 -4
- data/src/core/ext/upbdefs-generated/udpa/annotations/security.upbdefs.c +19 -23
- data/src/core/ext/upbdefs-generated/udpa/annotations/sensitive.upbdefs.c +4 -3
- data/src/core/ext/upbdefs-generated/udpa/annotations/status.upbdefs.c +5 -3
- data/src/core/ext/upbdefs-generated/udpa/annotations/versioning.upbdefs.c +5 -4
- data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.c +75 -0
- data/src/core/ext/upbdefs-generated/xds/annotations/v3/status.upbdefs.h +50 -0
- data/src/core/ext/upbdefs-generated/xds/core/v3/authority.upbdefs.c +13 -12
- data/src/core/ext/upbdefs-generated/xds/core/v3/collection_entry.upbdefs.c +25 -24
- data/src/core/ext/upbdefs-generated/xds/core/v3/context_params.upbdefs.c +16 -15
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource.upbdefs.c +17 -16
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_locator.upbdefs.c +33 -32
- data/src/core/ext/upbdefs-generated/xds/core/v3/resource_name.upbdefs.c +19 -18
- data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.c +45 -0
- data/src/core/ext/upbdefs-generated/xds/type/v3/typed_struct.upbdefs.h +35 -0
- data/src/core/ext/xds/xds_api.cc +325 -362
- data/src/core/ext/xds/xds_api.h +134 -82
- data/src/core/ext/xds/xds_bootstrap.h +10 -0
- data/src/core/ext/xds/xds_certificate_provider.cc +3 -3
- data/src/core/ext/xds/xds_channel_stack_modifier.cc +113 -0
- data/src/core/ext/xds/xds_channel_stack_modifier.h +52 -0
- data/src/core/ext/xds/xds_client.cc +527 -314
- data/src/core/ext/xds/xds_client.h +42 -37
- data/src/core/ext/xds/xds_client_stats.h +1 -1
- data/src/core/ext/xds/xds_server_config_fetcher.cc +5 -7
- data/src/core/lib/address_utils/parse_address.cc +2 -0
- data/src/core/lib/avl/avl.cc +5 -5
- data/src/core/lib/backoff/backoff.cc +1 -1
- data/src/core/lib/channel/channel_args.cc +24 -6
- data/src/core/lib/channel/channel_args.h +9 -0
- data/src/core/lib/channel/channel_stack_builder.cc +3 -3
- data/src/core/lib/channel/channel_trace.cc +1 -1
- data/src/core/lib/channel/channel_trace.h +1 -1
- data/src/core/lib/channel/channelz.cc +3 -3
- data/src/core/lib/channel/channelz.h +2 -2
- data/src/core/lib/channel/channelz_registry.cc +1 -1
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +1 -3
- data/src/core/lib/channel/connected_channel.h +1 -2
- data/src/core/lib/compression/compression.cc +2 -2
- data/src/core/lib/compression/compression_args.cc +6 -4
- data/src/core/lib/compression/compression_internal.cc +2 -2
- data/src/core/lib/compression/compression_internal.h +1 -1
- data/src/core/lib/config/core_configuration.cc +44 -2
- data/src/core/lib/config/core_configuration.h +39 -1
- data/src/core/lib/debug/stats.cc +1 -1
- data/src/core/lib/debug/stats_data.cc +13 -13
- data/src/core/lib/gpr/atm.cc +1 -1
- data/src/core/lib/gpr/cpu_posix.cc +1 -1
- data/src/core/lib/gpr/string.cc +2 -2
- data/src/core/lib/gpr/tls.h +1 -1
- data/src/core/lib/gpr/useful.h +79 -32
- data/src/core/lib/gprpp/arena.h +10 -0
- data/src/core/lib/gprpp/bitset.h +38 -16
- data/src/core/lib/gprpp/chunked_vector.h +211 -0
- data/src/core/lib/gprpp/construct_destruct.h +1 -1
- data/src/core/lib/gprpp/match.h +1 -1
- data/src/core/lib/gprpp/memory.h +6 -0
- data/src/core/lib/gprpp/overload.h +1 -1
- data/src/core/lib/gprpp/status_helper.cc +23 -3
- data/src/core/lib/gprpp/status_helper.h +12 -1
- data/src/core/lib/gprpp/table.h +411 -0
- data/src/core/lib/http/httpcli.cc +200 -182
- data/src/core/lib/http/parser.cc +2 -2
- data/src/core/lib/iomgr/call_combiner.cc +28 -10
- data/src/core/lib/iomgr/combiner.cc +6 -21
- data/src/core/lib/iomgr/endpoint_cfstream.cc +7 -6
- data/src/core/lib/iomgr/error.cc +113 -52
- data/src/core/lib/iomgr/error.h +50 -9
- data/src/core/lib/iomgr/error_cfstream.cc +5 -0
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +7 -7
- data/src/core/lib/iomgr/ev_poll_posix.cc +29 -20
- data/src/core/lib/iomgr/event_engine/closure.cc +41 -18
- data/src/core/lib/iomgr/event_engine/closure.h +10 -1
- data/src/core/lib/iomgr/event_engine/endpoint.cc +3 -3
- data/src/core/lib/iomgr/event_engine/iomgr.cc +1 -1
- data/src/core/lib/iomgr/event_engine/pollset.cc +5 -4
- data/src/core/lib/iomgr/event_engine/resolver.cc +10 -7
- data/src/core/lib/iomgr/event_engine/tcp.cc +9 -8
- data/src/core/lib/iomgr/event_engine/timer.cc +7 -2
- data/src/core/lib/iomgr/exec_ctx.cc +1 -9
- data/src/core/lib/iomgr/executor/mpmcqueue.cc +5 -7
- data/src/core/lib/iomgr/executor/mpmcqueue.h +3 -8
- data/src/core/lib/iomgr/executor.cc +6 -20
- data/src/core/lib/iomgr/iomgr.cc +3 -1
- data/src/core/lib/iomgr/iomgr_internal.cc +4 -9
- data/src/core/lib/iomgr/iomgr_internal.h +3 -2
- data/src/core/lib/iomgr/load_file.cc +2 -2
- data/src/core/lib/iomgr/lockfree_event.cc +18 -0
- data/src/core/lib/iomgr/pollset_custom.cc +1 -1
- data/src/core/lib/iomgr/pollset_custom.h +1 -1
- data/src/core/lib/iomgr/resolve_address_posix.cc +5 -7
- data/src/core/lib/iomgr/resource_quota.cc +13 -11
- data/src/core/lib/iomgr/socket_factory_posix.cc +2 -2
- data/src/core/lib/iomgr/socket_mutator.cc +2 -2
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +5 -3
- data/src/core/lib/iomgr/tcp_client_custom.cc +1 -1
- data/src/core/lib/iomgr/tcp_client_posix.cc +9 -18
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -3
- data/src/core/lib/iomgr/tcp_posix.cc +4 -5
- data/src/core/lib/iomgr/tcp_server_custom.cc +2 -1
- data/src/core/lib/iomgr/tcp_server_posix.cc +3 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +4 -5
- data/src/core/lib/iomgr/tcp_windows.cc +2 -2
- data/src/core/lib/iomgr/timer_generic.cc +13 -13
- data/src/core/lib/iomgr/timer_heap.cc +1 -1
- data/src/core/lib/json/json_util.cc +68 -0
- data/src/core/lib/json/json_util.h +57 -99
- data/src/core/lib/json/json_writer.cc +0 -3
- data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
- data/src/core/lib/security/authorization/authorization_policy_provider_vtable.cc +1 -1
- data/src/core/lib/security/authorization/evaluate_args.cc +14 -12
- data/src/core/lib/security/authorization/sdk_server_authz_filter.cc +13 -1
- data/src/core/lib/security/context/security_context.cc +4 -2
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +1 -1
- data/src/core/lib/security/credentials/credentials.cc +4 -2
- data/src/core/lib/security/credentials/credentials.h +6 -1
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +47 -11
- data/src/core/lib/security/credentials/external/external_account_credentials.h +1 -0
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +5 -9
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +2 -2
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +2 -2
- data/src/core/lib/security/security_connector/security_connector.cc +9 -4
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl_utils.cc +1 -1
- data/src/core/lib/security/security_connector/tls/tls_security_connector.cc +1 -0
- data/src/core/lib/security/security_connector/tls/tls_security_connector.h +0 -2
- data/src/core/lib/security/transport/client_auth_filter.cc +5 -5
- data/src/core/lib/security/transport/security_handshaker.cc +73 -43
- data/src/core/lib/security/transport/server_auth_filter.cc +3 -5
- data/src/core/lib/security/transport/tsi_error.cc +3 -5
- data/src/core/lib/slice/slice.cc +0 -16
- data/src/core/lib/slice/slice_api.cc +39 -0
- data/src/core/lib/slice/slice_buffer.cc +5 -5
- data/src/core/lib/slice/slice_intern.cc +8 -13
- data/src/core/lib/slice/slice_internal.h +1 -244
- data/src/core/lib/slice/slice_refcount.cc +17 -0
- data/src/core/lib/slice/slice_refcount.h +121 -0
- data/src/core/lib/slice/slice_refcount_base.h +173 -0
- data/src/core/lib/slice/slice_split.cc +100 -0
- data/src/core/lib/slice/slice_split.h +40 -0
- data/src/core/lib/slice/slice_string_helpers.cc +0 -83
- data/src/core/lib/slice/slice_string_helpers.h +0 -11
- data/src/core/lib/slice/static_slice.cc +529 -0
- data/src/core/lib/slice/static_slice.h +331 -0
- data/src/core/lib/surface/builtins.cc +49 -0
- data/src/core/{ext/filters/workarounds/workaround_cronet_compression_filter.h → lib/surface/builtins.h} +8 -9
- data/src/core/lib/surface/call.cc +103 -120
- data/src/core/lib/surface/call.h +0 -6
- data/src/core/lib/surface/channel.cc +19 -32
- data/src/core/lib/surface/channel.h +0 -9
- data/src/core/lib/surface/channel_init.cc +23 -76
- data/src/core/lib/surface/channel_init.h +52 -44
- data/src/core/lib/surface/completion_queue.cc +6 -5
- data/src/core/lib/surface/init.cc +0 -39
- data/src/core/lib/surface/init_secure.cc +17 -14
- data/src/core/lib/surface/lame_client.cc +18 -11
- data/src/core/lib/surface/lame_client.h +1 -1
- data/src/core/lib/surface/server.cc +25 -17
- data/src/core/lib/surface/server.h +17 -10
- data/src/core/lib/surface/validate_metadata.cc +5 -2
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -1
- data/src/core/lib/transport/error_utils.cc +42 -17
- data/src/core/lib/transport/error_utils.h +1 -1
- data/src/core/lib/transport/metadata.cc +31 -10
- data/src/core/lib/transport/metadata.h +2 -1
- data/src/core/lib/transport/metadata_batch.cc +35 -371
- data/src/core/lib/transport/metadata_batch.h +905 -71
- data/src/core/lib/transport/parsed_metadata.h +263 -0
- data/src/core/lib/transport/pid_controller.cc +4 -4
- data/src/core/lib/transport/static_metadata.cc +714 -846
- data/src/core/lib/transport/static_metadata.h +115 -379
- data/src/core/lib/transport/status_metadata.cc +1 -0
- data/src/core/lib/transport/transport.cc +4 -5
- data/src/core/lib/transport/transport_op_string.cc +40 -20
- data/src/core/plugin_registry/grpc_plugin_registry.cc +64 -43
- data/src/core/tsi/alts/crypt/aes_gcm.cc +3 -1
- data/src/core/tsi/alts/frame_protector/alts_frame_protector.cc +13 -12
- data/src/core/tsi/alts/frame_protector/frame_handler.cc +10 -11
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +1 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +12 -2
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_grpc_record_protocol_common.cc +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +2 -2
- data/src/core/tsi/fake_transport_security.cc +15 -7
- data/src/core/tsi/local_transport_security.cc +36 -73
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +16 -50
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.h +4 -3
- data/src/core/tsi/ssl_transport_security.cc +10 -2
- data/src/core/tsi/transport_security.cc +12 -0
- data/src/core/tsi/transport_security.h +16 -1
- data/src/core/tsi/transport_security_interface.h +26 -0
- data/src/ruby/ext/grpc/extconf.rb +12 -9
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +6 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/test_pb.rb +2 -2
- data/src/ruby/spec/client_server_spec.rb +1 -1
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +4 -4
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -6
- data/third_party/address_sorting/address_sorting_posix.c +1 -0
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_bool.c +20 -21
- data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strnid.c +104 -114
- data/third_party/boringssl-with-bazel/src/crypto/asn1/internal.h +13 -0
- data/third_party/boringssl-with-bazel/src/crypto/blake2/blake2.c +4 -6
- data/third_party/boringssl-with-bazel/src/crypto/chacha/chacha.c +38 -47
- data/third_party/boringssl-with-bazel/src/crypto/evp/scrypt.c +32 -34
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/bn/sqrt.c +5 -9
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/des.c +10 -11
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/des/internal.h +1 -3
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md4/md4.c +3 -6
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/md5/md5.c +4 -7
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha1.c +35 -35
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha256.c +11 -10
- data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/sha/sha512.c +10 -37
- data/third_party/boringssl-with-bazel/src/crypto/internal.h +39 -0
- data/third_party/boringssl-with-bazel/src/crypto/siphash/siphash.c +6 -6
- data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_purp.c +0 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/asn1.h +72 -45
- data/third_party/boringssl-with-bazel/src/include/openssl/base.h +5 -1
- data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +2 -2
- data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +479 -15
- data/third_party/boringssl-with-bazel/src/include/openssl/x509_vfy.h +16 -564
- data/third_party/boringssl-with-bazel/src/ssl/ssl_x509.cc +0 -1
- data/third_party/re2/re2/compile.cc +91 -109
- data/third_party/re2/re2/dfa.cc +27 -39
- data/third_party/re2/re2/filtered_re2.cc +18 -2
- data/third_party/re2/re2/filtered_re2.h +10 -5
- data/third_party/re2/re2/nfa.cc +1 -1
- data/third_party/re2/re2/parse.cc +42 -23
- data/third_party/re2/re2/perl_groups.cc +34 -34
- data/third_party/re2/re2/prefilter.cc +3 -2
- data/third_party/re2/re2/prog.cc +182 -4
- data/third_party/re2/re2/prog.h +28 -9
- data/third_party/re2/re2/re2.cc +87 -118
- data/third_party/re2/re2/re2.h +156 -141
- data/third_party/re2/re2/regexp.cc +12 -5
- data/third_party/re2/re2/regexp.h +8 -2
- data/third_party/re2/re2/set.cc +31 -9
- data/third_party/re2/re2/set.h +9 -4
- data/third_party/re2/re2/simplify.cc +11 -3
- data/third_party/re2/re2/tostring.cc +1 -1
- data/third_party/re2/re2/walker-inl.h +1 -1
- data/third_party/re2/util/mutex.h +2 -2
- data/third_party/re2/util/pcre.h +3 -3
- metadata +75 -63
- data/include/grpc/event_engine/slice_allocator.h +0 -71
- data/src/core/ext/filters/client_channel/service_config_call_data.h +0 -126
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +0 -211
- data/src/core/ext/filters/workarounds/workaround_utils.cc +0 -53
- data/src/core/ext/filters/workarounds/workaround_utils.h +0 -39
- data/src/core/ext/transport/chttp2/client/authority.cc +0 -42
- data/src/core/ext/transport/chttp2/client/authority.h +0 -36
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.cc +0 -67
- data/src/core/ext/transport/chttp2/transport/chttp2_slice_allocator.h +0 -74
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +0 -66
- data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +0 -58
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.c +0 -58
- data/src/core/ext/upb-generated/udpa/data/orca/v1/orca_load_report.upb.h +0 -130
- data/src/core/ext/upb-generated/udpa/type/v1/typed_struct.upb.h +0 -83
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.c +0 -44
- data/src/core/ext/upbdefs-generated/udpa/type/v1/typed_struct.upbdefs.h +0 -35
- data/src/core/lib/iomgr/udp_server.cc +0 -747
- data/src/core/lib/iomgr/udp_server.h +0 -103
- data/src/core/lib/transport/authority_override.cc +0 -40
- data/src/core/lib/transport/authority_override.h +0 -37
@@ -51,7 +51,7 @@
|
|
51
51
|
|
52
52
|
namespace grpc_core {
|
53
53
|
|
54
|
-
|
54
|
+
TraceFlag grpc_trace_chttp2_hpack_parser(false, "chttp2_hpack_parser");
|
55
55
|
|
56
56
|
/* state table for huffman decoding: given a state, gives an index/16 into
|
57
57
|
next_sub_tbl. Taking that index and adding the value of the nibble being
|
@@ -935,15 +935,20 @@ class HPackParser::String {
|
|
935
935
|
value_;
|
936
936
|
};
|
937
937
|
|
938
|
-
// Parser parses one
|
938
|
+
// Parser parses one key/value pair from a byte stream.
|
939
939
|
class HPackParser::Parser {
|
940
940
|
public:
|
941
|
-
Parser(Input* input,
|
942
|
-
|
941
|
+
Parser(Input* input, grpc_metadata_batch* metadata_buffer,
|
942
|
+
uint32_t metadata_size_limit, HPackTable* table,
|
943
|
+
uint8_t* dynamic_table_updates_allowed, uint32_t* frame_length,
|
944
|
+
LogInfo log_info)
|
943
945
|
: input_(input),
|
944
|
-
|
946
|
+
metadata_buffer_(metadata_buffer),
|
945
947
|
table_(table),
|
946
|
-
dynamic_table_updates_allowed_(dynamic_table_updates_allowed)
|
948
|
+
dynamic_table_updates_allowed_(dynamic_table_updates_allowed),
|
949
|
+
frame_length_(frame_length),
|
950
|
+
metadata_size_limit_(metadata_size_limit),
|
951
|
+
log_info_(log_info) {}
|
947
952
|
|
948
953
|
// Skip any priority bits, or return false on failure
|
949
954
|
bool SkipPriority() {
|
@@ -965,13 +970,12 @@ class HPackParser::Parser {
|
|
965
970
|
case 1:
|
966
971
|
switch (cur & 0xf) {
|
967
972
|
case 0: // literal key
|
968
|
-
return
|
969
|
-
ParseLiteralKey<String::Extern>());
|
973
|
+
return FinishHeaderOmitFromTable(ParseLiteralKey<String::Extern>());
|
970
974
|
case 0xf: // varint encoded key index
|
971
|
-
return
|
975
|
+
return FinishHeaderOmitFromTable(
|
972
976
|
ParseVarIdxKey<String::Extern>(0xf));
|
973
977
|
default: // inline encoded key index
|
974
|
-
return
|
978
|
+
return FinishHeaderOmitFromTable(
|
975
979
|
ParseIdxKey<String::Extern>(cur & 0xf));
|
976
980
|
}
|
977
981
|
// Update max table size.
|
@@ -999,23 +1003,22 @@ class HPackParser::Parser {
|
|
999
1003
|
case 4:
|
1000
1004
|
if (cur == 0x40) {
|
1001
1005
|
// literal key
|
1002
|
-
return
|
1003
|
-
ParseLiteralKey<String::Intern>());
|
1006
|
+
return FinishHeaderAndAddToTable(ParseLiteralKey<String::Intern>());
|
1004
1007
|
}
|
1005
1008
|
ABSL_FALLTHROUGH_INTENDED;
|
1006
1009
|
case 5:
|
1007
1010
|
case 6:
|
1008
1011
|
// inline encoded key index
|
1009
|
-
return
|
1012
|
+
return FinishHeaderAndAddToTable(
|
1010
1013
|
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1011
1014
|
case 7:
|
1012
1015
|
if (cur == 0x7f) {
|
1013
1016
|
// varint encoded key index
|
1014
|
-
return
|
1017
|
+
return FinishHeaderAndAddToTable(
|
1015
1018
|
ParseVarIdxKey<String::Intern>(0x3f));
|
1016
1019
|
} else {
|
1017
1020
|
// inline encoded key index
|
1018
|
-
return
|
1021
|
+
return FinishHeaderAndAddToTable(
|
1019
1022
|
ParseIdxKey<String::Intern>(cur & 0x3f));
|
1020
1023
|
}
|
1021
1024
|
// Indexed Header Field Representation
|
@@ -1056,102 +1059,110 @@ class HPackParser::Parser {
|
|
1056
1059
|
}
|
1057
1060
|
|
1058
1061
|
private:
|
1059
|
-
void GPR_ATTRIBUTE_NOINLINE LogHeader(
|
1060
|
-
char*
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1062
|
+
void GPR_ATTRIBUTE_NOINLINE LogHeader(const HPackTable::Memento& memento) {
|
1063
|
+
const char* type;
|
1064
|
+
switch (log_info_.type) {
|
1065
|
+
case LogInfo::kHeaders:
|
1066
|
+
type = "HDR";
|
1067
|
+
break;
|
1068
|
+
case LogInfo::kTrailers:
|
1069
|
+
type = "TRL";
|
1070
|
+
break;
|
1071
|
+
case LogInfo::kDontKnow:
|
1072
|
+
type = "???";
|
1073
|
+
break;
|
1066
1074
|
}
|
1067
|
-
gpr_log(
|
1068
|
-
|
1069
|
-
"Decode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
|
1070
|
-
k, v, GRPC_MDELEM_IS_INTERNED(md), GRPC_MDELEM_STORAGE(md),
|
1071
|
-
grpc_slice_is_interned(GRPC_MDKEY(md)),
|
1072
|
-
grpc_slice_is_interned(GRPC_MDVALUE(md)));
|
1073
|
-
gpr_free(k);
|
1074
|
-
gpr_free(v);
|
1075
|
+
gpr_log(GPR_DEBUG, "HTTP:%d:%s:%s: %s", log_info_.stream_id, type,
|
1076
|
+
log_info_.is_client ? "CLI" : "SVR", memento.DebugString().c_str());
|
1075
1077
|
}
|
1076
1078
|
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1079
|
+
bool EmitHeader(const HPackTable::Memento& md) {
|
1080
|
+
// Pass up to the transport
|
1081
|
+
if (GPR_UNLIKELY(metadata_buffer_ == nullptr)) return true;
|
1082
|
+
*frame_length_ += md.transport_size();
|
1083
|
+
if (GPR_UNLIKELY(*frame_length_ > metadata_size_limit_)) {
|
1084
|
+
return HandleMetadataSizeLimitExceeded(md);
|
1085
|
+
}
|
1084
1086
|
|
1085
|
-
|
1086
|
-
|
1087
|
+
grpc_error_handle err = metadata_buffer_->Set(md);
|
1088
|
+
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1089
|
+
input_->SetError(err);
|
1090
|
+
return false;
|
1091
|
+
}
|
1092
|
+
return true;
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
bool FinishHeaderAndAddToTable(absl::optional<HPackTable::Memento> md) {
|
1087
1096
|
// Allow higher code to just pass in failures ... simplifies things a bit.
|
1088
|
-
if (
|
1097
|
+
if (!md.has_value()) return false;
|
1089
1098
|
// Log if desired
|
1090
1099
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1091
|
-
LogHeader(md);
|
1092
|
-
}
|
1093
|
-
// Add to the hpack table if needed
|
1094
|
-
if (action == TableAction::kAddToTable) {
|
1095
|
-
GPR_DEBUG_ASSERT(GRPC_MDELEM_STORAGE(md) ==
|
1096
|
-
GRPC_MDELEM_STORAGE_INTERNED ||
|
1097
|
-
GRPC_MDELEM_STORAGE(md) == GRPC_MDELEM_STORAGE_STATIC);
|
1098
|
-
grpc_error_handle err = table_->Add(md);
|
1099
|
-
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1100
|
-
input_->SetError(err);
|
1101
|
-
return false;
|
1102
|
-
};
|
1100
|
+
LogHeader(*md);
|
1103
1101
|
}
|
1104
|
-
//
|
1105
|
-
|
1102
|
+
// Emit whilst we own the metadata.
|
1103
|
+
auto r = EmitHeader(*md);
|
1104
|
+
// Add to the hpack table
|
1105
|
+
grpc_error_handle err = table_->Add(std::move(*md));
|
1106
1106
|
if (GPR_UNLIKELY(err != GRPC_ERROR_NONE)) {
|
1107
1107
|
input_->SetError(err);
|
1108
1108
|
return false;
|
1109
|
+
};
|
1110
|
+
return r;
|
1111
|
+
}
|
1112
|
+
|
1113
|
+
bool FinishHeaderOmitFromTable(absl::optional<HPackTable::Memento> md) {
|
1114
|
+
// Allow higher code to just pass in failures ... simplifies things a bit.
|
1115
|
+
if (!md.has_value()) return false;
|
1116
|
+
return FinishHeaderOmitFromTable(*md);
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
bool FinishHeaderOmitFromTable(const HPackTable::Memento& md) {
|
1120
|
+
// Log if desired
|
1121
|
+
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1122
|
+
LogHeader(md);
|
1109
1123
|
}
|
1110
|
-
return
|
1124
|
+
return EmitHeader(md);
|
1111
1125
|
}
|
1112
1126
|
|
1113
1127
|
// Parse a string encoded key and a string encoded value
|
1114
1128
|
template <typename TakeValueType>
|
1115
|
-
|
1129
|
+
absl::optional<HPackTable::Memento> ParseLiteralKey() {
|
1116
1130
|
auto key = String::Parse(input_);
|
1117
|
-
if (!key.has_value()) return
|
1131
|
+
if (!key.has_value()) return {};
|
1118
1132
|
auto key_slice = key->Take<String::Intern>();
|
1119
|
-
auto value =
|
1133
|
+
auto value =
|
1134
|
+
ParseValueString(grpc_is_refcounted_slice_binary_header(key_slice));
|
1120
1135
|
if (GPR_UNLIKELY(!value.has_value())) {
|
1121
1136
|
grpc_slice_unref_internal(key_slice);
|
1122
|
-
return
|
1137
|
+
return {};
|
1123
1138
|
}
|
1124
|
-
return
|
1139
|
+
return grpc_metadata_batch::Parse(key_slice, value->Take<TakeValueType>());
|
1125
1140
|
}
|
1126
1141
|
|
1127
1142
|
// Parse an index encoded key and a string encoded value
|
1128
1143
|
template <typename TakeValueType>
|
1129
|
-
|
1130
|
-
auto elem = table_->
|
1131
|
-
if (GPR_UNLIKELY(
|
1132
|
-
return InvalidHPackIndexError(index,
|
1144
|
+
absl::optional<HPackTable::Memento> ParseIdxKey(uint32_t index) {
|
1145
|
+
const auto* elem = table_->Lookup(index);
|
1146
|
+
if (GPR_UNLIKELY(elem == nullptr)) {
|
1147
|
+
return InvalidHPackIndexError(index,
|
1148
|
+
absl::optional<HPackTable::Memento>());
|
1133
1149
|
}
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
return grpc_mdelem_from_slices(
|
1138
|
-
static_cast<const ManagedMemorySlice&>(
|
1139
|
-
grpc_slice_ref_internal(GRPC_MDKEY(elem))),
|
1140
|
-
value->Take<TakeValueType>());
|
1150
|
+
auto value = ParseValueString(elem->is_binary_header());
|
1151
|
+
if (GPR_UNLIKELY(!value.has_value())) return {};
|
1152
|
+
return elem->WithNewValue(value->Take<TakeValueType>());
|
1141
1153
|
}
|
1142
1154
|
|
1143
1155
|
// Parse a varint index encoded key and a string encoded value
|
1144
1156
|
template <typename TakeValueType>
|
1145
|
-
|
1157
|
+
absl::optional<HPackTable::Memento> ParseVarIdxKey(uint32_t offset) {
|
1146
1158
|
auto index = input_->ParseVarint(offset);
|
1147
|
-
if (GPR_UNLIKELY(!index.has_value())) return
|
1159
|
+
if (GPR_UNLIKELY(!index.has_value())) return {};
|
1148
1160
|
return ParseIdxKey<TakeValueType>(*index);
|
1149
1161
|
}
|
1150
1162
|
|
1151
1163
|
// Parse a string, figuring out if it's binary or not by the key name.
|
1152
|
-
|
1153
|
-
|
1154
|
-
if (grpc_is_refcounted_slice_binary_header(key)) {
|
1164
|
+
absl::optional<String> ParseValueString(bool is_binary) {
|
1165
|
+
if (is_binary) {
|
1155
1166
|
return String::ParseBinary(input_);
|
1156
1167
|
} else {
|
1157
1168
|
return String::Parse(input_);
|
@@ -1162,12 +1173,12 @@ class HPackParser::Parser {
|
|
1162
1173
|
bool FinishIndexed(absl::optional<uint32_t> index) {
|
1163
1174
|
*dynamic_table_updates_allowed_ = 0;
|
1164
1175
|
if (!index.has_value()) return false;
|
1165
|
-
|
1166
|
-
if (GPR_UNLIKELY(
|
1176
|
+
const auto* elem = table_->Lookup(*index);
|
1177
|
+
if (GPR_UNLIKELY(elem == nullptr)) {
|
1167
1178
|
return InvalidHPackIndexError(*index, false);
|
1168
1179
|
}
|
1169
1180
|
GRPC_STATS_INC_HPACK_RECV_INDEXED();
|
1170
|
-
return
|
1181
|
+
return FinishHeaderOmitFromTable(*elem);
|
1171
1182
|
}
|
1172
1183
|
|
1173
1184
|
// finish parsing a max table size change
|
@@ -1182,9 +1193,6 @@ class HPackParser::Parser {
|
|
1182
1193
|
false);
|
1183
1194
|
}
|
1184
1195
|
(*dynamic_table_updates_allowed_)--;
|
1185
|
-
if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_chttp2_hpack_parser)) {
|
1186
|
-
gpr_log(GPR_INFO, "MAX TABLE SIZE: %d", *size);
|
1187
|
-
}
|
1188
1196
|
grpc_error_handle err = table_->SetCurrentTableSize(*size);
|
1189
1197
|
if (err != GRPC_ERROR_NONE) {
|
1190
1198
|
input_->SetError(err);
|
@@ -1207,21 +1215,44 @@ class HPackParser::Parser {
|
|
1207
1215
|
GRPC_ERROR_INT_SIZE,
|
1208
1216
|
static_cast<intptr_t>(this->table_->num_entries()));
|
1209
1217
|
},
|
1210
|
-
result);
|
1218
|
+
std::move(result));
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
GPR_ATTRIBUTE_NOINLINE
|
1222
|
+
bool HandleMetadataSizeLimitExceeded(const HPackTable::Memento&) {
|
1223
|
+
gpr_log(GPR_DEBUG,
|
1224
|
+
"received initial metadata size exceeds limit (%" PRIu32
|
1225
|
+
" vs. %" PRIu32
|
1226
|
+
"). GRPC_ARG_MAX_METADATA_SIZE can be set to increase this limit.",
|
1227
|
+
*frame_length_, metadata_size_limit_);
|
1228
|
+
return input_->MaybeSetErrorAndReturn(
|
1229
|
+
[] {
|
1230
|
+
return grpc_error_set_int(
|
1231
|
+
GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1232
|
+
"received initial metadata size exceeds limit"),
|
1233
|
+
GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED);
|
1234
|
+
},
|
1235
|
+
false);
|
1211
1236
|
}
|
1212
1237
|
|
1213
|
-
Input* input_;
|
1214
|
-
|
1238
|
+
Input* const input_;
|
1239
|
+
grpc_metadata_batch* const metadata_buffer_;
|
1215
1240
|
HPackTable* const table_;
|
1216
|
-
uint8_t* dynamic_table_updates_allowed_;
|
1241
|
+
uint8_t* const dynamic_table_updates_allowed_;
|
1242
|
+
uint32_t* const frame_length_;
|
1243
|
+
const uint32_t metadata_size_limit_;
|
1244
|
+
const LogInfo log_info_;
|
1217
1245
|
};
|
1218
1246
|
|
1219
1247
|
UnmanagedMemorySlice HPackParser::String::Take(Extern) {
|
1220
1248
|
auto s = Match(
|
1221
1249
|
value_,
|
1222
1250
|
[](const grpc_slice& slice) {
|
1251
|
+
// TODO(ctiller): Think about this before submission.
|
1223
1252
|
GPR_DEBUG_ASSERT(!grpc_slice_is_interned(slice));
|
1224
|
-
|
1253
|
+
auto out_slice = grpc_slice_copy(slice);
|
1254
|
+
grpc_slice_unref_internal(slice);
|
1255
|
+
return static_cast<const UnmanagedMemorySlice&>(out_slice);
|
1225
1256
|
},
|
1226
1257
|
[](absl::Span<const uint8_t> span) {
|
1227
1258
|
return UnmanagedMemorySlice(
|
@@ -1263,11 +1294,16 @@ HPackParser::HPackParser() = default;
|
|
1263
1294
|
|
1264
1295
|
HPackParser::~HPackParser() = default;
|
1265
1296
|
|
1266
|
-
void HPackParser::BeginFrame(
|
1267
|
-
|
1297
|
+
void HPackParser::BeginFrame(grpc_metadata_batch* metadata_buffer,
|
1298
|
+
uint32_t metadata_size_limit, Boundary boundary,
|
1299
|
+
Priority priority, LogInfo log_info) {
|
1300
|
+
metadata_buffer_ = metadata_buffer;
|
1268
1301
|
boundary_ = boundary;
|
1269
1302
|
priority_ = priority;
|
1270
1303
|
dynamic_table_updates_allowed_ = 2;
|
1304
|
+
frame_length_ = 0;
|
1305
|
+
metadata_size_limit_ = metadata_size_limit;
|
1306
|
+
log_info_ = log_info;
|
1271
1307
|
}
|
1272
1308
|
|
1273
1309
|
grpc_error_handle HPackParser::Parse(const grpc_slice& slice, bool is_last) {
|
@@ -1310,9 +1346,10 @@ bool HPackParser::ParseInputInner(Input* input) {
|
|
1310
1346
|
}
|
1311
1347
|
}
|
1312
1348
|
while (!input->end_of_stream()) {
|
1313
|
-
if (GPR_UNLIKELY(
|
1314
|
-
|
1315
|
-
|
1349
|
+
if (GPR_UNLIKELY(!Parser(input, metadata_buffer_, metadata_size_limit_,
|
1350
|
+
&table_, &dynamic_table_updates_allowed_,
|
1351
|
+
&frame_length_, log_info_)
|
1352
|
+
.Parse())) {
|
1316
1353
|
return false;
|
1317
1354
|
}
|
1318
1355
|
input->UpdateFrontier();
|
@@ -1320,7 +1357,7 @@ bool HPackParser::ParseInputInner(Input* input) {
|
|
1320
1357
|
return true;
|
1321
1358
|
}
|
1322
1359
|
|
1323
|
-
void HPackParser::FinishFrame() {
|
1360
|
+
void HPackParser::FinishFrame() { metadata_buffer_ = nullptr; }
|
1324
1361
|
|
1325
1362
|
} // namespace grpc_core
|
1326
1363
|
|
@@ -1348,10 +1385,11 @@ static void force_client_rst_stream(void* sp, grpc_error_handle /*error*/) {
|
|
1348
1385
|
static void parse_stream_compression_md(grpc_chttp2_transport* /*t*/,
|
1349
1386
|
grpc_chttp2_stream* s,
|
1350
1387
|
grpc_metadata_batch* initial_metadata) {
|
1351
|
-
if (initial_metadata->
|
1388
|
+
if (initial_metadata->legacy_index()->named.content_encoding == nullptr ||
|
1352
1389
|
grpc_stream_compression_method_parse(
|
1353
|
-
GRPC_MDVALUE(
|
1354
|
-
|
1390
|
+
GRPC_MDVALUE(
|
1391
|
+
initial_metadata->legacy_index()->named.content_encoding->md),
|
1392
|
+
false, &s->stream_decompression_method) == 0) {
|
1355
1393
|
s->stream_decompression_method =
|
1356
1394
|
GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS;
|
1357
1395
|
}
|
@@ -1382,14 +1420,14 @@ grpc_error_handle grpc_chttp2_header_parser_parse(void* hpack_parser,
|
|
1382
1420
|
stream id on a header */
|
1383
1421
|
if (s != nullptr) {
|
1384
1422
|
if (parser->is_boundary()) {
|
1385
|
-
if (s->header_frames_received ==
|
1423
|
+
if (s->header_frames_received == 2) {
|
1386
1424
|
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1387
1425
|
"Too many trailer frames");
|
1388
1426
|
}
|
1389
1427
|
/* Process stream compression md element if it exists */
|
1390
1428
|
if (s->header_frames_received ==
|
1391
1429
|
0) { /* Only acts on initial metadata */
|
1392
|
-
parse_stream_compression_md(t, s, &s->
|
1430
|
+
parse_stream_compression_md(t, s, &s->initial_metadata_buffer);
|
1393
1431
|
}
|
1394
1432
|
s->published_metadata[s->header_frames_received] =
|
1395
1433
|
GRPC_METADATA_PUBLISHED_FROM_WIRE;
|
@@ -26,6 +26,7 @@
|
|
26
26
|
#include "src/core/ext/transport/chttp2/transport/frame.h"
|
27
27
|
#include "src/core/ext/transport/chttp2/transport/hpack_parser_table.h"
|
28
28
|
#include "src/core/lib/transport/metadata.h"
|
29
|
+
#include "src/core/lib/transport/metadata_batch.h"
|
29
30
|
|
30
31
|
namespace grpc_core {
|
31
32
|
|
@@ -48,9 +49,20 @@ class HPackParser {
|
|
48
49
|
// Yes there's a priority field
|
49
50
|
Included
|
50
51
|
};
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
// Details about a frame we only need to know for logging
|
53
|
+
struct LogInfo {
|
54
|
+
// The stream ID
|
55
|
+
uint32_t stream_id;
|
56
|
+
// Headers or trailers?
|
57
|
+
enum Type : uint8_t {
|
58
|
+
kHeaders,
|
59
|
+
kTrailers,
|
60
|
+
kDontKnow,
|
61
|
+
};
|
62
|
+
Type type;
|
63
|
+
// Client or server?
|
64
|
+
bool is_client;
|
65
|
+
};
|
54
66
|
|
55
67
|
HPackParser();
|
56
68
|
~HPackParser();
|
@@ -61,9 +73,11 @@ class HPackParser {
|
|
61
73
|
|
62
74
|
// Begin parsing a new frame
|
63
75
|
// Sink receives each parsed header,
|
64
|
-
void BeginFrame(
|
65
|
-
|
66
|
-
|
76
|
+
void BeginFrame(grpc_metadata_batch* metadata_buffer,
|
77
|
+
uint32_t metadata_size_limit, Boundary boundary,
|
78
|
+
Priority priority, LogInfo log_info);
|
79
|
+
// Start throwing away any received headers after parsing them.
|
80
|
+
void StopBufferingFrame() { metadata_buffer_ = nullptr; }
|
67
81
|
// Parse one slice worth of data
|
68
82
|
grpc_error_handle Parse(const grpc_slice& slice, bool is_last);
|
69
83
|
// Reset state ready for the next BeginFrame
|
@@ -85,8 +99,8 @@ class HPackParser {
|
|
85
99
|
grpc_error_handle ParseInput(Input input, bool is_last);
|
86
100
|
bool ParseInputInner(Input* input);
|
87
101
|
|
88
|
-
//
|
89
|
-
|
102
|
+
// Target metadata buffer
|
103
|
+
grpc_metadata_batch* metadata_buffer_ = nullptr;
|
90
104
|
|
91
105
|
// Bytes that could not be parsed last parsing round
|
92
106
|
std::vector<uint8_t> unparsed_bytes_;
|
@@ -99,6 +113,11 @@ class HPackParser {
|
|
99
113
|
// buffering.
|
100
114
|
Priority priority_;
|
101
115
|
uint8_t dynamic_table_updates_allowed_;
|
116
|
+
// Length of frame so far.
|
117
|
+
uint32_t frame_length_;
|
118
|
+
uint32_t metadata_size_limit_;
|
119
|
+
// Information for logging
|
120
|
+
LogInfo log_info_;
|
102
121
|
|
103
122
|
// hpack table
|
104
123
|
HPackTable table_;
|
@@ -38,32 +38,24 @@ extern grpc_core::TraceFlag grpc_http_trace;
|
|
38
38
|
|
39
39
|
namespace grpc_core {
|
40
40
|
|
41
|
-
HPackTable::HPackTable()
|
41
|
+
HPackTable::HPackTable() : static_metadata_(GetStaticMementos()) {}
|
42
42
|
|
43
|
-
HPackTable::~HPackTable()
|
44
|
-
for (size_t i = 0; i < num_entries_; i++) {
|
45
|
-
GRPC_MDELEM_UNREF(entries_[(first_entry_ + i) % entries_.size()]);
|
46
|
-
}
|
47
|
-
}
|
43
|
+
HPackTable::~HPackTable() = default;
|
48
44
|
|
49
45
|
/* Evict one element from the table */
|
50
46
|
void HPackTable::EvictOne() {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
hpack_constants::kEntryOverhead;
|
55
|
-
GPR_ASSERT(elem_bytes <= mem_used_);
|
56
|
-
mem_used_ -= static_cast<uint32_t>(elem_bytes);
|
47
|
+
auto first_entry = std::move(entries_[first_entry_]);
|
48
|
+
GPR_ASSERT(first_entry.transport_size() <= mem_used_);
|
49
|
+
mem_used_ -= first_entry.transport_size();
|
57
50
|
first_entry_ = ((first_entry_ + 1) % entries_.size());
|
58
51
|
num_entries_--;
|
59
|
-
GRPC_MDELEM_UNREF(first_entry);
|
60
52
|
}
|
61
53
|
|
62
54
|
void HPackTable::Rebuild(uint32_t new_cap) {
|
63
55
|
EntriesVec entries;
|
64
56
|
entries.resize(new_cap);
|
65
57
|
for (size_t i = 0; i < num_entries_; i++) {
|
66
|
-
entries[i] = entries_[(first_entry_ + i) % entries_.size()];
|
58
|
+
entries[i] = std::move(entries_[(first_entry_ + i) % entries_.size()]);
|
67
59
|
}
|
68
60
|
first_entry_ = 0;
|
69
61
|
entries_.swap(entries);
|
@@ -113,12 +105,7 @@ grpc_error_handle HPackTable::SetCurrentTableSize(uint32_t bytes) {
|
|
113
105
|
return GRPC_ERROR_NONE;
|
114
106
|
}
|
115
107
|
|
116
|
-
grpc_error_handle HPackTable::Add(
|
117
|
-
/* determine how many bytes of buffer this entry represents */
|
118
|
-
size_t elem_bytes = GRPC_SLICE_LENGTH(GRPC_MDKEY(md)) +
|
119
|
-
GRPC_SLICE_LENGTH(GRPC_MDVALUE(md)) +
|
120
|
-
hpack_constants::kEntryOverhead;
|
121
|
-
|
108
|
+
grpc_error_handle HPackTable::Add(Memento md) {
|
122
109
|
if (current_table_bytes_ > max_bytes_) {
|
123
110
|
return GRPC_ERROR_CREATE_FROM_CPP_STRING(absl::StrFormat(
|
124
111
|
"HPACK max table size reduced to %d but not reflected by hpack "
|
@@ -127,7 +114,7 @@ grpc_error_handle HPackTable::Add(grpc_mdelem md) {
|
|
127
114
|
}
|
128
115
|
|
129
116
|
// we can't add elements bigger than the max table size
|
130
|
-
if (
|
117
|
+
if (md.transport_size() > current_table_bytes_) {
|
131
118
|
// HPACK draft 10 section 4.4 states:
|
132
119
|
// If the size of the new entry is less than or equal to the maximum
|
133
120
|
// size, that entry is added to the table. It is not an error to
|
@@ -142,17 +129,17 @@ grpc_error_handle HPackTable::Add(grpc_mdelem md) {
|
|
142
129
|
}
|
143
130
|
|
144
131
|
// evict entries to ensure no overflow
|
145
|
-
while (
|
132
|
+
while (md.transport_size() >
|
133
|
+
static_cast<size_t>(current_table_bytes_) - mem_used_) {
|
146
134
|
EvictOne();
|
147
135
|
}
|
148
136
|
|
149
137
|
// copy the finalized entry in
|
150
|
-
|
151
|
-
|
138
|
+
mem_used_ += md.transport_size();
|
139
|
+
entries_[(first_entry_ + num_entries_) % entries_.size()] = std::move(md);
|
152
140
|
|
153
141
|
// update accounting values
|
154
142
|
num_entries_++;
|
155
|
-
mem_used_ += static_cast<uint32_t>(elem_bytes);
|
156
143
|
return GRPC_ERROR_NONE;
|
157
144
|
}
|
158
145
|
|
@@ -27,6 +27,7 @@
|
|
27
27
|
#include "src/core/lib/gprpp/memory.h"
|
28
28
|
#include "src/core/lib/iomgr/error.h"
|
29
29
|
#include "src/core/lib/transport/metadata.h"
|
30
|
+
#include "src/core/lib/transport/metadata_batch.h"
|
30
31
|
#include "src/core/lib/transport/static_metadata.h"
|
31
32
|
|
32
33
|
namespace grpc_core {
|
@@ -37,30 +38,16 @@ class HPackTable {
|
|
37
38
|
HPackTable();
|
38
39
|
~HPackTable();
|
39
40
|
|
40
|
-
HPackTable(const HPackTable&);
|
41
|
-
HPackTable& operator=(const HPackTable&);
|
41
|
+
HPackTable(const HPackTable&) = delete;
|
42
|
+
HPackTable& operator=(const HPackTable&) = delete;
|
42
43
|
|
43
44
|
void SetMaxBytes(uint32_t max_bytes);
|
44
45
|
grpc_error_handle SetCurrentTableSize(uint32_t bytes);
|
45
46
|
|
46
|
-
|
47
|
-
grpc_mdelem Peek(uint32_t index) const { return Lookup<false>(index); }
|
48
|
-
// Lookup, taking a ref if found.
|
49
|
-
grpc_mdelem Fetch(uint32_t index) const { return Lookup<true>(index); }
|
50
|
-
|
51
|
-
// add a table entry to the index
|
52
|
-
grpc_error_handle Add(grpc_mdelem md) GRPC_MUST_USE_RESULT;
|
53
|
-
|
54
|
-
// Current entry count in the table.
|
55
|
-
uint32_t num_entries() const { return num_entries_; }
|
47
|
+
using Memento = ParsedMetadata<grpc_metadata_batch>;
|
56
48
|
|
57
|
-
|
58
|
-
|
59
|
-
using EntriesVec = absl::InlinedVector<grpc_mdelem, kInlineEntries>;
|
60
|
-
|
61
|
-
/* lookup a table entry based on its hpack index */
|
62
|
-
template <bool take_ref>
|
63
|
-
grpc_mdelem Lookup(uint32_t index) const {
|
49
|
+
// Lookup, but don't ref.
|
50
|
+
const Memento* Lookup(uint32_t index) const {
|
64
51
|
// Static table comes first, just return an entry from it.
|
65
52
|
// NB: This imposes the constraint that the first
|
66
53
|
// GRPC_CHTTP2_LAST_STATIC_ENTRY entries in the core static metadata table
|
@@ -68,27 +55,45 @@ class HPackTable {
|
|
68
55
|
// reading the core static metadata table here; at that point we'd need our
|
69
56
|
// own singleton static metadata in the correct order.
|
70
57
|
if (index <= hpack_constants::kLastStaticEntry) {
|
71
|
-
return
|
58
|
+
return &static_metadata_.memento[index - 1];
|
72
59
|
} else {
|
73
|
-
return LookupDynamic
|
60
|
+
return LookupDynamic(index);
|
74
61
|
}
|
75
62
|
}
|
76
63
|
|
77
|
-
|
78
|
-
|
64
|
+
// add a table entry to the index
|
65
|
+
grpc_error_handle Add(Memento md) GRPC_MUST_USE_RESULT;
|
66
|
+
|
67
|
+
// Current entry count in the table.
|
68
|
+
uint32_t num_entries() const { return num_entries_; }
|
69
|
+
|
70
|
+
private:
|
71
|
+
struct StaticMementos {
|
72
|
+
StaticMementos() {
|
73
|
+
for (uint32_t i = 0; i < hpack_constants::kLastStaticEntry; i++) {
|
74
|
+
memento[i] = Memento(g_static_mdelem_manifested[i]);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
Memento memento[hpack_constants::kLastStaticEntry];
|
78
|
+
};
|
79
|
+
static const StaticMementos& GetStaticMementos() {
|
80
|
+
static const StaticMementos static_mementos;
|
81
|
+
return static_mementos;
|
82
|
+
}
|
83
|
+
|
84
|
+
enum { kInlineEntries = hpack_constants::kInitialTableEntries };
|
85
|
+
using EntriesVec = absl::InlinedVector<Memento, kInlineEntries>;
|
86
|
+
|
87
|
+
const Memento* LookupDynamic(uint32_t index) const {
|
79
88
|
// Not static - find the value in the list of valid entries
|
80
89
|
const uint32_t tbl_index = index - (hpack_constants::kLastStaticEntry + 1);
|
81
90
|
if (tbl_index < num_entries_) {
|
82
91
|
uint32_t offset =
|
83
92
|
(num_entries_ - 1u - tbl_index + first_entry_) % entries_.size();
|
84
|
-
|
85
|
-
if (take_ref) {
|
86
|
-
GRPC_MDELEM_REF(md);
|
87
|
-
}
|
88
|
-
return md;
|
93
|
+
return &entries_[offset];
|
89
94
|
}
|
90
95
|
// Invalid entry: return error
|
91
|
-
return
|
96
|
+
return nullptr;
|
92
97
|
}
|
93
98
|
|
94
99
|
void EvictOne();
|
@@ -110,6 +115,8 @@ class HPackTable {
|
|
110
115
|
uint32_t max_entries_ = hpack_constants::kInitialTableEntries;
|
111
116
|
// HPack table entries
|
112
117
|
EntriesVec entries_{hpack_constants::kInitialTableEntries};
|
118
|
+
// Mementos for static data
|
119
|
+
const StaticMementos& static_metadata_;
|
113
120
|
};
|
114
121
|
|
115
122
|
} // namespace grpc_core
|
@@ -120,7 +127,7 @@ class HPackTable {
|
|
120
127
|
inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) {
|
121
128
|
uintptr_t index =
|
122
129
|
reinterpret_cast<grpc_core::StaticMetadata*>(GRPC_MDELEM_DATA(md)) -
|
123
|
-
|
130
|
+
grpc_core::g_static_mdelem_table;
|
124
131
|
if (index < grpc_core::hpack_constants::kLastStaticEntry) {
|
125
132
|
return index + 1; // Hpack static metadata element indices start at 1
|
126
133
|
}
|