summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-05-14 11:43:10 -0400
committerNick Mathewson <nickm@torproject.org>2019-05-14 11:43:10 -0400
commit43d41194546dbf6a634648d592e97ccd10b04fda (patch)
tree38993fbcd05836ca6a9df5ec4c55e5ae46c97606
parent0f4f4fdcf56b88cd36bc94e8a45ccd9c5dce3a60 (diff)
parent3cafdeb8c0f1dfa60a964e4fba04b54d1ad97d15 (diff)
downloadtor-43d41194546dbf6a634648d592e97ccd10b04fda.tar.gz
tor-43d41194546dbf6a634648d592e97ccd10b04fda.zip
Merge remote-tracking branch 'tor-github/pr/1004'
-rw-r--r--changes/bug222107
-rw-r--r--scripts/maint/practracker/exceptions.txt4
-rw-r--r--src/core/or/circuituse.c17
3 files changed, 19 insertions, 9 deletions
diff --git a/changes/bug22210 b/changes/bug22210
new file mode 100644
index 0000000000..d7a00fd72c
--- /dev/null
+++ b/changes/bug22210
@@ -0,0 +1,7 @@
+ o Minor bugfixes (onion services, performance):
+ - If we are building circuits to onion services, in circuit_is_acceptable()
+ we only call tor_addr_parse() in places where we use the returned
+ family and address values from this function. Previously, we called
+ tor_addr_parse() in circuit_is_acceptable() even if it wasn't used.
+ This change will improve performance when building circuits. Fixes
+ bug 22210; bugfix on 0.2.8.12. Patch by Neel Chauhan
diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt
index ee4f421bdd..24452b6158 100644
--- a/scripts/maint/practracker/exceptions.txt
+++ b/scripts/maint/practracker/exceptions.txt
@@ -92,8 +92,8 @@ problem function-size /src/core/or/circuitlist.c:circuits_handle_oom() 117
problem function-size /src/core/or/circuitmux.c:circuitmux_set_policy() 110
problem function-size /src/core/or/circuitmux.c:circuitmux_attach_circuit() 114
problem function-size /src/core/or/circuitstats.c:circuit_build_times_parse_state() 124
-problem file-size /src/core/or/circuituse.c 3152
-problem function-size /src/core/or/circuituse.c:circuit_is_acceptable() 129
+problem file-size /src/core/or/circuituse.c 3155
+problem function-size /src/core/or/circuituse.c:circuit_is_acceptable() 133
problem function-size /src/core/or/circuituse.c:circuit_expire_building() 394
problem function-size /src/core/or/circuituse.c:circuit_log_ancient_one_hop_circuits() 126
problem function-size /src/core/or/circuituse.c:circuit_build_failed() 149
diff --git a/src/core/or/circuituse.c b/src/core/or/circuituse.c
index 2f27cf996f..226295425e 100644
--- a/src/core/or/circuituse.c
+++ b/src/core/or/circuituse.c
@@ -178,7 +178,6 @@ circuit_is_acceptable(const origin_circuit_t *origin_circ,
purpose == CIRCUIT_PURPOSE_S_HSDIR_POST ||
purpose == CIRCUIT_PURPOSE_C_HSDIR_GET) {
tor_addr_t addr;
- const int family = tor_addr_parse(&addr, conn->socks_request->address);
if (!exitnode && !build_state->onehop_tunnel) {
log_debug(LD_CIRC,"Not considering circuit with unknown router.");
return 0; /* this circuit is screwed and doesn't know it yet,
@@ -199,6 +198,8 @@ circuit_is_acceptable(const origin_circuit_t *origin_circ,
return 0; /* this is a circuit to somewhere else */
if (tor_digest_is_zero(digest)) {
/* we don't know the digest; have to compare addr:port */
+ const int family = tor_addr_parse(&addr,
+ conn->socks_request->address);
if (family < 0 ||
!tor_addr_eq(&build_state->chosen_exit->addr, &addr) ||
build_state->chosen_exit->port != conn->socks_request->port)
@@ -211,12 +212,14 @@ circuit_is_acceptable(const origin_circuit_t *origin_circ,
return 0;
}
}
- if (origin_circ->prepend_policy && family != -1) {
- int r = compare_tor_addr_to_addr_policy(&addr,
- conn->socks_request->port,
- origin_circ->prepend_policy);
- if (r == ADDR_POLICY_REJECTED)
- return 0;
+ if (origin_circ->prepend_policy) {
+ if (tor_addr_parse(&addr, conn->socks_request->address) != -1) {
+ int r = compare_tor_addr_to_addr_policy(&addr,
+ conn->socks_request->port,
+ origin_circ->prepend_policy);
+ if (r == ADDR_POLICY_REJECTED)
+ return 0;
+ }
}
if (exitnode && !connection_ap_can_use_exit(conn, exitnode)) {
/* can't exit from this router */