Go to the documentation of this file.
31 #if defined(ENABLE_DCO)
51 const uint8_t *encrypt_key,
const uint8_t *encrypt_iv,
52 const uint8_t *decrypt_key,
const uint8_t *decrypt_iv,
53 const char *ciphername)
56 msg(
D_DCO_DEBUG,
"%s: peer_id=%d keyid=%d, currently %d keys installed",
71 encrypt_key, encrypt_iv,
72 decrypt_key, decrypt_iv,
86 const struct key2 *
key2,
int key_direction,
87 const char *ciphername,
bool server)
92 return dco_install_key(multi, ks,
148 msg(
D_DCO,
"No encryption key found. Purging data channel keys");
153 msg(
D_DCO,
"Cannot delete primary key during wipe: %s (%d)", strerror(-ret), ret);
160 msg(
D_DCO,
"Cannot delete secondary key during wipe: %s (%d)", strerror(-ret), ret);
173 struct key_state *secondary = dco_get_secondary_key(multi, primary);
183 "primary-id=%d secondary-id=%d",
189 "primary-id=%d secondary-id=(to be deleted)",
196 msg(
D_DCO,
"Cannot swap keys: %s (%d)", strerror(-ret), ret);
214 msg(
D_DCO,
"Cannot delete secondary key: %s (%d)", strerror(-ret), ret);
222 for (
int i = 0; i <
TM_SIZE; ++i)
224 for (
int j = 0; j <
KS_SIZE; j++)
227 if (ks != primary && ks != secondary)
241 msg(msglevel,
"Note: --fragment disables data channel offload.");
247 msg(msglevel,
"Note: --http-proxy disables data channel offload.");
253 msg(msglevel,
"Note: --socks-proxy disables data channel offload.");
257 #if defined(TARGET_FREEBSD)
260 msg(msglevel,
"NOTE: TCP transport disables data channel offload on FreeBSD.");
268 msg(msglevel,
"NOTE: --remote is not defined, disabling data channel offload.");
290 msg(msglevel,
"No tls-client or tls-server option in configuration "
291 "detected. Disabling data channel offload.");
297 msg(msglevel,
"Note: dev-type not tun, disabling data channel offload.");
304 for (
int i = 0; i < l->
len; ++i)
306 if (!dco_check_option_ce(l->
array[i], msglevel))
314 if (!dco_check_option_ce(&o->
ce, msglevel))
323 msg(msglevel,
"--mode server is set. Disabling Data Channel Offload");
330 msg(msglevel,
"--windows-driver is set to '%s'. Disabling Data Channel Offload",
335 #elif defined(TARGET_LINUX)
347 int ret = net_iface_type(NULL, o->
dev, iftype);
348 if ((ret == 0) && (strcmp(iftype,
"ovpn-dco") != 0))
350 msg(msglevel,
"Interface %s exists and is non-DCO. Disabling data channel offload",
354 else if ((ret < 0) && (ret != -ENODEV))
356 msg(msglevel,
"Cannot retrieve type of device %s: %s (%d)", o->
dev,
357 strerror(-ret), ret);
362 #if defined(HAVE_LIBCAPNG)
369 if (!capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP))
371 msg(msglevel,
"--user specified but lacking CAP_SETPCAP. "
372 "Cannot retain CAP_NET_ADMIN. Disabling data channel offload");
375 if (!capng_have_capability(CAPNG_PERMITTED, CAP_NET_ADMIN))
377 msg(msglevel,
"--user specified but not permitted to retain CAP_NET_ADMIN. "
378 "Disabling data channel offload");
386 msg(msglevel,
"Note: NOT using '--topology subnet' disables data channel offload.");
392 msg(msglevel,
"Note: --management-query-proxy disables data channel offload.");
409 msg(msglevel,
"Note: --data-ciphers-fallback with cipher '%s' "
410 "disables data channel offload.", o->
ciphername);
414 #if defined(USE_COMP)
419 msg(msglevel,
"Note: '--allow-compression' is not set to 'no', disabling data channel offload.");
425 msg(msglevel,
"Consider using the '--compress migrate' option.");
434 while ((token =
strsep(&tmp_ciphers,
":")))
438 msg(msglevel,
"Note: cipher '%s' in --data-ciphers is not supported "
439 "by ovpn-dco, disabling data channel offload.", token);
454 msg(msglevel,
"OPTIONS IMPORT: Server did not request DATA_V2 packet "
455 "format required for data channel offload");
475 #ifdef TARGET_FREEBSD
513 struct sockaddr_storage *local)
515 #if ENABLE_IP_PKTINFO
529 struct sockaddr_in *sock_in4 = (
struct sockaddr_in *)local;
530 #if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
531 sock_in4->sin_addr = actual->pi.in4.ipi_addr;
532 #elif defined(IP_RECVDSTADDR)
533 sock_in4->sin_addr = actual->pi.in4;
538 sock_in4->sin_family = AF_INET;
544 struct sockaddr_in6 *sock_in6 = (
struct sockaddr_in6 *)local;
545 sock_in6->sin6_addr = actual->pi.in6.ipi6_addr;
546 sock_in6->sin6_family = AF_INET6;
566 struct sockaddr *remoteaddr, *localaddr = NULL;
567 struct sockaddr_storage local = { 0 };
583 struct in_addr vpn_ip4 = { 0 };
584 struct in_addr *vpn_addr4 = NULL;
588 vpn_addr4 = &vpn_ip4;
591 struct in6_addr *vpn_addr6 = NULL;
597 if (dco_multi_get_localaddr(m, mi, &local))
599 localaddr = (
struct sockaddr *)&local;
603 remoteaddr, vpn_addr4, vpn_addr6);
618 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
644 in_addr_t dest = htonl(addr->
v4.addr);
655 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
671 net_route_v4_del(&m->
top.
net_ctx, &ir->network, ir->netbits,
683 net_route_v6_del(&m->
top.
net_ctx, &ir6->network, ir6->netbits,
#define S_GENERATED_KEYS
The data channel keys have been generated The TLS session is fully authenticated when reaching this s...
static bool dco_check_option(int msglevel, const struct options *o)
Server-mode state structure for one single VPN tunnel.
union openvpn_sockaddr::@14 addr
enum dco_key_status dco_status
int dco_new_key(dco_context_t *dco, unsigned int peerid, int keyid, dco_key_slot_t slot, const uint8_t *encrypt_key, const uint8_t *encrypt_iv, const uint8_t *decrypt_key, const uint8_t *decrypt_iv, const char *ciphername)
bool enable_ncp_fallback
If defined fall back to ciphername if NCP fails.
static struct gc_arena gc_new(void)
const char * dco_get_supported_ciphers()
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
#define IFACE_TYPE_LEN_MAX
const char * socks_proxy_server
bool tls_item_in_cipher_list(const char *item, const char *list)
Return true iff item is present in the colon-separated zero-terminated cipher list.
struct tuntap * tuntap
Tun/tap virtual network interface.
#define TM_SIZE
Size of the tls_multi.session array.
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 link_socket_addr * lsa
struct in6_addr push_ifconfig_ipv6_local
#define COMP_F_ALLOW_COMPRESS
bool push_ifconfig_defined
in_addr_t push_ifconfig_local
struct connection_entry ce
void key_direction_state_init(struct key_direction_state *kds, int key_direction)
int dco_new_peer(dco_context_t *dco, unsigned int peerid, int sd, struct sockaddr *localaddr, struct sockaddr *remoteaddr, struct in_addr *remote_in4, struct in6_addr *remote_in6)
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
int mode
Role of this context within the OpenVPN process.
struct link_socket_info * link_socket_info
This variable is used instead link_socket->info for P2MP UDP childs.
Security parameter state for a single VPN tunnel.
enum ks_auth_state authenticated
Security parameter state of one TLS and data channel key session.
Container for unidirectional cipher and HMAC key material.
struct crypto_options crypto_options
struct context_2 c2
Level 2 context.
Container for two sets of OpenSSL cipher and/or HMAC contexts for both sending and receiving directio...
char * string_alloc(const char *str, struct gc_arena *gc)
struct mroute_addr::@1::@3 v4
static struct key_state * get_key_scan(struct tls_multi *multi, int index)
gets an item of key_state objects in the order they should be scanned by data channel modules.
struct context top
Storage structure for process-wide configuration.
enum windows_driver_type windows_driver
Key ordering of the key2.keys array.
struct compress_options comp
struct key_state key[KS_SIZE]
struct options options
Options loaded from command line or configuration file.
int dco_peer_id
This is the handle that DCO uses to identify this session with the kernel.
@ DCO_INSTALLED_SECONDARY
static int dco_p2p_add_new_peer(struct context *c)
bool dco_available(int msglevel)
@ KS_AUTH_TRUE
Key state is authenticated.
#define DCO_IROUTE_METRIC
static void dco_remove_peer(struct context *c)
static bool proto_is_udp(int proto)
Returns if the protocol being used is UDP.
struct link_socket_info info
struct link_socket_actual actual
static void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
struct link_socket * link_socket
unsigned int management_flags
struct connection_entry ** array
static bool dco_check_startup_option(int msglevel, const struct options *o)
Garbage collection arena used to keep track of dynamically allocated memory.
int key_id
Key id for this key_state, inherited from struct tls_session.
struct iroute_ipv6 * next
int dco_del_peer(dco_context_t *dco, unsigned int peerid)
struct http_proxy_options * http_proxy_options
Main OpenVPN server state structure.
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
struct key_state * tls_select_encryption_key(struct tls_multi *multi)
Selects the primary encryption that should be used to encrypt data of an outgoing packet.
struct mroute_addr::@1::@4 v6
int dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
int dco_swap_keys(dco_context_t *dco, unsigned int peer_id)
bool connection_established
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
static void gc_free(struct gc_arena *a)
struct connection_list * connection_list
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
struct key_ctx_bi key_ctx_bi
OpenSSL cipher and HMAC contexts for both sending and receiving directions.
@ WINDOWS_DRIVER_TAP_WINDOWS6
char * strsep(char **stringp, const char *delim)
static int init_key_dco_bi(struct tls_multi *multi, struct key_state *ks, const struct key2 *key2, int key_direction, const char *ciphername, bool server)
Container for bidirectional cipher and HMAC key material.
@ OVPN_KEY_SLOT_SECONDARY
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
bool push_ifconfig_ipv6_defined
struct iroute_ipv6 * iroutes_ipv6
#define COMP_F_ALLOW_ASYM
bool tun_name_is_fixed(const char *dev)
struct openvpn_sockaddr dest
#define SF_USE_IP_PKTINFO
#define KS_SIZE
Size of the tls_session.key array.
struct key keys[2]
Two unidirectional sets of key material.
const char * print_windows_driver(enum windows_driver_type windows_driver)
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
static bool dco_check_pull_options(int msglevel, const struct options *o)
struct context context
The context structure storing state for this VPN tunnel.
struct context_1 c1
Level 1 context.
int dev_type_enum(const char *dev, const char *dev_type)
openvpn_net_ctx_t net_ctx
Networking API opaque context.