Tor
0.4.7.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 | UPTIME_TO_GUARANTEE_STABLE (3600*24*30) |
#define | MTBF_TO_GUARANTEE_STABLE (60*60*24*5) |
#define | TIME_KNOWN_TO_GUARANTEE_FAMILIAR (8*24*60*60) |
#define | WFU_TO_GUARANTEE_GUARD (0.98) |
#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) |
Functions | |
static long | real_uptime (const routerinfo_t *router, time_t now) |
static int | dirserv_thinks_router_is_unreliable (time_t now, const routerinfo_t *router, int need_uptime, int need_capacity) |
static int | router_is_active (const routerinfo_t *ri, const node_t *node, time_t now) |
static int | dirserv_thinks_router_is_hs_dir (const routerinfo_t *router, const node_t *node, time_t now) |
static int | router_counts_toward_thresholds (const node_t *node, time_t now, const digestmap_t *omit_as_sybil, int require_mbw) |
void | dirserv_compute_performance_thresholds (digestmap_t *omit_as_sybil) |
void | dirserv_compute_bridge_flag_thresholds (void) |
char * | dirserv_get_flag_thresholds_line (void) |
int | running_long_enough_to_decide_unreachable (void) |
void | dirserv_set_router_is_running (routerinfo_t *router, time_t now) |
static int | should_publish_node_ipv6 (const node_t *node, const routerinfo_t *ri, time_t now) |
void | dirauth_set_routerstatus_from_routerinfo (routerstatus_t *rs, node_t *node, const routerinfo_t *ri, time_t now, int listbadexits) |
STATIC void | dirserv_set_routerstatus_testing (routerstatus_t *rs) |
void | dirserv_set_bridges_running (time_t now) |
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 202 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 477 of file voteflags.c.
#define MTBF_TO_GUARANTEE_STABLE (60*60*24*5) |
If a router's MTBF is at least this value, then it is always stable. See above. (Corresponds to about 7 days for current decay rates.)
Definition at line 47 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 472 of file voteflags.c.
#define TIME_KNOWN_TO_GUARANTEE_FAMILIAR (8*24*60*60) |
Similarly, every node with at least this much weighted time known can be considered familiar enough to be a guard. Corresponds to about 20 days for current decay rates.
Definition at line 52 of file voteflags.c.
#define UPTIME_TO_GUARANTEE_STABLE (3600*24*30) |
If a router's uptime is at least this value, then it is always considered stable, regardless of the rest of the network. This way we resist attacks where an attacker doubles the size of the network using allegedly high-uptime nodes, displacing all the current guards.
Definition at line 44 of file voteflags.c.
#define WFU_TO_GUARANTEE_GUARD (0.98) |
Similarly, every node with sufficient WFU is around enough to be a guard.
Definition at line 55 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 | ||
) |
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 564 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 239 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 433 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 656 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 483 of file voteflags.c.
Referenced by dirserv_set_bridges_running().
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 621 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 173 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 100 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 86 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 210 of file voteflags.c.
|
static |
Return 1 if ri's descriptor is "active" – running, valid, not hibernating, having observed bw greater 0, and not too old. Else return 0.
Definition at line 137 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 67 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 75 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().
|
static |
If exits can't be guards, then all guards must have a bandwidth this high.
Definition at line 81 of file voteflags.c.
|
static |
If exits can be guards, then all guards must have a bandwidth this high.
Definition at line 78 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 73 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 70 of file voteflags.c.
|
static |
Any router with an mtbf of at least this value is stable.
Definition at line 64 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().
|
static |
Any router with an uptime of at least this value is stable.
Definition at line 62 of file voteflags.c.
Referenced by dirserv_thinks_router_is_unreliable().