aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2023-10-05 08:17:59 -0400
committerNick Mathewson <nickm@torproject.org>2023-10-05 09:07:47 -0400
commita62ea322464d4e1f8b0c8d48e3ad779a80fafac6 (patch)
treee03d83667282bc43e3544cd54746c200026f0bb0 /src
parent940a4c7eaad3b93069a0dd8dc7d539b466cfe980 (diff)
downloadtor-a62ea322464d4e1f8b0c8d48e3ad779a80fafac6.tar.gz
tor-a62ea322464d4e1f8b0c8d48e3ad779a80fafac6.zip
Remove MIN_METHOD_FOR_CORRECT_BWWEIGHTSCALE
This also lets us discard extract_param_buggy, which we've been wanting to do.
Diffstat (limited to 'src')
-rw-r--r--src/feature/dirauth/dirvote.c73
-rw-r--r--src/feature/dirauth/dirvote.h8
-rw-r--r--src/test/test_dirvote.c25
3 files changed, 8 insertions, 98 deletions
diff --git a/src/feature/dirauth/dirvote.c b/src/feature/dirauth/dirvote.c
index 682e2b19cd..36025b88a9 100644
--- a/src/feature/dirauth/dirvote.c
+++ b/src/feature/dirauth/dirvote.c
@@ -1780,15 +1780,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
{
- if (consensus_method < MIN_METHOD_FOR_CORRECT_BWWEIGHTSCALE) {
- max_unmeasured_bw_kb = (int32_t) extract_param_buggy(
- params, "maxunmeasuredbw", DEFAULT_MAX_UNMEASURED_BW_KB);
- } else {
- max_unmeasured_bw_kb = dirvote_get_intermediate_param_value(
- param_list, "maxunmeasurdbw", DEFAULT_MAX_UNMEASURED_BW_KB);
- if (max_unmeasured_bw_kb < 1)
- max_unmeasured_bw_kb = 1;
- }
+ max_unmeasured_bw_kb = dirvote_get_intermediate_param_value(
+ param_list, "maxunmeasurdbw", DEFAULT_MAX_UNMEASURED_BW_KB);
+ if (max_unmeasured_bw_kb < 1)
+ max_unmeasured_bw_kb = 1;
}
/* Add the actual router entries. */
@@ -2371,15 +2366,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
{
int64_t weight_scale;
- if (consensus_method < MIN_METHOD_FOR_CORRECT_BWWEIGHTSCALE) {
- weight_scale = extract_param_buggy(params, "bwweightscale",
- BW_WEIGHT_SCALE);
- } else {
- weight_scale = dirvote_get_intermediate_param_value(
- param_list, "bwweightscale", BW_WEIGHT_SCALE);
- if (weight_scale < 1)
- weight_scale = 1;
- }
+ weight_scale = dirvote_get_intermediate_param_value(
+ param_list, "bwweightscale", BW_WEIGHT_SCALE);
+ if (weight_scale < 1)
+ weight_scale = 1;
added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
T, weight_scale);
}
@@ -2481,53 +2471,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
return result;
}
-/** Extract the value of a parameter from a string encoding a list of
- * parameters, badly.
- *
- * This is a deliberately buggy implementation, for backward compatibility
- * with versions of Tor affected by #19011. Once all authorities have
- * upgraded to consensus method 31 or later, then we can throw away this
- * function. */
-STATIC int64_t
-extract_param_buggy(const char *params,
- const char *param_name,
- int64_t default_value)
-{
- int64_t value = default_value;
- const char *param_str = NULL;
-
- if (params) {
- char *prefix1 = NULL, *prefix2=NULL;
- tor_asprintf(&prefix1, "%s=", param_name);
- tor_asprintf(&prefix2, " %s=", param_name);
- if (strcmpstart(params, prefix1) == 0)
- param_str = params;
- else
- param_str = strstr(params, prefix2);
- tor_free(prefix1);
- tor_free(prefix2);
- }
-
- if (param_str) {
- int ok=0;
- char *eq = strchr(param_str, '=');
- if (eq) {
- value = tor_parse_long(eq+1, 10, 1, INT32_MAX, &ok, NULL);
- if (!ok) {
- log_warn(LD_DIR, "Bad element '%s' in %s",
- escaped(param_str), param_name);
- value = default_value;
- }
- } else {
- log_warn(LD_DIR, "Bad element '%s' in %s",
- escaped(param_str), param_name);
- value = default_value;
- }
- }
-
- return value;
-}
-
/** Given a list of networkstatus_t for each vote, return a newly allocated
* string containing the "package" lines for the vote. */
STATIC char *
diff --git a/src/feature/dirauth/dirvote.h b/src/feature/dirauth/dirvote.h
index b879990462..4790180256 100644
--- a/src/feature/dirauth/dirvote.h
+++ b/src/feature/dirauth/dirvote.h
@@ -55,11 +55,6 @@
/** The highest consensus method that we currently support. */
#define MAX_SUPPORTED_CONSENSUS_METHOD 34
-/** Lowest consensus method for which we use the correct algorithm for
- * extracting the bwweightscale= and maxunmeasuredbw= parameters. See #19011.
- */
-#define MIN_METHOD_FOR_CORRECT_BWWEIGHTSCALE 31
-
/** Lowest consensus method for which we handle the MiddleOnly flag specially.
*/
#define MIN_METHOD_FOR_MIDDLEONLY 32
@@ -270,9 +265,6 @@ STATIC
char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
STATIC microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri,
int consensus_method);
-STATIC int64_t extract_param_buggy(const char *params,
- const char *param_name,
- int64_t default_value);
#endif /* defined(DIRVOTE_PRIVATE) */
diff --git a/src/test/test_dirvote.c b/src/test/test_dirvote.c
index 2b53955107..bb7e6fdf10 100644
--- a/src/test/test_dirvote.c
+++ b/src/test/test_dirvote.c
@@ -656,30 +656,6 @@ done:
ROUTER_FREE(pppp);
}
-static void
-test_dirvote_parse_param_buggy(void *arg)
-{
- (void)arg;
-
- /* Tests for behavior with bug emulation to migrate away from bug 19011. */
- tt_i64_op(extract_param_buggy("blah blah", "bwweightscale", 10000),
- OP_EQ, 10000);
- tt_i64_op(extract_param_buggy("bwweightscale=7", "bwweightscale", 10000),
- OP_EQ, 7);
- tt_i64_op(extract_param_buggy("bwweightscale=7 foo=9",
- "bwweightscale", 10000),
- OP_EQ, 10000);
- tt_i64_op(extract_param_buggy("foo=7 bwweightscale=777 bar=9",
- "bwweightscale", 10000),
- OP_EQ, 10000);
- tt_i64_op(extract_param_buggy("foo=7 bwweightscale=1234",
- "bwweightscale", 10000),
- OP_EQ, 1234);
-
- done:
- ;
-}
-
#define NODE(name, flags) \
{ \
#name, test_dirvote_##name, (flags), NULL, NULL \
@@ -692,5 +668,4 @@ struct testcase_t dirvote_tests[] = {
NODE(get_sybil_by_ip_version_ipv4, TT_FORK),
NODE(get_sybil_by_ip_version_ipv6, TT_FORK),
NODE(get_all_possible_sybil, TT_FORK),
- NODE(parse_param_buggy, 0),
END_OF_TESTCASES};