summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2015-01-21 15:27:12 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2015-01-21 15:27:12 +0100
commita7594a2230577a488cd8d17131f4ec5e0df6829e (patch)
tree7092f42ee52eaa6a9e558a43ba506ef1b29eef64 /src
parentceb66fb221184eb8f0136ac141ff6c2c8d3245fa (diff)
downloadfastd-a7594a2230577a488cd8d17131f4ec5e0df6829e.tar
fastd-a7594a2230577a488cd8d17131f4ec5e0df6829e.zip
Fix handling of severe packet reordering
fastd would incorrectly mark wrong sequence numbers as seen when reordering by more than 64 sequence numbers had occured.
Diffstat (limited to 'src')
-rw-r--r--src/methods/common.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/methods/common.c b/src/methods/common.c
index 24f099b..4d1a795 100644
--- a/src/methods/common.c
+++ b/src/methods/common.c
@@ -84,7 +84,7 @@ bool fastd_method_is_nonce_valid(const fastd_method_common_t *session, const uin
*/
fastd_tristate_t fastd_method_reorder_check(fastd_peer_t *peer, fastd_method_common_t *session, const uint8_t nonce[COMMON_NONCEBYTES], int64_t age) {
if (age < 0) {
- size_t shift = age < (-64) ? 64 : ((size_t)-age);
+ size_t shift = -age;
if (shift >= 64)
session->receive_reorder_seen = 0;
@@ -98,13 +98,13 @@ fastd_tristate_t fastd_method_reorder_check(fastd_peer_t *peer, fastd_method_com
session->reorder_timeout = ctx.now + REORDER_TIME;
return fastd_tristate_false;
}
- else if (age == 0 || session->receive_reorder_seen & (1 << (age-1))) {
+ else if (age == 0 || session->receive_reorder_seen & ((uint64_t)1 << (age-1))) {
pr_debug("dropping duplicate packet from %P (age %u)", peer, (unsigned)age);
return fastd_tristate_undef;
}
else {
pr_debug2("accepting reordered packet from %P (age %u)", peer, (unsigned)age);
- session->receive_reorder_seen |= (1 << (age-1));
+ session->receive_reorder_seen |= ((uint64_t)1 << (age-1));
return fastd_tristate_true;
}
}