[or-cvs] r10240: When choosing an entry guard for our circuit, avoid using gu (in tor/trunk: . src/or)

arma at seul.org arma at seul.org
Tue May 22 01:01:25 UTC 2007


Author: arma
Date: 2007-05-21 21:01:24 -0400 (Mon, 21 May 2007)
New Revision: 10240

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/or/circuitbuild.c
Log:
When choosing an entry guard for our circuit, avoid using guards
that are in the same family as the chosen exit -- not just guards
that are exactly the chosen exit. (Reported by lodger.)


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-05-22 01:00:24 UTC (rev 10239)
+++ tor/trunk/ChangeLog	2007-05-22 01:01:24 UTC (rev 10240)
@@ -156,6 +156,9 @@
     - Make the NodeFamilies config option work. (Reported by
       lodger -- it has never actually worked, even though we added it
       in Oct 2004.)
+    - When choosing an entry guard for our circuit, avoid using guards
+      that are in the same family as the chosen exit -- not just guards
+      that are exactly the chosen exit. (Reported by lodger.)
 
   o Minor bugfixes (controller):
     - Make 'getinfo fingerprint' return a 551 error if we're not a

Modified: tor/trunk/src/or/circuitbuild.c
===================================================================
--- tor/trunk/src/or/circuitbuild.c	2007-05-22 01:00:24 UTC (rev 10239)
+++ tor/trunk/src/or/circuitbuild.c	2007-05-22 01:01:24 UTC (rev 10240)
@@ -2339,11 +2339,14 @@
 {
   or_options_t *options = get_options();
   smartlist_t *live_entry_guards = smartlist_create();
+  smartlist_t *exit_family = smartlist_create();
   routerinfo_t *chosen_exit = build_state_get_exit_router(state);
   routerinfo_t *r = NULL;
   int need_uptime = state->need_uptime;
   int need_capacity = state->need_capacity;
 
+  routerlist_add_family(exit_family, chosen_exit);
+
   if (!entry_guards)
     entry_guards = smartlist_create();
 
@@ -2360,7 +2363,7 @@
   SMARTLIST_FOREACH(entry_guards, entry_guard_t *, entry,
     {
       r = entry_is_live(entry, need_uptime, need_capacity, 0);
-      if (r && r != chosen_exit) {
+      if (r && !smartlist_isin(exit_family, r)) {
         smartlist_add(live_entry_guards, r);
         if (smartlist_len(live_entry_guards) >= options->NumEntryGuards)
           break; /* we have enough */
@@ -2397,6 +2400,7 @@
 
   r = smartlist_choose(live_entry_guards);
   smartlist_free(live_entry_guards);
+  smartlist_free(exit_family);
   return r;
 }
 



More information about the tor-commits mailing list