Tor 0.4.9.0-alpha-dev
|
Authority code for deciding the performance thresholds for flags, and assigning flags to routers. More...
#include "core/or/or.h"
#include "feature/dirauth/voteflags.h"
#include "app/config/config.h"
#include "core/mainloop/mainloop.h"
#include "core/or/policies.h"
#include "feature/dirauth/bwauth.h"
#include "feature/dirauth/reachability.h"
#include "feature/dirauth/dirauth_sys.h"
#include "feature/hibernate/hibernate.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerset.h"
#include "feature/relay/router.h"
#include "feature/stats/rephist.h"
#include "feature/dirauth/dirauth_options_st.h"
#include "feature/nodelist/node_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/routerlist_st.h"
#include "feature/nodelist/vote_routerstatus_st.h"
#include "lib/container/order.h"
Go to the source code of this file.
Macros | |
#define | VOTEFLAGS_PRIVATE |
#define | ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4 |
#define | ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG 4 |
#define | REACHABLE_TIMEOUT (45*60) |
#define | HIBERNATION_PUBLICATION_SKEW (60*60) |
Variables | |
static uint32_t | stable_uptime = 0 |
static double | stable_mtbf = 0.0 |
static int | enough_mtbf_info = 0 |
static double | guard_wfu = 0.0 |
static long | guard_tk = 0 |
static uint32_t | fast_bandwidth_kb = 0 |
static uint32_t | guard_bandwidth_including_exits_kb = 0 |
static uint32_t | guard_bandwidth_excluding_exits_kb = 0 |
Authority code for deciding the performance thresholds for flags, and assigning flags to routers.
Definition in file voteflags.c.
#define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4 |
Don't consider routers with less bandwidth than this when computing thresholds.
Definition at line 169 of file voteflags.c.
#define HIBERNATION_PUBLICATION_SKEW (60*60) |
If we tested a router and found it reachable at least this long after it declared itself hibernating, it is probably done hibernating and we just missed a descriptor from it.
Definition at line 466 of file voteflags.c.
#define REACHABLE_TIMEOUT (45*60) |
Each server needs to have passed a reachability test no more than this number of seconds ago, or it is listed as down in the directory.
Definition at line 461 of file voteflags.c.
#define VOTEFLAGS_PRIVATE |
Definition at line 12 of file voteflags.c.
void dirauth_set_routerstatus_from_routerinfo | ( | routerstatus_t * | rs, |
node_t * | node, | ||
const routerinfo_t * | ri, | ||
time_t | now, | ||
int | listbadexits, | ||
int | listmiddleonly | ||
) |
Extract status information from ri and from other authority functions and store it in rs, as per set_routerstatus_from_routerinfo. Additionally, sets information in from the authority subsystem.
Definition at line 568 of file voteflags.c.
void dirserv_compute_bridge_flag_thresholds | ( | void | ) |
Definition at line 393 of file voteflags.c.
void dirserv_compute_performance_thresholds | ( | digestmap_t * | omit_as_sybil | ) |
Look through the routerlist, the Mean Time Between Failure history, and the Weighted Fractional Uptime history, and use them to set thresholds for the Stable, Fast, and Guard flags. Update the fields stable_uptime, stable_mtbf, enough_mtbf_info, guard_wfu, guard_tk, fast_bandwidth, guard_bandwidth_including_exits, and guard_bandwidth_excluding_exits.
Also, set the is_exit flag of each router appropriately.
Definition at line 206 of file voteflags.c.
char * dirserv_get_flag_thresholds_line | ( | void | ) |
Give a statement of our current performance thresholds for inclusion in a vote document.
Definition at line 403 of file voteflags.c.
void dirserv_set_bridges_running | ( | time_t | now | ) |
Use dirserv_set_router_is_running() to set bridges as running if they're reachable.
This function is called from set_bridge_running_callback() when running as a bridge authority.
Definition at line 671 of file voteflags.c.
void dirserv_set_router_is_running | ( | routerinfo_t * | router, |
time_t | now | ||
) |
Treat a router as alive if
Definition at line 472 of file voteflags.c.
Referenced by dirserv_set_bridges_running().
|
static |
Set routerstatus flags based on the authority options. Same as the testing function but for the main network.
Definition at line 549 of file voteflags.c.
STATIC void dirserv_set_routerstatus_testing | ( | routerstatus_t * | rs | ) |
Use TestingDirAuthVoteExit, TestingDirAuthVoteGuard, and TestingDirAuthVoteHSDir to give out the Exit, Guard, and HSDir flags, respectively. But don't set the corresponding node flags. Should only be called if TestingTorNetwork is set.
Definition at line 636 of file voteflags.c.
|
static |
Return true iff router should be assigned the "HSDir" flag.
Right now this means it advertises support for it, it has a high uptime, it's a directory cache, it has the Stable and Fast flags, and it's currently considered Running.
This function needs to be called after router->is_running has been set.
Definition at line 140 of file voteflags.c.
Referenced by dirauth_set_routerstatus_from_routerinfo().
|
static |
Return 1 if router is not suitable for these parameters, else 0. If need_uptime is non-zero, we require a minimum uptime. If need_capacity is non-zero, we require a minimum advertised bandwidth.
Definition at line 82 of file voteflags.c.
Referenced by dirauth_set_routerstatus_from_routerinfo().
|
inlinestatic |
Helper: estimate the uptime of a router given its stated uptime and the amount of time since it last stated its stated uptime.
Definition at line 68 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().
|
static |
Helper for dirserv_compute_performance_thresholds(): Decide whether to include a router in our calculations, and return true iff we should; the require_mbw parameter is passed in by dirserv_compute_performance_thresholds() and controls whether we ever count routers with only advertised bandwidths
Definition at line 177 of file voteflags.c.
|
static |
Return 1 if ri's descriptor is "active" – running, valid, not hibernating, and not too old. Else return 0.
Definition at line 118 of file voteflags.c.
int running_long_enough_to_decide_unreachable | ( | void | ) |
Directory authorities should avoid expressing an opinion on the Running flag if their own uptime is too low for the opinion to be accurate. They implement this step by not listing Running on the "known-flags" line in their vote.
The default threshold is 30 minutes, because authorities do a full reachability sweep of the ID space every 10*128=1280 seconds (see REACHABILITY_TEST_CYCLE_PERIOD).
For v3 dir auths, as long as some authorities express an opinion about Running, it's fine if a few authorities don't. There's an explicit check, when making the consensus, to abort if no authorities list Running as a known-flag.
For the bridge authority, if it doesn't vote about Running, the resulting networkstatus file simply won't list any bridges as Running. That means the supporting tools, like bridgedb/rdsys and onionoo, need to be able to handle getting a bridge networkstatus document with no Running flags. For more details, see https://bugs.torproject.org/tpo/anti-censorship/rdsys/102
Definition at line 451 of file voteflags.c.
|
static |
Definition at line 535 of file voteflags.c.
|
static |
If true, we have measured enough mtbf info to look at stable_mtbf rather than stable_uptime.
Definition at line 49 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().
|
static |
Any router with a bandwidth at least this high is "Fast"
Definition at line 57 of file voteflags.c.
|
static |
If exits can't be guards, then all guards must have a bandwidth this high.
Definition at line 63 of file voteflags.c.
|
static |
If exits can be guards, then all guards must have a bandwidth this high.
Definition at line 60 of file voteflags.c.
|
static |
Don't call a router a guard unless we've known about it for at least this many seconds.
Definition at line 55 of file voteflags.c.
|
static |
Any router with a weighted fractional uptime of at least this much might be good as a guard.
Definition at line 52 of file voteflags.c.
|
static |
Any router with an mtbf of at least this value is stable.
Definition at line 46 of file voteflags.c.
|
static |
Any router with an uptime of at least this value is stable.
Definition at line 44 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().