aboutsummaryrefslogtreecommitdiff
path: root/src/feature/nodelist
diff options
context:
space:
mode:
authorteor <teor@riseup.net>2020-05-11 17:21:47 +1000
committerteor <teor@riseup.net>2020-05-18 21:53:52 +1000
commit280195f41471862964f5c47446e5ccd01afdd96b (patch)
tree1fd7945b0d7389d1aca6dd4f7ba554d8b37c6c4d /src/feature/nodelist
parentce11e3bf6946d1659e5915abac30b1972fc799c8 (diff)
downloadtor-280195f41471862964f5c47446e5ccd01afdd96b.tar.gz
tor-280195f41471862964f5c47446e5ccd01afdd96b.zip
nodelist: Move the v3 onion service rendezvous check
And delete a loop that is now empty. This change should improve tor's performance, because we no longer iterate through the nodelist twice for every node in every circuit path. Part of 34200.
Diffstat (limited to 'src/feature/nodelist')
-rw-r--r--src/feature/nodelist/node_select.c13
-rw-r--r--src/feature/nodelist/routerlist.c6
-rw-r--r--src/feature/nodelist/routerlist.h1
3 files changed, 9 insertions, 11 deletions
diff --git a/src/feature/nodelist/node_select.c b/src/feature/nodelist/node_select.c
index ce07c450e8..7015063d05 100644
--- a/src/feature/nodelist/node_select.c
+++ b/src/feature/nodelist/node_select.c
@@ -973,7 +973,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
const int rendezvous_v3 = (flags & CRN_RENDEZVOUS_V3) != 0;
const bool initiate_ipv6_extend = (flags & CRN_INITIATE_IPV6_EXTEND) != 0;
- const smartlist_t *node_list = nodelist_get_list();
smartlist_t *sl=smartlist_new(),
*excludednodes=smartlist_new();
const node_t *choice = NULL;
@@ -984,15 +983,6 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
rule = weight_for_exit ? WEIGHT_FOR_EXIT :
(need_guard ? WEIGHT_FOR_GUARD : WEIGHT_FOR_MID);
- SMARTLIST_FOREACH_BEGIN(node_list, const node_t *, node) {
- if (rendezvous_v3 &&
- !node_supports_v3_rendezvous_point(node)) {
- /* Exclude relays that can not become a rendezvous for a hidden service
- * version 3. */
- smartlist_add(excludednodes, (node_t*)node);
- }
- } SMARTLIST_FOREACH_END(node);
-
/* If the node_t is not found we won't be to exclude ourself but we
* won't be able to pick ourself in router_choose_random_node() so
* this is fine to at least try with our routerinfo_t object. */
@@ -1001,7 +991,8 @@ router_choose_random_node(smartlist_t *excludedsmartlist,
router_add_running_nodes_to_smartlist(sl, need_uptime, need_capacity,
need_guard, need_desc, pref_addr,
- direct_conn, initiate_ipv6_extend);
+ direct_conn, rendezvous_v3,
+ initiate_ipv6_extend);
log_debug(LD_CIRC,
"We found %d running nodes.",
smartlist_len(sl));
diff --git a/src/feature/nodelist/routerlist.c b/src/feature/nodelist/routerlist.c
index c18051d416..d4dfffa1ab 100644
--- a/src/feature/nodelist/routerlist.c
+++ b/src/feature/nodelist/routerlist.c
@@ -520,6 +520,7 @@ router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
int need_capacity, int need_guard,
int need_desc, int pref_addr,
int direct_conn,
+ bool rendezvous_v3,
bool initiate_ipv6_extend)
{
const int check_reach = !router_or_conn_should_skip_reachable_address_check(
@@ -546,6 +547,11 @@ router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
* 0.3.1.0-alpha. */
if (node_allows_single_hop_exits(node))
continue;
+ /* Exclude relays that can not become a rendezvous for a hidden service
+ * version 3. */
+ if (rendezvous_v3 &&
+ !node_supports_v3_rendezvous_point(node))
+ continue;
/* Choose a node with an OR address that matches the firewall rules */
if (direct_conn && check_reach &&
!fascist_firewall_allows_node(node,
diff --git a/src/feature/nodelist/routerlist.h b/src/feature/nodelist/routerlist.h
index 1297bb4b65..d6d6064281 100644
--- a/src/feature/nodelist/routerlist.h
+++ b/src/feature/nodelist/routerlist.h
@@ -62,6 +62,7 @@ void router_add_running_nodes_to_smartlist(smartlist_t *sl, int need_uptime,
int need_capacity, int need_guard,
int need_desc, int pref_addr,
int direct_conn,
+ bool rendezvous_v3,
bool initiate_ipv6_extend);
const routerinfo_t *routerlist_find_my_routerinfo(void);