OpenVPN
Typedefs | Functions | Variables
multi.c File Reference
#include "syshead.h"
#include "forward.h"
#include "multi.h"
#include "push.h"
#include "run_command.h"
#include "otime.h"
#include "gremlin.h"
#include "mstats.h"
#include "ssl_verify.h"
#include "ssl_ncp.h"
#include "vlan.h"
#include <inttypes.h>
#include "memdbg.h"
#include "crypto_backend.h"
#include "ssl_util.h"
#include "dco.h"
#include "reflect_filter.h"
Include dependency graph for multi.c:

Go to the source code of this file.

Typedefs

typedef enum client_connect_return(* multi_client_connect_handler) (struct multi_context *m, struct multi_instance *mi, bool from_deferred, unsigned int *option_types_found)
 

Functions

static void set_cc_config (struct multi_instance *mi, struct buffer_list *cc_config)
 
static void update_mstat_n_clients (const int n_clients)
 
static bool learn_address_script (const struct multi_context *m, const struct multi_instance *mi, const char *op, const struct mroute_addr *addr)
 
void multi_ifconfig_pool_persist (struct multi_context *m, bool force)
 
static void multi_reap_range (const struct multi_context *m, int start_bucket, int end_bucket)
 
static void multi_reap_all (const struct multi_context *m)
 
static struct multi_reapmulti_reap_new (int buckets_per_pass)
 
void multi_reap_process_dowork (const struct multi_context *m)
 
static void multi_reap_free (struct multi_reap *mr)
 
static int reap_buckets_per_pass (int n_buckets)
 
static uint32_t cid_hash_function (const void *key, uint32_t iv)
 
static bool cid_compare_function (const void *key1, const void *key2)
 
void multi_init (struct multi_context *m, struct context *t, bool tcp_mode)
 
const char * multi_instance_string (const struct multi_instance *mi, bool null, struct gc_arena *gc)
 
static void generate_prefix (struct multi_instance *mi)
 
void ungenerate_prefix (struct multi_instance *mi)
 
static void multi_del_iroutes (struct multi_context *m, struct multi_instance *mi)
 
static void setenv_stats (struct multi_context *m, struct context *c)
 
static void multi_client_disconnect_setenv (struct multi_context *m, struct multi_instance *mi)
 
static void multi_client_disconnect_script (struct multi_context *m, struct multi_instance *mi)
 
void multi_close_instance (struct multi_context *m, struct multi_instance *mi, bool shutdown)
 
void multi_uninit (struct multi_context *m)
 
struct multi_instancemulti_create_instance (struct multi_context *m, const struct mroute_addr *real)
 
void multi_print_status (struct multi_context *m, struct status_output *so, const int version)
 
static struct multi_instancemulti_learn_addr (struct multi_context *m, struct multi_instance *mi, const struct mroute_addr *addr, const unsigned int flags)
 
static struct multi_instancemulti_get_instance_by_virtual_addr (struct multi_context *m, const struct mroute_addr *addr, bool cidr_routing)
 
static struct multi_instancemulti_learn_in_addr_t (struct multi_context *m, struct multi_instance *mi, in_addr_t a, int netbits, bool primary)
 
static struct multi_instancemulti_learn_in6_addr (struct multi_context *m, struct multi_instance *mi, struct in6_addr a6, int netbits, bool primary)
 
static void multi_add_iroutes (struct multi_context *m, struct multi_instance *mi)
 
static void multi_delete_dup (struct multi_context *m, struct multi_instance *new_mi)
 
static void check_stale_routes (struct multi_context *m)
 
static bool ifconfig_push_constraint_satisfied (const struct context *c)
 
static void multi_select_virtual_addr (struct multi_context *m, struct multi_instance *mi)
 
static void multi_set_virtual_addr_env (struct multi_instance *mi)
 
static void multi_client_connect_post (struct multi_context *m, struct multi_instance *mi, const char *dc_file, unsigned int *option_types_found)
 
static void multi_client_connect_post_plugin (struct multi_context *m, struct multi_instance *mi, const struct plugin_return *pr, unsigned int *option_types_found)
 
enum client_connect_return multi_client_connect_mda (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 
static void multi_client_connect_setenv (struct multi_context *m, struct multi_instance *mi)
 
static bool multi_client_set_protocol_options (struct context *c)
 Calculates the options that depend on the client capabilities based on local options and available peer info. More...
 
static void ccs_delete_deferred_ret_file (struct multi_instance *mi)
 Delete the temporary file for the return value of client connect It also removes it from client_connect_defer_state and environment. More...
 
static bool ccs_gen_deferred_ret_file (struct multi_instance *mi)
 Create a temporary file for the return value of client connect and puts it into the client_connect_defer_state and environment as "client_connect_deferred_file". More...
 
static enum client_connect_return ccs_test_deferred_ret_file (struct multi_instance *mi)
 Tests whether the deferred return value file exists and returns the contained return value. More...
 
static void ccs_delete_config_file (struct multi_instance *mi)
 Deletes the temporary file for the config directives of the client connect script and removes it into the client_connect_defer_state and environment. More...
 
static bool ccs_gen_config_file (struct multi_instance *mi)
 Create a temporary file for the config directives of the client connect script and puts it into the client_connect_defer_state and environment as "client_connect_config_file". More...
 
static enum client_connect_return multi_client_connect_call_plugin_v1 (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 
static enum client_connect_return multi_client_connect_call_plugin_v2 (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 
static enum client_connect_return multi_client_connect_script_deferred (struct multi_context *m, struct multi_instance *mi, unsigned int *option_types_found)
 
static enum client_connect_return multi_client_connect_call_script (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 Runs the –client-connect script if one is defined. More...
 
static bool multi_client_setup_dco_initial (struct multi_context *m, struct multi_instance *mi, struct gc_arena *gc)
 
static bool multi_client_generate_tls_keys (struct context *c)
 Generates the data channel keys. More...
 
static void multi_client_connect_late_setup (struct multi_context *m, struct multi_instance *mi, const unsigned int option_types_found)
 
static void multi_client_connect_early_setup (struct multi_context *m, struct multi_instance *mi)
 
static enum client_connect_return multi_client_connect_compress_migrate (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 Do the necessary modification for doing the compress migrate. More...
 
static enum client_connect_return multi_client_connect_source_ccd (struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
 Try to source a dynamic config file from the –client-config-dir directory. More...
 
static void multi_connection_established (struct multi_context *m, struct multi_instance *mi)
 
void multi_add_mbuf (struct multi_context *m, struct multi_instance *mi, struct mbuf_buffer *mb)
 
static void multi_unicast (struct multi_context *m, const struct buffer *buf, struct multi_instance *mi)
 
static void multi_bcast (struct multi_context *m, const struct buffer *buf, const struct multi_instance *sender_instance, const struct mroute_addr *sender_addr, uint16_t vid)
 
static unsigned int compute_wakeup_sigma (const struct timeval *delta)
 
static void multi_schedule_context_wakeup (struct multi_context *m, struct multi_instance *mi)
 
bool multi_process_post (struct multi_context *m, struct multi_instance *mi, const unsigned int flags)
 Perform postprocessing of a VPN tunnel instance. More...
 
void multi_process_float (struct multi_context *m, struct multi_instance *mi)
 Handles peer floating. More...
 
void multi_close_instance_on_signal (struct multi_context *m, struct multi_instance *mi)
 
static void multi_signal_instance (struct multi_context *m, struct multi_instance *mi, const int sig)
 
bool multi_process_incoming_link (struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags)
 Demultiplex and process a packet received over the external network interface. More...
 
bool multi_process_incoming_tun (struct multi_context *m, const unsigned int mpp_flags)
 Determine the destination VPN tunnel of a packet received over the virtual tun/tap network interface and then process it accordingly. More...
 
struct multi_instancemulti_get_queue (struct mbuf_set *ms)
 
bool multi_process_timeout (struct multi_context *m, const unsigned int mpp_flags)
 
void multi_process_drop_outgoing_tun (struct multi_context *m, const unsigned int mpp_flags)
 
void route_quota_exceeded (const struct multi_instance *mi)
 
static bool stale_route_check_trigger (struct multi_context *m)
 
void multi_process_per_second_timers_dowork (struct multi_context *m)
 
void multi_top_init (struct multi_context *m, struct context *top)
 
void multi_top_free (struct multi_context *m)
 
static bool is_exit_restart (int sig)
 
static void multi_push_restart_schedule_exit (struct multi_context *m, bool next_server)
 
bool multi_process_signal (struct multi_context *m)
 
static void management_callback_status (void *arg, const int version, struct status_output *so)
 
static int management_callback_n_clients (void *arg)
 
static int management_callback_kill_by_cn (void *arg, const char *del_cn)
 
static int management_callback_kill_by_addr (void *arg, const in_addr_t addr, const int port)
 
static void management_delete_event (void *arg, event_t event)
 
static struct multi_instancelookup_by_cid (struct multi_context *m, const unsigned long cid)
 
static bool management_kill_by_cid (void *arg, const unsigned long cid, const char *kill_msg)
 
static bool management_client_pending_auth (void *arg, const unsigned long cid, const unsigned int mda_key_id, const char *extra, unsigned int timeout)
 
static bool management_client_auth (void *arg, const unsigned long cid, const unsigned int mda_key_id, const bool auth, const char *reason, const char *client_reason, struct buffer_list *cc_config)
 
static char * management_get_peer_info (void *arg, const unsigned long cid)
 
void init_management_callback_multi (struct multi_context *m)
 
void multi_assign_peer_id (struct multi_context *m, struct multi_instance *mi)
 Assigns a peer-id to a a client and adds the instance to the the instances array of the multi_context structure. More...
 
void tunnel_server (struct context *top)
 Main event loop for OpenVPN in server mode. More...
 

Variables

static const multi_client_connect_handler client_connect_handlers []
 

Typedef Documentation

◆ multi_client_connect_handler

typedef enum client_connect_return(* multi_client_connect_handler) (struct multi_context *m, struct multi_instance *mi, bool from_deferred, unsigned int *option_types_found)

Definition at line 2662 of file multi.c.

Function Documentation

◆ ccs_delete_config_file()

static void ccs_delete_config_file ( struct multi_instance mi)
static

◆ ccs_delete_deferred_ret_file()

static void ccs_delete_deferred_ret_file ( struct multi_instance mi)
static

◆ ccs_gen_config_file()

static bool ccs_gen_config_file ( struct multi_instance mi)
static

Create a temporary file for the config directives of the client connect script and puts it into the client_connect_defer_state and environment as "client_connect_config_file".

Returns
boolean value if creation was successful

Definition at line 2069 of file multi.c.

References context::c2, ccs_delete_config_file(), multi_instance::client_connect_defer_state, client_connect_defer_state::config_file, multi_instance::context, context_2::es, gc_free(), gc_new(), context::options, platform_create_temp_file(), setenv_str(), string_alloc(), and options::tmp_dir.

Referenced by multi_client_connect_call_plugin_v1(), and multi_client_connect_call_script().

◆ ccs_gen_deferred_ret_file()

static bool ccs_gen_deferred_ret_file ( struct multi_instance mi)
static

Create a temporary file for the return value of client connect and puts it into the client_connect_defer_state and environment as "client_connect_deferred_file".

Returns
boolean value if creation was successful

Definition at line 1962 of file multi.c.

References context::c2, ccs_delete_deferred_ret_file(), multi_instance::client_connect_defer_state, multi_instance::context, client_connect_defer_state::deferred_ret_file, context_2::es, gc_free(), gc_new(), context::options, platform_create_temp_file(), setenv_str(), string_alloc(), and options::tmp_dir.

Referenced by multi_client_connect_call_plugin_v1(), and multi_client_connect_call_script().

◆ ccs_test_deferred_ret_file()

static enum client_connect_return ccs_test_deferred_ret_file ( struct multi_instance mi)
static

Tests whether the deferred return value file exists and returns the contained return value.

Returns
CC_RET_SKIPPED if the file does not exist or is empty. CC_RET_DEFERRED, CC_RET_SUCCEEDED or CC_RET_FAILED depending on the value stored in the file.

Definition at line 1995 of file multi.c.

References CC_RET_DEFERRED, CC_RET_FAILED, CC_RET_SKIPPED, CC_RET_SUCCEEDED, multi_instance::client_connect_defer_state, client_connect_defer_state::deferred_ret_file, M_WARN, and msg.

Referenced by multi_client_connect_call_plugin_v1(), multi_client_connect_call_script(), and multi_client_connect_script_deferred().

◆ check_stale_routes()

static void check_stale_routes ( struct multi_context m)
static

◆ cid_compare_function()

static bool cid_compare_function ( const void *  key1,
const void *  key2 
)
static

Definition at line 262 of file multi.c.

References key1.

Referenced by multi_init().

◆ cid_hash_function()

static uint32_t cid_hash_function ( const void *  key,
uint32_t  iv 
)
static

Definition at line 255 of file multi.c.

Referenced by multi_init().

◆ compute_wakeup_sigma()

static unsigned int compute_wakeup_sigma ( const struct timeval *  delta)
inlinestatic

Definition at line 2972 of file multi.c.

Referenced by multi_push_restart_schedule_exit(), and multi_schedule_context_wakeup().

◆ generate_prefix()

static void generate_prefix ( struct multi_instance mi)
static

◆ ifconfig_push_constraint_satisfied()

static bool ifconfig_push_constraint_satisfied ( const struct context c)
static

◆ init_management_callback_multi()

void init_management_callback_multi ( struct multi_context m)

◆ is_exit_restart()

static bool is_exit_restart ( int  sig)
static

Definition at line 3830 of file multi.c.

Referenced by multi_process_signal().

◆ learn_address_script()

static bool learn_address_script ( const struct multi_context m,
const struct multi_instance mi,
const char *  op,
const struct mroute_addr addr 
)
static

◆ lookup_by_cid()

static struct multi_instance* lookup_by_cid ( struct multi_context m,
const unsigned long  cid 
)
static

◆ management_callback_kill_by_addr()

static int management_callback_kill_by_addr ( void *  arg,
const in_addr_t  addr,
const int  port 
)
static

◆ management_callback_kill_by_cn()

static int management_callback_kill_by_cn ( void *  arg,
const char *  del_cn 
)
static

◆ management_callback_n_clients()

static int management_callback_n_clients ( void *  arg)
static

Definition at line 3917 of file multi.c.

References multi_context::n_clients.

Referenced by init_management_callback_multi().

◆ management_callback_status()

static void management_callback_status ( void *  arg,
const int  version,
struct status_output so 
)
static

Definition at line 3902 of file multi.c.

References multi_print_status(), and multi_context::status_file_version.

Referenced by init_management_callback_multi().

◆ management_client_auth()

static bool management_client_auth ( void *  arg,
const unsigned long  cid,
const unsigned int  mda_key_id,
const bool  auth,
const char *  reason,
const char *  client_reason,
struct buffer_list cc_config 
)
static

◆ management_client_pending_auth()

static bool management_client_pending_auth ( void *  arg,
const unsigned long  cid,
const unsigned int  mda_key_id,
const char *  extra,
unsigned int  timeout 
)
static

◆ management_delete_event()

static void management_delete_event ( void *  arg,
event_t  event 
)
static

Definition at line 3981 of file multi.c.

References multi_context::mtcp, and multi_tcp_delete_event().

Referenced by init_management_callback_multi().

◆ management_get_peer_info()

static char* management_get_peer_info ( void *  arg,
const unsigned long  cid 
)
static

◆ management_kill_by_cid()

static bool management_kill_by_cid ( void *  arg,
const unsigned long  cid,
const char *  kill_msg 
)
static

◆ multi_add_iroutes()

static void multi_add_iroutes ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_add_mbuf()

void multi_add_mbuf ( struct multi_context m,
struct multi_instance mi,
struct mbuf_buffer mb 
)

◆ multi_assign_peer_id()

void multi_assign_peer_id ( struct multi_context m,
struct multi_instance mi 
)

Assigns a peer-id to a a client and adds the instance to the the instances array of the multi_context structure.

Parameters
m- The single multi_context structure.
mi- The multi_instance of the VPN tunnel to be postprocessed.

Definition at line 4144 of file multi.c.

References ASSERT, context::c2, multi_instance::context, multi_context::instances, multi_context::max_clients, MAX_PEER_ID, tls_multi::peer_id, and context_2::tls_multi.

Referenced by multi_create_instance_tcp(), and multi_get_create_instance_udp().

◆ multi_bcast()

static void multi_bcast ( struct multi_context m,
const struct buffer buf,
const struct multi_instance sender_instance,
const struct mroute_addr sender_addr,
uint16_t  vid 
)
static

◆ multi_client_connect_call_plugin_v1()

static enum client_connect_return multi_client_connect_call_plugin_v1 ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)
static

Contrary to the plugin v2 API, we do not demand a working deferred plugin as all return can be handled by the files and plugin_call return success if a plugin is not defined

plugin api v1 client connect async feature has both plugin and file return status, so in cases where the file has a code that demands override, we override our return code

Definition at line 2096 of file multi.c.

References argv_free(), argv_new(), argv_printf(), ASSERT, context::c2, CC_RET_DEFERRED, CC_RET_FAILED, CC_RET_SKIPPED, CC_RET_SUCCEEDED, ccs_delete_config_file(), ccs_delete_deferred_ret_file(), ccs_gen_config_file(), ccs_gen_deferred_ret_file(), ccs_test_deferred_ret_file(), cleanup(), multi_instance::client_connect_defer_state, client_connect_defer_state::config_file, multi_instance::context, client_connect_defer_state::deferred_ret_file, context_2::es, M_WARN, msg, multi_client_connect_post(), OPENVPN_PLUGIN_CLIENT_CONNECT, OPENVPN_PLUGIN_CLIENT_CONNECT_DEFER, OPENVPN_PLUGIN_FUNC_DEFERRED, OPENVPN_PLUGIN_FUNC_SUCCESS, plugin_call(), plugin_defined(), and context::plugins.

◆ multi_client_connect_call_plugin_v2()

static enum client_connect_return multi_client_connect_call_plugin_v2 ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)
static

◆ multi_client_connect_call_script()

static enum client_connect_return multi_client_connect_call_script ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)
static

◆ multi_client_connect_compress_migrate()

static enum client_connect_return multi_client_connect_compress_migrate ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)
static

Do the necessary modification for doing the compress migrate.

This is implemented as a connect handler as it fits the modify config for a client paradigm and also is early enough in the chain to be overwritten by another ccd/script to do compression on a special client.

Definition at line 2569 of file multi.c.

References compress_options::alg, context::c2, CC_RET_SUCCEEDED, options::comp, COMP_ALG_STUB, COMP_F_MIGRATE, multi_instance::context, compress_options::flags, M_USAGE, OPT_P_COMP, context::options, tls_multi::peer_info, push_option(), tls_multi::remote_usescomp, and context_2::tls_multi.

◆ multi_client_connect_early_setup()

static void multi_client_connect_early_setup ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_client_connect_late_setup()

static void multi_client_connect_late_setup ( struct multi_context m,
struct multi_instance mi,
const unsigned int  option_types_found 
)
static

◆ multi_client_connect_mda()

enum client_connect_return multi_client_connect_mda ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)

◆ multi_client_connect_post()

static void multi_client_connect_post ( struct multi_context m,
struct multi_instance mi,
const char *  dc_file,
unsigned int *  option_types_found 
)
static

◆ multi_client_connect_post_plugin()

static void multi_client_connect_post_plugin ( struct multi_context m,
struct multi_instance mi,
const struct plugin_return pr,
unsigned int *  option_types_found 
)
static

◆ multi_client_connect_script_deferred()

static enum client_connect_return multi_client_connect_script_deferred ( struct multi_context m,
struct multi_instance mi,
unsigned int *  option_types_found 
)
static

◆ multi_client_connect_setenv()

static void multi_client_connect_setenv ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_client_connect_source_ccd()

static enum client_connect_return multi_client_connect_source_ccd ( struct multi_context m,
struct multi_instance mi,
bool  deferred,
unsigned int *  option_types_found 
)
static

◆ multi_client_disconnect_script()

static void multi_client_disconnect_script ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_client_disconnect_setenv()

static void multi_client_disconnect_setenv ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_client_generate_tls_keys()

static bool multi_client_generate_tls_keys ( struct context c)
static

◆ multi_client_set_protocol_options()

static bool multi_client_set_protocol_options ( struct context c)
static

◆ multi_client_setup_dco_initial()

static bool multi_client_setup_dco_initial ( struct multi_context m,
struct multi_instance mi,
struct gc_arena gc 
)
static

◆ multi_close_instance()

void multi_close_instance ( struct multi_context m,
struct multi_instance mi,
bool  shutdown 
)

◆ multi_close_instance_on_signal()

void multi_close_instance_on_signal ( struct multi_context m,
struct multi_instance mi 
)

◆ multi_connection_established()

static void multi_connection_established ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_create_instance()

struct multi_instance* multi_create_instance ( struct multi_context m,
const struct mroute_addr real 
)

◆ multi_del_iroutes()

static void multi_del_iroutes ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_delete_dup()

static void multi_delete_dup ( struct multi_context m,
struct multi_instance new_mi 
)
static

◆ multi_get_instance_by_virtual_addr()

static struct multi_instance* multi_get_instance_by_virtual_addr ( struct multi_context m,
const struct mroute_addr addr,
bool  cidr_routing 
)
static

◆ multi_get_queue()

struct multi_instance* multi_get_queue ( struct mbuf_set ms)

◆ multi_ifconfig_pool_persist()

void multi_ifconfig_pool_persist ( struct multi_context m,
bool  force 
)

◆ multi_init()

void multi_init ( struct multi_context m,
struct context t,
bool  tcp_mode 
)

Definition at line 292 of file multi.c.

References ASSERT, context::c1, options::cf_initial_max, options::cf_initial_per, options::cf_max, options::cf_per, cid_compare_function(), multi_context::cid_hash, cid_hash_function(), CLEAR, D_MULTI_LOW, multi_context::deferred_shutdown_signal, options::dev, options::dev_type, dev_type_enum(), DEV_TYPE_TUN, DEV_TYPE_UNDEF, options::duplicate_cn, multi_context::enable_c2c, options::enable_c2c, event_timeout_init(), frequency_limit_init(), get_random(), multi_context::hash, hash_init(), options::ifconfig_ipv6_pool_base, options::ifconfig_ipv6_pool_defined, options::ifconfig_ipv6_pool_netbits, multi_context::ifconfig_pool, IFCONFIG_POOL_30NET, options::ifconfig_pool_defined, options::ifconfig_pool_end, IFCONFIG_POOL_INDIV, ifconfig_pool_init(), context_1::ifconfig_pool_persist, ifconfig_pool_read(), options::ifconfig_pool_start, initial_rate_limit_init(), multi_context::initial_rate_limiter, multi_context::instances, multi_context::iter, multi_context::local, tuntap::local, M_INFO, multi_context::max_clients, options::max_clients, multi_context::mbuf, mbuf_init(), mroute_addr_compare_function(), mroute_addr_hash_function(), mroute_extract_in_addr_t(), mroute_helper_init(), msg, multi_context::mtcp, MULTI_CACHE_ROUTE_TTL, multi_reap_new(), multi_tcp_init(), options::n_bcast_buf, multi_context::new_connection_limiter, context::options, options::real_hash_size, reap_buckets_per_pass(), multi_context::reaper, multi_context::route_helper, multi_context::schedule, schedule_init(), deferred_signal_schedule_entry::signal_received, options::stale_routes_ageing_time, multi_context::stale_routes_check_et, options::stale_routes_check_interval, multi_context::status_file_version, options::status_file_version, multi_context::tcp_queue_limit, options::tcp_queue_limit, TOP_NET30, options::topology, context_1::tuntap, multi_context::vhash, and options::virtual_hash_size.

Referenced by tunnel_server_tcp(), and tunnel_server_udp().

◆ multi_instance_string()

const char* multi_instance_string ( const struct multi_instance mi,
bool  null,
struct gc_arena gc 
)

◆ multi_learn_addr()

static struct multi_instance* multi_learn_addr ( struct multi_context m,
struct multi_instance mi,
const struct mroute_addr addr,
const unsigned int  flags 
)
static

◆ multi_learn_in6_addr()

static struct multi_instance* multi_learn_in6_addr ( struct multi_context m,
struct multi_instance mi,
struct in6_addr  a6,
int  netbits,
bool  primary 
)
static

◆ multi_learn_in_addr_t()

static struct multi_instance* multi_learn_in_addr_t ( struct multi_context m,
struct multi_instance mi,
in_addr_t  a,
int  netbits,
bool  primary 
)
static

◆ multi_print_status()

void multi_print_status ( struct multi_context m,
struct status_output so,
const int  version 
)

◆ multi_process_drop_outgoing_tun()

void multi_process_drop_outgoing_tun ( struct multi_context m,
const unsigned int  mpp_flags 
)

◆ multi_process_float()

void multi_process_float ( struct multi_context m,
struct multi_instance mi 
)

◆ multi_process_per_second_timers_dowork()

void multi_process_per_second_timers_dowork ( struct multi_context m)

◆ multi_process_post()

bool multi_process_post ( struct multi_context m,
struct multi_instance mi,
const unsigned int  flags 
)

Perform postprocessing of a VPN tunnel instance.

After some VPN tunnel activity has taken place, the VPN tunnel's state may need updating and some follow-up action may be required. This function controls the necessary postprocessing. It is called by many other functions that handle VPN tunnel related activity, such as multi_process_incoming_link(), multi_process_outgoing_link(), multi_process_incoming_tun(), multi_process_outgoing_tun(), and multi_process_timeout(), among others.

Parameters
m- The single multi_context structure.
mi- The multi_instance of the VPN tunnel to be postprocessed.
flags- Fast I/O optimization flags.
Returns
  • True, if the VPN tunnel instance mi was not closed due to a signal during processing.
  • False, if the VPN tunnel instance mi was closed.

Definition at line 3041 of file multi.c.

References ANY_OUT, auth_deferred_status::auth_control_file, key_state::authenticated, context::c2, multi_instance::client_connect_defer_state, multi_instance::context, client_connect_defer_state::deferred_ret_file, context_2::fragment, is_cas_pending(), IS_SIG, tls_session::key, KS_AUTH_DEFERRED, KS_AUTH_FALSE, KS_PRIMARY, buffer::len, MPP_CLOSE_ON_SIGNAL, MPP_CONDITIONAL_PRE_SELECT, MPP_PRE_SELECT, MPP_RECORD_TOUCH, multi_context::mpp_touched, multi_close_instance_on_signal(), multi_connection_established(), multi_schedule_context_wakeup(), multi_set_pending(), tls_multi::multi_state, fragment_master::outgoing, multi_context::pending, key_state::plugin_auth, pre_select(), key_state::script_auth, tls_multi::session, context_2::timeval, context_2::tls_multi, TM_ACTIVE, context_2::to_link, context_2::to_tun, and multi_context::top.

Referenced by multi_create_instance(), multi_process_drop_outgoing_tun(), multi_process_incoming_link(), multi_process_incoming_tun(), multi_process_outgoing_link_dowork(), multi_process_outgoing_tun(), multi_process_timeout(), multi_tcp_dispatch(), and multi_tcp_process_outgoing_link().

◆ multi_process_signal()

bool multi_process_signal ( struct multi_context m)

◆ multi_process_timeout()

bool multi_process_timeout ( struct multi_context m,
const unsigned int  mpp_flags 
)

◆ multi_push_restart_schedule_exit()

static void multi_push_restart_schedule_exit ( struct multi_context m,
bool  next_server 
)
static

◆ multi_reap_all()

static void multi_reap_all ( const struct multi_context m)
static

Definition at line 208 of file multi.c.

References multi_reap_range().

Referenced by multi_uninit().

◆ multi_reap_free()

static void multi_reap_free ( struct multi_reap mr)
static

Definition at line 238 of file multi.c.

Referenced by multi_uninit().

◆ multi_reap_new()

static struct multi_reap* multi_reap_new ( int  buckets_per_pass)
static

Definition at line 214 of file multi.c.

References ALLOC_OBJ, multi_reap::bucket_base, multi_reap::buckets_per_pass, multi_reap::last_call, and now.

Referenced by multi_init().

◆ multi_reap_process_dowork()

void multi_reap_process_dowork ( const struct multi_context m)

◆ multi_reap_range()

static void multi_reap_range ( const struct multi_context m,
int  start_bucket,
int  end_bucket 
)
static

◆ multi_schedule_context_wakeup()

static void multi_schedule_context_wakeup ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_select_virtual_addr()

static void multi_select_virtual_addr ( struct multi_context m,
struct multi_instance mi 
)
static

◆ multi_set_virtual_addr_env()

static void multi_set_virtual_addr_env ( struct multi_instance mi)
static

◆ multi_signal_instance()

static void multi_signal_instance ( struct multi_context m,
struct multi_instance mi,
const int  sig 
)
static

◆ multi_top_free()

void multi_top_free ( struct multi_context m)

◆ multi_top_init()

void multi_top_init ( struct multi_context m,
struct context top 
)

◆ multi_unicast()

static void multi_unicast ( struct multi_context m,
const struct buffer buf,
struct multi_instance mi 
)
inlinestatic

◆ multi_uninit()

void multi_uninit ( struct multi_context m)

◆ reap_buckets_per_pass()

static int reap_buckets_per_pass ( int  n_buckets)
static

Definition at line 247 of file multi.c.

References constrain_int(), REAP_DIVISOR, REAP_MAX, and REAP_MIN.

Referenced by multi_init().

◆ route_quota_exceeded()

void route_quota_exceeded ( const struct multi_instance mi)

◆ set_cc_config()

static void set_cc_config ( struct multi_instance mi,
struct buffer_list cc_config 
)
static

Definition at line 74 of file multi.c.

References buffer_list_free(), and multi_instance::cc_config.

Referenced by management_client_auth(), and multi_close_instance().

◆ setenv_stats()

static void setenv_stats ( struct multi_context m,
struct context c 
)
static

◆ stale_route_check_trigger()

static bool stale_route_check_trigger ( struct multi_context m)
static

◆ ungenerate_prefix()

void ungenerate_prefix ( struct multi_instance mi)

Definition at line 513 of file multi.c.

References multi_instance::msg_prefix, and set_prefix().

Referenced by multi_close_instance(), and multi_get_create_instance_udp().

◆ update_mstat_n_clients()

static void update_mstat_n_clients ( const int  n_clients)
inlinestatic

Definition at line 82 of file multi.c.

Referenced by multi_close_instance(), and multi_connection_established().

Variable Documentation

◆ client_connect_handlers

const multi_client_connect_handler client_connect_handlers[]
static
multi_client_connect_call_plugin_v1
static enum client_connect_return multi_client_connect_call_plugin_v1(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Definition: multi.c:2096
multi_client_connect_compress_migrate
static enum client_connect_return multi_client_connect_compress_migrate(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Do the necessary modification for doing the compress migrate.
Definition: multi.c:2569
multi_client_connect_call_plugin_v2
static enum client_connect_return multi_client_connect_call_plugin_v2(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Definition: multi.c:2191
multi_client_connect_mda
enum client_connect_return multi_client_connect_mda(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Definition: multi.c:1722
multi_client_connect_call_script
static enum client_connect_return multi_client_connect_call_script(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Runs the –client-connect script if one is defined.
Definition: multi.c:2288
multi_client_connect_source_ccd
static enum client_connect_return multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *mi, bool deferred, unsigned int *option_types_found)
Try to source a dynamic config file from the –client-config-dir directory.
Definition: multi.c:2603