diff options
author | Peter Hessler <phessler@cvs.openbsd.org> | 2016-09-03 19:55:43 +0000 |
---|---|---|
committer | Peter Hessler <phessler@cvs.openbsd.org> | 2016-09-03 19:55:43 +0000 |
commit | 7c14636ac2aca138db2c302faa5301a864e58d43 (patch) | |
tree | bb479d8017c039ea3d6e86465e7d32c570d383cf /sys | |
parent | a453be600ad49dd7c8daf8860541e5ac4022b5ed (diff) |
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
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/bfd.c | 12 |
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); } /* |