49 lines
1.8 KiB
Diff
49 lines
1.8 KiB
Diff
From 3ca24f24d9322256bc4c6d3bd237f8b98f073030 Mon Sep 17 00:00:00 2001
|
|
From: Nikos Mavrogiannopoulos <nmav@redhat.com>
|
|
Date: Mon, 29 Aug 2016 13:02:54 +0200
|
|
Subject: [PATCH] dtls: ensure that the DTLS window doesn't get stalled
|
|
|
|
That is ensure that it is forwarded at least one place if more than 16
|
|
packets have been received since the first one.
|
|
---
|
|
lib/dtls-sw.c | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/lib/dtls-sw.c b/lib/dtls-sw.c
|
|
index 616bd5a..8c334c0 100644
|
|
--- a/lib/dtls-sw.c
|
|
+++ b/lib/dtls-sw.c
|
|
@@ -51,7 +51,15 @@
|
|
|
|
#define DTLS_WINDOW_MARK(W, S) ((W)->dtls_sw_bits |= ((uint64_t) 1 << DTLS_WINDOW_OFFSET(W, S)))
|
|
|
|
-#define DTLS_WINDOW_UPDATE(W) while ((W)->dtls_sw_bits & (uint64_t) 1) { \
|
|
+/* We forcefully advance the window once we have received more than
|
|
+ * 8 packets since the first one. That way we ensure that we don't
|
|
+ * get stuck on connections with many lost packets. */
|
|
+#define DTLS_WINDOW_UPDATE(W) \
|
|
+ if (((W)->dtls_sw_bits & 0xffffffffffff0000LL) != 0) { \
|
|
+ (W)->dtls_sw_bits = (W)->dtls_sw_bits >> 1; \
|
|
+ (W)->dtls_sw_start++; \
|
|
+ } \
|
|
+ while ((W)->dtls_sw_bits & (uint64_t) 1) { \
|
|
(W)->dtls_sw_bits = (W)->dtls_sw_bits >> 1; \
|
|
(W)->dtls_sw_start++; \
|
|
}
|
|
--
|
|
libgit2 0.24.0
|
|
|
|
diff --git a/tests/mini-dtls-record.c b/tests/mini-dtls-record.c
|
|
index 1b5a055..8d32d8f 100644
|
|
--- a/tests/mini-dtls-record.c
|
|
+++ b/tests/mini-dtls-record.c
|
|
@@ -163,7 +163,7 @@ static ssize_t n_push(gnutls_transport_ptr_t tr, const void *data, size_t len)
|
|
|
|
/* The first five messages are handshake. Thus corresponds to msg_seq+5 */
|
|
static int recv_msg_seq[] =
|
|
- { 1, 2, 3, 4, 5, 6, 12, 28, 7, 8, 9, 10, 11, 13, 15, 16, 14, 18, 20,
|
|
+ { 1, 2, 3, 4, 5, 6, 12, 28, 8, 9, 10, 11, 13, 15, 16, 14, 18, 20,
|
|
19, 21, 22, 23, 25, 24, 26, 27, 29, 30, 31, 33, 32, 34, 35, 38, 36, 37,
|
|
-1
|
|
};
|