Tor  0.4.7.0-alpha-dev
Macros | Functions | Variables
selftest.c File Reference

Relay self-testing. More...

#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/extendinfo.h"
#include "core/or/extend_info_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/relay.h"
#include "feature/control/control_events.h"
#include "feature/dirauth/authmode.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/relay_periodic.h"
#include "feature/relay/router.h"
#include "feature/relay/selftest.h"

Go to the source code of this file.

Macros

#define SELF_EXCLUDED_WARN_INTERVAL   3600
 

Functions

static bool have_orport_for_family (int family)
 
static void inform_testing_reachability (const tor_addr_t *addr, uint16_t port)
 
void router_reset_reachability (void)
 
static int router_reachability_checks_disabled (const or_options_t *options)
 
int router_orport_seems_reachable (const or_options_t *options, int family)
 
int router_dirport_seems_reachable (const or_options_t *options)
 
static int router_should_check_reachability (void)
 
static extend_info_textend_info_from_router (const routerinfo_t *r, int family)
 
static void router_do_orport_reachability_checks (const routerinfo_t *me, int family, int orport_reachable)
 
void router_do_reachability_checks (void)
 
static bool ready_to_publish (const or_options_t *options)
 
void router_orport_found_reachable (int family)
 
void router_perform_bandwidth_test (int num_circs, time_t now)
 

Variables

static bool can_reach_or_port_ipv4 = false
 
static bool can_reach_or_port_ipv6 = false
 
static bool have_informed_testing_or_port_ipv4 = false
 
static bool have_informed_testing_or_port_ipv6 = false
 

Detailed Description

Relay self-testing.

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

Definition in file selftest.c.

Function Documentation

◆ extend_info_from_router()

static extend_info_t* extend_info_from_router ( const routerinfo_t r,
int  family 
)
static

Allocate and return a new extend_info_t that can be used to build a circuit to or through the router r, using an address from family (if available).

Clients don't have routerinfos, so this function should only be called on a server.

If the requested address is not available, returns NULL.

Definition at line 202 of file selftest.c.

Referenced by router_do_orport_reachability_checks().

◆ have_orport_for_family()

static bool have_orport_for_family ( int  family)
static

Return true if we have configured an ORPort for the given family that we would like to advertise.

Like other self-testing functions, this function looks at our most recently built descriptor.

Definition at line 179 of file selftest.c.

◆ inform_testing_reachability()

static void inform_testing_reachability ( const tor_addr_t addr,
uint16_t  port 
)
static

Log a message informing the user that we are testing a port for reachability, if we have not already logged such a message.

Calls to router_reset_reachability() will reset our view of whether we have logged this message for a given port.

Definition at line 314 of file selftest.c.

◆ ready_to_publish()

static bool ready_to_publish ( const or_options_t options)
static

Return true if this module knows of no reason why we shouldn't publish a server descriptor.

Definition at line 355 of file selftest.c.

◆ router_dirport_seems_reachable()

int router_dirport_seems_reachable ( const or_options_t options)

Relay DirPorts are no longer used (though authorities are). In either case, reachability self test is done anymore, since network re-entry towards an authority DirPort is not allowed. Thus, consider it always reachable.

Definition at line 137 of file selftest.c.

◆ router_do_orport_reachability_checks()

static void router_do_orport_reachability_checks ( const routerinfo_t me,
int  family,
int  orport_reachable 
)
static

Launch a self-testing circuit to one of our ORPorts, using an address from family (if available). The circuit can be used to test reachability or bandwidth. me is our own routerinfo.

Logs an info-level status message. If orport_reachable is false, call it a reachability circuit. Otherwise, call it a bandwidth circuit.

See router_do_reachability_checks() for details.

Definition at line 245 of file selftest.c.

Referenced by router_do_reachability_checks().

◆ router_do_reachability_checks()

void router_do_reachability_checks ( void  )

Some time has passed, or we just got new directory information. See if we currently believe our ORPort 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().

Definition at line 284 of file selftest.c.

Referenced by check_for_reachability_bw_callback(), and directory_info_has_arrived().

◆ router_orport_found_reachable()

void router_orport_found_reachable ( int  family)

Annotate that we found our ORPort reachable with a given address family.

Definition at line 364 of file selftest.c.

◆ router_orport_seems_reachable()

int router_orport_seems_reachable ( const or_options_t options,
int  family 
)

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.

If ‘family’`is AF_INET or AF_INET6, return true only when we should skip the given family's orport check (Because it's been checked, or because we aren't checking it.) If family is 0, return true if we can skip all orport checks.

Definition at line 101 of file selftest.c.

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

◆ 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.

May use IPv4 and IPv6 testing circuits (if available).

Definition at line 417 of file selftest.c.

◆ 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 81 of file selftest.c.

◆ router_reset_reachability()

void router_reset_reachability ( void  )

Forget what we have learned about our reachability status.

Definition at line 68 of file selftest.c.

◆ router_should_check_reachability()

static int router_should_check_reachability ( void  )
static

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

Definition at line 146 of file selftest.c.

Referenced by router_do_reachability_checks().

Variable Documentation

◆ can_reach_or_port_ipv4

bool can_reach_or_port_ipv4 = false
static

Whether we can reach our IPv4 ORPort from the outside.

Definition at line 55 of file selftest.c.

Referenced by router_orport_found_reachable(), and router_reset_reachability().

◆ can_reach_or_port_ipv6

bool can_reach_or_port_ipv6 = false
static

Whether we can reach our IPv6 ORPort from the outside.

Definition at line 57 of file selftest.c.

Referenced by router_orport_found_reachable(), and router_reset_reachability().

◆ have_informed_testing_or_port_ipv4

bool have_informed_testing_or_port_ipv4 = false
static

Has informed_testing_reachable logged a message about testing our IPv4 ORPort?

Definition at line 61 of file selftest.c.

Referenced by inform_testing_reachability(), and router_reset_reachability().

◆ have_informed_testing_or_port_ipv6

bool have_informed_testing_or_port_ipv6 = false
static

Has informed_testing_reachable logged a message about testing our IPv6 ORPort?

Definition at line 64 of file selftest.c.

Referenced by inform_testing_reachability(), and router_reset_reachability().