[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/maint-0.3.1] New configuration option MaxConsensusAgeForDiffs
commit abb9a5bdda9bde028704c01c47191c64cfa088c8
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Wed Jul 12 13:15:16 2017 -0400
New configuration option MaxConsensusAgeForDiffs
Relay operators (especially bridge operators) can use this to lower
or raise the number of consensuses that they're willing to hold for
diff generation purposes.
This enables a workaround for bug 22883.
---
changes/bug22883-config | 7 +++++++
doc/tor.1.txt | 10 ++++++++++
src/or/config.c | 1 +
src/or/consdiffmgr.c | 13 ++++++++++++-
src/or/or.h | 5 +++++
5 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/changes/bug22883-config b/changes/bug22883-config
new file mode 100644
index 0000000..d60594d
--- /dev/null
+++ b/changes/bug22883-config
@@ -0,0 +1,7 @@
+ o Minor features (directory cache, consensus diff):
+ - Add a new MaxConsensusAgeForDiffs option to allow directory cache
+ operators with low-resource environments to adjust the number of
+ consensuses they'll store and generate diffs from. Most cache operators
+ should leave it unchanged. Helps to work around bug 22883.
+
+
diff --git a/doc/tor.1.txt b/doc/tor.1.txt
index 2459969..e17c111 100644
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@ -2072,6 +2072,16 @@ details.)
because clients connect via the ORPort by default. Setting either DirPort
or BridgeRelay and setting DirCache to 0 is not supported. (Default: 1)
+[[MaxConsensusAgeForDiffs]] **MaxConsensusAgeForDiffs** __N__ **minutes**|**hours**|**days**|**weeks**::
+ When this option is nonzero, Tor caches will not try to generate
+ consensus diffs for any consensus older than this amount of time.
+ If this option is set to zero, Tor will pick a reasonable default from
+ the current networkstatus document. You should not set this
+ option unless your cache is severely low on disk space or CPU.
+ If you need to set it, keeping it above 3 or 4 hours will help clients
+ much more than setting it to zero.
+ (Default: 0)
+
DIRECTORY AUTHORITY SERVER OPTIONS
----------------------------------
diff --git a/src/or/config.c b/src/or/config.c
index 7d2ebbd..a0ff0e8 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -393,6 +393,7 @@ static config_var_t option_vars_[] = {
V(MaxAdvertisedBandwidth, MEMUNIT, "1 GB"),
V(MaxCircuitDirtiness, INTERVAL, "10 minutes"),
V(MaxClientCircuitsPending, UINT, "32"),
+ V(MaxConsensusAgeForDiffs, INTERVAL, "0 seconds"),
VAR("MaxMemInQueues", MEMUNIT, MaxMemInQueues_raw, "0"),
OBSOLETE("MaxOnionsPending"),
V(MaxOnionQueueDelay, MSEC_INTERVAL, "1750 msec"),
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c
index 638fcd6..a3ffed1 100644
--- a/src/or/consdiffmgr.c
+++ b/src/or/consdiffmgr.c
@@ -14,6 +14,7 @@
#define CONSDIFFMGR_PRIVATE
#include "or.h"
+#include "config.h"
#include "conscache.h"
#include "consdiff.h"
#include "consdiffmgr.h"
@@ -462,12 +463,22 @@ cdm_cache_lookup_consensus(consensus_flavor_t flavor, time_t valid_after)
static int32_t
get_max_age_to_cache(void)
{
- /* The parameter is in hours. */
const int32_t DEFAULT_MAX_AGE_TO_CACHE = 8192;
const int32_t MIN_MAX_AGE_TO_CACHE = 0;
const int32_t MAX_MAX_AGE_TO_CACHE = 8192;
const char MAX_AGE_TO_CACHE_NAME[] = "max-consensus-age-to-cache-for-diff";
+ const or_options_t *options = get_options();
+
+ if (options->MaxConsensusAgeForDiffs) {
+ const int v = options->MaxConsensusAgeForDiffs;
+ if (v >= MAX_MAX_AGE_TO_CACHE * 3600)
+ return MAX_MAX_AGE_TO_CACHE;
+ else
+ return v;
+ }
+
+ /* The parameter is in hours, so we multiply */
return 3600 * networkstatus_get_param(NULL,
MAX_AGE_TO_CACHE_NAME,
DEFAULT_MAX_AGE_TO_CACHE,
diff --git a/src/or/or.h b/src/or/or.h
index 1f55b55..77207bc 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4558,6 +4558,11 @@ typedef struct {
/** Bool (default: 0): Tells if a %include was used on torrc */
int IncludeUsed;
+
+ /** The seconds after expiration which we as a relay should keep old
+ * consensuses around so that we can generate diffs from them. If 0,
+ * use the default. */
+ int MaxConsensusAgeForDiffs;
} or_options_t;
/** Persistent state for an onion router, as saved to disk. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits