37#ifdef HAVE_SYS_INOTIFY_H
38#include <sys/inotify.h>
46 bool request_resend_wkc)
63 msg(
D_MULTI_DEBUG,
"Reset packet from client, sending HMAC based reset challenge");
113 from, hmac, handwindow, 0);
129 "ignoring connection attempt from old client (%s)", peer);
143 from, hmac, handwindow, 0);
209 bool peer_id_disabled =
false;
214 uint32_t peer_id = ntohl(*(uint32_t *)ptr) & 0xFFFFFF;
217 if (!peer_id_disabled && (peer_id < m->max_clients) && (m->
instances[peer_id]))
232 if (!v2 || peer_id_disabled)
248 "MULTI: Connection attempt from %s ignored while server is "
285 "MULTI: Connection from %s would exceed new connection frequency limit as controlled by --connect-freq",
295 const char *
status = mi ?
"[ok]" :
"[failed]";
342#ifdef MULTI_DEBUG_EVENT_LOOP
365 printf(
"IO %s\n", buf);
368#ifdef ENABLE_MANAGEMENT
404#ifdef ENABLE_ASYNC_PUSH
408 multi_process_file_closed(m, mpp_flags);
411#if defined(ENABLE_DCO) \
412 && (defined(TARGET_LINUX) || defined(TARGET_FREEBSD) || defined(TARGET_WIN32))
463 flags &= ~IOW_READ_TUN;
static bool buf_copy(struct buffer *dest, const struct buffer *src)
static bool buf_advance(struct buffer *buf, int size)
static void gc_free(struct gc_arena *a)
#define buf_init(buf, offset)
static struct gc_arena gc_new(void)
#define CO_FORCE_TLSCRYPTV2_COOKIE
Bit-flag indicating that we do not allow clients that do not support resending the wrapped client key...
mbedtls_md_context_t hmac_ctx_t
Generic HMAC context.
Interface functions to the internal and external multiplexers.
#define TM_INITIAL
As yet un-trusted tls_session being negotiated.
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 ...
bool multi_process_incoming_link(struct multi_context *m, struct multi_instance *instance, const unsigned int mpp_flags, struct link_socket *sock)
Demultiplex and process a packet received over the external network interface.
void process_outgoing_link(struct context *c, struct link_socket *sock)
Write a packet to the external network interface.
void read_incoming_link(struct context *c, struct link_socket *sock)
Read a packet from the external network interface.
struct multi_instance * multi_get_create_instance_udp(struct multi_context *m, bool *floated, struct link_socket *sock)
Get, and if necessary create, the multi_instance associated with a packet's source address.
void read_incoming_tun(struct context *c)
Read a packet from the virtual tun/tap network interface.
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.
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 SERVICE_STATUS status
struct hash_element * hash_lookup_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv)
static uint32_t hash_value(const struct hash *hash, const void *key)
static void hash_add_fast(struct hash *hash, struct hash_bucket *bucket, const void *key, uint32_t hv, void *value)
void management_io(struct management *man)
static bool mbuf_defined(const struct mbuf_set *ms)
bool mroute_extract_openvpn_sockaddr(struct mroute_addr *addr, const struct openvpn_sockaddr *osaddr, bool use_port)
const char * mroute_addr_print(const struct mroute_addr *ma, struct gc_arena *gc)
static bool do_pre_decrypt_check(struct multi_context *m, struct tls_pre_decrypt_state *state, struct mroute_addr addr)
unsigned int p2mp_iow_flags(const struct multi_context *m)
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_process_io_udp(struct multi_context *m, struct link_socket *sock)
static void multi_process_outgoing_link(struct multi_context *m, const unsigned int mpp_flags)
struct multi_instance * multi_create_instance(struct multi_context *m, const struct mroute_addr *real, struct link_socket *sock)
void ungenerate_prefix(struct multi_instance *mi)
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...
Header file for server-mode related structures and functions.
bool multi_process_incoming_dco(struct multi_context *m)
Process an incoming DCO message (from kernel space).
#define MPP_CONDITIONAL_PRE_SELECT
#define MPP_CLOSE_ON_SIGNAL
static struct multi_instance * multi_process_outgoing_link_pre(struct multi_context *m)
static bool multi_process_outgoing_link_dowork(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags)
static void msg_set_prefix(const char *prefix)
static bool check_debug_level(unsigned int level)
bool frequency_limit_event_allowed(struct frequency_limit *f)
bool packet_id_read(struct packet_id_net *pin, struct buffer *buf, bool long_form)
static void reset_packet_id_send(struct packet_id_send *p)
Reset the current send packet id to its initial state.
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...
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.
static bool session_id_defined(const struct session_id *sid1)
const char * print_link_socket_actual(const struct link_socket_actual *act, struct gc_arena *gc)
static bool link_socket_actual_match(const struct link_socket_actual *a1, const struct link_socket_actual *a2)
bool session_skip_to_pre_start(struct tls_session *session, struct tls_pre_decrypt_state *state, struct link_socket_actual *from)
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 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.
void free_tls_pre_decrypt_state(struct tls_pre_decrypt_state *state)
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.
SSL control channel wrap/unwrap and decode functions.
static const char * packet_opcode_name(int op)
#define P_CONTROL_HARD_RESET_SERVER_V2
@ VERDICT_VALID_ACK_V1
This packet is a valid ACK control packet from the peer, i.e.
@ VERDICT_VALID_WKC_V1
The packet is a valid control packet with appended wrapped client key.
@ VERDICT_VALID_RESET_V2
This packet is a valid reset packet from the peer (all but tls-crypt-v2)
@ VERDICT_VALID_RESET_V3
This is a valid v3 reset (tls-crypt-v2)
@ VERDICT_VALID_CONTROL_V1
This packet is a valid control packet from the peer.
Wrapper structure for dynamically allocated memory.
int len
Length in bytes of the actual content within the allocated memory.
int offset
Offset in bytes of the actual content within the allocated memory.
struct tuntap * tuntap
Tun/tap virtual network interface.
hmac_ctx_t * session_id_hmac
the HMAC we use to generate and verify our syn cookie like session ids from the server.
struct tls_auth_standalone * tls_auth_standalone
TLS state structure required for the initial authentication of a client's connection attempt.
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
struct link_socket_actual from
struct link_socket_actual * to_link_addr
struct context_buffers * buffers
Contains all state information for one tunnel.
struct context_2 c2
Level 2 context.
struct options options
Options loaded from command line or configuration file.
struct context_1 c1
Level 1 context.
unsigned int flags
Bit-flags determining behavior of security operation functions.
struct packet_id packet_id
Current packet ID state for both sending and receiving directions.
Garbage collection arena used to keep track of dynamically allocated memory.
struct openvpn_sockaddr dest
struct link_socket_info info
Main OpenVPN server state structure.
struct mbuf_set * mbuf
Set of buffers for passing data channel packets between VPN tunnel instances.
struct initial_packet_rate_limit * initial_rate_limiter
struct deferred_signal_schedule_entry deferred_shutdown_signal
struct link_socket_actual * hmac_reply_dest
struct multi_io * multi_io
I/O state and events tracker.
struct hash * hash
VPN tunnel instances indexed by real address of the remote peer.
struct link_socket * hmac_reply_ls
struct frequency_limit * new_connection_limiter
struct context top
Storage structure for process-wide configuration.
struct multi_instance * pending
struct multi_instance ** instances
Array of multi_instances.
Server-mode state structure for one single VPN tunnel.
struct mroute_addr real
External network address of the remote peer.
struct context context
The context structure storing state for this VPN tunnel.
Data structure for describing the packet id that is received/send to the network.
struct packet_id_send send
struct tls_wrap_ctx tls_wrap
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
int n_sessions
Number of sessions negotiated thus far.
struct that stores the temporary data for the tls lite decrypt functions
struct session_id peer_session_id
struct session_id server_session_id
struct tls_wrap_ctx tls_wrap_tmp
Security parameter state of a single session within a VPN tunnel.
struct crypto_options opt
Crypto state.
static bool tuntap_ring_empty(struct tuntap *tt)