Skip to content

Commit d2fd47d

Browse files
authored
quic: prevent premature 1-RTT packets (#6805)
1 parent bf71b6f commit d2fd47d

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/waltz/quic/fd_quic.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,11 @@ fd_quic_tx_enc_level( fd_quic_conn_t * conn, int acks ) {
888888
return fd_quic_enc_level_appdata_id;
889889
}
890890

891-
if( conn->flags && conn->upd_pkt_number >= app_pkt_number ) {
891+
/* only allow 1-RTT "flag" frames when we have the keys, to prevent e.g. early 1-RTT PINGs */
892+
uint flags_pending = conn->flags & ~(FD_QUIC_CONN_FLAGS_CLOSE_SENT | FD_QUIC_CONN_FLAGS_PING_SENT);
893+
if( ( flags_pending != 0U )
894+
& ( conn->upd_pkt_number >= app_pkt_number )
895+
& fd_uint_extract_bit( conn->keys_avail, fd_quic_enc_level_appdata_id ) ) {
892896
return fd_quic_enc_level_appdata_id;
893897
}
894898

@@ -2891,7 +2895,7 @@ fd_quic_svc_poll( fd_quic_t * quic,
28912895
}
28922896
} else if( quic->config.keep_alive & !!(conn->let_die_time_ns > now) ) {
28932897
/* send PING */
2894-
if( !( conn->flags & FD_QUIC_CONN_FLAGS_PING ) ) {
2898+
if( !( conn->flags & ( FD_QUIC_CONN_FLAGS_PING | FD_QUIC_CONN_FLAGS_PING_SENT ) ) ) {
28952899
conn->flags |= FD_QUIC_CONN_FLAGS_PING;
28962900
conn->upd_pkt_number = FD_QUIC_PKT_NUM_PENDING; /* update to be sent in next packet */
28972901
}
@@ -3876,8 +3880,7 @@ fd_quic_conn_service( fd_quic_t * quic, fd_quic_conn_t * conn, long now ) {
38763880
/* Send new rtt measurement probe? */
38773881
if( FD_UNLIKELY( now > conn->last_ack + (long)conn->rtt_period_ns ) ) {
38783882
/* send PING */
3879-
if( !( conn->flags & ( FD_QUIC_CONN_FLAGS_PING | FD_QUIC_CONN_FLAGS_PING_SENT ) )
3880-
&& conn->state == FD_QUIC_CONN_STATE_ACTIVE ) {
3883+
if( !( conn->flags & ( FD_QUIC_CONN_FLAGS_PING | FD_QUIC_CONN_FLAGS_PING_SENT ) ) ) {
38813884
conn->flags |= FD_QUIC_CONN_FLAGS_PING;
38823885
conn->upd_pkt_number = FD_QUIC_PKT_NUM_PENDING; /* update to be sent in next packet */
38833886
}

0 commit comments

Comments
 (0)