diff options
| author | jsing <> | 2026-04-29 15:04:15 +0000 |
|---|---|---|
| committer | jsing <> | 2026-04-29 15:04:15 +0000 |
| commit | dc2d3a2e58818a1cd2370eb926859e774cda4863 (patch) | |
| tree | fe70d903241b58fb9fc552dd0f9a42cfc0410c70 /src | |
| parent | 6673b1f6a6bded8786fbe9889614bd84a31e9c16 (diff) | |
| download | openbsd-dc2d3a2e58818a1cd2370eb926859e774cda4863.tar.gz openbsd-dc2d3a2e58818a1cd2370eb926859e774cda4863.tar.bz2 openbsd-dc2d3a2e58818a1cd2370eb926859e774cda4863.zip | |
Avoid unnecessary lookups in dtls1_retransmit_message().
dtls1_retransmit_buffered_messages() is iterating over the sent_messages
pqueue, only to pass dtls1_retransmit_message() a sequence number that it
turns back into a priority, to then do a lookup on the sent_messages pqueue.
This is pointless given that we already have the message that we need to
retransmit - just pass that to dtls1_retransmit_message() directly.
ok kenjiro@ tb@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/d1_both.c | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/src/lib/libssl/d1_both.c b/src/lib/libssl/d1_both.c index a80f26b31a..6554b0a9b8 100644 --- a/src/lib/libssl/d1_both.c +++ b/src/lib/libssl/d1_both.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: d1_both.c,v 1.89 2026/04/29 15:00:53 jsing Exp $ */ | 1 | /* $OpenBSD: d1_both.c,v 1.90 2026/04/29 15:04:15 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * DTLS implementation written by Nagendra Modadugu | 3 | * DTLS implementation written by Nagendra Modadugu |
| 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. | 4 | * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. |
| @@ -899,37 +899,11 @@ dtls1_get_queue_priority(unsigned short seq, int is_ccs) | |||
| 899 | } | 899 | } |
| 900 | 900 | ||
| 901 | static int | 901 | static int |
| 902 | dtls1_retransmit_message(SSL *s, unsigned short seq, int *found) | 902 | dtls1_retransmit_message(SSL *s, hm_fragment *frag) |
| 903 | { | 903 | { |
| 904 | int ret; | ||
| 905 | /* XDTLS: for now assuming that read/writes are blocking */ | ||
| 906 | pitem *item; | ||
| 907 | hm_fragment *frag; | ||
| 908 | unsigned long header_length; | ||
| 909 | unsigned char seq64be[8]; | ||
| 910 | struct dtls1_retransmit_state saved_state; | 904 | struct dtls1_retransmit_state saved_state; |
| 911 | 905 | unsigned long header_length; | |
| 912 | /* | 906 | int ret; |
| 913 | OPENSSL_assert(s->init_num == 0); | ||
| 914 | OPENSSL_assert(s->init_off == 0); | ||
| 915 | */ | ||
| 916 | |||
| 917 | /* XDTLS: the requested message ought to be found, otherwise error */ | ||
| 918 | memset(seq64be, 0, sizeof(seq64be)); | ||
| 919 | seq64be[6] = (unsigned char)(seq >> 8); | ||
| 920 | seq64be[7] = (unsigned char)seq; | ||
| 921 | |||
| 922 | item = pqueue_find(s->d1->sent_messages, seq64be); | ||
| 923 | if (item == NULL) { | ||
| 924 | #ifdef DEBUG | ||
| 925 | fprintf(stderr, "retransmit: message %d non-existent\n", seq); | ||
| 926 | #endif | ||
| 927 | *found = 0; | ||
| 928 | return 0; | ||
| 929 | } | ||
| 930 | |||
| 931 | *found = 1; | ||
| 932 | frag = (hm_fragment *)item->data; | ||
| 933 | 907 | ||
| 934 | if (frag->msg_header.is_ccs) | 908 | if (frag->msg_header.is_ccs) |
| 935 | header_length = DTLS1_CCS_HEADER_LENGTH; | 909 | header_length = DTLS1_CCS_HEADER_LENGTH; |
| @@ -978,17 +952,12 @@ dtls1_retransmit_buffered_messages(SSL *s) | |||
| 978 | piterator iter; | 952 | piterator iter; |
| 979 | pitem *item; | 953 | pitem *item; |
| 980 | hm_fragment *frag; | 954 | hm_fragment *frag; |
| 981 | int found = 0; | ||
| 982 | 955 | ||
| 983 | iter = pqueue_iterator(sent); | 956 | iter = pqueue_iterator(sent); |
| 984 | 957 | ||
| 985 | for (item = pqueue_next(&iter); item != NULL; | 958 | for (item = pqueue_next(&iter); item != NULL; item = pqueue_next(&iter)) { |
| 986 | item = pqueue_next(&iter)) { | ||
| 987 | frag = (hm_fragment *)item->data; | 959 | frag = (hm_fragment *)item->data; |
| 988 | if (dtls1_retransmit_message(s, | 960 | if (dtls1_retransmit_message(s, frag) <= 0) { |
| 989 | (unsigned short)dtls1_get_queue_priority( | ||
| 990 | frag->msg_header.seq, frag->msg_header.is_ccs), | ||
| 991 | &found) <= 0 && found) { | ||
| 992 | #ifdef DEBUG | 961 | #ifdef DEBUG |
| 993 | fprintf(stderr, "dtls1_retransmit_message() failed\n"); | 962 | fprintf(stderr, "dtls1_retransmit_message() failed\n"); |
| 994 | #endif | 963 | #endif |
