Move buffered_app_data from s->d1 to s->rlayer.d
Reviewed-by: Richard Levitte <levitte@openssl.org>
This commit is contained in:
parent
c661ac1689
commit
24a1e2f2ec
4 changed files with 29 additions and 30 deletions
20
ssl/d1_lib.c
20
ssl/d1_lib.c
|
@ -138,7 +138,6 @@ int dtls1_new(SSL *s)
|
|||
|
||||
d1->buffered_messages = pqueue_new();
|
||||
d1->sent_messages = pqueue_new();
|
||||
d1->buffered_app_data.q = pqueue_new();
|
||||
|
||||
if (s->server) {
|
||||
d1->cookie_len = sizeof(s->d1->cookie);
|
||||
|
@ -147,14 +146,11 @@ int dtls1_new(SSL *s)
|
|||
d1->link_mtu = 0;
|
||||
d1->mtu = 0;
|
||||
|
||||
if (!d1->buffered_messages || !d1->sent_messages
|
||||
|| !d1->buffered_app_data.q) {
|
||||
if (!d1->buffered_messages || !d1->sent_messages) {
|
||||
if (d1->buffered_messages)
|
||||
pqueue_free(d1->buffered_messages);
|
||||
if (d1->sent_messages)
|
||||
pqueue_free(d1->sent_messages);
|
||||
if (d1->buffered_app_data.q)
|
||||
pqueue_free(d1->buffered_app_data.q);
|
||||
OPENSSL_free(d1);
|
||||
ssl3_free(s);
|
||||
return (0);
|
||||
|
@ -169,7 +165,6 @@ static void dtls1_clear_queues(SSL *s)
|
|||
{
|
||||
pitem *item = NULL;
|
||||
hm_fragment *frag = NULL;
|
||||
DTLS1_RECORD_DATA *rdata;
|
||||
|
||||
while ((item = pqueue_pop(s->d1->buffered_messages)) != NULL) {
|
||||
frag = (hm_fragment *)item->data;
|
||||
|
@ -182,15 +177,6 @@ static void dtls1_clear_queues(SSL *s)
|
|||
dtls1_hm_fragment_free(frag);
|
||||
pitem_free(item);
|
||||
}
|
||||
|
||||
while ((item = pqueue_pop(s->d1->buffered_app_data.q)) != NULL) {
|
||||
rdata = (DTLS1_RECORD_DATA *)item->data;
|
||||
if (rdata->rbuf.buf) {
|
||||
OPENSSL_free(rdata->rbuf.buf);
|
||||
}
|
||||
OPENSSL_free(item->data);
|
||||
pitem_free(item);
|
||||
}
|
||||
}
|
||||
|
||||
void dtls1_free(SSL *s)
|
||||
|
@ -203,7 +189,6 @@ void dtls1_free(SSL *s)
|
|||
|
||||
pqueue_free(s->d1->buffered_messages);
|
||||
pqueue_free(s->d1->sent_messages);
|
||||
pqueue_free(s->d1->buffered_app_data.q);
|
||||
|
||||
OPENSSL_free(s->d1);
|
||||
s->d1 = NULL;
|
||||
|
@ -213,7 +198,6 @@ void dtls1_clear(SSL *s)
|
|||
{
|
||||
pqueue buffered_messages;
|
||||
pqueue sent_messages;
|
||||
pqueue buffered_app_data;
|
||||
unsigned int mtu;
|
||||
unsigned int link_mtu;
|
||||
|
||||
|
@ -222,7 +206,6 @@ void dtls1_clear(SSL *s)
|
|||
if (s->d1) {
|
||||
buffered_messages = s->d1->buffered_messages;
|
||||
sent_messages = s->d1->sent_messages;
|
||||
buffered_app_data = s->d1->buffered_app_data.q;
|
||||
mtu = s->d1->mtu;
|
||||
link_mtu = s->d1->link_mtu;
|
||||
|
||||
|
@ -241,7 +224,6 @@ void dtls1_clear(SSL *s)
|
|||
|
||||
s->d1->buffered_messages = buffered_messages;
|
||||
s->d1->sent_messages = sent_messages;
|
||||
s->d1->buffered_app_data.q = buffered_app_data;
|
||||
}
|
||||
|
||||
ssl3_clear(s);
|
||||
|
|
|
@ -136,12 +136,16 @@ int DTLS_RECORD_LAYER_new(RECORD_LAYER *rl)
|
|||
|
||||
d->unprocessed_rcds.q = pqueue_new();
|
||||
d->processed_rcds.q = pqueue_new();
|
||||
d->buffered_app_data.q = pqueue_new();
|
||||
|
||||
if (!d->unprocessed_rcds.q || !d->processed_rcds.q) {
|
||||
if (!d->unprocessed_rcds.q || !d->processed_rcds.q
|
||||
|| !d->buffered_app_data.q) {
|
||||
if (d->unprocessed_rcds.q)
|
||||
pqueue_free(d->unprocessed_rcds.q);
|
||||
if (d->processed_rcds.q)
|
||||
pqueue_free(d->processed_rcds.q);
|
||||
if (d->buffered_app_data.q)
|
||||
pqueue_free(d->buffered_app_data.q);
|
||||
OPENSSL_free(d);
|
||||
rl->d = NULL;
|
||||
return (0);
|
||||
|
@ -155,6 +159,7 @@ void DTLS_RECORD_LAYER_free(RECORD_LAYER *rl)
|
|||
DTLS_RECORD_LAYER_clear(rl);
|
||||
pqueue_free(rl->d->unprocessed_rcds.q);
|
||||
pqueue_free(rl->d->processed_rcds.q);
|
||||
pqueue_free(rl->d->buffered_app_data.q);
|
||||
OPENSSL_free(rl->d);
|
||||
rl->d = NULL;
|
||||
}
|
||||
|
@ -166,6 +171,7 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
|
|||
DTLS1_RECORD_DATA *rdata;
|
||||
pqueue unprocessed_rcds;
|
||||
pqueue processed_rcds;
|
||||
pqueue buffered_app_data;
|
||||
|
||||
d = rl->d;
|
||||
|
||||
|
@ -187,11 +193,22 @@ void DTLS_RECORD_LAYER_clear(RECORD_LAYER *rl)
|
|||
pitem_free(item);
|
||||
}
|
||||
|
||||
while ((item = pqueue_pop(d->buffered_app_data.q)) != NULL) {
|
||||
rdata = (DTLS1_RECORD_DATA *)item->data;
|
||||
if (rdata->rbuf.buf) {
|
||||
OPENSSL_free(rdata->rbuf.buf);
|
||||
}
|
||||
OPENSSL_free(item->data);
|
||||
pitem_free(item);
|
||||
}
|
||||
|
||||
unprocessed_rcds = d->unprocessed_rcds.q;
|
||||
processed_rcds = d->processed_rcds.q;
|
||||
buffered_app_data = d->buffered_app_data.q;
|
||||
memset(d, 0, sizeof *d);
|
||||
d->unprocessed_rcds.q = unprocessed_rcds;
|
||||
d->processed_rcds.q = processed_rcds;
|
||||
d->buffered_app_data.q = buffered_app_data;
|
||||
}
|
||||
|
||||
static int have_handshake_fragment(SSL *s, int type, unsigned char *buf,
|
||||
|
@ -441,7 +458,7 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
|
|||
*/
|
||||
if (s->state == SSL_ST_OK && rr->length == 0) {
|
||||
pitem *item;
|
||||
item = pqueue_pop(s->d1->buffered_app_data.q);
|
||||
item = pqueue_pop(s->rlayer.d->buffered_app_data.q);
|
||||
if (item) {
|
||||
#ifndef OPENSSL_NO_SCTP
|
||||
/* Restore bio_dgram_sctp_rcvinfo struct */
|
||||
|
@ -491,8 +508,8 @@ int dtls1_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek)
|
|||
* the packets were reordered on their way, so buffer the application
|
||||
* data for later processing rather than dropping the connection.
|
||||
*/
|
||||
if (dtls1_buffer_record(s, &(s->d1->buffered_app_data), rr->seq_num) <
|
||||
0) {
|
||||
if (dtls1_buffer_record(s, &(s->rlayer.d->buffered_app_data),
|
||||
rr->seq_num) < 0) {
|
||||
SSLerr(SSL_F_DTLS1_READ_BYTES, ERR_R_INTERNAL_ERROR);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -151,7 +151,12 @@ typedef struct dtls_record_layer_st {
|
|||
/* Received handshake records (processed and unprocessed) */
|
||||
record_pqueue unprocessed_rcds;
|
||||
record_pqueue processed_rcds;
|
||||
|
||||
/*
|
||||
* Buffered application records. Only for records between CCS and
|
||||
* Finished to prevent either protocol violation or unnecessary message
|
||||
* loss.
|
||||
*/
|
||||
record_pqueue buffered_app_data;
|
||||
/*
|
||||
* storage for Alert/Handshake protocol data received but not yet
|
||||
* processed by ssl3_read_bytes:
|
||||
|
|
|
@ -1415,12 +1415,7 @@ typedef struct dtls1_state_st {
|
|||
pqueue buffered_messages;
|
||||
/* Buffered (sent) handshake records */
|
||||
pqueue sent_messages;
|
||||
/*
|
||||
* Buffered application records. Only for records between CCS and
|
||||
* Finished to prevent either protocol violation or unnecessary message
|
||||
* loss.
|
||||
*/
|
||||
record_pqueue buffered_app_data;
|
||||
|
||||
/* Is set when listening for new connections with dtls1_listen() */
|
||||
unsigned int listen;
|
||||
unsigned int link_mtu; /* max on-the-wire DTLS packet size */
|
||||
|
|
Loading…
Reference in a new issue