Pad packet containing challenges
@@ -2776,6 +2776,7 @@ int picoquic_prepare_packet_almost_ready(picoquic_cnx_t* cnx, picoquic_path_t* p
uint8_t* bytes_next = NULL;
int more_data = 0;
int stream_tried_and_failed = 0;
+ int is_challenge_sent = 0;
/* Perform amplification prevention check */
if (!cnx->initial_validated &&
@@ -2842,6 +2843,7 @@ int picoquic_prepare_packet_almost_ready(picoquic_cnx_t* cnx, picoquic_path_t* p
if (bytes_next > bytes_challenge) {
path_x->challenge_time = current_time;
path_x->challenge_repeat_count++;
+ is_challenge_sent = 1;
}
/* add an ACK just to be nice */
@@ -3031,7 +3033,7 @@ int picoquic_prepare_packet_almost_ready(picoquic_cnx_t* cnx, picoquic_path_t* p
/* Ensure that all packets are properly padded before being sent. */
- if (*is_initial_sent && cnx->client_mode) {
+ if ((*is_initial_sent && cnx->client_mode) || (is_challenge_sent && length < PICOQUIC_ENFORCED_INITIAL_MTU)){
length = picoquic_pad_to_target_length(bytes, length, (uint32_t)(send_buffer_min_max - checksum_overhead));
}
else {
@@ -3079,6 +3081,7 @@ int picoquic_prepare_packet_ready(picoquic_cnx_t* cnx, picoquic_path_t* path_x,
uint8_t* bytes_next;
int more_data = 0;
int ack_sent = 0;
+ int is_challenge_sent = 0;
packet->pc = pc;
@@ -3152,6 +3155,7 @@ int picoquic_prepare_packet_ready(picoquic_cnx_t* cnx, picoquic_path_t* path_x,
if (bytes_next > bytes_challenge) {
path_x->challenge_time = current_time;
path_x->challenge_repeat_count++;
+ is_challenge_sent = 1;
}
/* add an ACK just to be nice */
@@ -3424,7 +3428,7 @@ int picoquic_prepare_packet_ready(picoquic_cnx_t* cnx, picoquic_path_t* path_x,
if (ret == 0 && length > header_length) {
/* Ensure that all packets are properly padded before being sent. */
- if (*is_initial_sent && cnx->client_mode) {
+ if ((*is_initial_sent && cnx->client_mode) || (is_challenge_sent && length < PICOQUIC_ENFORCED_INITIAL_MTU)){
length = picoquic_pad_to_target_length(bytes, length, (uint32_t)(send_buffer_min_max - checksum_overhead));
}
else {
