]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Changing MaxAdvertisedBW may not need a republish
authorSebastian Hahn <sebastian@torproject.org>
Tue, 7 Jul 2009 16:04:00 +0000 (18:04 +0200)
committerRoger Dingledine <arma@torproject.org>
Tue, 28 Jul 2009 03:53:06 +0000 (23:53 -0400)
Relays no longer publish a new server descriptor if they change
their MaxAdvertisedBandwidth config option but it doesn't end up
changing their advertised bandwidth numbers. Bugfix on 0.2.0.28-rc;
fixes bug 1026. Patch from Sebastian.

ChangeLog
src/or/config.c
src/or/or.h
src/or/router.c

index 2747420dd6d213975160713df9b4edab760a6bc2..97972e8a127b373dabef7e0337e17354523eef96 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,10 @@ Changes in version 0.2.1.19 - 2009-07-??
       and confuse fewer users.
 
   o Minor bugfixes:
+    - Relays no longer publish a new server descriptor if they change
+      their MaxAdvertisedBandwidth config option but it doesn't end up
+      changing their advertised bandwidth numbers. Bugfix on 0.2.0.28-rc;
+      fixes bug 1026. Patch from Sebastian.
     - Avoid leaking memory every time we get a create cell but we have
       so many already queued that we refuse it. Bugfix on 0.2.0.19-alpha;
       fixes bug 1034. Reported by BarkerJr.
index b744f8faf43f28d6e6dcce2a7371f53b7cdf3f6a..3f45b1e5e28ee15fd440ed2d9a0a4c49aa5dca1a 100644 (file)
@@ -1222,6 +1222,30 @@ options_need_geoip_info(or_options_t *options, const char **reason_out)
   return bridge_usage || routerset_usage;
 }
 
+/** Return the bandwidthrate that we are going to report to the authorities
+ * based on the config options. */
+int
+get_effective_bwrate(or_options_t *options)
+{
+  int bw = (int)options->BandwidthRate;
+  if (bw > options->MaxAdvertisedBandwidth)
+    bw = (int)options->MaxAdvertisedBandwidth;
+  if (options->RelayBandwidthRate > 0 && bw > options->RelayBandwidthRate)
+    bw = (int)options->RelayBandwidthRate;
+  return bw;
+}
+
+/** Return the bandwidthburst that we are going to report to the authorities
+ * based on the config options. */
+int
+get_effective_bwburst(or_options_t *options)
+{
+  int bw = (int)options->BandwidthBurst;
+  if (options->RelayBandwidthBurst > 0 && bw > options->RelayBandwidthBurst)
+    bw = (int)options->RelayBandwidthBurst;
+  return bw;
+}
+
 /** Fetch the active option list, and take actions based on it. All of the
  * things we do should survive being done repeatedly.  If present,
  * <b>old_options</b> contains the previous value of the options.
@@ -3744,9 +3768,7 @@ options_transition_affects_descriptor(or_options_t *old_options,
                                       or_options_t *new_options)
 {
   /* XXX We can be smarter here. If your DirPort isn't being
-   * published and you just turned it off, no need to republish. If
-   * you changed your bandwidthrate but maxadvertisedbandwidth still
-   * trumps, no need to republish. Etc. */
+   * published and you just turned it off, no need to republish. Etc. */
   if (!opt_streq(old_options->DataDirectory, new_options->DataDirectory) ||
       !opt_streq(old_options->Nickname,new_options->Nickname) ||
       !opt_streq(old_options->Address,new_options->Address) ||
@@ -3759,10 +3781,9 @@ options_transition_affects_descriptor(or_options_t *old_options,
       old_options->NoPublish != new_options->NoPublish ||
       old_options->_PublishServerDescriptor !=
         new_options->_PublishServerDescriptor ||
-      old_options->BandwidthRate != new_options->BandwidthRate ||
-      old_options->BandwidthBurst != new_options->BandwidthBurst ||
-      old_options->MaxAdvertisedBandwidth !=
-        new_options->MaxAdvertisedBandwidth ||
+      get_effective_bwrate(old_options) != get_effective_bwrate(new_options) ||
+      get_effective_bwburst(old_options) !=
+        get_effective_bwburst(new_options) ||
       !opt_streq(old_options->ContactInfo, new_options->ContactInfo) ||
       !opt_streq(old_options->MyFamily, new_options->MyFamily) ||
       !opt_streq(old_options->AccountingStart, new_options->AccountingStart) ||
index fba7af0da0bcfa72c4a0fadfe4b388f04206dd59..1dcff28d6d22a5e4f462865c9d8daff508f8c870 100644 (file)
@@ -2926,6 +2926,9 @@ int options_need_geoip_info(or_options_t *options, const char **reason_out);
 int getinfo_helper_config(control_connection_t *conn,
                           const char *question, char **answer);
 
+int get_effective_bwrate(or_options_t *options);
+int get_effective_bwburst(or_options_t *options);
+
 #ifdef CONFIG_PRIVATE
 /* Used only by config.c and test.c */
 or_options_t *options_new(void);
index 6f899854e322e31380264de5f4a20b1ef1691333..859a1e805ab939c1821c0b18cad31dd09f8d7110 100644 (file)
@@ -1300,18 +1300,10 @@ router_rebuild_descriptor(int force)
   ri->platform = tor_strdup(platform);
 
   /* compute ri->bandwidthrate as the min of various options */
-  ri->bandwidthrate = (int)options->BandwidthRate;
-  if (ri->bandwidthrate > options->MaxAdvertisedBandwidth)
-    ri->bandwidthrate = (int)options->MaxAdvertisedBandwidth;
-  if (options->RelayBandwidthRate > 0 &&
-      ri->bandwidthrate > options->RelayBandwidthRate)
-    ri->bandwidthrate = (int)options->RelayBandwidthRate;
+  ri->bandwidthrate = get_effective_bwrate(options);
 
   /* and compute ri->bandwidthburst similarly */
-  ri->bandwidthburst = (int)options->BandwidthBurst;
-  if (options->RelayBandwidthBurst > 0 &&
-      ri->bandwidthburst > options->RelayBandwidthBurst)
-    ri->bandwidthburst = (int)options->RelayBandwidthBurst;
+  ri->bandwidthburst = get_effective_bwburst(options);
 
   ri->bandwidthcapacity = hibernating ? 0 : rep_hist_bandwidth_assess();