[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] prop224: Always note down the use of internal circuit
commit 400ba2f636edf5afb14fe3b57f23d80e433d893d
Author: David Goulet <dgoulet@xxxxxxxxxxxxxx>
Date: Fri Aug 4 12:06:34 2017 -0400
prop224: Always note down the use of internal circuit
Also, this removes all the callsite of this rephist in the hs subsystem
Fixes #23097
Signed-off-by: David Goulet <dgoulet@xxxxxxxxxxxxxx>
---
src/or/circuituse.c | 31 ++++++++++++++++++++++++++-----
src/or/circuituse.h | 3 ++-
src/or/hs_circuit.c | 12 +-----------
src/or/hs_circuit.h | 2 +-
src/or/hs_service.c | 6 +++---
5 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 5292dc01d..66006542d 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1114,11 +1114,32 @@ needs_exit_circuits(time_t now, int *needs_uptime, int *needs_capacity)
/* Return true if we need any more hidden service server circuits.
* HS servers only need an internal circuit. */
STATIC int
-needs_hs_server_circuits(int num_uptime_internal)
+needs_hs_server_circuits(time_t now, int num_uptime_internal)
{
- return ((rend_num_services() || hs_service_get_num_services()) &&
- num_uptime_internal < SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS &&
- router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN);
+ if (!rend_num_services() && !hs_service_get_num_services()) {
+ /* No services, we don't need anything. */
+ goto no_need;
+ }
+
+ if (num_uptime_internal >= SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS) {
+ /* We have sufficient amount of internal circuit. */
+ goto no_need;
+ }
+
+ if (router_have_consensus_path() == CONSENSUS_PATH_UNKNOWN) {
+ /* Consensus hasn't been checked or might be invalid so requesting
+ * internal circuits is not wise. */
+ goto no_need;
+ }
+
+ /* At this point, we need a certain amount of circuits and we will most
+ * likely use them for rendezvous so we note down the use of internal
+ * circuit for our prediction for circuit needing uptime and capacity. */
+ rep_hist_note_used_internal(now, 1, 1);
+
+ return 1;
+ no_need:
+ return 0;
}
/* We need at least this many internal circuits for hidden service clients */
@@ -1217,7 +1238,7 @@ circuit_predict_and_launch_new(void)
return;
}
- if (needs_hs_server_circuits(num_uptime_internal)) {
+ if (needs_hs_server_circuits(now, num_uptime_internal)) {
flags = (CIRCLAUNCH_NEED_CAPACITY | CIRCLAUNCH_NEED_UPTIME |
CIRCLAUNCH_IS_INTERNAL);
diff --git a/src/or/circuituse.h b/src/or/circuituse.h
index ad4c214a3..e66679586 100644
--- a/src/or/circuituse.h
+++ b/src/or/circuituse.h
@@ -68,7 +68,8 @@ STATIC int circuit_is_available_for_use(const circuit_t *circ);
STATIC int needs_exit_circuits(time_t now,
int *port_needs_uptime,
int *port_needs_capacity);
-STATIC int needs_hs_server_circuits(int num_uptime_internal);
+STATIC int needs_hs_server_circuits(time_t now,
+ int num_uptime_internal);
STATIC int needs_hs_client_circuits(time_t now,
int *needs_uptime,
diff --git a/src/or/hs_circuit.c b/src/or/hs_circuit.c
index f6594739b..d0265dc54 100644
--- a/src/or/hs_circuit.c
+++ b/src/or/hs_circuit.c
@@ -480,8 +480,6 @@ launch_rendezvous_point_circuit(const hs_service_t *service,
tor_assert(data);
circ_needs_uptime = hs_service_requires_uptime_circ(service->config.ports);
- /* Help predict this next time */
- rep_hist_note_used_internal(now, circ_needs_uptime, 1);
/* Get the extend info data structure for the chosen rendezvous point
* specified by the given link specifiers. */
@@ -632,10 +630,6 @@ retry_service_rendezvous_point(const origin_circuit_t *circ)
* has no anonymity (single onion), this change of behavior won't affect
* security directly. */
- /* Help predict this next time */
- rep_hist_note_used_internal(time(NULL), bstate->need_uptime,
- bstate->need_capacity);
-
new_circ = circuit_launch_by_extend_info(CIRCUIT_PURPOSE_S_CONNECT_REND,
bstate->chosen_exit, flags);
if (new_circ == NULL) {
@@ -728,7 +722,7 @@ hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
int
hs_circ_launch_intro_point(hs_service_t *service,
const hs_service_intro_point_t *ip,
- extend_info_t *ei, time_t now)
+ extend_info_t *ei)
{
/* Standard flags for introduction circuit. */
int ret = -1, circ_flags = CIRCLAUNCH_NEED_UPTIME | CIRCLAUNCH_IS_INTERNAL;
@@ -748,10 +742,6 @@ hs_circ_launch_intro_point(hs_service_t *service,
safe_str_client(extend_info_describe(ei)),
safe_str_client(service->onion_address));
- /* Note down that we are about to use an internal circuit. */
- rep_hist_note_used_internal(now, circ_flags & CIRCLAUNCH_NEED_UPTIME,
- circ_flags & CIRCLAUNCH_NEED_CAPACITY);
-
/* Note down the launch for the retry period. Even if the circuit fails to
* be launched, we still want to respect the retry period to avoid stress on
* the circuit subsystem. */
diff --git a/src/or/hs_circuit.h b/src/or/hs_circuit.h
index 8706e6b0e..9e359394e 100644
--- a/src/or/hs_circuit.h
+++ b/src/or/hs_circuit.h
@@ -24,7 +24,7 @@ void hs_circ_service_rp_has_opened(const hs_service_t *service,
origin_circuit_t *circ);
int hs_circ_launch_intro_point(hs_service_t *service,
const hs_service_intro_point_t *ip,
- extend_info_t *ei, time_t now);
+ extend_info_t *ei);
int hs_circ_launch_rendezvous_point(const hs_service_t *service,
const curve25519_public_key_t *onion_key,
const uint8_t *rendezvous_cookie);
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 4c0ec628c..5f3696454 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -1749,7 +1749,7 @@ run_build_descriptor_event(time_t now)
/* For the given service, launch any intro point circuits that could be
* needed. This considers every descriptor of the service. */
static void
-launch_intro_point_circuits(hs_service_t *service, time_t now)
+launch_intro_point_circuits(hs_service_t *service)
{
tor_assert(service);
@@ -1785,7 +1785,7 @@ launch_intro_point_circuits(hs_service_t *service, time_t now)
/* Launch a circuit to the intro point. */
ip->circuit_retries++;
- if (hs_circ_launch_intro_point(service, ip, ei, now) < 0) {
+ if (hs_circ_launch_intro_point(service, ip, ei) < 0) {
log_warn(LD_REND, "Unable to launch intro circuit to node %s "
"for service %s.",
safe_str_client(extend_info_describe(ei)),
@@ -1910,7 +1910,7 @@ run_build_circuit_event(time_t now)
* circuit creation so make sure this service is respecting that limit. */
if (can_service_launch_intro_circuit(service, now)) {
/* Launch intro point circuits if needed. */
- launch_intro_point_circuits(service, now);
+ launch_intro_point_circuits(service);
/* Once the circuits have opened, we'll make sure to update the
* descriptor intro point list and cleanup any extraneous. */
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits