[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9423: Bugfix: If we're not marking exits as guards, ignore exit ba (in tor/trunk: . doc src/or)



Author: arma
Date: 2007-01-26 04:03:20 -0500 (Fri, 26 Jan 2007)
New Revision: 9423

Modified:
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/dirserv.c
Log:
Bugfix: If we're not marking exits as guards, ignore exit bandwidth
when we're deciding the required bandwidth to become a guard.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-26 08:13:53 UTC (rev 9422)
+++ tor/trunk/ChangeLog	2007-01-26 09:03:20 UTC (rev 9423)
@@ -23,6 +23,8 @@
       pointer loops.
     - Fix a memory leak when sending a 503 response for a networkstatus
       request.
+    - If we're not marking exits as guards, ignore exit bandwidth
+      when we're deciding the required bandwidth to become a guard.
 
   o Minor bugfixes:
     - When computing clock skew from directory HTTP headers, consider what
@@ -50,6 +52,9 @@
       connections. (Fixes bug 382.)
 
   o Minor features:
+    - Create a new file ReleaseNotes which was the old ChangeLog. The
+      new ChangeLog file now includes the summaries for even development
+      versions.
     - Check for addresses with invalid characters at the exit as well
       as at the client, and warn less verbosely when they fail. You can
       override this by setting ServerDNSAllowNonRFC953Addresses to 1.

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2007-01-26 08:13:53 UTC (rev 9422)
+++ tor/trunk/doc/TODO	2007-01-26 09:03:20 UTC (rev 9423)
@@ -29,7 +29,7 @@
     connect to guards that we think are unreachable from time to time.
     Make sure that we don't freak out when the network is down.
 
-R - Reconstruct ChangeLog; put rolled-up info in ReleaseNotes or something.
+  o Reconstruct ChangeLog; put rolled-up info in ReleaseNotes or something.
 
 Items for 0.1.2.x:
   - weight dir requests by advertised bandwidth? with maybe a lower cutoff

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2007-01-26 08:13:53 UTC (rev 9422)
+++ tor/trunk/src/or/dirserv.c	2007-01-26 09:03:20 UTC (rev 9423)
@@ -1332,7 +1332,8 @@
  * generate_v2_networkstatus */
 static uint32_t stable_uptime = 0; /* start at a safe value */
 static uint32_t fast_bandwidth = 0;
-static uint32_t guard_bandwidth = 0;
+static uint32_t guard_bandwidth_including_exits = 0;
+static uint32_t guard_bandwidth_excluding_exits = 0;
 static uint64_t total_bandwidth = 0;
 static uint64_t total_exit_bandwidth = 0;
 
@@ -1386,14 +1387,21 @@
 static void
 dirserv_compute_performance_thresholds(routerlist_t *rl)
 {
-  smartlist_t *uptimes, *bandwidths;
+  smartlist_t *uptimes, *bandwidths, *bandwidths_excluding_exits;
   time_t now = time(NULL);
 
+  /* initialize these all here, in case there are no routers */
+  stable_uptime = 0;
+  fast_bandwidth = 0;
+  guard_bandwidth_including_exits = 0;
+  guard_bandwidth_excluding_exits = 0;
+
   total_bandwidth = 0;
   total_exit_bandwidth = 0;
 
   uptimes = smartlist_create();
   bandwidths = smartlist_create();
+  bandwidths_excluding_exits = smartlist_create();
 
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
     if (ri->is_running && ri->is_valid) {
@@ -1404,14 +1412,20 @@
       smartlist_add(uptimes, up);
       *bw = router_get_advertised_bandwidth(ri);
       total_bandwidth += *bw;
-      if (ri->is_exit && !ri->is_bad_exit)
+      if (ri->is_exit && !ri->is_bad_exit) {
         total_exit_bandwidth += *bw;
+      } else {
+        uint32_t *bw_not_exit = tor_malloc(sizeof(uint32_t));
+        *bw_not_exit = *bw;
+        smartlist_add(bandwidths_excluding_exits, bw_not_exit);
+      }
       smartlist_add(bandwidths, bw);
     }
   });
 
   smartlist_sort(uptimes, _compare_uint32);
   smartlist_sort(bandwidths, _compare_uint32);
+  smartlist_sort(bandwidths_excluding_exits, _compare_uint32);
 
   if (smartlist_len(uptimes))
     stable_uptime = *(uint32_t*)smartlist_get(uptimes,
@@ -1423,20 +1437,29 @@
     if (fast_bandwidth < ROUTER_REQUIRED_MIN_BANDWIDTH)
       fast_bandwidth = *(uint32_t*)smartlist_get(bandwidths,
                                                  smartlist_len(bandwidths)/4);
-    guard_bandwidth = *(uint32_t*)smartlist_get(bandwidths,
-                                                smartlist_len(bandwidths)/2);
+    guard_bandwidth_including_exits =
+      *(uint32_t*)smartlist_get(bandwidths, smartlist_len(bandwidths)/2);
   }
 
+  if (smartlist_len(bandwidths_excluding_exits)) {
+    guard_bandwidth_excluding_exits =
+      *(uint32_t*)smartlist_get(bandwidths_excluding_exits,
+                                smartlist_len(bandwidths_excluding_exits)/2);
+  }
+
   log(LOG_INFO, LD_DIRSERV,
-      "Cutoffs: %lus uptime, %lu b/s fast, %lu b/s guard.",
+      "Cutoffs: %lus uptime, %lu b/s fast, %lu or %lu b/s guard.",
       (unsigned long)stable_uptime,
       (unsigned long)fast_bandwidth,
-      (unsigned long)guard_bandwidth);
+      (unsigned long)guard_bandwidth_including_exits,
+      (unsigned long)guard_bandwidth_excluding_exits);
 
   SMARTLIST_FOREACH(uptimes, uint32_t *, up, tor_free(up));
   SMARTLIST_FOREACH(bandwidths, uint32_t *, bw, tor_free(bw));
+  SMARTLIST_FOREACH(bandwidths_excluding_exits, uint32_t *, bw, tor_free(bw));
   smartlist_free(uptimes);
   smartlist_free(bandwidths);
+  smartlist_free(bandwidths_excluding_exits);
 }
 
 /** For authoritative directories only: replace the contents of
@@ -1564,8 +1587,10 @@
       int f_named = naming && ri->is_named;
       int f_valid = ri->is_valid;
       int f_guard = f_fast && f_stable &&
-        router_get_advertised_bandwidth(ri) >= guard_bandwidth &&
-        (!f_exit || exits_can_be_guards);
+        (!f_exit || exits_can_be_guards) &&
+        router_get_advertised_bandwidth(ri) >=
+          (exits_can_be_guards ? guard_bandwidth_including_exits :
+                                 guard_bandwidth_excluding_exits);
       int f_bad_exit = listbadexits && ri->is_bad_exit;
       /* 0.1.1.9-alpha is the first version to support fetch by descriptor
        * hash. */