[tor-commits] [tor/master] Merge branch 'bug1863_bwhist' into maint-0.2.2

nickm at torproject.org nickm at torproject.org
Fri Feb 25 16:25:06 UTC 2011


commit aa178aae03048caf24ce5df4b2d643c7e7afdc7b
Merge: 16b8b9b 0642b92
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Feb 25 11:22:12 2011 -0500

    Merge branch 'bug1863_bwhist' into maint-0.2.2

 changes/1863_bwhist |   16 +++
 src/or/config.c     |    4 +
 src/or/or.h         |    8 ++-
 src/or/rephist.c    |  295 +++++++++++++++++++++++++++-----------------------
 4 files changed, 186 insertions(+), 137 deletions(-)

diff --combined src/or/config.c
index 178ed1e,78978dc..4d2c872
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -195,7 -195,6 +195,7 @@@ static config_var_t _option_vars[] = 
    V(CircuitStreamTimeout,        INTERVAL, "0"),
    V(CircuitPriorityHalflife,     DOUBLE,  "-100.0"), /*negative:'Use default'*/
    V(ClientDNSRejectInternalAddresses, BOOL,"1"),
 +  V(ClientRejectInternalAddresses, BOOL,   "1"),
    V(ClientOnly,                  BOOL,     "0"),
    V(ConsensusParams,             STRING,   NULL),
    V(ConnLimit,                   UINT,     "1000"),
@@@ -288,7 -287,6 +288,7 @@@
    OBSOLETE("IgnoreVersion"),
    V(KeepalivePeriod,             INTERVAL, "5 minutes"),
    VAR("Log",                     LINELIST, Logs,             NULL),
 +  V(LogMessageDomains,           BOOL,     "0"),
    OBSOLETE("LinkPadding"),
    OBSOLETE("LogLevel"),
    OBSOLETE("LogFile"),
@@@ -407,7 -405,6 +407,7 @@@ static config_var_t testing_tor_network
    V(AuthDirMaxServersPerAddr,    UINT,     "0"),
    V(AuthDirMaxServersPerAuthAddr,UINT,     "0"),
    V(ClientDNSRejectInternalAddresses, BOOL,"0"),
 +  V(ClientRejectInternalAddresses, BOOL,   "0"),
    V(ExitPolicyRejectPrivate,     BOOL,     "0"),
    V(V3AuthVotingInterval,        INTERVAL, "5 minutes"),
    V(V3AuthVoteDelay,             INTERVAL, "20 seconds"),
@@@ -446,15 -443,19 +446,19 @@@ static config_var_t _state_vars[] = 
    V(BWHistoryReadEnds,                ISOTIME,  NULL),
    V(BWHistoryReadInterval,            UINT,     "900"),
    V(BWHistoryReadValues,              CSV,      ""),
+   V(BWHistoryReadMaxima,              CSV,      ""),
    V(BWHistoryWriteEnds,               ISOTIME,  NULL),
    V(BWHistoryWriteInterval,           UINT,     "900"),
    V(BWHistoryWriteValues,             CSV,      ""),
+   V(BWHistoryWriteMaxima,             CSV,      ""),
    V(BWHistoryDirReadEnds,             ISOTIME,  NULL),
    V(BWHistoryDirReadInterval,         UINT,     "900"),
    V(BWHistoryDirReadValues,           CSV,      ""),
+   V(BWHistoryDirReadMaxima,           CSV,      ""),
    V(BWHistoryDirWriteEnds,            ISOTIME,  NULL),
    V(BWHistoryDirWriteInterval,        UINT,     "900"),
    V(BWHistoryDirWriteValues,          CSV,      ""),
+   V(BWHistoryDirWriteMaxima,          CSV,      ""),
  
    V(TorVersion,                       STRING,   NULL),
  
@@@ -1253,6 -1254,7 +1257,6 @@@ options_act(or_options_t *old_options
  
    /* Check for transitions that need action. */
    if (old_options) {
 -
      if ((options->UseEntryGuards && !old_options->UseEntryGuards) ||
          (options->ExcludeNodes &&
           !routerset_equal(old_options->ExcludeNodes,options->ExcludeNodes)) ||
@@@ -1300,12 -1302,11 +1304,12 @@@
      if (options_transition_affects_workers(old_options, options)) {
        log_info(LD_GENERAL,
                 "Worker-related options changed. Rotating workers.");
 +
 +      if (init_keys() < 0) {
 +        log_warn(LD_BUG,"Error initializing keys; exiting");
 +        return -1;
 +      }
        if (server_mode(options) && !server_mode(old_options)) {
 -        if (init_keys() < 0) {
 -          log_warn(LD_BUG,"Error initializing keys; exiting");
 -          return -1;
 -        }
          ip_address_changed(0);
          if (can_complete_circuit || !any_predicted_circuits(time(NULL)))
            inform_testing_reachability();
@@@ -2842,9 -2843,7 +2846,9 @@@ compute_publishserverdescriptor(or_opti
      else if (!strcasecmp(string, "bridge"))
        *auth |= BRIDGE_AUTHORITY;
      else if (!strcasecmp(string, "hidserv"))
 -      *auth |= HIDSERV_AUTHORITY;
 +      log_warn(LD_CONFIG,
 +               "PublishServerDescriptor hidserv is invalid. See "
 +               "PublishHidServDescriptors.");
      else if (!strcasecmp(string, "") || !strcmp(string, "0"))
        /* no authority */;
      else
@@@ -3348,11 -3347,6 +3352,11 @@@ options_validate(or_options_t *old_opti
                             "PerConnBWBurst", 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) {
        tor_asprintf(msg,
@@@ -3381,6 -3375,9 +3385,6 @@@
      }
    }
  
 -  if (options->RelayBandwidthRate && !options->RelayBandwidthBurst)
 -    options->RelayBandwidthBurst = options->RelayBandwidthRate;
 -
    if (options->RelayBandwidthRate > options->RelayBandwidthBurst)
      REJECT("RelayBandwidthBurst must be at least equal "
             "to RelayBandwidthRate.");
@@@ -3817,9 -3814,7 +3821,9 @@@ options_transition_affects_workers(or_o
                                         new_options->ServerDNSSearchDomains ||
        old_options->SafeLogging != new_options->SafeLogging ||
        old_options->ClientOnly != new_options->ClientOnly ||
 -      !config_lines_eq(old_options->Logs, new_options->Logs))
 +      public_server_mode(old_options) != public_server_mode(new_options) ||
 +      !config_lines_eq(old_options->Logs, new_options->Logs) ||
 +      old_options->LogMessageDomains != new_options->LogMessageDomains)
      return 1;
  
    /* Check whether log options match. */
@@@ -4395,9 -4390,6 +4399,9 @@@ options_init_logs(or_options_t *options
    }
    smartlist_free(elts);
  
 +  if (ok && !validate_only)
 +    logs_set_domain_logging(options->LogMessageDomains);
 +
    return ok?0:-1;
  }
  
@@@ -5157,9 -5149,6 +5161,9 @@@ or_state_load(void
    return r;
  }
  
 +/** If writing the state to disk fails, try again after this many seconds. */
 +#define STATE_WRITE_RETRY_INTERVAL 3600
 +
  /** Write the persistent state to disk. Return 0 for success, <0 on failure. */
  int
  or_state_save(time_t now)
@@@ -5194,14 -5183,10 +5198,14 @@@
    tor_free(state);
    fname = get_datadir_fname("state");
    if (write_str_to_file(fname, contents, 0)<0) {
 -    log_warn(LD_FS, "Unable to write state to file \"%s\"", fname);
 +    log_warn(LD_FS, "Unable to write state to file \"%s\"; "
 +             "will try again later", fname);
      global_state->LastWritten = -1;
      tor_free(fname);
      tor_free(contents);
 +    /* Try again after STATE_WRITE_RETRY_INTERVAL (or sooner, if the state
 +     * changes sooner). */
 +    global_state->next_write = now + STATE_WRITE_RETRY_INTERVAL;
      return -1;
    }
  
diff --combined src/or/or.h
index 2a55668,e0f8bab..74ff743
--- a/src/or/or.h
+++ b/src/or/or.h
@@@ -583,9 -583,6 +583,9 @@@ typedef enum 
  /** This is a connection on the NATD port, and the destination IP:Port was
   * either ill-formed or out-of-range. */
  #define END_STREAM_REASON_INVALID_NATD_DEST 261
 +/** The target address is in a private network (like 127.0.0.1 or 10.0.0.1);
 + * you don't want to do that over a randomly chosen exit */
 +#define END_STREAM_REASON_PRIVATE_ADDR 262
  
  /** Bitwise-and this value with endreason to mask out all flags. */
  #define END_STREAM_REASON_MASK 511
@@@ -768,8 -765,6 +768,8 @@@ typedef enum 
  /** Initial value for both sides of a circuit transmission window when the
   * circuit is initialized.  Measured in cells. */
  #define CIRCWINDOW_START 1000
 +#define CIRCWINDOW_START_MIN 100
 +#define CIRCWINDOW_START_MAX 1000
  /** Amount to increment a circuit window when we get a circuit SENDME. */
  #define CIRCWINDOW_INCREMENT 100
  /** Initial value on both sides of a stream transmission window when the
@@@ -1173,10 -1168,6 +1173,10 @@@ typedef struct edge_connection_t 
     * zero, abandon the associated mapaddress. */
    unsigned int chosen_exit_retries:3;
  
 +  /** True iff this is an AP connection that came from a transparent or
 +   * NATd connection */
 +  unsigned int is_transparent_ap:1;
 +
    /** If this is a DNSPort connection, this field holds the pending DNS
     * request that we're going to try to answer.  */
    struct evdns_server_request *dns_server_request;
@@@ -2345,9 -2336,6 +2345,9 @@@ typedef struct 
    config_line_t *Logs; /**< New-style list of configuration lines
                          * for logs */
  
 +  int LogMessageDomains; /**< Boolean: Should we log the domain(s) in which
 +                          * each log message occurs? */
 +
    char *DebugLogFile; /**< Where to send verbose log messages. */
    char *DataDirectory; /**< OR only: where to store long-term data. */
    char *Nickname; /**< OR only: nickname of this onion router. */
@@@ -2759,10 -2747,6 +2759,10 @@@
     * Helps avoid some cross-site attacks. */
    int ClientDNSRejectInternalAddresses;
  
 +  /** If true, do not accept any requests to connect to internal addresses
 +   * over randomly chosen exits. */
 +  int ClientRejectInternalAddresses;
 +
    /** The length of time that we think a consensus should be fresh. */
    int V3AuthVotingInterval;
    /** The length of time we think it will take to distribute votes. */
@@@ -2872,19 -2856,25 +2872,25 @@@ typedef struct 
     * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
     * of the entries of Values.  The "Values" lists hold decimal string
     * representations of the number of bytes read or written in each
-    * interval. */
+    * interval. The "Maxima" list holds decimal strings describing the highest
+    * rate achieved during the interval.
+    */
    time_t      BWHistoryReadEnds;
    int         BWHistoryReadInterval;
    smartlist_t *BWHistoryReadValues;
+   smartlist_t *BWHistoryReadMaxima;
    time_t      BWHistoryWriteEnds;
    int         BWHistoryWriteInterval;
    smartlist_t *BWHistoryWriteValues;
+   smartlist_t *BWHistoryWriteMaxima;
    time_t      BWHistoryDirReadEnds;
    int         BWHistoryDirReadInterval;
    smartlist_t *BWHistoryDirReadValues;
+   smartlist_t *BWHistoryDirReadMaxima;
    time_t      BWHistoryDirWriteEnds;
    int         BWHistoryDirWriteInterval;
    smartlist_t *BWHistoryDirWriteValues;
+   smartlist_t *BWHistoryDirWriteMaxima;
  
    /** Build time histogram */
    config_line_t * BuildtimeHistogram;
@@@ -2958,11 -2948,6 +2964,11 @@@ struct socks_request_t 
  
  /* Circuit Build Timeout "public" structures. */
  
 +/** Precision multiplier for the Bw weights */
 +#define BW_WEIGHT_SCALE   10000
 +#define BW_MIN_WEIGHT_SCALE 1
 +#define BW_MAX_WEIGHT_SCALE INT32_MAX
 +
  /** Total size of the circuit timeout history to accumulate.
   * 1000 is approx 2.5 days worth of continual-use circuits. */
  #define CBT_NCIRCUITS_TO_OBSERVE 1000
@@@ -2972,8 -2957,6 +2978,8 @@@
  
  /** Number of modes to use in the weighted-avg computation of Xm */
  #define CBT_DEFAULT_NUM_XM_MODES 3
 +#define CBT_MIN_NUM_XM_MODES 1
 +#define CBT_MAX_NUM_XM_MODES 20
  
  /** A build_time_t is milliseconds */
  typedef uint32_t build_time_t;
@@@ -2995,16 -2978,12 +3001,16 @@@
   * build in terms of CDF quantile.
   */
  #define CBT_DEFAULT_CLOSE_QUANTILE 95
 +#define CBT_MIN_CLOSE_QUANTILE CBT_MIN_QUANTILE_CUTOFF
 +#define CBT_MAX_CLOSE_QUANTILE CBT_MAX_QUANTILE_CUTOFF
  
  /**
   * How many circuits count as recent when considering if the
   * connection has gone gimpy or changed.
   */
  #define CBT_DEFAULT_RECENT_CIRCUITS 20
 +#define CBT_MIN_RECENT_CIRCUITS 3
 +#define CBT_MAX_RECENT_CIRCUITS 1000
  
  /**
   * Maximum count of timeouts that finish the first hop in the past
@@@ -3015,37 -2994,25 +3021,37 @@@
   * gives us.
   */
  #define CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT (CBT_DEFAULT_RECENT_CIRCUITS*9/10)
 +#define CBT_MIN_MAX_RECENT_TIMEOUT_COUNT 3
 +#define CBT_MAX_MAX_RECENT_TIMEOUT_COUNT 10000
  
  /** Minimum circuits before estimating a timeout */
  #define CBT_DEFAULT_MIN_CIRCUITS_TO_OBSERVE 100
 +#define CBT_MIN_MIN_CIRCUITS_TO_OBSERVE 1
 +#define CBT_MAX_MIN_CIRCUITS_TO_OBSERVE 10000
  
  /** Cutoff percentile on the CDF for our timeout estimation. */
  #define CBT_DEFAULT_QUANTILE_CUTOFF 80
 +#define CBT_MIN_QUANTILE_CUTOFF 10
 +#define CBT_MAX_QUANTILE_CUTOFF 99
  double circuit_build_times_quantile_cutoff(void);
  
  /** How often in seconds should we build a test circuit */
  #define CBT_DEFAULT_TEST_FREQUENCY 60
 +#define CBT_MIN_TEST_FREQUENCY 1
 +#define CBT_MAX_TEST_FREQUENCY INT32_MAX
  
  /** Lowest allowable value for CircuitBuildTimeout in milliseconds */
  #define CBT_DEFAULT_TIMEOUT_MIN_VALUE (1500)
 +#define CBT_MIN_TIMEOUT_MIN_VALUE 500
 +#define CBT_MAX_TIMEOUT_MIN_VALUE INT32_MAX
  
  /** Initial circuit build timeout in milliseconds */
  #define CBT_DEFAULT_TIMEOUT_INITIAL_VALUE (60*1000)
 +#define CBT_MIN_TIMEOUT_INITIAL_VALUE CBT_MIN_TIMEOUT_MIN_VALUE
 +#define CBT_MAX_TIMEOUT_INITIAL_VALUE INT32_MAX
  int32_t circuit_build_times_initial_timeout(void);
  
 -#if CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT < 1
 +#if CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT < CBT_MIN_MAX_RECENT_TIMEOUT_COUNT
  #error "RECENT_CIRCUITS is set too low."
  #endif
  





More information about the tor-commits mailing list