mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
Refactor the scaling parameter fetching into a single function.
Also, deprecate the torrc options for the scaling values. It's unlikely anyone but developers will ever tweak them, even if we provided a single ratio value.
This commit is contained in:
parent
2b2c7f23f5
commit
dfcfb5d17d
@ -1238,11 +1238,7 @@ The following options are useful only for clients (that is, if
|
|||||||
|
|
||||||
**PathBiasDropGuards** __NUM__ +
|
**PathBiasDropGuards** __NUM__ +
|
||||||
|
|
||||||
**PathBiasScaleThreshold** __NUM__ +
|
**PathBiasScaleThreshold** __NUM__::
|
||||||
|
|
||||||
**PathBiasMultFactor** __NUM__ +
|
|
||||||
|
|
||||||
**PathBiasScaleFactor** __NUM__::
|
|
||||||
These options override the default behavior of Tor's (**currently
|
These options override the default behavior of Tor's (**currently
|
||||||
experimental**) path bias detection algorithm. To try to find broken or
|
experimental**) path bias detection algorithm. To try to find broken or
|
||||||
misbehaving guard nodes, Tor looks for nodes where more than a certain
|
misbehaving guard nodes, Tor looks for nodes where more than a certain
|
||||||
@ -1256,14 +1252,13 @@ The following options are useful only for clients (that is, if
|
|||||||
is set to 1, we disable use of that guard. +
|
is set to 1, we disable use of that guard. +
|
||||||
+
|
+
|
||||||
When we have seen more than PathBiasScaleThreshold
|
When we have seen more than PathBiasScaleThreshold
|
||||||
circuits through a guard, we scale our observations by
|
circuits through a guard, we scale our observations by 0.5 (governed by
|
||||||
PathBiasMultFactor/PathBiasScaleFactor, so that new observations don't get
|
the consensus) so that new observations don't get swamped by old ones. +
|
||||||
swamped by old ones. +
|
|
||||||
+
|
+
|
||||||
By default, or if a negative value is provided for one of these options,
|
By default, or if a negative value is provided for one of these options,
|
||||||
Tor uses reasonable defaults from the networkstatus consensus document.
|
Tor uses reasonable defaults from the networkstatus consensus document.
|
||||||
If no defaults are available there, these options default to 150, .70,
|
If no defaults are available there, these options default to 150, .70,
|
||||||
.50, .30, 0, 300, 1, and 2 respectively.
|
.50, .30, 0, and 300 respectively.
|
||||||
|
|
||||||
**PathBiasUseThreshold** __NUM__ +
|
**PathBiasUseThreshold** __NUM__ +
|
||||||
|
|
||||||
|
@ -1175,38 +1175,31 @@ pathbias_get_scale_threshold(const or_options_t *options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scale factor is the denominator for our scaling
|
* Compute the path bias scaling ratio from the consensus
|
||||||
* of circuit counts for our path bias window.
|
* parameters pb_multfactor/pb_scalefactor.
|
||||||
*
|
*
|
||||||
* Note that our use of doubles for the path bias state
|
* Returns a value in (0, 1.0] which we multiply our pathbias
|
||||||
* file means that powers of 2 work best here.
|
* counts with to scale them down.
|
||||||
*/
|
*/
|
||||||
static int
|
static double
|
||||||
pathbias_get_scale_factor(const or_options_t *options)
|
pathbias_get_scale_ratio(const or_options_t *options)
|
||||||
{
|
{
|
||||||
#define DFLT_PATH_BIAS_SCALE_FACTOR 2
|
/*
|
||||||
if (options->PathBiasScaleFactor >= 1)
|
* The scale factor is the denominator for our scaling
|
||||||
return options->PathBiasScaleFactor;
|
* of circuit counts for our path bias window.
|
||||||
else
|
*
|
||||||
return networkstatus_get_param(NULL, "pb_scalefactor",
|
* Note that our use of doubles for the path bias state
|
||||||
DFLT_PATH_BIAS_SCALE_FACTOR, 1, INT32_MAX);
|
* file means that powers of 2 work best here.
|
||||||
}
|
*/
|
||||||
|
int denominator = networkstatus_get_param(NULL, "pb_scalefactor",
|
||||||
/**
|
2, 2, INT32_MAX);
|
||||||
* The mult factor is the numerator for our scaling
|
/**
|
||||||
* of circuit counts for our path bias window. It
|
* The mult factor is the numerator for our scaling
|
||||||
* allows us to scale by fractions.
|
* of circuit counts for our path bias window. It
|
||||||
*/
|
* allows us to scale by fractions.
|
||||||
static int
|
*/
|
||||||
pathbias_get_mult_factor(const or_options_t *options)
|
return networkstatus_get_param(NULL, "pb_multfactor",
|
||||||
{
|
1, 1, denominator)/((double)denominator);
|
||||||
#define DFLT_PATH_BIAS_MULT_FACTOR 1
|
|
||||||
if (options->PathBiasMultFactor >= 1)
|
|
||||||
return options->PathBiasMultFactor;
|
|
||||||
else
|
|
||||||
return networkstatus_get_param(NULL, "pb_multfactor",
|
|
||||||
DFLT_PATH_BIAS_MULT_FACTOR, 1,
|
|
||||||
pathbias_get_scale_factor(options));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The minimum number of circuit usage attempts before we start
|
/** The minimum number of circuit usage attempts before we start
|
||||||
@ -2301,17 +2294,13 @@ pathbias_check_use_rate(entry_guard_t *guard)
|
|||||||
|
|
||||||
/* If we get a ton of circuits, just scale everything down */
|
/* If we get a ton of circuits, just scale everything down */
|
||||||
if (guard->use_attempts > pathbias_get_scale_use_threshold(options)) {
|
if (guard->use_attempts > pathbias_get_scale_use_threshold(options)) {
|
||||||
const int scale_factor = pathbias_get_scale_factor(options);
|
double scale_ratio = pathbias_get_scale_ratio(options);
|
||||||
const int mult_factor = pathbias_get_mult_factor(options);
|
|
||||||
int opened_attempts = pathbias_count_circs_in_states(guard,
|
int opened_attempts = pathbias_count_circs_in_states(guard,
|
||||||
PATH_STATE_USE_ATTEMPTED, PATH_STATE_USE_SUCCEEDED);
|
PATH_STATE_USE_ATTEMPTED, PATH_STATE_USE_SUCCEEDED);
|
||||||
guard->use_attempts -= opened_attempts;
|
guard->use_attempts -= opened_attempts;
|
||||||
|
|
||||||
guard->use_attempts *= mult_factor;
|
guard->use_attempts *= scale_ratio;
|
||||||
guard->use_successes *= mult_factor;
|
guard->use_successes *= scale_ratio;
|
||||||
|
|
||||||
guard->use_attempts /= scale_factor;
|
|
||||||
guard->use_successes /= scale_factor;
|
|
||||||
|
|
||||||
guard->use_attempts += opened_attempts;
|
guard->use_attempts += opened_attempts;
|
||||||
|
|
||||||
@ -2449,8 +2438,7 @@ pathbias_check_close_rate(entry_guard_t *guard)
|
|||||||
|
|
||||||
/* If we get a ton of circuits, just scale everything down */
|
/* If we get a ton of circuits, just scale everything down */
|
||||||
if (guard->circ_attempts > pathbias_get_scale_threshold(options)) {
|
if (guard->circ_attempts > pathbias_get_scale_threshold(options)) {
|
||||||
const int scale_factor = pathbias_get_scale_factor(options);
|
double scale_ratio = pathbias_get_scale_ratio(options);
|
||||||
const int mult_factor = pathbias_get_mult_factor(options);
|
|
||||||
int opened_attempts = pathbias_count_circs_in_states(guard,
|
int opened_attempts = pathbias_count_circs_in_states(guard,
|
||||||
PATH_STATE_BUILD_ATTEMPTED, PATH_STATE_BUILD_ATTEMPTED);
|
PATH_STATE_BUILD_ATTEMPTED, PATH_STATE_BUILD_ATTEMPTED);
|
||||||
int opened_built = pathbias_count_circs_in_states(guard,
|
int opened_built = pathbias_count_circs_in_states(guard,
|
||||||
@ -2459,19 +2447,12 @@ pathbias_check_close_rate(entry_guard_t *guard)
|
|||||||
guard->circ_attempts -= opened_attempts;
|
guard->circ_attempts -= opened_attempts;
|
||||||
guard->circ_successes -= opened_built;
|
guard->circ_successes -= opened_built;
|
||||||
|
|
||||||
guard->circ_attempts *= mult_factor;
|
guard->circ_attempts *= scale_ratio;
|
||||||
guard->circ_successes *= mult_factor;
|
guard->circ_successes *= scale_ratio;
|
||||||
guard->timeouts *= mult_factor;
|
guard->timeouts *= scale_ratio;
|
||||||
guard->successful_circuits_closed *= mult_factor;
|
guard->successful_circuits_closed *= scale_ratio;
|
||||||
guard->collapsed_circuits *= mult_factor;
|
guard->collapsed_circuits *= scale_ratio;
|
||||||
guard->unusable_circuits *= mult_factor;
|
guard->unusable_circuits *= scale_ratio;
|
||||||
|
|
||||||
guard->circ_attempts /= scale_factor;
|
|
||||||
guard->circ_successes /= scale_factor;
|
|
||||||
guard->timeouts /= scale_factor;
|
|
||||||
guard->successful_circuits_closed /= scale_factor;
|
|
||||||
guard->collapsed_circuits /= scale_factor;
|
|
||||||
guard->unusable_circuits /= scale_factor;
|
|
||||||
|
|
||||||
guard->circ_attempts += opened_attempts;
|
guard->circ_attempts += opened_attempts;
|
||||||
guard->circ_successes += opened_built;
|
guard->circ_successes += opened_built;
|
||||||
|
@ -321,8 +321,8 @@ static config_var_t option_vars_[] = {
|
|||||||
V(PathBiasWarnRate, DOUBLE, "-1"),
|
V(PathBiasWarnRate, DOUBLE, "-1"),
|
||||||
V(PathBiasExtremeRate, DOUBLE, "-1"),
|
V(PathBiasExtremeRate, DOUBLE, "-1"),
|
||||||
V(PathBiasScaleThreshold, INT, "-1"),
|
V(PathBiasScaleThreshold, INT, "-1"),
|
||||||
V(PathBiasScaleFactor, INT, "-1"),
|
OBSOLETE("PathBiasScaleFactor"),
|
||||||
V(PathBiasMultFactor, INT, "-1"),
|
OBSOLETE("PathBiasMultFactor"),
|
||||||
V(PathBiasDropGuards, AUTOBOOL, "0"),
|
V(PathBiasDropGuards, AUTOBOOL, "0"),
|
||||||
OBSOLETE("PathBiasUseCloseCounts"),
|
OBSOLETE("PathBiasUseCloseCounts"),
|
||||||
|
|
||||||
|
@ -3949,8 +3949,6 @@ typedef struct {
|
|||||||
double PathBiasExtremeRate;
|
double PathBiasExtremeRate;
|
||||||
int PathBiasDropGuards;
|
int PathBiasDropGuards;
|
||||||
int PathBiasScaleThreshold;
|
int PathBiasScaleThreshold;
|
||||||
int PathBiasScaleFactor;
|
|
||||||
int PathBiasMultFactor;
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user