aboutsummaryrefslogtreecommitdiff
path: root/src/or/dirserv.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-03-15 10:15:59 -0400
committerNick Mathewson <nickm@torproject.org>2016-03-21 13:24:09 -0400
commit48f8229504a00085676a737d9b519548ffc9d145 (patch)
tree964e9b717a9dcb084d3c0b602978ee706666ba7d /src/or/dirserv.c
parentfa07c60c67d69ff25c4e64172e3a38b29a2e6143 (diff)
downloadtor-48f8229504a00085676a737d9b519548ffc9d145.tar.gz
tor-48f8229504a00085676a737d9b519548ffc9d145.zip
After we strip out duplicate entries from 'routers', don't use 'rl'.
We've got to make sure that every single subsequent calculation in dirserv_generate_networkstatus_vote_obj() are based on the list of routerinfo_t *after* we've removed possible duplicates, not before. Fortunately, none of the functions that were taking a routerlist_t as an argument were actually using any fields other than this list of routers. Resolves issue 18318.DG3.
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r--src/or/dirserv.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 016514f10f..ab8ddfe840 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1422,7 +1422,7 @@ router_counts_toward_thresholds(const node_t *node, time_t now,
*
* Also, set the is_exit flag of each router appropriately. */
static void
-dirserv_compute_performance_thresholds(routerlist_t *rl,
+dirserv_compute_performance_thresholds(const smartlist_t *routers,
digestmap_t *omit_as_sybil)
{
int n_active, n_active_nonexit, n_familiar;
@@ -1450,18 +1450,18 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
* sort them and use that to compute thresholds. */
n_active = n_active_nonexit = 0;
/* Uptime for every active router. */
- uptimes = tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
+ uptimes = tor_calloc(smartlist_len(routers), sizeof(uint32_t));
/* Bandwidth for every active router. */
- bandwidths_kb = tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
+ bandwidths_kb = tor_calloc(smartlist_len(routers), sizeof(uint32_t));
/* Bandwidth for every active non-exit router. */
bandwidths_excluding_exits_kb =
- tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
+ tor_calloc(smartlist_len(routers), sizeof(uint32_t));
/* Weighted mean time between failure for each active router. */
- mtbfs = tor_calloc(smartlist_len(rl->routers), sizeof(double));
+ mtbfs = tor_calloc(smartlist_len(routers), sizeof(double));
/* Time-known for each active router. */
- tks = tor_calloc(smartlist_len(rl->routers), sizeof(long));
+ tks = tor_calloc(smartlist_len(routers), sizeof(long));
/* Weighted fractional uptime for each active router. */
- wfus = tor_calloc(smartlist_len(rl->routers), sizeof(double));
+ wfus = tor_calloc(smartlist_len(routers), sizeof(double));
nodelist_assert_ok();
@@ -1596,11 +1596,11 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
* networkstatus_getinfo_by_purpose().
*/
void
-dirserv_compute_bridge_flag_thresholds(routerlist_t *rl)
+dirserv_compute_bridge_flag_thresholds(const smartlist_t *routers)
{
digestmap_t *omit_as_sybil = digestmap_new();
- dirserv_compute_performance_thresholds(rl, omit_as_sybil);
+ dirserv_compute_performance_thresholds(routers, omit_as_sybil);
digestmap_free(omit_as_sybil, NULL);
}
@@ -1753,16 +1753,13 @@ dirserv_get_bandwidth_for_router_kb(const routerinfo_t *ri)
* how many measured bandwidths we know. This is used to decide whether we
* ever trust advertised bandwidths for purposes of assigning flags. */
static void
-dirserv_count_measured_bws(routerlist_t *rl)
+dirserv_count_measured_bws(const smartlist_t *routers)
{
/* Initialize this first */
routers_with_measured_bw = 0;
- tor_assert(rl);
- tor_assert(rl->routers);
-
/* Iterate over the routerlist and count measured bandwidths */
- SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, ri) {
+ SMARTLIST_FOREACH_BEGIN(routers, const routerinfo_t *, ri) {
/* Check if we know a measured bandwidth for this one */
if (dirserv_has_measured_bw(ri->cache_info.identity_digest)) {
++routers_with_measured_bw;
@@ -2854,6 +2851,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
routers = smartlist_new();
smartlist_add_all(routers, rl->routers);
routers_make_ed_keys_unique(routers);
+ /* After this point, don't use rl->routers; use 'routers' instead. */
routers_sort_by_identity(routers);
omit_as_sybil = get_possible_sybil_list(routers);
@@ -2864,9 +2862,9 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
/* Count how many have measured bandwidths so we know how to assign flags;
* this must come before dirserv_compute_performance_thresholds() */
- dirserv_count_measured_bws(rl);
+ dirserv_count_measured_bws(routers);
- dirserv_compute_performance_thresholds(rl, omit_as_sybil);
+ dirserv_compute_performance_thresholds(routers, omit_as_sybil);
routerstatuses = smartlist_new();
microdescriptors = smartlist_new();