[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10411: If the user makes a torrc that exceeds the bandwidth cap by (in tor/trunk: . src/or)
Author: nickm
Date: 2007-05-30 03:18:00 -0400 (Wed, 30 May 2007)
New Revision: 10411
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/or/config.c
Log:
r13090@catbus: nickm | 2007-05-30 03:17:57 -0400
If the user makes a torrc that exceeds the bandwidth cap by one byte, let them have it.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r13090] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-05-30 06:05:08 UTC (rev 10410)
+++ tor/trunk/ChangeLog 2007-05-30 07:18:00 UTC (rev 10411)
@@ -119,6 +119,8 @@
patterns can be reconfigured with AutomapHostsSuffixes.
- If Tor is invoked from something that isn't a shell (e.g. Vidalia),
now we expand "-f ~/.tor/torrc" correctly. Suggested by Matt Edman.
+ - Treat "2gb" when given in torrc for a bandwidth as meaning 2gb, minus 1
+ byte: the actual maximum declared bandwidth.
o Removed features:
- Removed support for the old binary "version 0" controller protocol.
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2007-05-30 06:05:08 UTC (rev 10410)
+++ tor/trunk/src/or/config.c 2007-05-30 07:18:00 UTC (rev 10411)
@@ -2322,13 +2322,18 @@
* Else return 0.
*/
static int
-ensure_bandwidth_cap(uint64_t value, const char *desc, char **msg)
+ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
{
int r;
char buf[1024];
- if (value > ROUTER_MAX_DECLARED_BANDWIDTH) {
+ if (*value == ROUTER_MAX_DECLARED_BANDWIDTH) {
+ /* This handles an understandable special case where somebody says "2gb"
+ * whereas our actual maximum is 2gb-1 (INT_MAX) */
+ --*value;
+ }
+ if (*value > ROUTER_MAX_DECLARED_BANDWIDTH) {
r = tor_snprintf(buf, sizeof(buf), "%s ("U64_FORMAT") must be at most %d",
- desc, U64_PRINTF_ARG(value),
+ desc, U64_PRINTF_ARG(*value),
ROUTER_MAX_DECLARED_BANDWIDTH);
*msg = tor_strdup(r >= 0 ? buf : "internal error");
return -1;
@@ -2761,19 +2766,19 @@
if (options->KeepalivePeriod < 1)
REJECT("KeepalivePeriod option must be positive.");
- if (ensure_bandwidth_cap(options->BandwidthRate,
+ if (ensure_bandwidth_cap(&options->BandwidthRate,
"BandwidthRate", msg) < 0)
return -1;
- if (ensure_bandwidth_cap(options->BandwidthBurst,
+ if (ensure_bandwidth_cap(&options->BandwidthBurst,
"BandwidthBurst", msg) < 0)
return -1;
- if (ensure_bandwidth_cap(options->MaxAdvertisedBandwidth,
+ if (ensure_bandwidth_cap(&options->MaxAdvertisedBandwidth,
"MaxAdvertisedBandwidth", msg) < 0)
return -1;
- if (ensure_bandwidth_cap(options->RelayBandwidthRate,
+ if (ensure_bandwidth_cap(&options->RelayBandwidthRate,
"RelayBandwidthRate", msg) < 0)
return -1;
- if (ensure_bandwidth_cap(options->RelayBandwidthBurst,
+ if (ensure_bandwidth_cap(&options->RelayBandwidthBurst,
"RelayBandwidthBurst", msg) < 0)
return -1;