OpenVPN
Enumerations | Functions
mudp.c File Reference
#include "syshead.h"
#include "multi.h"
#include <inttypes.h>
#include "forward.h"
#include "memdbg.h"
#include "ssl_pkt.h"
Include dependency graph for mudp.c:

Go to the source code of this file.

Enumerations

enum  pre_decrypt_verdict { PRE_DECRYPT_NO_ACTION , PRE_DECRYPT_CREATE_SESSION , PRE_DECRYPT_CREATE_SESSION_SKIP }
 Verdict if this packet should create a new session. More...
 

Functions

static void send_standalone_reply (struct multi_context *m, struct buffer *buf, const char *prefix, const char *detail, struct link_socket *sock)
 Send an already-built standalone control packet back to the peer that just contacted us (c2.from), synchronously and without keeping any state.
 
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, struct link_socket *sock)
 
static enum pre_decrypt_verdict do_pre_decrypt_check (struct multi_context *m, struct tls_pre_decrypt_state *state, struct mroute_addr addr, struct link_socket *sock)
 Returns a verdict if this packet should create a new session.
 
static struct multi_instance * handle_connection_attempt (struct multi_context *m, struct link_socket *sock, struct mroute_addr *real)
 Handles a packet if no existing session exists for this incoming packet.
 
static struct multi_instance * multi_get_instance_udp_real (struct multi_context *m, struct mroute_addr *real)
 Looks up an multi instance by its real address (IP and port)
 
struct multi_instance * multi_get_instance_udp_control (struct multi_context *m, struct link_socket *sock)
 
struct multi_instance * multi_get_instance_udp_data (struct multi_context *m, bool *floated, struct mroute_addr *real, struct link_socket *sock)
 Get a client instance based on real address.
 
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.
 
static void multi_process_outgoing_link (struct multi_context *m, const unsigned int mpp_flags)
 
void multi_process_io_udp (struct multi_context *m, struct link_socket *sock, unsigned int rwflags)
 

Enumeration Type Documentation

◆ pre_decrypt_verdict

Verdict if this packet should create a new session.

If a packet is invalid or we send out an HMAC based challenge, we do not want to create a new session.

Enumerator
PRE_DECRYPT_NO_ACTION 

This packet should not create a new session.

PRE_DECRYPT_CREATE_SESSION 

This packet creates a new session on the first packet on the session.

We only do this for legacy tls-crypt-v2 clients that do not work with the HMAC cookie challenge approach where we need to keep the client specific tls-crypt key to be able to decrypt the third packet

PRE_DECRYPT_CREATE_SESSION_SKIP 

Creates a new session.

The HMAC challenge has been already completed and the first two packets of the three way handshake are skipped in the session setup

Definition at line 95 of file mudp.c.

Function Documentation

◆ do_pre_decrypt_check()

static enum pre_decrypt_verdict do_pre_decrypt_check ( struct multi_context *  m,
struct tls_pre_decrypt_state *  state,
struct mroute_addr  addr,
struct link_socket *  sock 
)
static

◆ handle_connection_attempt()

static struct multi_instance * handle_connection_attempt ( struct multi_context *  m,
struct link_socket *  sock,
struct mroute_addr *  real 
)
static

◆ multi_get_instance_udp_control()

struct multi_instance * multi_get_instance_udp_control ( struct multi_context *  m,
struct link_socket *  sock 
)

◆ multi_get_instance_udp_data()

struct multi_instance * multi_get_instance_udp_data ( struct multi_context *  m,
bool *  floated,
struct mroute_addr *  real,
struct link_socket *  sock 
)

◆ multi_get_instance_udp_real()

static struct multi_instance * multi_get_instance_udp_real ( struct multi_context *  m,
struct mroute_addr *  real 
)
static

Looks up an multi instance by its real address (IP and port)

Parameters
mmulti context
realAddress to look up
Returns
instance matching the address, NULL otherwise

Definition at line 316 of file mudp.c.

References multi_context::hash, hash_lookup_fast(), hash_value(), and hash_element::value.

Referenced by multi_get_instance_udp_control(), and multi_get_instance_udp_data().

◆ multi_process_io_udp()

void multi_process_io_udp ( struct multi_context *  m,
struct link_socket *  sock,
unsigned int  rwflags 
)

◆ multi_process_outgoing_link()

static void multi_process_outgoing_link ( struct multi_context *  m,
const unsigned int  mpp_flags 
)
inlinestatic

Definition at line 452 of file mudp.c.

References multi_process_outgoing_link_dowork(), and multi_context::pending.

Referenced by multi_process_io_udp().

◆ send_hmac_reset_packet()

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,
struct link_socket *  sock 
)
static

◆ send_standalone_reply()

static void send_standalone_reply ( struct multi_context *  m,
struct buffer *  buf,
const char *  prefix,
const char *  detail,
struct link_socket *  sock 
)
static

Send an already-built standalone control packet back to the peer that just contacted us (c2.from), synchronously and without keeping any state.

We do not want to keep state for a reply to an initial/out-of-band packet, so we send it without queueing. If we hit EAGAIN on a busy socket the packet is lost and the client simply retries – an acceptable compromise that avoids consuming server resources under attack.

Parameters
mthe server's multi_context
bufthe packet to send (built by a tls_*_standalone() helper)
prefixmsg() prefix to set for the duration of the send
detailD_MULTI_DEBUG message describing the reply
sockthe socket to send the reply on

Definition at line 56 of file mudp.c.

References ASSERT, context_buffers::aux_buf, buf_copy(), buf_init, context_2::buffers, context::c2, D_MULTI_DEBUG, context_2::from, buffer::len, msg, msg_set_prefix(), buffer::offset, process_outgoing_link(), context_2::to_link, context_2::to_link_addr, and multi_context::top.

Referenced by send_hmac_reset_packet().