MINOR: quic-be: Parse the NEW_TOKEN frame

Rename ->data qf_new_token struct field to ->w_data to distinguish it from
->r_data new field used to parse the NEW_TOKEN frame. Indeed to build the
NEW_TOKEN we need to write it to a static buffer into the frame struct. To
parse it we only need to store the address of the token field into the
RX buffer.
This commit is contained in:
Frederic Lecaille 2025-08-05 14:15:46 +02:00
parent 64e32a0767
commit 8f23d4d287
3 changed files with 9 additions and 15 deletions

View file

@ -161,7 +161,10 @@ struct qf_crypto {
struct qf_new_token {
uint64_t len;
unsigned char data[QUIC_TOKEN_LEN];
/* Used only to send data */
unsigned char w_data[QUIC_TOKEN_LEN];
/* Used only to receive data */
const unsigned char *r_data;
};
struct qf_stream {

View file

@ -496,14 +496,14 @@ int quic_build_post_handshake_frames(struct quic_conn *qc)
}
new_token_frm_len =
quic_generate_token(frm->new_token.data,
sizeof(frm->new_token.data), &qc->peer_addr);
quic_generate_token(frm->new_token.w_data,
sizeof(frm->new_token.w_data), &qc->peer_addr);
if (!new_token_frm_len) {
TRACE_ERROR("token generation failed", QUIC_EV_CONN_IO_CB, qc);
goto err;
}
BUG_ON(new_token_frm_len != sizeof(frm->new_token.data));
BUG_ON(new_token_frm_len != sizeof(frm->new_token.w_data));
frm->new_token.len = new_token_frm_len;
LIST_APPEND(&frm_list, &frm->list);
}

View file

@ -485,7 +485,7 @@ static int quic_build_new_token_frame(unsigned char **pos, const unsigned char *
if (!quic_enc_int(pos, end, new_token_frm->len) || end - *pos < new_token_frm->len)
return 0;
memcpy(*pos, new_token_frm->data, new_token_frm->len);
memcpy(*pos, new_token_frm->w_data, new_token_frm->len);
*pos += new_token_frm->len;
return 1;
@ -503,16 +503,7 @@ static int quic_parse_new_token_frame(struct quic_frame *frm, struct quic_conn *
if (!quic_dec_int(&new_token_frm->len, pos, end) || end - *pos < new_token_frm->len)
return 0;
/* TODO token length is unknown as it is dependent from the peer. Hence
* dynamic allocation should be implemented for token storage, albeit
* with constraint to ensure memory usage remains reasonable.
*/
#if 0
if (sizeof(new_token_frm->data) < new_token_frm->len)
return 0;
memcpy(new_token_frm->data, *pos, new_token_frm->len);
#endif
new_token_frm->r_data = *pos;
*pos += new_token_frm->len;
return 1;