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

[or-cvs] r9154: Stop recommmending exits as guards when the exit bandwidth i (in tor/trunk: . doc src/or)



Author: nickm
Date: 2006-12-19 14:48:48 -0500 (Tue, 19 Dec 2006)
New Revision: 9154

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/doc/TODO
   tor/trunk/src/or/dirserv.c
Log:
 r11643@Kushana:  nickm | 2006-12-19 13:15:14 -0500
 Stop recommmending exits as guards when the exit bandwidth is less than a third of the total bandwidth.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11643] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2006-12-18 23:08:18 UTC (rev 9153)
+++ tor/trunk/ChangeLog	2006-12-19 19:48:48 UTC (rev 9154)
@@ -23,6 +23,8 @@
       options files.
     - Reject *:563 (NTTPS) in the default exit policy. We already reject
       NNTP by default, so this seems like a sensible addition.
+    - Authorities do not recommend exits as guards if this would shift excess
+      load to the exit nodes.
 
   o Security bugfixes:
     - Stop sending the HttpProxyAuthenticator string to directory

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-12-18 23:08:18 UTC (rev 9153)
+++ tor/trunk/doc/TODO	2006-12-19 19:48:48 UTC (rev 9154)
@@ -28,7 +28,7 @@
 N - Test guard unreachable logic; make sure that we actually attempt to
     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.
-N - Stop recommending exits as guards?
+  o Stop recommending exits as guards?
     look at the overall fraction of exits in the network. if the
     fraction is too small, none of them get to be guards.
 

Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c	2006-12-18 23:08:18 UTC (rev 9153)
+++ tor/trunk/src/or/dirserv.c	2006-12-19 19:48:48 UTC (rev 9154)
@@ -1293,6 +1293,8 @@
 static uint32_t stable_uptime = 0; /* start at a safe value */
 static uint32_t fast_bandwidth = 0;
 static uint32_t guard_bandwidth = 0;
+static uint64_t total_bandwidth = 0;
+static uint64_t total_exit_bandwidth = 0;
 
 static INLINE int
 real_uptime(routerinfo_t *router, time_t now)
@@ -1331,15 +1333,20 @@
   return 0;
 }
 
-/** Look through the routerlist, and assign the median uptime
- * of running valid servers to stable_uptime, and the relative bandwidth
- * capacities to fast_bandwidth and guard_bandwidth. */
+/** Look through the routerlist, and assign the median uptime of running valid
+ * servers to stable_uptime, and the relative bandwidth capacities to
+ * fast_bandwidth and guard_bandwidth.  Set total_bandwidth to the total
+ * capacity of all running valid servers and total_exit_bandwidth to the
+ * capacity of all running valid exits. */
 static void
 dirserv_compute_performance_thresholds(routerlist_t *rl)
 {
   smartlist_t *uptimes, *bandwidths;
   time_t now = time(NULL);
 
+  total_bandwidth = 0;
+  total_exit_bandwidth = 0;
+
   uptimes = smartlist_create();
   bandwidths = smartlist_create();
 
@@ -1350,6 +1357,8 @@
       *up = (uint32_t) real_uptime(ri, now);
       smartlist_add(uptimes, up);
       *bw = router_get_advertised_bandwidth(ri);
+      total_bandwidth += *bw;
+      total_exit_bandwidth += *bw;
       smartlist_add(bandwidths, bw);
     }
   });
@@ -1417,6 +1426,7 @@
   int naming = options->NamingAuthoritativeDir;
   int versioning = options->VersioningAuthoritativeDir;
   int listbadexits = options->AuthDirListBadExits;
+  int exits_can_be_guards;
   const char *contact;
 
   if (resolve_my_address(LOG_WARN, options, &addr, &hostname)<0) {
@@ -1485,6 +1495,8 @@
 
   dirserv_compute_performance_thresholds(rl);
 
+  exits_can_be_guards = total_exit_bandwidth > (total_bandwidth / 3);
+
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, {
     if (ri->cache_info.published_on >= cutoff) {
       int f_exit = exit_policy_is_general_exit(ri->exit_policy);
@@ -1504,7 +1516,8 @@
       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;
+        router_get_advertised_bandwidth(ri) > guard_bandwidth &&
+        (!f_exit || exits_can_be_guards);
       int f_bad_exit = listbadexits && ri->is_bad_exit;
       /* 0.1.1.9-alpha is the first version to support fetch by descriptor
        * hash. */