Tor  0.4.3.0-alpha-dev
Macros | Functions | Variables
circuituse.c File Reference

Launch the right sort of circuits and attach the right streams to them. More...

#include "core/or/or.h"
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/or/channel.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuitstats.h"
#include "core/or/circuituse.h"
#include "core/or/circuitpadding.h"
#include "core/or/connection_edge.h"
#include "core/or/policies.h"
#include "feature/client/addressmap.h"
#include "feature/client/bridges.h"
#include "feature/client/circpathbias.h"
#include "feature/client/entrynodes.h"
#include "feature/client/proxymode.h"
#include "feature/control/control_events.h"
#include "feature/dircommon/directory.h"
#include "feature/hs/hs_circuit.h"
#include "feature/hs/hs_client.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_ident.h"
#include "feature/hs/hs_stats.h"
#include "feature/nodelist/describe.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/routermode.h"
#include "feature/relay/selftest.h"
#include "feature/rend/rendclient.h"
#include "feature/rend/rendcommon.h"
#include "feature/rend/rendservice.h"
#include "feature/stats/predict_ports.h"
#include "lib/math/fp.h"
#include "lib/time/tvdiff.h"
#include "core/or/cpath_build_state_st.h"
#include "feature/dircommon/dir_connection_st.h"
#include "core/or/entry_connection_st.h"
#include "core/or/extend_info_st.h"
#include "core/or/or_circuit_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/socks_request_st.h"

Go to the source code of this file.

Macros

#define SET_CUTOFF(target, msec)
 
#define MAX_ANCIENT_ONEHOP_CIRCUITS_TO_LOG   10
 
#define MAX_UNUSED_OPEN_CIRCUITS   14
 
#define SUFFICIENT_UPTIME_INTERNAL_HS_SERVERS   3
 
#define SUFFICIENT_INTERNAL_HS_CLIENTS   3
 
#define SUFFICIENT_UPTIME_INTERNAL_HS_CLIENTS   2
 
#define DFLT_CBT_UNUSED_OPEN_CIRCS   (10)
 
#define MIN_CBT_UNUSED_OPEN_CIRCS   0
 
#define MAX_CBT_UNUSED_OPEN_CIRCS   MAX_UNUSED_OPEN_CIRCUITS
 
#define TESTING_CIRCUIT_INTERVAL   300
 
#define IDLE_ONE_HOP_CIRC_TIMEOUT   60
 
#define NUM_PARALLEL_TESTING_CIRCS   4
 
#define MAX_CIRCUIT_FAILURES   5
 

Functions

STATIC void circuit_expire_old_circuits_clientside (void)
 
static void circuit_increment_failure_count (void)
 
static int circuit_matches_with_rend_stream (const edge_connection_t *edge_conn, const origin_circuit_t *origin_circ)
 
static int circuit_is_acceptable (const origin_circuit_t *origin_circ, const entry_connection_t *conn, int must_be_open, uint8_t purpose, int need_uptime, int need_internal, time_t now)
 
static int circuit_is_better (const origin_circuit_t *oa, const origin_circuit_t *ob, const entry_connection_t *conn)
 
static origin_circuit_tcircuit_get_best (const entry_connection_t *conn, int must_be_open, uint8_t purpose, int need_uptime, int need_internal)
 
static int count_pending_general_client_circuits (void)
 
void circuit_expire_building (void)
 
void circuit_expire_waiting_for_better_guard (void)
 
void circuit_log_ancient_one_hop_circuits (int age)
 
void circuit_remove_handled_ports (smartlist_t *needed_ports)
 
int circuit_stream_is_being_handled (entry_connection_t *conn, uint16_t port, int min)
 
STATIC int circuit_is_available_for_use (const circuit_t *circ)
 
STATIC int needs_exit_circuits (time_t now, int *needs_uptime, int *needs_capacity)
 
STATIC int needs_hs_server_circuits (time_t now, int num_uptime_internal)
 
STATIC int needs_hs_client_circuits (time_t now, int *needs_uptime, int *needs_capacity, int num_internal, int num_uptime_internal)
 
STATIC int needs_circuits_for_build (int num)
 
static void circuit_launch_predicted_hs_circ (int flags)
 
static void circuit_predict_and_launch_new (void)
 
void circuit_build_needed_circs (time_t now)
 
void circuit_expire_old_circs_as_needed (time_t now)
 
void circuit_detach_stream (circuit_t *circ, edge_connection_t *conn)
 
void circuit_expire_old_circuits_serverside (time_t now)
 
void reset_bandwidth_test (void)
 
int circuit_enough_testing_circs (void)
 
static void circuit_testing_opened (origin_circuit_t *circ)
 
static void circuit_testing_failed (origin_circuit_t *circ, int at_last_hop)
 
void circuit_has_opened (origin_circuit_t *circ)
 
static int circuit_try_clearing_isolation_state (origin_circuit_t *circ)
 
void circuit_try_attaching_streams (origin_circuit_t *circ)
 
void circuit_build_failed (origin_circuit_t *circ)
 
origin_circuit_tcircuit_launch (uint8_t purpose, int flags)
 
static int have_enough_path_info (int need_exit)
 
int circuit_purpose_is_hidden_service (uint8_t purpose)
 
bool circuit_purpose_is_hs_client (const uint8_t purpose)
 
bool circuit_purpose_is_hs_service (const uint8_t purpose)
 
bool circuit_purpose_is_hs_vanguards (const uint8_t purpose)
 
bool circuit_is_hs_v2 (const circuit_t *circ)
 
bool circuit_is_hs_v3 (const circuit_t *circ)
 
int circuit_should_use_vanguards (uint8_t purpose)
 
static int circuit_should_cannibalize_to_build (uint8_t purpose_to_build, int has_extend_info, int onehop_tunnel)
 
origin_circuit_tcircuit_launch_by_extend_info (uint8_t purpose, extend_info_t *extend_info, int flags)
 
void circuit_reset_failure_count (int timeout)
 
static int circuit_get_open_circ_or_launch (entry_connection_t *conn, uint8_t desired_circuit_purpose, origin_circuit_t **circp)
 
static int cpath_is_on_circuit (origin_circuit_t *circ, crypt_path_t *crypt_path)
 
static int optimistic_data_enabled (void)
 
static void link_apconn_to_circ (entry_connection_t *apconn, origin_circuit_t *circ, crypt_path_t *cpath)
 
int hostname_in_track_host_exits (const or_options_t *options, const char *address)
 
static void consider_recording_trackhost (const entry_connection_t *conn, const origin_circuit_t *circ)
 
int connection_ap_handshake_attach_chosen_circuit (entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
 
static int connection_ap_get_nonrend_circ_purpose (const entry_connection_t *conn)
 
int connection_ap_handshake_attach_circuit (entry_connection_t *conn)
 
void circuit_change_purpose (circuit_t *circ, uint8_t new_purpose)
 
void mark_circuit_unusable_for_new_conns (origin_circuit_t *circ)
 
void circuit_sent_valid_data (origin_circuit_t *circ, uint16_t relay_body_len)
 
void circuit_read_valid_data (origin_circuit_t *circ, uint16_t relay_body_len)
 

Variables

static time_t last_expired_clientside_circuits = 0
 
static int have_performed_bandwidth_test = 0
 
static int n_circuit_failures = 0
 
static int did_circs_fail_last_period = 0
 

Detailed Description

Launch the right sort of circuits and attach the right streams to them.

As distinct from circuitlist.c, which manages lookups to find circuits, and circuitbuild.c, which handles the logistics of circuit construction, this module keeps track of which streams can be attached to which circuits (in circuit_get_best()), and attaches streams to circuits (with circuit_try_attaching_streams(), connection_ap_handshake_attach_circuit(), and connection_ap_handshake_attach_chosen_circuit() ).

This module also makes sure that we are building circuits for all of the predicted ports, using circuit_remove_handled_ports(), circuit_stream_is_being_handled(), and circuit_build_needed_cirs(). It handles launching circuits for specific targets using circuit_launch_by_extend_info().

This is also where we handle expiring circuits that have been around for too long without actually completing, along with the circuit_build_timeout logic in circuitstats.c.

Definition in file circuituse.c.

Macro Definition Documentation

◆ IDLE_ONE_HOP_CIRC_TIMEOUT

#define IDLE_ONE_HOP_CIRC_TIMEOUT   60

How long do we wait before killing circuits with the properties described below?

Probably we could choose a number here as low as 5 to 10 seconds, since these circs are used for begindir, and a) generally you either ask another begindir question right after or you don't for a long time, b) clients at least through 0.2.1.x choose from the whole set of directory mirrors at each choice, and c) re-establishing a one-hop circuit via create-fast is a light operation assuming the TLS conn is still there.

I expect "b" to go away one day when we move to using directory guards, but I think "a" and "c" are good enough reasons that a low number is safe even then.

Definition at line 1561 of file circuituse.c.

◆ MAX_CIRCUIT_FAILURES

#define MAX_CIRCUIT_FAILURES   5

Don't retry launching a new circuit if we try this many times with no success.

Definition at line 1933 of file circuituse.c.

◆ MAX_UNUSED_OPEN_CIRCUITS

#define MAX_UNUSED_OPEN_CIRCUITS   14

Don't keep more than this many unused open circuits around.

Definition at line 1084 of file circuituse.c.

◆ NUM_PARALLEL_TESTING_CIRCS

#define NUM_PARALLEL_TESTING_CIRCS   4

Number of testing circuits we want open before testing our bandwidth.

Definition at line 1598 of file circuituse.c.

◆ SET_CUTOFF

#define SET_CUTOFF (   target,
  msec 
)
Value:
do { \
long ms = tor_lround(msec); \
struct timeval diff; \
diff.tv_sec = ms / 1000; \
diff.tv_usec = (int)((ms % 1000) * 1000); \
timersub(&now, &diff, &target); \
} while (0)
long tor_lround(double d)
Definition: fp.c:31

◆ TESTING_CIRCUIT_INTERVAL

#define TESTING_CIRCUIT_INTERVAL   300

Build a new test circuit every 5 minutes

Definition at line 1326 of file circuituse.c.

Function Documentation

◆ circuit_build_failed()

void circuit_build_failed ( origin_circuit_t circ)

Called whenever a circuit could not be successfully built.

Definition at line 1772 of file circuituse.c.

Referenced by circuit_about_to_free().

◆ circuit_build_needed_circs()

void circuit_build_needed_circs ( time_t  now)

This function is called once a second, if router_have_minimum_dir_info() is true. Its job is to make sure all services we offer have enough circuits available. Some services just want enough circuits for current tasks, whereas others want a minimum set of idle circuits hanging around.

Definition at line 1334 of file circuituse.c.

Referenced by second_elapsed_callback().

◆ circuit_change_purpose()

void circuit_change_purpose ( circuit_t circ,
uint8_t  new_purpose 
)

Change circ's purpose to new_purpose.

Definition at line 3095 of file circuituse.c.

Referenced by finalize_rend_circuit().

◆ circuit_detach_stream()

void circuit_detach_stream ( circuit_t circ,
edge_connection_t conn 
)

If the stream conn is a member of any of the linked lists of circ, then remove it from the list.

Definition at line 1388 of file circuituse.c.

Referenced by connection_exit_about_to_close().

◆ circuit_enough_testing_circs()

int circuit_enough_testing_circs ( void  )

Return 1 if we've already exercised our bandwidth, or if we have fewer than NUM_PARALLEL_TESTING_CIRCS testing circuits established or on the way. Else return 0.

Definition at line 1617 of file circuituse.c.

Referenced by rep_hist_circbuilding_dormant(), and router_do_reachability_checks().

◆ circuit_expire_building()

void circuit_expire_building ( void  )

Close all circuits that start at us, aren't open, and were born at least CircuitBuildTimeout seconds ago.

TODO: This function is now partially redundant to circuit_build_times_handle_completed_hop(), but that function only covers circuits up to and including 3 hops that are still actually completing hops. However, circuit_expire_building() also handles longer circuits, as well as circuits that are completely stalled. In the future (after prop247/other path selection revamping), we probably want to eliminate this rats nest in favor of a simpler approach.

Because circuit build timeout is calculated only based on 3 hop general purpose circuit construction, we need to scale the timeout to make it properly apply to longer circuits, and circuits of certain usage types. The following diagram illustrates how we derive the scaling below. In short, we calculate the number of times our telescoping-based circuit construction causes cells to traverse each link for the circuit purpose types in question, and then assume each link is equivalent.

OP –a--> A –b--> B –c--> C OP –a--> A –b--> B –c--> C –d--> D

Let h = a = b = c = d

Three hops (general_cutoff) RTTs = 3a + 2b + c RTTs = 6h Cannibalized: RTTs = a+b+c+d RTTs = 4h Four hops: RTTs = 4a + 3b + 2c + d RTTs = 10h Client INTRODUCE1+ACK: // XXX: correct? RTTs = 5a + 4b + 3c + 2d RTTs = 14h Server intro: RTTs = 4a + 3b + 2c RTTs = 9h

Definition at line 457 of file circuituse.c.

Referenced by second_elapsed_callback().

◆ circuit_expire_old_circs_as_needed()

void circuit_expire_old_circs_as_needed ( time_t  now)

Called once a second either directly or from circuit_build_needed_circs(). As appropriate (once per NewCircuitPeriod) resets failure counts and expires old circuits.

Definition at line 1357 of file circuituse.c.

Referenced by second_elapsed_callback().

◆ circuit_expire_old_circuits_clientside()

STATIC void circuit_expire_old_circuits_clientside ( void  )

Find each circuit that has been unused for too long, or dirty for too long and has no streams on it: mark it for close.

Definition at line 1474 of file circuituse.c.

Referenced by circuit_expire_old_circs_as_needed().

◆ circuit_expire_old_circuits_serverside()

void circuit_expire_old_circuits_serverside ( time_t  now)

Find each non-origin circuit that has been unused for too long, has no streams on it, came from a client, and ends here: mark it for close.

Definition at line 1568 of file circuituse.c.

Referenced by expire_old_circuits_serverside_callback().

◆ circuit_expire_waiting_for_better_guard()

void circuit_expire_waiting_for_better_guard ( void  )

Mark for close all circuits that start here, that were built through a guard we weren't sure if we wanted to use, and that have been waiting around for way too long.

Definition at line 854 of file circuituse.c.

Referenced by second_elapsed_callback().

◆ circuit_get_best()

static origin_circuit_t* circuit_get_best ( const entry_connection_t conn,
int  must_be_open,
uint8_t  purpose,
int  need_uptime,
int  need_internal 
)
static

Find the best circ that conn can use, preferably one which is dirty. Circ must not be too old.

Conn must be defined.

If must_be_open, ignore circs not in CIRCUIT_STATE_OPEN.

circ_purpose specifies what sort of circuit we must have. It can be C_GENERAL, C_INTRODUCE_ACK_WAIT, or C_REND_JOINED.

If it's REND_JOINED and must_be_open==0, then return the closest rendezvous-purposed circuit that you can find.

If it's INTRODUCE_ACK_WAIT and must_be_open==0, then return the closest introduce-purposed circuit that you can find.

Definition at line 341 of file circuituse.c.

◆ circuit_get_open_circ_or_launch()

static int circuit_get_open_circ_or_launch ( entry_connection_t conn,
uint8_t  desired_circuit_purpose,
origin_circuit_t **  circp 
)
static

Find an open circ that we're happy to use for conn and return 1. If there isn't one, and there isn't one on the way, launch one and return 0. If it will never work, return -1.

Write the found or in-progress or launched circ into *circp.

Definition at line 2244 of file circuituse.c.

◆ circuit_has_opened()

void circuit_has_opened ( origin_circuit_t circ)

The circuit circ has just become open. Take the next step: for rendezvous circuits, we pass circ to the appropriate function in rendclient or rendservice. For general circuits, we call connection_ap_attach_pending, which looks for pending streams that could use circ.

Definition at line 1681 of file circuituse.c.

◆ circuit_increment_failure_count()

static void circuit_increment_failure_count ( void  )
static

Record another failure at opening a general circuit. When we have too many, we'll stop trying for the remainder of this minute.

Definition at line 2217 of file circuituse.c.

◆ circuit_is_acceptable()

static int circuit_is_acceptable ( const origin_circuit_t origin_circ,
const entry_connection_t conn,
int  must_be_open,
uint8_t  purpose,
int  need_uptime,
int  need_internal,
time_t  now 
)
static

Return 1 if circ could be returned by circuit_get_best(). Else return 0.

Definition at line 111 of file circuituse.c.

Referenced by circuit_get_best().

◆ circuit_is_better()

static int circuit_is_better ( const origin_circuit_t oa,
const origin_circuit_t ob,
const entry_connection_t conn 
)
static

Return 1 if circuit a is better than circuit b for conn, and return 0 otherwise. Used by circuit_get_best.

Definition at line 249 of file circuituse.c.

Referenced by circuit_get_best().

◆ circuit_is_hs_v2()

bool circuit_is_hs_v2 ( const circuit_t circ)

Retrun true iff the given circuit is an HS v2 circuit.

Definition at line 2006 of file circuituse.c.

Referenced by cleanup_on_free_client_circ().

◆ circuit_is_hs_v3()

bool circuit_is_hs_v3 ( const circuit_t circ)

Retrun true iff the given circuit is an HS v3 circuit.

Definition at line 2014 of file circuituse.c.

Referenced by cleanup_on_free_client_circ().

◆ circuit_launch()

origin_circuit_t* circuit_launch ( uint8_t  purpose,
int  flags 
)

Launch a new circuit; see circuit_launch_by_extend_info() for details on arguments.

Definition at line 1938 of file circuituse.c.

Referenced by circuit_expire_old_circs_as_needed(), and circuit_launch_predicted_hs_circ().

◆ circuit_launch_by_extend_info()

origin_circuit_t* circuit_launch_by_extend_info ( uint8_t  purpose,
extend_info_t extend_info,
int  flags 
)

Launch a new circuit with purpose purpose and exit node extend_info (or NULL to select a random exit node). If flags contains CIRCLAUNCH_NEED_UPTIME, choose among routers with high uptime. If CIRCLAUNCH_NEED_CAPACITY is set, choose among routers with high bandwidth. If CIRCLAUNCH_IS_INTERNAL is true, the last hop need not be an exit node. If CIRCLAUNCH_ONEHOP_TUNNEL is set, the circuit will have only one hop. Return the newly allocated circuit on success, or NULL on failure.

Definition at line 2101 of file circuituse.c.

Referenced by circuit_launch().

◆ circuit_launch_predicted_hs_circ()

static void circuit_launch_predicted_hs_circ ( int  flags)
static

Launch the appropriate type of predicted circuit for hidden services, depending on our options.

Definition at line 1221 of file circuituse.c.

◆ circuit_log_ancient_one_hop_circuits()

void circuit_log_ancient_one_hop_circuits ( int  age)

As a diagnostic for bug 8387, log information about how many one-hop circuits we have around that have been there for at least age seconds. Log a few of them. Ignores Single Onion Service intro, it is expected to be long-term one-hop circuits.

Definition at line 878 of file circuituse.c.

◆ circuit_matches_with_rend_stream()

static int circuit_matches_with_rend_stream ( const edge_connection_t edge_conn,
const origin_circuit_t origin_circ 
)
static

Check whether the hidden service destination of the stream at edge_conn is the same as the destination of the circuit at origin_circ.

Definition at line 81 of file circuituse.c.

◆ circuit_predict_and_launch_new()

static void circuit_predict_and_launch_new ( void  )
static

Determine how many circuits we have open that are clean, Make sure it's enough for all the upcoming behaviors we predict we'll have. But put an upper bound on the total number of circuits.

Definition at line 1240 of file circuituse.c.

◆ circuit_purpose_is_hidden_service()

int circuit_purpose_is_hidden_service ( uint8_t  purpose)

Tell us if a circuit is a hidden service circuit.

Definition at line 1961 of file circuituse.c.

Referenced by circuit_should_use_vanguards(), and middle_node_must_be_vanguard().

◆ circuit_purpose_is_hs_client()

bool circuit_purpose_is_hs_client ( const uint8_t  purpose)

Retrun true iff the given circuit is an HS client circuit.

Definition at line 1983 of file circuituse.c.

Referenced by circuit_purpose_is_hidden_service(), and hs_circ_cleanup_on_free().

◆ circuit_purpose_is_hs_service()

bool circuit_purpose_is_hs_service ( const uint8_t  purpose)

Retrun true iff the given circuit is an HS service circuit.

Definition at line 1991 of file circuituse.c.

Referenced by circuit_purpose_is_hidden_service().

◆ circuit_purpose_is_hs_vanguards()

bool circuit_purpose_is_hs_vanguards ( const uint8_t  purpose)

Retrun true iff the given circuit is an HS Vanguards circuit.

Definition at line 1999 of file circuituse.c.

Referenced by circuit_purpose_is_hidden_service().

◆ circuit_read_valid_data()

void circuit_read_valid_data ( origin_circuit_t circ,
uint16_t  relay_body_len 
)

Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to the valid delivered read field and the overhead field, respectively.

Definition at line 3184 of file circuituse.c.

◆ circuit_remove_handled_ports()

void circuit_remove_handled_ports ( smartlist_t needed_ports)

Remove any elements in needed_ports that are handled by an open or in-progress circuit.

Definition at line 1010 of file circuituse.c.

Referenced by circuit_get_unhandled_ports().

◆ circuit_reset_failure_count()

void circuit_reset_failure_count ( int  timeout)

Reset the failure count for opening general circuits. This means we will try MAX_CIRCUIT_FAILURES times more (if necessary) before stopping again.

Definition at line 2228 of file circuituse.c.

Referenced by circuit_expire_old_circs_as_needed().

◆ circuit_sent_valid_data()

void circuit_sent_valid_data ( origin_circuit_t circ,
uint16_t  relay_body_len 
)

Add relay_body_len and RELAY_PAYLOAD_SIZE-relay_body_len to the valid delivered written fields and the overhead field, respectively.

Definition at line 3163 of file circuituse.c.

◆ circuit_should_cannibalize_to_build()

static int circuit_should_cannibalize_to_build ( uint8_t  purpose_to_build,
int  has_extend_info,
int  onehop_tunnel 
)
static

Return true for the set of conditions for which it is OK to use a cannibalized circuit.

Don't cannibalize for onehops, or certain purposes.

Definition at line 2053 of file circuituse.c.

◆ circuit_should_use_vanguards()

int circuit_should_use_vanguards ( uint8_t  purpose)

Return true if this circuit purpose should use vanguards or pinned Layer2 or Layer3 guards.

This function takes both the circuit purpose and the torrc options for pinned middles/vanguards into account (ie: the circuit must be a hidden service circuit and vanguards/pinned middles must be enabled for it to return true).

Definition at line 2031 of file circuituse.c.

Referenced by build_middle_exclude_list(), circuit_launch_predicted_hs_circ(), circuit_should_cannibalize_to_build(), get_circuit_purpose_needed_to_cannibalize(), guards_choose_guard(), and route_len_for_purpose().

◆ circuit_stream_is_being_handled()

int circuit_stream_is_being_handled ( entry_connection_t conn,
uint16_t  port,
int  min 
)

Return 1 if at least min general-purpose non-internal circuits will have an acceptable exit node for exit stream conn if it is defined, else for "*:port". Else return 0.

Definition at line 1035 of file circuituse.c.

◆ circuit_testing_failed()

static void circuit_testing_failed ( origin_circuit_t circ,
int  at_last_hop 
)
static

A testing circuit has failed to build. Take whatever stats we want.

Definition at line 1659 of file circuituse.c.

◆ circuit_testing_opened()

static void circuit_testing_opened ( origin_circuit_t circ)
static

A testing circuit has completed. Take whatever stats we want. Noticing reachability is taken care of in onionskin_answer(), so there's no need to record anything here. But if we still want to do the bandwidth test, and we now have enough testing circuits open, do it.

Definition at line 1641 of file circuituse.c.

◆ circuit_try_attaching_streams()

void circuit_try_attaching_streams ( origin_circuit_t circ)

Called when a circuit becomes ready for streams to be attached to it.

Definition at line 1755 of file circuituse.c.

◆ circuit_try_clearing_isolation_state()

static int circuit_try_clearing_isolation_state ( origin_circuit_t circ)
static

If the stream-isolation state of circ can be cleared, clear it. Return non-zero iff circ's isolation state was cleared.

Definition at line 1733 of file circuituse.c.

Referenced by circuit_try_attaching_streams().

◆ connection_ap_get_nonrend_circ_purpose()

static int connection_ap_get_nonrend_circ_purpose ( const entry_connection_t conn)
static

Return an appropriate circuit purpose for non-rend streams. We don't handle rends here because a rend stream triggers two circuit builds with different purposes, so it is handled elsewhere.

This function just figures out what type of hsdir activity this is, and tells us. Everything else is general.

Definition at line 2814 of file circuituse.c.

◆ connection_ap_handshake_attach_chosen_circuit()

int connection_ap_handshake_attach_chosen_circuit ( entry_connection_t conn,
origin_circuit_t circ,
crypt_path_t cpath 
)

Attempt to attach the connection conn to circ, and send a begin or resolve cell as appropriate. Return values are as for connection_ap_handshake_attach_circuit. The stream will exit from the hop indicated by cpath, or from the last hop in circ's cpath if cpath is NULL.

Definition at line 2762 of file circuituse.c.

◆ connection_ap_handshake_attach_circuit()

int connection_ap_handshake_attach_circuit ( entry_connection_t conn)

Try to find a safe live circuit for stream conn. If we find one, attach the stream, send appropriate cells, and return 1. Otherwise, try to launch new circuit(s) for the stream. If we can launch circuits, return 0. Otherwise, if we simply can't proceed with this stream, return -1. (conn needs to die, and is maybe already marked).

Definition at line 2847 of file circuituse.c.

◆ consider_recording_trackhost()

static void consider_recording_trackhost ( const entry_connection_t conn,
const origin_circuit_t circ 
)
static

If an exit wasn't explicitly specified for conn, consider saving the exit that we did choose for use by future connections to conn's destination.

Definition at line 2724 of file circuituse.c.

Referenced by connection_ap_handshake_attach_chosen_circuit().

◆ count_pending_general_client_circuits()

static int count_pending_general_client_circuits ( void  )
static

Return the number of not-yet-open general-purpose origin circuits.

Definition at line 397 of file circuituse.c.

◆ cpath_is_on_circuit()

static int cpath_is_on_circuit ( origin_circuit_t circ,
crypt_path_t crypt_path 
)
static

Return true iff crypt_path is one of the crypt_paths for circ.

Definition at line 2602 of file circuituse.c.

◆ hostname_in_track_host_exits()

int hostname_in_track_host_exits ( const or_options_t options,
const char *  address 
)

Return true iff address is matched by one of the entries in TrackHostExits.

Definition at line 2702 of file circuituse.c.

Referenced by consider_recording_trackhost().

◆ link_apconn_to_circ()

static void link_apconn_to_circ ( entry_connection_t apconn,
origin_circuit_t circ,
crypt_path_t cpath 
)
static

Attach the AP stream apconn to circ's linked list of p_streams. Also set apconn's cpath_layer to cpath, or to the last hop in circ's cpath if cpath is NULL.

Definition at line 2634 of file circuituse.c.

Referenced by connection_ap_handshake_attach_chosen_circuit().

◆ mark_circuit_unusable_for_new_conns()

void mark_circuit_unusable_for_new_conns ( origin_circuit_t circ)

Mark circ so that no more connections can be attached to it.

Definition at line 3139 of file circuituse.c.

Referenced by circuit_mark_all_dirty_circs_as_unusable().

◆ optimistic_data_enabled()

static int optimistic_data_enabled ( void  )
static

Return true iff client-side optimistic data is supported.

Definition at line 2615 of file circuituse.c.

◆ reset_bandwidth_test()

void reset_bandwidth_test ( void  )

Reset have_performed_bandwidth_test, so we'll start building testing circuits again so we can exercise our bandwidth.

Definition at line 1607 of file circuituse.c.

Variable Documentation

◆ did_circs_fail_last_period

int did_circs_fail_last_period = 0
static

Before the last time we called circuit_reset_failure_count(), were there a lot of failures?

Definition at line 1929 of file circuituse.c.

Referenced by circuit_reset_failure_count().

◆ have_performed_bandwidth_test

int have_performed_bandwidth_test = 0
static

True iff we've ever had enough testing circuits open to test our bandwidth.

Definition at line 1602 of file circuituse.c.

Referenced by circuit_enough_testing_circs(), circuit_testing_opened(), and reset_bandwidth_test().

◆ last_expired_clientside_circuits

time_t last_expired_clientside_circuits = 0
static

For debugging #8387: track when we last called circuit_expire_old_circuits_clientside.

Definition at line 869 of file circuituse.c.

Referenced by circuit_expire_old_circuits_clientside().

◆ n_circuit_failures

int n_circuit_failures = 0
static

Number of consecutive failures so far; should only be touched by circuit_launch_new and circuit_*_failure_count.

Definition at line 1926 of file circuituse.c.

Referenced by circuit_increment_failure_count(), and circuit_reset_failure_count().