[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] nodelist: Move the v3 onion service rendezvous check
commit 280195f41471862964f5c47446e5ccd01afdd96b
Author: teor <teor@xxxxxxxxxx>
Date: Mon May 11 17:21:47 2020 +1000
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.
---
src/core/or/circuitbuild.c | 1 +
src/feature/nodelist/node_select.c | 13 ++-----------
src/feature/nodelist/routerlist.c | 6 ++++++
src/feature/nodelist/routerlist.h | 1 +
4 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/src/core/or/circuitbuild.c b/src/core/or/circuitbuild.c
index 4dc3067a7..d7b07c490 100644
--- a/src/core/or/circuitbuild.c
+++ b/src/core/or/circuitbuild.c
@@ -1802,6 +1802,7 @@ pick_restricted_middle_node(router_crn_flags_t flags,
(flags & CRN_NEED_DESC) != 0,
(flags & CRN_PREF_ADDR) != 0,
(flags & CRN_DIRECT_CONN) != 0,
+ (flags & CRN_RENDEZVOUS_V3) != 0,
(flags & CRN_INITIATE_IPV6_EXTEND) != 0);
/* Filter all_live_nodes to only add live *and* whitelisted middles
diff --git a/src/feature/nodelist/node_select.c b/src/feature/nodelist/node_select.c
index ce07c450e..7015063d0 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 c18051d41..d4dfffa1a 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 1297bb4b6..d6d606428 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);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits