Skip to content

Commit

Permalink
QUIC_CHANNEL: Handle deferred packet processing after yielding of sec…
Browse files Browse the repository at this point in the history
…rets correctly

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #19703)
  • Loading branch information
hlandau committed Jan 13, 2023
1 parent d7668ff commit 4e64437
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
24 changes: 17 additions & 7 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ static int ch_on_handshake_yield_secret(uint32_t enc_level, int direction,
return 0;
}

ch->have_new_secret = 1;
return 1;
}

Expand Down Expand Up @@ -1007,14 +1008,23 @@ static void ch_tick(QUIC_TICK_RESULT *res, void *arg)
}
}

/* Handle any incoming data from the network. */
ch_rx(ch);
do {
/* Handle any incoming data from the network. */
ch_rx(ch);

/*
* Allow the handshake layer to check for any new incoming data and generate
* new outgoing data.
*/
ossl_quic_dhs_tick(ch->dhs);
/*
* Allow the handshake layer to check for any new incoming data and generate
* new outgoing data.
*/
ch->have_new_secret = 0;
ossl_quic_dhs_tick(ch->dhs);

/*
* If the handshake layer gave us a new secret, we need to do RX again
* because packets that were not previously processable and were
* deferred might now be processable.
*/
} while (ch->have_new_secret);

/*
* Handle any timer events which are due to fire; namely, the loss detection
Expand Down
6 changes: 6 additions & 0 deletions ssl/quic/quic_channel_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ struct quic_channel_st {

/* Are we in server mode? Never changes after instantiation. */
unsigned int is_server : 1;

/*
* Set temporarily when the handshake layer has given us a new secret. Used
* to determine if we need to check our RX queues again.
*/
unsigned int have_new_secret : 1;
};

# endif
Expand Down

0 comments on commit 4e64437

Please sign in to comment.