diff --git a/src/tango/fd_tango_base.h b/src/tango/fd_tango_base.h index 41b8ca2c91..0049a11969 100644 --- a/src/tango/fd_tango_base.h +++ b/src/tango/fd_tango_base.h @@ -242,7 +242,7 @@ FD_FN_CONST static inline long fd_seq_diff( ulong a, ulong b ) { return (long)(a chunk whose index is 0 (chunk0). fd_chunk_to_laddr_const is for const-correctness. - fd_laddr_to_chunk: vica versa. */ + fd_laddr_to_chunk: vice versa. */ FD_FN_CONST static inline void * /* Will be aligned FD_CHUNK_ALIGN and in [ chunk0, chunk0 + FD_CHUNK_SZ*(UINT_MAX+1) ) */ fd_chunk_to_laddr( void * chunk0, /* Assumed aligned FD_CHUNK_ALIGN */ diff --git a/src/waltz/quic/fd_quic.c b/src/waltz/quic/fd_quic.c index 5b8627ebde..19eb6b5e53 100644 --- a/src/waltz/quic/fd_quic.c +++ b/src/waltz/quic/fd_quic.c @@ -1238,7 +1238,7 @@ fd_quic_send_retry( fd_quic_t * quic, dst_udp_port, 1 ) == FD_QUIC_FAILED ) ) { return FD_QUIC_PARSE_FAIL; - }; + } return 0UL; } @@ -1531,11 +1531,11 @@ fd_quic_handle_v1_initial( fd_quic_t * quic, ulong pn_offset = initial->pkt_num_pnoff; ulong body_sz = initial->len; /* not a protected field */ - /* length of payload + num packet bytes */ + /* length of payload + num packet bytes */ - ulong pkt_number = (ulong)ULONG_MAX; - ulong pkt_number_sz = (ulong)ULONG_MAX; - ulong tot_sz = (ulong)ULONG_MAX; + ulong pkt_number = ULONG_MAX; + ulong pkt_number_sz = ULONG_MAX; + ulong tot_sz = ULONG_MAX; # if !FD_QUIC_DISABLE_CRYPTO /* this decrypts the header */ @@ -1704,9 +1704,9 @@ fd_quic_handle_v1_handshake( ulong body_sz = handshake->len; /* not a protected field */ /* length of payload + num packet bytes */ - ulong pkt_number = (ulong)-1; - ulong pkt_number_sz = (ulong)-1; - ulong tot_sz = (ulong)-1; + ulong pkt_number = ULONG_MAX; + ulong pkt_number_sz = ULONG_MAX; + ulong tot_sz = ULONG_MAX; # if !FD_QUIC_DISABLE_CRYPTO /* this decrypts the header */ @@ -1858,7 +1858,7 @@ fd_quic_handle_v1_retry( fd_memcpy( &conn->token, retry_token, conn->token_len ); /* have to rewind the handshake data */ - uint enc_level = 0; + uint enc_level = fd_quic_enc_level_initial_id; conn->hs_sent_bytes[enc_level] = 0; conn->hs_data_empty = 0; @@ -2369,7 +2369,7 @@ fd_quic_process_packet( fd_quic_t * quic, /* 0UL means no progress, so fail */ if( FD_UNLIKELY( ( rc == FD_QUIC_PARSE_FAIL ) | - ( rc == 0UL ) )) { + ( rc == 0UL ) ) ) { FD_DEBUG( FD_LOG_DEBUG(( "fd_quic_process_quic_packet_v1 failed (stuck=%d)", rc==0UL )) ); return; } @@ -2675,7 +2675,7 @@ fd_quic_frame_handle_crypto_frame( void * vp_context, if( !conn->tls_hs ) { /* Handshake already completed. Ignore frame */ - /* TODO consider aborting conn if too many unsoliticted crypto frames arrive */ + /* TODO consider aborting conn if too many unsolicited crypto frames arrive */ } else if( FD_UNLIKELY( rcv_offset > exp_offset ) ) { /* if data arrived early, we could buffer, but for now we simply won't ack */ /* TODO buffer handshake data */ @@ -4097,7 +4097,7 @@ fd_quic_conn_free( fd_quic_t * quic, this should not occur, so this branch should not execute but if a stream doesn't get cleaned up properly, this fixes the stream map */ - if( fd_quic_stream_map_key_cnt( conn->stream_map ) > 0 ) { + if( FD_UNLIKELY( fd_quic_stream_map_key_cnt( conn->stream_map ) > 0 ) ) { FD_LOG_WARNING(( "stream_map not empty. cnt: %lu", (ulong)fd_quic_stream_map_key_cnt( conn->stream_map ) )); while( fd_quic_stream_map_key_cnt( conn->stream_map ) > 0 ) { @@ -4126,12 +4126,7 @@ fd_quic_conn_free( fd_quic_t * quic, /* remove connection from service queue */ if( FD_LIKELY( conn->svc_type != UINT_MAX ) ) { - uint prev_idx = conn->svc_prev; - uint next_idx = conn->svc_next; - fd_quic_conn_t * prev = fd_quic_conn_at_idx( state, prev_idx ); - fd_quic_conn_t * next = fd_quic_conn_at_idx( state, next_idx ); - *fd_ptr_if( prev_idx!=UINT_MAX, &prev->svc_next, &state->svc_queue[ conn->svc_type ].tail ) = next_idx; - *fd_ptr_if( next_idx!=UINT_MAX, &next->svc_prev, &state->svc_queue[ conn->svc_type ].head ) = prev_idx; + fd_quic_svc_unqueue( state, conn ); } /* put connection back in free list */ @@ -5069,11 +5064,6 @@ fd_quic_frame_handle_ack_frame( fd_quic_ack_frame_t * data, uchar const * p, ulong p_sz) { - (void)vp_context; - (void)data; - (void)p; - (void)p_sz; - fd_quic_frame_context_t context = *(fd_quic_frame_context_t*)vp_context; uint enc_level = context.pkt->enc_level; @@ -5084,7 +5074,7 @@ fd_quic_frame_handle_ack_frame( return FD_QUIC_PARSE_FAIL; } - /* track lowest packet ack'd */ + /* track lowest packet acked */ ulong low_ack_pkt_number = data->largest_ack - data->first_ack_range; /* ack packets are not ack-eliciting (they are acked with other things) */ @@ -5316,9 +5306,6 @@ fd_quic_frame_handle_stream_frame( fd_quic_stream_frame_t * data, uchar const * p, ulong p_sz ) { - (void)data; - (void)p; - (void)p_sz; fd_quic_frame_context_t * context = (fd_quic_frame_context_t *)vp_context; fd_quic_t * quic = context->quic; @@ -5440,7 +5427,7 @@ fd_quic_frame_handle_stream_frame( /* peer created a stream, we cannot send on it */ stream->state = FD_QUIC_STREAM_STATE_TX_FIN; - stream->stream_flags = 0UL; + stream->stream_flags = 0u; /* flow control */ stream->tx_max_stream_data = 0; /* can't send since peer initiated */ diff --git a/src/waltz/quic/fd_quic_private.h b/src/waltz/quic/fd_quic_private.h index 58eedcce2e..c65a41ac78 100644 --- a/src/waltz/quic/fd_quic_private.h +++ b/src/waltz/quic/fd_quic_private.h @@ -390,9 +390,9 @@ fd_quic_lazy_ack_pkt( fd_quic_t * quic, /* fd_quic_conn_error sets the connection state to aborted. This does not destroy the connection object. Rather, it will eventually cause the connection to be freed during a later fd_quic_service call. - reason is a RFC 9000 QUIC error code. error_line is a implementation - defined error code for internal use (usually the source line of code - in fd_quic.c) */ + reason is an RFC 9000 QUIC error code. error_line is an + implementation defined error code for internal use (usually the + source line of code in fd_quic.c) */ void fd_quic_conn_error( fd_quic_conn_t * conn, diff --git a/src/waltz/quic/fd_quic_retry.h b/src/waltz/quic/fd_quic_retry.h index 04ff620359..48361073d5 100644 --- a/src/waltz/quic/fd_quic_retry.h +++ b/src/waltz/quic/fd_quic_retry.h @@ -26,7 +26,7 @@ FD_PROTOTYPES_BEGIN /* fd_quic_retry_integrity_tag_{sign,verify} implement the RFC 9001 "Retry Integrity Tag" AEAD scheme. - This is a standard and mandatory step in the QUIC retry proces, both + This is a standard and mandatory step in the QUIC retry process, both on the server (sign) and client (verify) side. Confusingly, all inputs to these functions are either public constants (e.g. the hardcoded encryption key) or sent in plain text over the wire. Thus, @@ -43,7 +43,7 @@ FD_PROTOTYPES_BEGIN fd_quic_retry_integrity_tag_decrypt checks whether a Retry Integrity Tag matches the byte range at retry_pseudo_pkt. It returns - FD_QUIC_SUCCESS if the integrity tag is vaild, and FD_QUIC_FAILURE + FD_QUIC_SUCCESS if the integrity tag is valid, and FD_QUIC_FAILURE otherwise. */ static inline void diff --git a/src/waltz/quic/fd_quic_stream.h b/src/waltz/quic/fd_quic_stream.h index 0583362d60..9adc8a5b46 100644 --- a/src/waltz/quic/fd_quic_stream.h +++ b/src/waltz/quic/fd_quic_stream.h @@ -153,8 +153,6 @@ struct fd_quic_stream { (stream)->next = (stream)->prev = stream; \ } while(0) - - /* stream map for use in fd_map_dynamic map */ struct fd_quic_stream_map { ulong stream_id; /* key */ diff --git a/src/waltz/quic/templ/fd_quic_templ.h b/src/waltz/quic/templ/fd_quic_templ.h index fd97061f86..a9e81bd2cc 100644 --- a/src/waltz/quic/templ/fd_quic_templ.h +++ b/src/waltz/quic/templ/fd_quic_templ.h @@ -195,7 +195,7 @@ FD_TEMPL_DEF_STRUCT_END(retry_hdr) } Figure 19: 1-RTT Packet */ FD_TEMPL_DEF_STRUCT_BEGIN(one_rtt) - FD_TEMPL_MBR_ELEM ( h0, uchar ) + FD_TEMPL_MBR_ELEM ( h0, uchar ) FD_TEMPL_MBR_ELEM_HIDDEN( dst_conn_id_len, uint ) FD_TEMPL_MBR_ELEM_VAR ( dst_conn_id, 0,160, dst_conn_id_len ) diff --git a/src/waltz/tls/fd_tls_estate.h b/src/waltz/tls/fd_tls_estate.h index 91f13d1329..ecd59dbf69 100644 --- a/src/waltz/tls/fd_tls_estate.h +++ b/src/waltz/tls/fd_tls_estate.h @@ -125,6 +125,10 @@ FD_PROTOTYPES_END Finished" verify data. */ struct fd_tls_estate_srv { + /* TLS base (hs) handles are deliberately placed at the start. + Allows for type punning between fd_quic_tls_hs_t and + fd_tls_estate_{srv,cli}_t. DO NOT MOVE. + Type of handshake object depends on is_server. */ fd_tls_estate_base_t base; uchar server_cert_rpk : 1; /* 0: X.509 1: raw public key */ @@ -181,6 +185,10 @@ FD_PROTOTYPES_END Thus, estate_cli is not optimized for memory use. */ struct fd_tls_estate_cli { + /* TLS handshake handles are deliberately placed at the start. + Allows for type punning between fd_quic_tls_hs_t and + fd_tls_estate_{srv,cli}_t. DO NOT MOVE. + Type of handshake object depends on is_server. */ fd_tls_estate_base_t base; uchar server_pubkey [ 32 ]; diff --git a/src/waltz/tls/test_tls.c b/src/waltz/tls/test_tls.c index d90670560a..159756f2e1 100644 --- a/src/waltz/tls/test_tls.c +++ b/src/waltz/tls/test_tls.c @@ -134,10 +134,10 @@ test_tls_client_respond( fd_tls_t * client, while( (rec = test_record_recv( &test_server_out )) ) { long res = fd_tls_client_handshake( client, hs, rec->buf, rec->cur, rec->level ); if( res<0L ) { + fd_halt(); FD_LOG_ERR(( "fd_tls_client_handshake failed (alert %ld-%s; reason %u-%s)", res, fd_tls_alert_cstr( (uint)-res ), hs->base.reason, fd_tls_reason_cstr( hs->base.reason ) )); - fd_halt(); } } } @@ -149,10 +149,10 @@ test_tls_server_respond( fd_tls_t * server, while( (rec = test_record_recv( &test_client_out )) ) { long res = fd_tls_server_handshake( server, hs, rec->buf, rec->cur, rec->level ); if( res<0L ) { + fd_halt(); FD_LOG_ERR(( "fd_tls_server_handshake failed (alert %ld-%s; reason %u-%s)", res, fd_tls_alert_cstr( (uint)-res ), hs->base.reason, fd_tls_reason_cstr( hs->base.reason ) )); - fd_halt(); } } }