mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Provide a DROPTIMEOUTS command to drop CBT times
This allows us to reset CBT when we change guards in fixed-guards onionperf instances (#33325 and children).
This commit is contained in:
parent
1d32c3114f
commit
6ec01c5f72
@ -53,9 +53,6 @@
|
||||
#undef log
|
||||
#include <math.h>
|
||||
|
||||
static void cbt_control_event_buildtimeout_set(
|
||||
const circuit_build_times_t *cbt,
|
||||
buildtimeout_set_event_t type);
|
||||
static void circuit_build_times_scale_circ_counts(circuit_build_times_t *cbt);
|
||||
|
||||
#define CBT_BIN_TO_MS(bin) ((bin)*CBT_BIN_WIDTH + (CBT_BIN_WIDTH/2))
|
||||
@ -545,7 +542,7 @@ circuit_build_times_get_initial_timeout(void)
|
||||
* Leave estimated parameters, timeout and network liveness intact
|
||||
* for future use.
|
||||
*/
|
||||
STATIC void
|
||||
void
|
||||
circuit_build_times_reset(circuit_build_times_t *cbt)
|
||||
{
|
||||
memset(cbt->circuit_build_times, 0, sizeof(cbt->circuit_build_times));
|
||||
@ -1894,7 +1891,7 @@ circuit_build_times_update_last_circ(circuit_build_times_t *cbt)
|
||||
cbt->last_circ_at = approx_time();
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
cbt_control_event_buildtimeout_set(const circuit_build_times_t *cbt,
|
||||
buildtimeout_set_event_t type)
|
||||
{
|
||||
|
@ -12,6 +12,8 @@
|
||||
#ifndef TOR_CIRCUITSTATS_H
|
||||
#define TOR_CIRCUITSTATS_H
|
||||
|
||||
#include "feature/control/control_events.h"
|
||||
|
||||
const circuit_build_times_t *get_circuit_build_times(void);
|
||||
circuit_build_times_t *get_circuit_build_times_mutable(void);
|
||||
double get_circuit_build_close_time_ms(void);
|
||||
@ -49,6 +51,10 @@ double circuit_build_times_close_rate(const circuit_build_times_t *cbt);
|
||||
|
||||
void circuit_build_times_update_last_circ(circuit_build_times_t *cbt);
|
||||
void circuit_build_times_mark_circ_as_measurement_only(origin_circuit_t *circ);
|
||||
void circuit_build_times_reset(circuit_build_times_t *cbt);
|
||||
void cbt_control_event_buildtimeout_set(
|
||||
const circuit_build_times_t *cbt,
|
||||
buildtimeout_set_event_t type);
|
||||
|
||||
/** Total size of the circuit timeout history to accumulate.
|
||||
* 1000 is approx 2.5 days worth of continual-use circuits. */
|
||||
@ -137,7 +143,6 @@ int32_t circuit_build_times_initial_timeout(void);
|
||||
STATIC double circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
|
||||
double quantile);
|
||||
STATIC int circuit_build_times_update_alpha(circuit_build_times_t *cbt);
|
||||
STATIC void circuit_build_times_reset(circuit_build_times_t *cbt);
|
||||
|
||||
/* Network liveness functions */
|
||||
STATIC int circuit_build_times_network_check_changed(
|
||||
|
@ -20,9 +20,11 @@
|
||||
#include "core/or/circuitlist.h"
|
||||
#include "core/or/circuituse.h"
|
||||
#include "core/or/connection_edge.h"
|
||||
#include "core/or/circuitstats.h"
|
||||
#include "feature/client/addressmap.h"
|
||||
#include "feature/client/dnsserv.h"
|
||||
#include "feature/client/entrynodes.h"
|
||||
#include "feature/control/control_events.h"
|
||||
#include "feature/control/control.h"
|
||||
#include "feature/control/control_auth.h"
|
||||
#include "feature/control/control_cmd.h"
|
||||
@ -1396,6 +1398,33 @@ handle_control_dropguards(control_connection_t *conn,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const control_cmd_syntax_t droptimeouts_syntax = {
|
||||
.max_args = 0,
|
||||
};
|
||||
|
||||
/** Implementation for the DROPTIMEOUTS command. */
|
||||
static int
|
||||
handle_control_droptimeouts(control_connection_t *conn,
|
||||
const control_cmd_args_t *args)
|
||||
{
|
||||
(void) args; /* We don't take arguments. */
|
||||
|
||||
static int have_warned = 0;
|
||||
if (! have_warned) {
|
||||
log_warn(LD_CONTROL, "DROPTIMEOUTS is dangerous; make sure you understand "
|
||||
"the risks before using it. It may be removed in a future "
|
||||
"version of Tor.");
|
||||
have_warned = 1;
|
||||
}
|
||||
|
||||
circuit_build_times_reset(get_circuit_build_times_mutable());
|
||||
send_control_done(conn);
|
||||
cbt_control_event_buildtimeout_set(get_circuit_build_times(),
|
||||
BUILDTIMEOUT_SET_EVENT_RESET);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *hsfetch_keywords[] = {
|
||||
"SERVER", NULL,
|
||||
};
|
||||
@ -2331,6 +2360,7 @@ static const control_cmd_def_t CONTROL_COMMANDS[] =
|
||||
ONE_LINE(protocolinfo, 0),
|
||||
ONE_LINE(authchallenge, CMD_FL_WIPE),
|
||||
ONE_LINE(dropguards, 0),
|
||||
ONE_LINE(droptimeouts, 0),
|
||||
ONE_LINE(hsfetch, 0),
|
||||
MULTLINE(hspost, 0),
|
||||
ONE_LINE(add_onion, CMD_FL_WIPE),
|
||||
|
Loading…
Reference in New Issue
Block a user