summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphessler <phessler@openbsd.org>2016-09-03 19:55:42 +0000
committerphessler <phessler@openbsd.org>2016-09-03 19:55:42 +0000
commitc66fc7a50c15a3ed4e77d1e16f830a04dda437e0 (patch)
tree47576efd0344a33e9b25ba8b6f7ac248480cdc4a
parentif_get requires the corresponding if_put call. (diff)
downloadwireguard-openbsd-c66fc7a50c15a3ed4e77d1e16f830a04dda437e0.tar.xz
wireguard-openbsd-c66fc7a50c15a3ed4e77d1e16f830a04dda437e0.zip
in order to avoid problems with precise timing, obey rfc 5880 section 6.8.7,
and jitter the sender by 70%-90% of the requested tx time
-rw-r--r--sys/net/bfd.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sys/net/bfd.c b/sys/net/bfd.c
index 265c64ca2fc..35499cc0ddf 100644
--- a/sys/net/bfd.c
+++ b/sys/net/bfd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bfd.c,v 1.9 2016/09/03 19:17:49 phessler Exp $ */
+/* $OpenBSD: bfd.c,v 1.10 2016/09/03 19:55:42 phessler Exp $ */
/*
* Copyright (c) 2016 Peter Hessler <phessler@openbsd.org>
@@ -363,8 +363,10 @@ bfd_send_task(void *arg)
{
struct bfd_softc *sc = (struct bfd_softc *)arg;
+ /* add 70%-90% jitter to our transmits, rfc 5880 6.8.7 */
if (!timeout_pending(&sc->sc_timo_tx))
- timeout_add_usec(&sc->sc_timo_tx, sc->mintx);
+ timeout_add_usec(&sc->sc_timo_tx,
+ sc->mintx * (arc4random_uniform(20) + 70) / 100);
return;
}
@@ -592,10 +594,10 @@ bfd_timeout_tx(void *v)
}
}
- /* XXX - we're getting lucky with timing, need a better mechanism */
-printf("%s: timeout_tx: %u\n", __func__, sc->mintx);
+ /* add 70%-90% jitter to our transmits, rfc 5880 6.8.7 */
if (!timeout_pending(&sc->sc_timo_tx))
- timeout_add_usec(&sc->sc_timo_tx, sc->mintx);
+ timeout_add_usec(&sc->sc_timo_tx,
+ sc->mintx * (arc4random_uniform(20) + 70) / 100);
}
/*