From 32f4631bae36001b7a72209835032c9f2c8d6773 Mon Sep 17 00:00:00 2001 From: Raimo Niskanen Date: Thu, 25 Jul 2024 17:51:36 +0200 Subject: [PATCH] Use read_ahead in SSL for KTLS --- lib/ssl/src/inet_tls_dist.erl | 12 +++++++----- lib/ssl/src/tls_gen_connection_1_3.erl | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/ssl/src/inet_tls_dist.erl b/lib/ssl/src/inet_tls_dist.erl index c93bb2759634..3f46d5663d22 100644 --- a/lib/ssl/src/inet_tls_dist.erl +++ b/lib/ssl/src/inet_tls_dist.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2011-2023. All Rights Reserved. +%% Copyright Ericsson AB 2011-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -233,7 +233,8 @@ listen(Name, Host) -> fam_listen(Family, Name, Host) -> ForcedOptions = - [Family, {active, false}, {packet, 4}, {nodelay, true}], + [Family, {active, false}, {packet, 4}, + {read_ahead, false}, {nodelay, true}], ListenFun = fun (First, Last, ListenOptions) -> listen_loop( @@ -342,7 +343,7 @@ accept_one(Family, Socket, NetKernel) -> case ssl:handshake( Socket, - trace([{active, false},{packet, 4}|Opts]), + trace([{active, false}, {packet, 4}, {read_ahead, false} | Opts]), net_kernel:connecttime()) of {ok, SslSocket} -> @@ -640,7 +641,8 @@ do_setup( inet_tcp_dist:merge_options( ConnectOptions, get_ssl_options(client)), - [Family, binary, {active, false}, {packet, 4}, {nodelay, true}], + [Family, binary, {active, false}, {packet, 4}, + {read_ahead, false}, {nodelay, true}], [{server_name_indication, Host}]), KTLS = proplists:get_value(ktls, Opts, false), dist_util:reset_timer(Timer), @@ -943,7 +945,7 @@ inet_set_ktls( inet:setopts( Socket, [list, {packet, Packet}, {packet_size, PacketSize}, - {header, Header}, {active, Active}]) + {read_ahead, false}, {header, Header}, {active, Active}]) of ok -> ok; diff --git a/lib/ssl/src/tls_gen_connection_1_3.erl b/lib/ssl/src/tls_gen_connection_1_3.erl index 22df97f066cd..fc9753200221 100644 --- a/lib/ssl/src/tls_gen_connection_1_3.erl +++ b/lib/ssl/src/tls_gen_connection_1_3.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2022-2023. All Rights Reserved. +%% Copyright Ericsson AB 2022-2024. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -380,7 +380,7 @@ init_max_early_data_size(server) -> ssl_config:get_max_early_data_size(). internal_active_n(#{ktls := true}, Socket) -> - inet:setopts(Socket, [{packet, ssl_tls}]), + inet:setopts(Socket, [{packet, ssl_tls}, {read_ahead, false}]), 1; internal_active_n(#{erl_dist := true}, _) -> %% Start with a random number between 1 and ?INTERNAL_ACTIVE_N