tor  0.4.0.1-alpha
Macros | Functions | Variables
selftest.c File Reference
#include "core/or/or.h"
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/netstatus.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/crypt_path_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/relay.h"
#include "feature/control/control.h"
#include "feature/dirclient/dirclient.h"
#include "feature/dircommon/directory.h"
#include "feature/nodelist/authority_cert_st.h"
#include "feature/nodelist/routerinfo.h"
#include "feature/nodelist/routerinfo_st.h"
#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerset.h"
#include "feature/nodelist/torcert.h"
#include "feature/relay/router.h"
#include "feature/relay/selftest.h"

Go to the source code of this file.

Macros

#define SELFTEST_PRIVATE
 
#define SELF_EXCLUDED_WARN_INTERVAL   3600
 

Functions

void router_reset_reachability (void)
 
static int router_reachability_checks_disabled (const or_options_t *options)
 
int check_whether_orport_reachable (const or_options_t *options)
 
int check_whether_dirport_reachable (const or_options_t *options)
 
static int router_should_check_reachability (int test_or, int test_dir)
 
static extend_info_textend_info_from_router (const routerinfo_t *r)
 
void router_do_reachability_checks (int test_or, int test_dir)
 
void router_orport_found_reachable (void)
 
void router_dirport_found_reachable (void)
 
void router_perform_bandwidth_test (int num_circs, time_t now)
 

Variables

static int can_reach_or_port = 0
 
static int can_reach_dir_port = 0
 

Detailed Description

Relay self-testing.

Relays need to make sure that their own ports are reasonable, and estimate their own bandwidth, before publishing.

Definition in file selftest.c.

Function Documentation

◆ check_whether_dirport_reachable()

int check_whether_dirport_reachable ( const or_options_t options)

Return 0 if we need to do a DirPort reachability check, because:

  • no reachability check has been done yet, or
  • we've initiated reachability checks, but none have succeeded. Return 1 if we don't need to do a DirPort reachability check, because:
  • we've seen a successful reachability check, or
  • there is no DirPort set, or
  • AssumeReachable is set, or
  • the network is disabled.

Definition at line 91 of file selftest.c.

References can_reach_dir_port, and router_reachability_checks_disabled().

Referenced by rep_hist_circbuilding_dormant().

◆ check_whether_orport_reachable()

int check_whether_orport_reachable ( const or_options_t options)

Return 0 if we need to do an ORPort reachability check, because:

  • no reachability check has been done yet, or
  • we've initiated reachability checks, but none have succeeded. Return 1 if we don't need to do an ORPort reachability check, because:
  • we've seen a successful reachability check, or
  • AssumeReachable is set, or
  • the network is disabled.

Definition at line 74 of file selftest.c.

References can_reach_or_port, and router_reachability_checks_disabled().

Referenced by circuit_testing_failed(), circuit_testing_opened(), reachability_warnings_callback(), rep_hist_circbuilding_dormant(), and router_do_reachability_checks().

◆ extend_info_from_router()

static extend_info_t* extend_info_from_router ( const routerinfo_t r)
static

Allocate and return a new extend_info_t that can be used to build a circuit to or through the router r. Uses the primary address of the router, so should only be called on a server.

Definition at line 133 of file selftest.c.

References tor_assert().

Referenced by router_do_reachability_checks().

◆ router_dirport_found_reachable()

void router_dirport_found_reachable ( void  )

Annotate that we found our DirPort reachable.

Definition at line 246 of file selftest.c.

References routerinfo_t::addr, can_reach_dir_port, and tor_dup_ip().

◆ router_do_reachability_checks()

void router_do_reachability_checks ( int  test_or,
int  test_dir 
)

Some time has passed, or we just got new directory information. See if we currently believe our ORPort or DirPort to be unreachable. If so, launch a new test for it.

For ORPort, we simply try making a circuit that ends at ourselves. Success is noticed in onionskin_answer().

For DirPort, we make a connection via Tor to our DirPort and ask for our own server descriptor. Success is noticed in connection_dir_client_reached_eof().

Definition at line 171 of file selftest.c.

References check_whether_orport_reachable(), circuit_enough_testing_circs(), extend_info_from_router(), and router_should_check_reachability().

Referenced by check_for_reachability_bw_callback(), and directory_info_has_arrived().

◆ router_orport_found_reachable()

void router_orport_found_reachable ( void  )

Annotate that we found our ORPort reachable.

Definition at line 219 of file selftest.c.

References routerinfo_t::addr, can_reach_or_port, and tor_dup_ip().

◆ router_perform_bandwidth_test()

void router_perform_bandwidth_test ( int  num_circs,
time_t  now 
)

We have enough testing circuits open. Send a bunch of "drop" cells down each of them, to exercise our bandwidth.

Definition at line 276 of file selftest.c.

References CELL_MAX_NETWORK_SIZE, and CIRCWINDOW_START.

◆ router_reachability_checks_disabled()

static int router_reachability_checks_disabled ( const or_options_t options)
static

Return 1 if we won't do reachability checks, because:

  • AssumeReachable is set, or
  • the network is disabled. Otherwise, return 0.

Definition at line 59 of file selftest.c.

References or_options_t::AssumeReachable.

Referenced by check_whether_dirport_reachable(), and check_whether_orport_reachable().

◆ router_reset_reachability()

void router_reset_reachability ( void  )

Forget what we have learned about our reachability status.

Definition at line 48 of file selftest.c.

References can_reach_dir_port, and can_reach_or_port.

◆ router_should_check_reachability()

static int router_should_check_reachability ( int  test_or,
int  test_dir 
)
static

See if we currently believe our ORPort or DirPort to be unreachable. If so, return 1 else return 0.

Definition at line 103 of file selftest.c.

References or_options_t::ExcludeNodes, routerset_contains_router(), and or_options_t::StrictNodes.

Referenced by router_do_reachability_checks().

Variable Documentation

◆ can_reach_dir_port

int can_reach_dir_port = 0
static

Whether we can reach our DirPort from the outside.

Definition at line 44 of file selftest.c.

Referenced by check_whether_dirport_reachable(), router_dirport_found_reachable(), and router_reset_reachability().

◆ can_reach_or_port

int can_reach_or_port = 0
static

Whether we can reach our ORPort from the outside.

Definition at line 42 of file selftest.c.

Referenced by check_whether_orport_reachable(), router_orport_found_reachable(), and router_reset_reachability().