From 20b75989acb457e5a2f931f8ad74517f885940ed Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 7 Feb 2011 23:21:33 -0500 Subject: [PATCH 1/2] dtrt when only relaybandwidthburst is set fixes bug 2470 --- changes/bug2470 | 5 +++++ src/or/config.c | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 changes/bug2470 diff --git a/changes/bug2470 b/changes/bug2470 new file mode 100644 index 0000000000..8ff97b7bca --- /dev/null +++ b/changes/bug2470 @@ -0,0 +1,5 @@ + o Major bugfixes: + - If relays set RelayBandwidthBurst but not RelayBandwidthRate, + Tor would ignore their RelayBandwidthBurst setting, + potentially using more bandwidth than expected. Bugfix on + 0.2.0.1-alpha. Reported by Paul Wouters. Fixes bug 2470. diff --git a/src/or/config.c b/src/or/config.c index f8cfd29f84..8066a23a4a 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3401,6 +3401,8 @@ options_validate(or_options_t *old_options, or_options_t *options, if (options->RelayBandwidthRate && !options->RelayBandwidthBurst) options->RelayBandwidthBurst = options->RelayBandwidthRate; + if (options->RelayBandwidthBurst && !options->RelayBandwidthRate) + options->RelayBandwidthRate = options->RelayBandwidthBurst; if (options->RelayBandwidthRate > options->RelayBandwidthBurst) REJECT("RelayBandwidthBurst must be at least equal " From bcbcda309a24ebe9022ad47c023af12877535780 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Mon, 7 Feb 2011 23:22:45 -0500 Subject: [PATCH 2/2] move the clause above the "if bw is too low" check --- src/or/config.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 8066a23a4a..a955b1728b 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3368,6 +3368,11 @@ options_validate(or_options_t *old_options, or_options_t *options, "RelayBandwidthBurst", msg) < 0) return -1; + if (options->RelayBandwidthRate && !options->RelayBandwidthBurst) + options->RelayBandwidthBurst = options->RelayBandwidthRate; + if (options->RelayBandwidthBurst && !options->RelayBandwidthRate) + options->RelayBandwidthRate = options->RelayBandwidthBurst; + if (server_mode(options)) { if (options->BandwidthRate < ROUTER_REQUIRED_MIN_BANDWIDTH) { r = tor_snprintf(buf, sizeof(buf), @@ -3399,11 +3404,6 @@ options_validate(or_options_t *old_options, or_options_t *options, } } - if (options->RelayBandwidthRate && !options->RelayBandwidthBurst) - options->RelayBandwidthBurst = options->RelayBandwidthRate; - if (options->RelayBandwidthBurst && !options->RelayBandwidthRate) - options->RelayBandwidthRate = options->RelayBandwidthBurst; - if (options->RelayBandwidthRate > options->RelayBandwidthBurst) REJECT("RelayBandwidthBurst must be at least equal " "to RelayBandwidthRate.");