mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
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@torproject.org>
This commit is contained in:
parent
0a0bbfe96f
commit
400ba2f636
@ -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.
|
/* Return true if we need any more hidden service server circuits.
|
||||||
* HS servers only need an internal circuit. */
|
* HS servers only need an internal circuit. */
|
||||||
STATIC int
|
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()) &&
|
if (!rend_num_services() && !hs_service_get_num_services()) {
|
||||||
num_uptime_internal < SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS &&
|
/* No services, we don't need anything. */
|
||||||
router_have_consensus_path() != CONSENSUS_PATH_UNKNOWN);
|
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 */
|
/* We need at least this many internal circuits for hidden service clients */
|
||||||
@ -1217,7 +1238,7 @@ circuit_predict_and_launch_new(void)
|
|||||||
return;
|
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 |
|
flags = (CIRCLAUNCH_NEED_CAPACITY | CIRCLAUNCH_NEED_UPTIME |
|
||||||
CIRCLAUNCH_IS_INTERNAL);
|
CIRCLAUNCH_IS_INTERNAL);
|
||||||
|
|
||||||
|
@ -68,7 +68,8 @@ STATIC int circuit_is_available_for_use(const circuit_t *circ);
|
|||||||
STATIC int needs_exit_circuits(time_t now,
|
STATIC int needs_exit_circuits(time_t now,
|
||||||
int *port_needs_uptime,
|
int *port_needs_uptime,
|
||||||
int *port_needs_capacity);
|
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,
|
STATIC int needs_hs_client_circuits(time_t now,
|
||||||
int *needs_uptime,
|
int *needs_uptime,
|
||||||
|
@ -480,8 +480,6 @@ launch_rendezvous_point_circuit(const hs_service_t *service,
|
|||||||
tor_assert(data);
|
tor_assert(data);
|
||||||
|
|
||||||
circ_needs_uptime = hs_service_requires_uptime_circ(service->config.ports);
|
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
|
/* Get the extend info data structure for the chosen rendezvous point
|
||||||
* specified by the given link specifiers. */
|
* 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
|
* has no anonymity (single onion), this change of behavior won't affect
|
||||||
* security directly. */
|
* 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,
|
new_circ = circuit_launch_by_extend_info(CIRCUIT_PURPOSE_S_CONNECT_REND,
|
||||||
bstate->chosen_exit, flags);
|
bstate->chosen_exit, flags);
|
||||||
if (new_circ == NULL) {
|
if (new_circ == NULL) {
|
||||||
@ -728,7 +722,7 @@ hs_circ_retry_service_rendezvous_point(origin_circuit_t *circ)
|
|||||||
int
|
int
|
||||||
hs_circ_launch_intro_point(hs_service_t *service,
|
hs_circ_launch_intro_point(hs_service_t *service,
|
||||||
const hs_service_intro_point_t *ip,
|
const hs_service_intro_point_t *ip,
|
||||||
extend_info_t *ei, time_t now)
|
extend_info_t *ei)
|
||||||
{
|
{
|
||||||
/* Standard flags for introduction circuit. */
|
/* Standard flags for introduction circuit. */
|
||||||
int ret = -1, circ_flags = CIRCLAUNCH_NEED_UPTIME | CIRCLAUNCH_IS_INTERNAL;
|
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(extend_info_describe(ei)),
|
||||||
safe_str_client(service->onion_address));
|
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
|
/* 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
|
* be launched, we still want to respect the retry period to avoid stress on
|
||||||
* the circuit subsystem. */
|
* the circuit subsystem. */
|
||||||
|
@ -24,7 +24,7 @@ void hs_circ_service_rp_has_opened(const hs_service_t *service,
|
|||||||
origin_circuit_t *circ);
|
origin_circuit_t *circ);
|
||||||
int hs_circ_launch_intro_point(hs_service_t *service,
|
int hs_circ_launch_intro_point(hs_service_t *service,
|
||||||
const hs_service_intro_point_t *ip,
|
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,
|
int hs_circ_launch_rendezvous_point(const hs_service_t *service,
|
||||||
const curve25519_public_key_t *onion_key,
|
const curve25519_public_key_t *onion_key,
|
||||||
const uint8_t *rendezvous_cookie);
|
const uint8_t *rendezvous_cookie);
|
||||||
|
@ -1749,7 +1749,7 @@ run_build_descriptor_event(time_t now)
|
|||||||
/* For the given service, launch any intro point circuits that could be
|
/* For the given service, launch any intro point circuits that could be
|
||||||
* needed. This considers every descriptor of the service. */
|
* needed. This considers every descriptor of the service. */
|
||||||
static void
|
static void
|
||||||
launch_intro_point_circuits(hs_service_t *service, time_t now)
|
launch_intro_point_circuits(hs_service_t *service)
|
||||||
{
|
{
|
||||||
tor_assert(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. */
|
/* Launch a circuit to the intro point. */
|
||||||
ip->circuit_retries++;
|
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 "
|
log_warn(LD_REND, "Unable to launch intro circuit to node %s "
|
||||||
"for service %s.",
|
"for service %s.",
|
||||||
safe_str_client(extend_info_describe(ei)),
|
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. */
|
* circuit creation so make sure this service is respecting that limit. */
|
||||||
if (can_service_launch_intro_circuit(service, now)) {
|
if (can_service_launch_intro_circuit(service, now)) {
|
||||||
/* Launch intro point circuits if needed. */
|
/* 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
|
/* Once the circuits have opened, we'll make sure to update the
|
||||||
* descriptor intro point list and cleanup any extraneous. */
|
* descriptor intro point list and cleanup any extraneous. */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user