diff options
author | Roger Dingledine <arma@torproject.org> | 2006-08-16 03:44:13 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2006-08-16 03:44:13 +0000 |
commit | 6650470575e0e13a3b3dc33cb2e326f2402793b1 (patch) | |
tree | b25212fc3e6bbc4f260277f0e23e2500092f6c6e /src | |
parent | d8fc598a2ad9a958f536d33331a5debddd79bace (diff) | |
download | tor-6650470575e0e13a3b3dc33cb2e326f2402793b1.tar.gz tor-6650470575e0e13a3b3dc33cb2e326f2402793b1.zip |
automatically avoid picking more than one node from the same
/16 network when constructing a circuit.
svn:r7068
Diffstat (limited to 'src')
-rw-r--r-- | src/or/routerlist.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index e15fc71187..ee324d62bb 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -596,6 +596,21 @@ router_reset_status_download_failures(void) 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 @@ routerlist_add_family(smartlist_t *sl, routerinfo_t *router) 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; |