Tor 0.4.9.2-alpha-dev
|
Functions to queue create cells for processing. More...
#include "core/or/or.h"
#include "feature/relay/onion_queue.h"
#include "app/config/config.h"
#include "core/mainloop/cpuworker.h"
#include "core/or/circuitlist.h"
#include "core/or/onion.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/stats/rephist.h"
#include "core/or/or_circuit_st.h"
#include "core/or/channel.h"
Go to the source code of this file.
Data Structures | |
struct | onion_queue_t |
Macros | |
#define | ONION_QUEUE_WAIT_CUTOFF_DEFAULT 5 |
#define | ONION_QUEUE_WAIT_CUTOFF_MIN 0 |
#define | ONION_QUEUE_WAIT_CUTOFF_MAX INT32_MAX |
#define | ONION_QUEUE_MAX_DELAY_DEFAULT 1750 |
#define | ONION_QUEUE_MAX_DELAY_MIN 1 |
#define | ONION_QUEUE_MAX_DELAY_MAX INT32_MAX |
#define | MAX_QUEUE_IDX ONION_HANDSHAKE_TYPE_NTOR |
#define | WARN_TOO_MANY_CIRC_CREATIONS_INTERVAL (60) |
Typedefs | |
typedef struct onion_queue_head_t | onion_queue_head_t |
Functions | |
TOR_TAILQ_HEAD (onion_queue_head_t, onion_queue_t) | |
static void | onion_queue_entry_remove (onion_queue_t *victim) |
static time_t | get_onion_queue_wait_cutoff (void) |
static uint32_t | get_onion_queue_max_delay (const or_options_t *options) |
static uint16_t | onionskin_type_to_queue (uint16_t type) |
static int | have_room_for_onionskin (uint16_t type) |
int | onion_pending_add (or_circuit_t *circ, create_cell_t *onionskin) |
static uint16_t | decide_next_handshake_type (void) |
or_circuit_t * | onion_next_task (create_cell_t **onionskin_out) |
int | onion_num_pending (uint16_t handshake_type) |
void | onion_pending_remove (or_circuit_t *circ) |
void | clear_pending_onions (void) |
void | onion_consensus_has_changed (const networkstatus_t *ns) |
Variables | |
static onion_queue_head_t | ol_list [MAX_QUEUE_IDX+1] |
static int | ol_entries [MAX_QUEUE_IDX+1] |
static time_t | ns_onion_queue_wait_cutoff = ONION_QUEUE_WAIT_CUTOFF_DEFAULT |
static uint32_t | ns_onion_queue_max_delay = ONION_QUEUE_MAX_DELAY_DEFAULT |
Functions to queue create cells for processing.
Relays invoke these functions when they receive a CREATE or EXTEND cell in command.c or relay.c, in order to queue the pending request. They also invoke them from cpuworker.c, which handles dispatching onionskin requests to different worker threads.
This module also handles:
Definition in file onion_queue.c.
#define MAX_QUEUE_IDX ONION_HANDSHAKE_TYPE_NTOR |
We have 3 queues: tap, fast, and ntor. (ntorv3 goes into ntor queue).
Definition at line 67 of file onion_queue.c.
#define ONION_QUEUE_MAX_DELAY_DEFAULT 1750 |
Definition at line 49 of file onion_queue.c.
#define ONION_QUEUE_MAX_DELAY_MAX INT32_MAX |
Definition at line 51 of file onion_queue.c.
#define ONION_QUEUE_MAX_DELAY_MIN 1 |
Definition at line 50 of file onion_queue.c.
#define ONION_QUEUE_WAIT_CUTOFF_DEFAULT 5 |
Onion queue default, max and min.
Definition at line 44 of file onion_queue.c.
#define ONION_QUEUE_WAIT_CUTOFF_MAX INT32_MAX |
Definition at line 46 of file onion_queue.c.
#define ONION_QUEUE_WAIT_CUTOFF_MIN 0 |
Definition at line 45 of file onion_queue.c.
typedef struct onion_queue_head_t onion_queue_head_t |
Definition at line 64 of file onion_queue.c.
void clear_pending_onions | ( | void | ) |
Remove all circuits from the pending list. Called from tor_free_all.
Definition at line 349 of file onion_queue.c.
|
static |
Choose which onion queue we'll pull from next. If one is empty choose the other; if they both have elements, load balance across them but favoring NTOR.
Definition at line 256 of file onion_queue.c.
Referenced by onion_next_task().
|
inlinestatic |
Return the max onion queue delay value either from the torrc options (if the user explicitly set it) else from the cached parameter.
Definition at line 96 of file onion_queue.c.
|
inlinestatic |
Return the onion queue wait cutoff value from the cached parameter.
Definition at line 88 of file onion_queue.c.
|
static |
Return true iff we have room to queue another onionskin of type type.
Definition at line 132 of file onion_queue.c.
void onion_consensus_has_changed | ( | const networkstatus_t * | ns | ) |
Consensus has changed, update the cached parameters.
Definition at line 365 of file onion_queue.c.
or_circuit_t * onion_next_task | ( | create_cell_t ** | onionskin_out | ) |
Remove the highest priority item from ol_list[] and return it, or return NULL if the lists are empty.
Definition at line 265 of file onion_queue.c.
int onion_num_pending | ( | uint16_t | handshake_type | ) |
Return the number of handshake_type-style create requests pending.
Definition at line 297 of file onion_queue.c.
int onion_pending_add | ( | or_circuit_t * | circ, |
create_cell_t * | onionskin | ||
) |
Add circ to the end of ol_list and return 0, except if ol_list is too long, in which case do nothing and return -1.
Definition at line 177 of file onion_queue.c.
void onion_pending_remove | ( | or_circuit_t * | circ | ) |
Go through ol_list, find the onion_queue_t element which points to circ, remove and free that element. Leave circ itself alone.
Definition at line 306 of file onion_queue.c.
Referenced by circuit_about_to_free().
|
static |
Remove a queue entry victim from the queue, unlinking it from its circuit and freeing it and any structures it owns.
Definition at line 323 of file onion_queue.c.
Referenced by clear_pending_onions(), and onion_pending_remove().
|
inlinestatic |
We combine ntorv3 and ntor into the same queue, so we must use this function to convert the cell type to a queue index.
Definition at line 109 of file onion_queue.c.
Referenced by onion_num_pending().
|
static |
Definition at line 84 of file onion_queue.c.
|
static |
Consensus parameters.
Definition at line 83 of file onion_queue.c.
Referenced by get_onion_queue_wait_cutoff().
|
static |
Number of entries of each type currently in each element of ol_list[].
Definition at line 78 of file onion_queue.c.
Referenced by clear_pending_onions(), onion_next_task(), and onion_num_pending().
|
static |
Array of queues of circuits waiting for CPU workers. An element is NULL if that queue is empty.
Definition at line 71 of file onion_queue.c.
Referenced by clear_pending_onions(), and onion_next_task().