Loading ChangeLog +2 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ Changes in version 0.2.1.17-?? - 2009-??-?? o Minor bugfixes: - Serve the DirPortFrontPage page even when we have been approaching our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. - Do not cap bandwidths reported by directory authorities; they are already adjusted to reflect reality. o Major features: - Clients now use the bandwidth values in the consensus, rather than Loading src/or/routerlist.c +9 −25 Original line number Diff line number Diff line Loading @@ -1523,15 +1523,12 @@ router_get_advertised_bandwidth_capped(routerinfo_t *router) return result; } /** Eventually, the number we return will come from the directory * consensus, so clients can dynamically update to better numbers. * * But for now, or in case there is no consensus available, just return * a sufficient default. */ static uint32_t get_max_believable_bandwidth(void) /** Return bw*1000, unless bw*1000 would overflow, in which case return * INT32_MAX. */ static INLINE int32_t kb_to_bytes(uint32_t bw) { return DEFAULT_MAX_BELIEVABLE_BANDWIDTH; return (bw > (INT32_MAX/1000)) ? INT32_MAX : bw*1000; } /** Helper function: Loading Loading @@ -1568,7 +1565,6 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, int n_unknown = 0; bitarray_t *exit_bits; bitarray_t *guard_bits; uint32_t max_believable_bw = get_max_believable_bandwidth(); int me_idx = -1; /* Can't choose exit and guard at same time */ Loading Loading @@ -1598,7 +1594,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = status->is_exit; is_guard = status->is_possible_guard; if (status->has_bandwidth) { this_bw = status->bandwidth*1000; this_bw = kb_to_bytes(status->bandwidth); } else { /* guess */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ Loading @@ -1617,7 +1613,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = router->is_exit; is_guard = router->is_possible_guard; if (rs && rs->has_bandwidth) { this_bw = rs->bandwidth*1000; this_bw = kb_to_bytes(rs->bandwidth); } else if (rs) { /* guess; don't trust the descriptor */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ Loading @@ -1626,27 +1622,15 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, flags |= is_exit ? 2 : 0; flags |= is_guard ? 4 : 0; } else /* bridge or other descriptor not in our consensus */ this_bw = router_get_advertised_bandwidth(router); this_bw = router_get_advertised_bandwidth_capped(router); } if (is_exit) bitarray_set(exit_bits, i); if (is_guard) bitarray_set(guard_bits, i); /* if they claim something huge, don't believe it */ if (this_bw > max_believable_bw) { char fp[HEX_DIGEST_LEN+1]; base16_encode(fp, sizeof(fp), statuses ? status->identity_digest : router->cache_info.identity_digest, DIGEST_LEN); log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Bandwidth %d for router %s (%s) exceeds allowed max %d, capping", this_bw, router ? router->nickname : "(null)", fp, max_believable_bw); this_bw = max_believable_bw; } if (is_known) { bandwidths[i] = (int32_t) this_bw; // safe since MAX_BELIEVABLE<INT32_MAX tor_assert(bandwidths[i] >= 0); if (is_guard) total_guard_bw += this_bw; else Loading Loading
ChangeLog +2 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,8 @@ Changes in version 0.2.1.17-?? - 2009-??-?? o Minor bugfixes: - Serve the DirPortFrontPage page even when we have been approaching our quotas recently. Fixes bug 1013; bugfix on 0.2.1.8-alpha. - Do not cap bandwidths reported by directory authorities; they are already adjusted to reflect reality. o Major features: - Clients now use the bandwidth values in the consensus, rather than Loading
src/or/routerlist.c +9 −25 Original line number Diff line number Diff line Loading @@ -1523,15 +1523,12 @@ router_get_advertised_bandwidth_capped(routerinfo_t *router) return result; } /** Eventually, the number we return will come from the directory * consensus, so clients can dynamically update to better numbers. * * But for now, or in case there is no consensus available, just return * a sufficient default. */ static uint32_t get_max_believable_bandwidth(void) /** Return bw*1000, unless bw*1000 would overflow, in which case return * INT32_MAX. */ static INLINE int32_t kb_to_bytes(uint32_t bw) { return DEFAULT_MAX_BELIEVABLE_BANDWIDTH; return (bw > (INT32_MAX/1000)) ? INT32_MAX : bw*1000; } /** Helper function: Loading Loading @@ -1568,7 +1565,6 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, int n_unknown = 0; bitarray_t *exit_bits; bitarray_t *guard_bits; uint32_t max_believable_bw = get_max_believable_bandwidth(); int me_idx = -1; /* Can't choose exit and guard at same time */ Loading Loading @@ -1598,7 +1594,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = status->is_exit; is_guard = status->is_possible_guard; if (status->has_bandwidth) { this_bw = status->bandwidth*1000; this_bw = kb_to_bytes(status->bandwidth); } else { /* guess */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ Loading @@ -1617,7 +1613,7 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, is_exit = router->is_exit; is_guard = router->is_possible_guard; if (rs && rs->has_bandwidth) { this_bw = rs->bandwidth*1000; this_bw = kb_to_bytes(rs->bandwidth); } else if (rs) { /* guess; don't trust the descriptor */ /* XXX022 once consensuses always list bandwidths, we can take * this guessing business out. -RD */ Loading @@ -1626,27 +1622,15 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, bandwidth_weight_rule_t rule, flags |= is_exit ? 2 : 0; flags |= is_guard ? 4 : 0; } else /* bridge or other descriptor not in our consensus */ this_bw = router_get_advertised_bandwidth(router); this_bw = router_get_advertised_bandwidth_capped(router); } if (is_exit) bitarray_set(exit_bits, i); if (is_guard) bitarray_set(guard_bits, i); /* if they claim something huge, don't believe it */ if (this_bw > max_believable_bw) { char fp[HEX_DIGEST_LEN+1]; base16_encode(fp, sizeof(fp), statuses ? status->identity_digest : router->cache_info.identity_digest, DIGEST_LEN); log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Bandwidth %d for router %s (%s) exceeds allowed max %d, capping", this_bw, router ? router->nickname : "(null)", fp, max_believable_bw); this_bw = max_believable_bw; } if (is_known) { bandwidths[i] = (int32_t) this_bw; // safe since MAX_BELIEVABLE<INT32_MAX tor_assert(bandwidths[i] >= 0); if (is_guard) total_guard_bw += this_bw; else Loading