Skip to content

Commit c3e0731

Browse files
quic: fix client key discard
1 parent bb7b0af commit c3e0731

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/waltz/quic/fd_quic.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ fd_quic_handle_v1_handshake(
18861886
/* RFC 9000 Section 17.2.2.1. Abandoning Initial Packets
18871887
> A server stops sending and processing Initial packets when it
18881888
> receives its first Handshake packet. */
1889-
fd_quic_abandon_enc_level( conn, fd_quic_enc_level_initial_id );
1889+
if( FD_LIKELY( quic->config.role==FD_QUIC_ROLE_SERVER ) ) fd_quic_abandon_enc_level( conn, fd_quic_enc_level_initial_id );
18901890
conn->peer_enc_level = (uchar)fd_uchar_max( conn->peer_enc_level, fd_quic_enc_level_handshake_id );
18911891

18921892
/* handle frames */
@@ -3562,12 +3562,6 @@ fd_quic_conn_tx( fd_quic_t * quic,
35623562
* This ensures that ack-only packets only occur when nothing else needs
35633563
* to be sent */
35643564
uint enc_level = fd_quic_tx_enc_level( conn, 1 /* acks */ );
3565-
/* RFC 9000 Section 17.2.2.1. Abandoning Initial Packets
3566-
> A client stops both sending and processing Initial packets when
3567-
> it sends its first Handshake packet. */
3568-
if( quic->config.role==FD_QUIC_ROLE_CLIENT && enc_level==fd_quic_enc_level_handshake_id ) {
3569-
fd_quic_abandon_enc_level( conn, fd_quic_enc_level_initial_id );
3570-
}
35713565

35723566
/* nothing to send / bad state? */
35733567
if( enc_level == ~0u ) return;
@@ -3588,6 +3582,13 @@ fd_quic_conn_tx( fd_quic_t * quic,
35883582
//}
35893583

35903584
while( enc_level != ~0u ) {
3585+
/* RFC 9000 Section 17.2.2.1. Abandoning Initial Packets
3586+
> A client stops both sending and processing Initial packets when
3587+
> it sends its first Handshake packet. */
3588+
if( FD_UNLIKELY( (quic->config.role==FD_QUIC_ROLE_CLIENT) & (enc_level==fd_quic_enc_level_handshake_id) ) ) {
3589+
fd_quic_abandon_enc_level( conn, fd_quic_enc_level_initial_id );
3590+
}
3591+
35913592
uint initial_pkt = 0; /* is this the first initial packet? */
35923593

35933594

src/waltz/quic/tests/test_quic_retry_integration.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ test_initial_token_odd_sz( fd_quic_t * server_quic,
9191
/* Verify server sent a retry packet (difference-based check) */
9292
FD_TEST( server_quic->metrics.conn_retry_cnt == initial_retry_count + 1 );
9393

94-
/* Verify the 46-byte token was counted in the "other sizes" category */
94+
/* Verify the 46-byte token was counted in the "other sizes" category
95+
See test_retry_integration for details on the expected increases */
9596
FD_TEST( server_quic->metrics.initial_token_len_cnt[2] == initial_token_len_other + 1 );
96-
FD_TEST( server_quic->metrics.initial_token_len_cnt[1] == initial_token_len_our + 1 );
97+
FD_TEST( server_quic->metrics.initial_token_len_cnt[1] == initial_token_len_our + 2 );
9798

9899
/* Verify the connection was created */
99100
FD_TEST( server_quic->metrics.conn_created_cnt == conn_created_count + 1 );
@@ -126,10 +127,13 @@ test_retry_integration( fd_quic_t * server_quic,
126127
FD_TEST( server_quic->metrics.conn_created_cnt== 1 );
127128
FD_TEST( server_quic->metrics.conn_retry_cnt == 1 );
128129

129-
/* Check initial token length metrics - should have seen 1 packet with no token (idx 0)
130-
and 1 packet with retry token (idx 1) */
130+
/* Check initial token length metrics - should have seen:
131+
* 1 packet with no token (idx 0), the very first initial
132+
* 2 packets with retry token with correct fd_quic len (idx 1):
133+
- first the Initial with crypto frames triggered by Retry
134+
- second an Initial with ack frame, ACKing server Initial */
131135
FD_TEST( server_quic->metrics.initial_token_len_cnt[0] == 1 ); /* no token */
132-
FD_TEST( server_quic->metrics.initial_token_len_cnt[1] == 1 ); /* retry token */
136+
FD_TEST( server_quic->metrics.initial_token_len_cnt[1] == 2 ); /* retry token */
133137
FD_TEST( server_quic->metrics.initial_token_len_cnt[2] == 0 ); /* other sizes */
134138
/* Server: Retry, Initial, Handshake
135139
Client: Initial, Initial, Handshake */

0 commit comments

Comments
 (0)