summaryrefslogtreecommitdiff
path: root/src/lib/frct.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2022-03-28 20:29:03 +0200
committerSander Vrijders <sander@ouroboros.rocks>2022-03-30 15:12:25 +0200
commit64cbe652a72ac81a3d5efc4bb01d25dd52166137 (patch)
tree9d801d60aafae22d0de4602bdb2fde4217f5a33d /src/lib/frct.c
parentefe850f4f90967649cdb27cfa29ca0a17127f932 (diff)
downloadouroboros-64cbe652a72ac81a3d5efc4bb01d25dd52166137.tar.gz
ouroboros-64cbe652a72ac81a3d5efc4bb01d25dd52166137.zip
lib: Fix unidirectional FRCT traffic handling
Unidirectional traffic has one of the peers only send bare FRCT packets. These never set a DRF, since they have no sequence number. At the receiver, all these ACKs and window updates were always dropped as the receiver connection record was timed out. Also fixes a SEGV if flow control kicks in (passing NULL timeout to pthread_cond_timedwait). Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/frct.c')
-rw-r--r--src/lib/frct.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/frct.c b/src/lib/frct.c
index c9e45ef8..d703aeaa 100644
--- a/src/lib/frct.c
+++ b/src/lib/frct.c
@@ -294,7 +294,7 @@ static void send_frct_pkt(struct frcti * frcti)
diff = ts_diff_ns(&frcti->rcv_cr.act, &now);
- if (diff > frcti->a || diff < frcti->mdev) {
+ if (diff > frcti->a || diff < TICTIME) {
pthread_rwlock_unlock(&frcti->lock);
return;
}
@@ -371,7 +371,7 @@ static struct frcti * frcti_create(int fd,
frcti->probe = false;
frcti->srtt = 0; /* Updated on first ACK */
- frcti->mdev = 10 * MILLION; /* Initial rxm will be after 20 ms */
+ frcti->mdev = 10 * MILLION; /* Updated on first ACK */
frcti->rto = BILLION; /* Initial rxm will be after 1 s */
#ifdef PROC_FLOW_STATS
frcti->n_rtx = 0;
@@ -540,7 +540,6 @@ static int __frcti_window_wait(struct frcti * frcti,
while (snd_cr->seqno == snd_cr->rwe && ret != -ETIMEDOUT) {
struct timespec now;
-
pthread_rwlock_unlock(&frcti->lock);
pthread_mutex_lock(&frcti->mtx);
@@ -554,9 +553,12 @@ static int __frcti_window_wait(struct frcti * frcti,
pthread_cleanup_push(__cleanup_mutex_unlock, &frcti->mtx);
- ret = -pthread_cond_timedwait(&frcti->cond,
- &frcti->mtx,
- abstime);
+ if (abstime != NULL)
+ ret = -pthread_cond_timedwait(&frcti->cond,
+ &frcti->mtx,
+ abstime);
+ else
+ ret = -pthread_cond_wait(&frcti->cond, &frcti->mtx);
pthread_cleanup_pop(false);
@@ -800,7 +802,7 @@ static void __frcti_rcv(struct frcti * frcti,
if (pci->flags & FRCT_DRF) { /* New run. */
rcv_cr->lwe = seqno;
rcv_cr->rwe = seqno + RQ_SIZE;
- } else {
+ } else if (pci->flags & FRCT_DATA) {
goto drop_packet;
}
}