Go to the documentation of this file.
37 #ifdef HAVE_SYS_INOTIFY_H
38 #include <sys/inotify.h>
46 bool request_resend_wkc)
61 msg(
D_MULTI_DEBUG,
"Reset packet from client, sending HMAC based reset challenge");
107 if (early_neg_support)
111 from, hmac, handwindow, 0);
127 "ignoring connection attempt from old client (%s)", peer);
141 from, hmac, handwindow, 0);
204 bool peer_id_disabled =
false;
209 uint32_t peer_id = ntohl(*(uint32_t *)ptr) & 0xFFFFFF;
212 if (!peer_id_disabled && (peer_id < m->max_clients) && (m->
instances[peer_id]))
227 if (!v2 || peer_id_disabled)
243 "MULTI: Connection attempt from %s ignored while server is "
280 "MULTI: Connection from %s would exceed new connection frequency limit as controlled by --connect-freq",
290 const char *
status = mi ?
"[ok]" :
"[failed]";
336 #ifdef MULTI_DEBUG_EVENT_LOOP
359 printf(
"IO %s\n", buf);
362 #ifdef ENABLE_MANAGEMENT
398 #ifdef ENABLE_ASYNC_PUSH
402 multi_process_file_closed(m, mpp_flags);
405 #if defined(ENABLE_DCO) && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD))
424 static inline unsigned int
488 #ifdef ENABLE_ASYNC_PUSH
489 multi.
top.
c2.inotify_fd = inotify_init();
490 if (multi.
top.
c2.inotify_fd < 0)
524 #ifdef ENABLE_ASYNC_PUSH
525 close(
top->
c2.inotify_fd);
unsigned int event_set_status
struct tls_auth_standalone * tls_auth_standalone
TLS state structure required for the initial authentication of a client's connection attempt.
@ VERDICT_VALID_RESET_V2
This packet is a valid reset packet from the peer (all but tls-crypt-v2)
Server-mode state structure for one single VPN tunnel.
bool multi_process_incoming_dco(struct multi_context *m)
Process an incoming DCO message (from kernel space).
static bool mbuf_defined(const struct mbuf_set *ms)
#define MPP_CLOSE_ON_SIGNAL
static struct hash_bucket * hash_bucket(struct hash *hash, uint32_t hv)
static struct gc_arena gc_new(void)
mbedtls_md_context_t hmac_ctx_t
Generic HMAC context.
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
int len
Length in bytes of the actual content within the allocated memory.
static unsigned int p2mp_iow_flags(const struct multi_context *m)
bool reflect_filter_rate_limit_check(struct initial_packet_rate_limit *irl)
checks if the connection is still allowed to connect under the rate limit.
void tunnel_server_udp(struct context *top)
Main event loop for OpenVPN in UDP server mode.
struct tuntap * tuntap
Tun/tap virtual network interface.
Contains all state information for one tunnel.
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
struct buffer tls_reset_standalone(struct tls_wrap_ctx *ctx, struct tls_auth_standalone *tas, struct session_id *own_sid, struct session_id *remote_sid, uint8_t header, bool request_resend_wkc)
This function creates a reset packet using the information from the tls pre decrypt state.
struct mroute_addr real
External network address of the remote peer.
enum first_packet_verdict tls_pre_decrypt_lite(const struct tls_auth_standalone *tas, struct tls_pre_decrypt_state *state, const struct link_socket_actual *from, const struct buffer *buf)
Inspect an incoming packet for which no VPN tunnel is active, and determine whether a new VPN tunnel ...
void multi_uninit(struct multi_context *m)
@ VERDICT_VALID_CONTROL_V1
This packet is a valid control packet from the peer.
void free_tls_pre_decrypt_state(struct tls_pre_decrypt_state *state)
#define CO_FORCE_TLSCRYPTV2_COOKIE
Bit-flag indicating that we do not allow clients that do not support resending the wrapped client key...
static bool buf_copy(struct buffer *dest, const struct buffer *src)
struct context_buffers * buffers
static void send_hmac_reset_packet(struct multi_context *m, struct tls_pre_decrypt_state *state, struct tls_auth_standalone *tas, struct session_id *sid, bool request_resend_wkc)
void multi_ifconfig_pool_persist(struct multi_context *m, bool force)
int mode
Role of this context within the OpenVPN process.
struct link_socket_actual * to_link_addr
struct session_id server_session_id
static void buf_reset_len(struct buffer *buf)
struct tls_wrap_ctx tls_wrap_tmp
struct frequency_limit * new_connection_limiter
struct deferred_signal_schedule_entry deferred_shutdown_signal
struct context_2 c2
Level 2 context.
struct crypto_options opt
Crypto state.
struct multi_instance ** instances
Array of multi_instances.
struct session_id peer_session_id
static bool buf_advance(struct buffer *buf, int size)
void multi_init(struct multi_context *m, struct context *t, bool tcp_mode)
struct context top
Storage structure for process-wide configuration.
static void reset_packet_id_send(struct packet_id_send *p)
Reset the current send packet id to its initial state.
static void hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv, void *value)
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...
static void io_wait(struct context *c, const unsigned int flags)
#define MPP_CONDITIONAL_PRE_SELECT
static void multi_process_io_udp(struct multi_context *m)
bool multi_process_timeout(struct multi_context *m, const unsigned int mpp_flags)
void ungenerate_prefix(struct multi_instance *mi)
static bool multi_process_outgoing_link_dowork(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
void close_instance(struct context *c)
static void perf_pop(void)
struct that stores the temporary data for the tls lite decrypt functions
struct hash_element * hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
struct options options
Options loaded from command line or configuration file.
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
struct hash * hash
VPN tunnel instances indexed by real address of the remote peer.
static void multi_process_per_second_timers(struct multi_context *m)
bool session_skip_to_pre_start(struct tls_session *session, struct tls_pre_decrypt_state *state, struct link_socket_actual *from)
#define MULTI_CHECK_SIG(m)
static bool tuntap_ring_empty(struct tuntap *tt)
struct multi_instance * pending
static void msg_set_prefix(const char *prefix)
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
hmac_ctx_t * session_id_hmac
the HMAC we use to generate and verify our syn cookie like session ids from the server.
bool mroute_extract_openvpn_sockaddr(struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port)
Wrapper structure for dynamically allocated memory.
struct multi_instance * multi_create_instance(struct multi_context *m, const struct mroute_addr *real)
struct multi_instance * multi_get_create_instance_udp(struct multi_context *m, bool *floated)
Get, and if necessary create, the multi_instance associated with a packet's source address.
struct session_id calculate_session_id_hmac(struct session_id client_sid, const struct openvpn_sockaddr *from, hmac_ctx_t *hmac, int handwindow, int offset)
Calculates the HMAC based server session id based on a client session id and socket addr.
Security parameter state of a single session within a VPN tunnel.
struct timeval timeval
Time to next event of timers and similar.
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 ...
static bool session_id_defined(const struct session_id *sid1)
Garbage collection arena used to keep track of dynamically allocated memory.
void context_clear_2(struct context *c)
const char * mroute_addr_print(const struct mroute_addr *ma, struct gc_arena *gc)
void uninit_management_callback(void)
void reflect_filter_rate_limit_decrease(struct initial_packet_rate_limit *irl)
decreases the counter of initial packets seen, so connections that successfully completed the three-w...
Main OpenVPN server state structure.
void init_management_callback_multi(struct multi_context *m)
void multi_top_init(struct multi_context *m, struct context *top)
struct tls_wrap_ctx tls_wrap
static bool check_debug_level(unsigned int level)
struct env_set * es
Set of environment variables.
int n_sessions
Number of sessions negotiated thus far.
#define CC_HARD_USR1_TO_HUP
static bool do_pre_decrypt_check(struct multi_context *m, struct tls_pre_decrypt_state *state, struct mroute_addr addr)
struct link_socket_actual * hmac_reply_dest
void init_instance_handle_signals(struct context *c, const struct env_set *env, const unsigned int flags)
struct packet_id_send send
static SERVICE_STATUS status
void read_incoming_link(struct context *c)
Read a packet from the external network interface.
const char * print_link_socket_actual(const struct link_socket_actual *act, struct gc_arena *gc)
static void gc_free(struct gc_arena *a)
@ VERDICT_VALID_RESET_V3
This is a valid v3 reset (tls-crypt-v2)
bool check_session_id_hmac(struct tls_pre_decrypt_state *state, const struct openvpn_sockaddr *from, hmac_ctx_t *hmac, int handwindow)
Checks if a control packet has a correct HMAC server session id.
struct link_socket_actual from
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.
struct initial_packet_rate_limit * initial_rate_limiter
#define TM_INITIAL
As yet un-trusted tls_session being negotiated.
static bool multi_process_outgoing_tun(struct multi_context *m, const unsigned int mpp_flags)
Send a packet over the virtual tun/tap network interface to its locally reachable destination.
static void multi_process_outgoing_link(struct multi_context *m, const unsigned int mpp_flags)
struct packet_id packet_id
Current packet ID state for both sending and receiving directions.
struct openvpn_sockaddr dest
@ VERDICT_VALID_ACK_V1
This packet is a valid ACK control packet from the peer, i.e.
unsigned int flags
Bit-flags determining behavior of security operation functions.
void multi_top_free(struct multi_context *m)
@ VERDICT_VALID_WKC_V1
The packet is a valid control packet with appended wrapped client key.
void process_outgoing_link(struct context *c)
Write a packet to the external network interface.
static void perf_push(int type)
void management_io(struct management *man)
struct context context
The context structure storing state for this VPN tunnel.
static void multi_get_timeout(struct multi_context *m, struct timeval *dest)
void initialization_sequence_completed(struct context *c, const unsigned int flags)
static struct multi_instance * multi_process_outgoing_link_pre(struct multi_context *m)
static uint32_t hash_value(const struct hash *hash, const void *key)
#define P_CONTROL_HARD_RESET_SERVER_V2
struct context_1 c1
Level 1 context.
static bool link_socket_actual_match(const struct link_socket_actual *a1, const struct link_socket_actual *a2)
static const char * packet_opcode_name(int op)
bool frequency_limit_event_allowed(struct frequency_limit *f)