summaryrefslogtreecommitdiff
path: root/lib/dtls-sw.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-08-29 13:02:54 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-08-29 13:47:31 +0200
commit3ca24f24d9322256bc4c6d3bd237f8b98f073030 (patch)
treea8ee596b9f3aef2e100217f86d2444694bee4ae7 /lib/dtls-sw.c
parentd4122565ba7c2551d727cf812c65bf6f2f8666a3 (diff)
downloadgnutls-3ca24f24d9322256bc4c6d3bd237f8b98f073030.tar.gz
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.
Diffstat (limited to 'lib/dtls-sw.c')
-rw-r--r--lib/dtls-sw.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/dtls-sw.c b/lib/dtls-sw.c
index 616bd5a868..8c334c05af 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++; \
}