Skip to content

Commit 35b4c5a

Browse files
quic: tx_buf_sz pow2
1 parent ec6aea0 commit 35b4c5a

File tree

8 files changed

+28
-7
lines changed

8 files changed

+28
-7
lines changed

src/app/shared_dev/commands/bench/fd_benchs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ populate_quic_limits( fd_quic_limits_t * limits ) {
176176
limits->handshake_cnt = limits->conn_cnt;
177177
limits->conn_id_cnt = 16;
178178
limits->inflight_frame_cnt = 1500;
179-
limits->tx_buf_sz = FD_TXN_MTU;
179+
limits->tx_buf_sz = 1UL<<11;
180180
limits->stream_pool_cnt = 1UL<<16;
181181
limits->stream_id_cnt = 1UL<<16;
182182
}

src/discof/send/fd_send_tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fd_quic_limits_t quic_limits = {
4848
.inflight_frame_cnt = 16UL * MAX_STAKED_LEADERS,
4949
.min_inflight_frame_cnt_conn = 4UL,
5050
.stream_id_cnt = 16UL,
51-
.tx_buf_sz = FD_TXN_MTU,
51+
.tx_buf_sz = 1UL<<11,
5252
.stream_pool_cnt = 2048UL
5353
};
5454

src/waltz/quic/fd_quic_stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fd_quic_buffer_load( fd_quic_buffer_t * buf,
7575

7676
if( mtail >= mhead ) {
7777
/* free space split */
78-
ulong end_sz = cap - mhead;
78+
ulong end_sz = cap - mtail;
7979
if( data_sz <= end_sz ) {
8080
/* consists entirely of space at end of buffer */
8181
fd_memcpy( data, raw + mtail, data_sz );
@@ -97,6 +97,8 @@ fd_quic_stream_align( void );
9797

9898
ulong
9999
fd_quic_stream_footprint( ulong tx_buf_sz ) {
100+
if( FD_UNLIKELY( !fd_ulong_is_pow2( tx_buf_sz ) ) ) return 0UL;
101+
100102
ulong align = fd_quic_stream_align();
101103
ulong offs = 0ul;
102104

src/waltz/quic/fd_quic_stream_pool.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ fd_quic_stream_pool_footprint( ulong count, ulong tx_buf_sz ) {
1313
FD_QUIC_STREAM_POOL_ALIGN );
1414

1515
ulong stream_foot = fd_quic_stream_footprint( tx_buf_sz );
16+
if( FD_UNLIKELY( !stream_foot ) ) return 0UL;
1617

1718
return foot + stream_foot * count;
1819
}
@@ -38,6 +39,7 @@ fd_quic_stream_pool_new( void * mem, ulong count, ulong tx_buf_sz ) {
3839
offs += fd_ulong_align_up( sizeof( fd_quic_stream_pool_t ), FD_QUIC_STREAM_POOL_ALIGN );
3940

4041
ulong stream_foot = fd_quic_stream_footprint( tx_buf_sz );
42+
if( FD_UNLIKELY( !stream_foot ) ) { FD_LOG_WARNING(( "stream footprint is 0: Confirm tx_buf_sz is pow2!" )); return NULL; }
4143

4244
FD_QUIC_STREAM_LIST_SENTINEL( pool->head );
4345

src/waltz/quic/tests/fd_quic_test_helpers.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
#include <sys/socket.h>
99
#include <arpa/inet.h>
1010
#include <netinet/in.h>
11-
#include "../../../ballet/txn/fd_txn.h" /* FD_TXN_MTU */
12-
#include "../../../util/net/fd_eth.h"
1311
#include "../../../util/net/fd_ip4.h"
1412

1513
#if defined(__linux__)

src/waltz/quic/tests/fd_quic_test_helpers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#include "../../aio/fd_aio_pcapng.h"
66
#include "../../udpsock/fd_udpsock.h"
77
#include "../../tls/test_tls_helper.h"
8-
#include "../../../util/net/fd_eth.h"
8+
#include "../../../ballet/txn/fd_txn.h" /* FD_TXN_MTU */
9+
910
#include <stdio.h>
1011

1112
/* Common helpers for QUIC tests. The tests using these gain the

src/waltz/quic/tests/test_quic_bw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ main( int argc,
9494
float loss = fd_env_strip_cmdline_float ( &argc, &argv, "--loss", NULL, 0.0f );
9595
float reorder = fd_env_strip_cmdline_float ( &argc, &argv, "--reorder", NULL, 0.0f );
9696
float duration = fd_env_strip_cmdline_float ( &argc, &argv, "--duration", NULL, 10.0f );
97-
ushort sz = fd_env_strip_cmdline_ushort( &argc, &argv, "--sz", NULL, FRAG_SZ );
97+
ushort sz = fd_env_strip_cmdline_ushort( &argc, &argv, "--sz", NULL, 1UL<<10 );
9898
FD_TEST( sz<=FRAG_SZ );
9999

100100
ulong page_sz = fd_cstr_to_shmem_page_sz( _page_sz );

src/waltz/quic/tests/test_quic_streams.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,22 @@ ulong test_clock( void * ctx ) {
7777
return now;
7878
}
7979

80+
static void
81+
test_invalid_tx_buf_sz( fd_wksp_t * wksp ) {
82+
FD_LOG_NOTICE(( "Testing invalid tx_buf_sz" ));
83+
FD_TEST( !fd_ulong_pow2( FD_TXN_MTU ) );
84+
85+
fd_quic_limits_t const bad_limits = {
86+
.conn_cnt = 2,
87+
.conn_id_cnt = 4,
88+
.handshake_cnt = 10,
89+
.inflight_frame_cnt = 100 * 2,
90+
.tx_buf_sz = FD_TXN_MTU,
91+
.stream_pool_cnt = 512
92+
};
93+
FD_TEST( !fd_quic_new( wksp, &bad_limits ) );
94+
}
95+
8096
int
8197
main( int argc,
8298
char ** argv ) {
@@ -100,6 +116,8 @@ main( int argc,
100116
fd_wksp_t * wksp = fd_wksp_new_anonymous( page_sz, page_cnt, fd_shmem_cpu_idx( numa_idx ), "wksp", 0UL );
101117
FD_TEST( wksp );
102118

119+
test_invalid_tx_buf_sz( wksp );
120+
103121
FD_LOG_NOTICE(( "Creating server QUIC" ));
104122

105123
fd_quic_limits_t const quic_server_limits = {

0 commit comments

Comments
 (0)