Browse Source

Implement an option to cap bandwidth-to-advertise. Arma: can you improve the manpage entry by explaining why you would want to do this?

svn:r3813
Nick Mathewson 20 years ago
parent
commit
ec81f87018
5 changed files with 14 additions and 1 deletions
  1. 1 1
      doc/TODO
  2. 4 0
      doc/tor.1.in
  3. 1 0
      src/or/config.c
  4. 2 0
      src/or/or.h
  5. 6 0
      src/or/router.c

+ 1 - 1
doc/TODO

@@ -25,7 +25,7 @@ R  o pick the whole path when you start the circuit.
      they're rejected.
    - controller should have an event to learn about new addressmappings?
    - how do ulimits work on win32, anyway?
-   - have a separate config option which caps bandwidth-to-advertise.
+   o have a separate config option which caps bandwidth-to-advertise.
 
 For 0.1.0.x:
 

+ 4 - 0
doc/tor.1.in

@@ -48,6 +48,10 @@ the specified number of bytes per second. (Default: 780 KB)
 \fBBandwidthBurst \fR\fIN\fR \fBbytes\fR|\fBKB\fR|\fBMB\fR|\fBGB\fR|\fBTB\fP
 Limit the maximum token bucket size (also known as the burst) to the given number of bytes. (Default: 48 MB)
 .TP
+\fBMaxAdvertisedBandwidth \fR\fIN\fR \fBbytes\fR|\fBKB\fR|\fBMB\fR|\fBGB\fR|\fBTB\fP
+If set, we will not advertise more than this amount of bandwidth, no
+matter how much we think we actually have.
+.TP
 \fBDataDirectory \fR\fIDIR\fP
 Store working data in DIR (Default: @LOCALSTATEDIR@/lib/tor)
 .TP

+ 1 - 0
src/or/config.c

@@ -99,6 +99,7 @@ static config_var_t config_vars[] = {
   VAR("AuthoritativeDirectory",BOOL,   AuthoritativeDir,     "0"),
   VAR("BandwidthRate",       MEMUNIT,  BandwidthRate,        "1 MB"),
   VAR("BandwidthBurst",      MEMUNIT,  BandwidthBurst,       "5 MB"),
+  VAR("MaxAdvertisedBandwidth",MEMUNIT,MaxAdvertisedBandwidth,"128 TB"),
   VAR("ClientOnly",          BOOL,     ClientOnly,           "0"),
   VAR("ContactInfo",         STRING,   ContactInfo,          NULL),
   VAR("ControlPort",         UINT,     ControlPort,          "0"),

+ 2 - 0
src/or/or.h

@@ -1019,6 +1019,8 @@ typedef struct {
                            * use in a second? */
   uint64_t BandwidthBurst; /**< How much bandwidth, at maximum, are we willing to
                             * use in a second? */
+  uint64_t MaxAdvertisedBandwidth; /**< How much bandwidth are we willing to
+                                    * tell people we have? */
   int NumCpus; /**< How many CPUs should we try to use? */
   int RunTesting; /**< If true, create testing circuits to measure how well the
                    * other ORs are running. */

+ 6 - 0
src/or/router.c

@@ -684,6 +684,12 @@ int router_rebuild_descriptor(int force) {
   ri->bandwidthrate = (int)options->BandwidthRate;
   ri->bandwidthburst = (int)options->BandwidthBurst;
   ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();
+
+  if (options->BandwidthRate > options->MaxAdvertisedBandwidth)
+    ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth;
+  if (ri->bandwidthcapacity > options->MaxAdvertisedBandwidth)
+    ri->bandwidthcapacity = (int)options->MaxAdvertisedBandwidth;
+
   router_add_exit_policy_from_config(ri);
   if (desc_routerinfo) /* inherit values */
     ri->is_verified = desc_routerinfo->is_verified;