Merge remote-tracking branch 'tor-github/pr/1004'

This commit is contained in:
Nick Mathewson 2019-05-14 11:43:10 -04:00
commit 43d4119454
3 changed files with 19 additions and 9 deletions

7
changes/bug22210 Normal file
View File

@ -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

View File

@ -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

View File

@ -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 */