[or-cvs] r7068: automatically avoid picking more than one node from the same (tor/trunk/src/or)

arma at seul.org arma at seul.org
Wed Aug 16 03:44:14 UTC 2006


Author: arma
Date: 2006-08-15 23:44:13 -0400 (Tue, 15 Aug 2006)
New Revision: 7068

Modified:
   tor/trunk/src/or/routerlist.c
Log:
automatically avoid picking more than one node from the same
/16 network when constructing a circuit.


Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c	2006-08-16 02:18:55 UTC (rev 7067)
+++ tor/trunk/src/or/routerlist.c	2006-08-16 03:44:13 UTC (rev 7068)
@@ -596,6 +596,21 @@
   mark_all_trusteddirservers_up();
 }
 
+/** Look through the routerlist and identify routers that
+ * advertise the same /16 network address as <b>router</b>.
+ * Add each of them to <b>sl</b>.
+ */
+static void
+routerlist_add_network_family(smartlist_t *sl, routerinfo_t *router)
+{
+  SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, r,
+  {
+    if (router != r &&
+        (router->addr & 0xffff0000) == (r->addr & 0xffff0000))
+      smartlist_add(sl, r);
+  });
+}
+
 /** Add all the family of <b>router</b> to the smartlist <b>sl</b>.
  * This is used to make sure we don't pick siblings in a single path.
  */
@@ -605,6 +620,10 @@
   routerinfo_t *r;
   config_line_t *cl;
 
+  /* First, add any routers with similar network addresses.
+   * XXX It's possible this will be really expensive; we'll see. */
+  routerlist_add_network_family(sl, router);
+
   if (!router->declared_family)
     return;
 



More information about the tor-commits mailing list