OpenVPN
dco.c
Go to the documentation of this file.
1 /*
2  * OpenVPN -- An application to securely tunnel IP networks
3  * over a single TCP/UDP port, with support for SSL/TLS-based
4  * session authentication and key exchange,
5  * packet encryption, packet authentication, and
6  * packet compression.
7  *
8  * Copyright (C) 2021-2023 Arne Schwabe <arne@rfc2549.org>
9  * Copyright (C) 2021-2023 Antonio Quartulli <a@unstable.cc>
10  * Copyright (C) 2021-2023 OpenVPN Inc <sales@openvpn.net>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program (see the file COPYING included with this
23  * distribution); if not, write to the Free Software Foundation, Inc.,
24  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25  */
26 
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30 
31 #if defined(ENABLE_DCO)
32 
33 #include "syshead.h"
34 #include "crypto.h"
35 #include "dco.h"
36 #include "errlevel.h"
37 #include "multi.h"
38 #include "networking.h"
39 #include "openvpn.h"
40 #include "options.h"
41 #include "ssl_common.h"
42 #include "ssl_ncp.h"
43 #include "tun.h"
44 
45 #ifdef HAVE_LIBCAPNG
46 #include <cap-ng.h>
47 #endif
48 
49 static int
50 dco_install_key(struct tls_multi *multi, struct key_state *ks,
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)
54 
55 {
56  msg(D_DCO_DEBUG, "%s: peer_id=%d keyid=%d, currently %d keys installed",
57  __func__, multi->dco_peer_id, ks->key_id, multi->dco_keys_installed);
58 
59  /* Install a key in the PRIMARY slot only when no other key exist.
60  * From that moment on, any new key will be installed in the SECONDARY
61  * slot and will be promoted to PRIMARY when userspace says so (a swap
62  * will be performed in that case)
63  */
64  dco_key_slot_t slot = OVPN_KEY_SLOT_PRIMARY;
65  if (multi->dco_keys_installed > 0)
66  {
68  }
69 
70  int ret = dco_new_key(multi->dco, multi->dco_peer_id, ks->key_id, slot,
71  encrypt_key, encrypt_iv,
72  decrypt_key, decrypt_iv,
73  ciphername);
74  if ((ret == 0) && (multi->dco_keys_installed < 2))
75  {
76  multi->dco_keys_installed++;
79  }
80 
81  return ret;
82 }
83 
84 int
85 init_key_dco_bi(struct tls_multi *multi, struct key_state *ks,
86  const struct key2 *key2, int key_direction,
87  const char *ciphername, bool server)
88 {
89  struct key_direction_state kds;
90  key_direction_state_init(&kds, key_direction);
91 
92  return dco_install_key(multi, ks,
93  key2->keys[kds.out_key].cipher,
94  key2->keys[(int)server].hmac,
95  key2->keys[kds.in_key].cipher,
96  key2->keys[1 - (int)server].hmac,
97  ciphername);
98 }
99 
108 static struct key_state *
109 dco_get_secondary_key(struct tls_multi *multi, const struct key_state *primary)
110 {
111  for (int i = 0; i < KEY_SCAN_SIZE; ++i)
112  {
113  struct key_state *ks = get_key_scan(multi, i);
114  struct key_ctx_bi *key = &ks->crypto_options.key_ctx_bi;
115 
116  if (ks == primary)
117  {
118  continue;
119  }
120 
121  if (ks->state >= S_GENERATED_KEYS && ks->authenticated == KS_AUTH_TRUE)
122  {
123  ASSERT(key->initialized);
124  return ks;
125  }
126  }
127 
128  return NULL;
129 }
130 
131 bool
132 dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
133 {
134  /* this function checks if keys have to be swapped or erased, therefore it
135  * can't do much if we don't have any key installed
136  */
137  if (multi->dco_keys_installed == 0)
138  {
139  return true;
140  }
141 
142  struct key_state *primary = tls_select_encryption_key(multi);
143  /* no primary key available -> no usable key exists, therefore we should
144  * tell DCO to simply wipe all keys
145  */
146  if (!primary)
147  {
148  msg(D_DCO, "No encryption key found. Purging data channel keys");
149 
150  int ret = dco_del_key(dco, multi->dco_peer_id, OVPN_KEY_SLOT_PRIMARY);
151  if (ret < 0)
152  {
153  msg(D_DCO, "Cannot delete primary key during wipe: %s (%d)", strerror(-ret), ret);
154  return false;
155  }
156 
157  ret = dco_del_key(dco, multi->dco_peer_id, OVPN_KEY_SLOT_SECONDARY);
158  if (ret < 0)
159  {
160  msg(D_DCO, "Cannot delete secondary key during wipe: %s (%d)", strerror(-ret), ret);
161  return false;
162  }
163 
164  multi->dco_keys_installed = 0;
165  return true;
166  }
167 
168  /* if we have a primary key, it must have been installed already (keys
169  * are installed upon generation in the TLS code)
170  */
171  ASSERT(primary->dco_status != DCO_NOT_INSTALLED);
172 
173  struct key_state *secondary = dco_get_secondary_key(multi, primary);
174  /* if the current primary key was installed as secondary in DCO,
175  * this means we have promoted it since installation in DCO, and
176  * we now need to tell DCO to swap keys
177  */
178  if (primary->dco_status == DCO_INSTALLED_SECONDARY)
179  {
180  if (secondary)
181  {
182  msg(D_DCO_DEBUG, "Swapping primary and secondary keys to "
183  "primary-id=%d secondary-id=%d",
184  primary->key_id, secondary->key_id);
185  }
186  else
187  {
188  msg(D_DCO_DEBUG, "Swapping primary and secondary keys to"
189  "primary-id=%d secondary-id=(to be deleted)",
190  primary->key_id);
191  }
192 
193  int ret = dco_swap_keys(dco, multi->dco_peer_id);
194  if (ret < 0)
195  {
196  msg(D_DCO, "Cannot swap keys: %s (%d)", strerror(-ret), ret);
197  return false;
198  }
199 
201  if (secondary)
202  {
203  ASSERT(secondary->dco_status == DCO_INSTALLED_PRIMARY);
204  secondary->dco_status = DCO_INSTALLED_SECONDARY;
205  }
206  }
207 
208  /* if we have no secondary key anymore, inform DCO about it */
209  if (!secondary && multi->dco_keys_installed == 2)
210  {
211  int ret = dco_del_key(dco, multi->dco_peer_id, OVPN_KEY_SLOT_SECONDARY);
212  if (ret < 0)
213  {
214  msg(D_DCO, "Cannot delete secondary key: %s (%d)", strerror(-ret), ret);
215  return false;
216  }
217  multi->dco_keys_installed = 1;
218  }
219 
220  /* all keys that are not installed are set to NOT installed. Include also
221  * keys that might even be considered as active keys to be sure*/
222  for (int i = 0; i < TM_SIZE; ++i)
223  {
224  for (int j = 0; j < KS_SIZE; j++)
225  {
226  struct key_state *ks = &multi->session[i].key[j];
227  if (ks != primary && ks != secondary)
228  {
230  }
231  }
232  }
233  return true;
234 }
235 
236 static bool
237 dco_check_option_ce(const struct connection_entry *ce, int msglevel)
238 {
239  if (ce->fragment)
240  {
241  msg(msglevel, "Note: --fragment disables data channel offload.");
242  return false;
243  }
244 
245  if (ce->http_proxy_options)
246  {
247  msg(msglevel, "Note: --http-proxy disables data channel offload.");
248  return false;
249  }
250 
251  if (ce->socks_proxy_server)
252  {
253  msg(msglevel, "Note: --socks-proxy disables data channel offload.");
254  return false;
255  }
256 
257 #if defined(TARGET_FREEBSD)
258  if (!proto_is_udp(ce->proto))
259  {
260  msg(msglevel, "NOTE: TCP transport disables data channel offload on FreeBSD.");
261  return false;
262  }
263 #endif
264 
265 #if defined(_WIN32)
266  if (!ce->remote)
267  {
268  msg(msglevel, "NOTE: --remote is not defined, disabling data channel offload.");
269  return false;
270  }
271 #endif
272 
273  return true;
274 }
275 
276 bool
277 dco_check_startup_option(int msglevel, const struct options *o)
278 {
279  /* check if no dev name was specified at all. In the case,
280  * later logic will most likely stop OpenVPN, so no need to
281  * print any message here.
282  */
283  if (!o->dev)
284  {
285  return false;
286  }
287 
288  if (!o->tls_client && !o->tls_server)
289  {
290  msg(msglevel, "No tls-client or tls-server option in configuration "
291  "detected. Disabling data channel offload.");
292  return false;
293  }
294 
295  if (dev_type_enum(o->dev, o->dev_type) != DEV_TYPE_TUN)
296  {
297  msg(msglevel, "Note: dev-type not tun, disabling data channel offload.");
298  return false;
299  }
300 
301  if (o->connection_list)
302  {
303  const struct connection_list *l = o->connection_list;
304  for (int i = 0; i < l->len; ++i)
305  {
306  if (!dco_check_option_ce(l->array[i], msglevel))
307  {
308  return false;
309  }
310  }
311  }
312  else
313  {
314  if (!dco_check_option_ce(&o->ce, msglevel))
315  {
316  return false;
317  }
318  }
319 
320 #if defined(_WIN32)
321  if (o->mode == MODE_SERVER)
322  {
323  msg(msglevel, "--mode server is set. Disabling Data Channel Offload");
324  return false;
325  }
326 
329  {
330  msg(msglevel, "--windows-driver is set to '%s'. Disabling Data Channel Offload",
332  return false;
333  }
334 
335 #elif defined(TARGET_LINUX)
336  /* if the device name is fixed, we need to check if an interface with this
337  * name already exists. IF it does, it must be a DCO interface, otherwise
338  * DCO has to be disabled in order to continue.
339  */
340  if (tun_name_is_fixed(o->dev))
341  {
342  char iftype[IFACE_TYPE_LEN_MAX];
343  /* we pass NULL as net_ctx because using DCO on Linux implies that we
344  * are using SITNL and the latter does not need any context. This way we
345  * don't need to have the net_ctx percolate all the way here
346  */
347  int ret = net_iface_type(NULL, o->dev, iftype);
348  if ((ret == 0) && (strcmp(iftype, "ovpn-dco") != 0))
349  {
350  msg(msglevel, "Interface %s exists and is non-DCO. Disabling data channel offload",
351  o->dev);
352  return false;
353  }
354  else if ((ret < 0) && (ret != -ENODEV))
355  {
356  msg(msglevel, "Cannot retrieve type of device %s: %s (%d)", o->dev,
357  strerror(-ret), ret);
358  }
359  }
360 #endif /* if defined(_WIN32) */
361 
362 #if defined(HAVE_LIBCAPNG)
363  /* DCO can't operate without CAP_NET_ADMIN. To retain it when switching user
364  * we need CAP_SETPCAP. CAP_NET_ADMIN also needs to be part of the permitted set
365  * of capabilities in order to retain it.
366  */
367  if (o->username)
368  {
369  if (!capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP))
370  {
371  msg(msglevel, "--user specified but lacking CAP_SETPCAP. "
372  "Cannot retain CAP_NET_ADMIN. Disabling data channel offload");
373  return false;
374  }
375  if (!capng_have_capability(CAPNG_PERMITTED, CAP_NET_ADMIN))
376  {
377  msg(msglevel, "--user specified but not permitted to retain CAP_NET_ADMIN. "
378  "Disabling data channel offload");
379  return false;
380  }
381  }
382 #endif /* if defined(HAVE_LIBCAPNG) */
383 
384  if (o->mode == MODE_SERVER && o->topology != TOP_SUBNET)
385  {
386  msg(msglevel, "Note: NOT using '--topology subnet' disables data channel offload.");
387  return false;
388  }
389 
390  /* now that all options have been confirmed to be supported, check
391  * if DCO is truly available on the system
392  */
393  return dco_available(msglevel);
394 }
395 
396 bool
397 dco_check_option(int msglevel, const struct options *o)
398 {
399  /* At this point the ciphers have already been normalised */
400  if (o->enable_ncp_fallback
402  {
403  msg(msglevel, "Note: --data-cipher-fallback with cipher '%s' "
404  "disables data channel offload.", o->ciphername);
405  return false;
406  }
407 
408 #if defined(USE_COMP)
409  if (o->comp.alg != COMP_ALG_UNDEF
412  {
413  msg(msglevel, "Note: '--allow-compression' is not set to 'no', disabling data channel offload.");
414 
415  if (o->mode == MODE_SERVER && !(o->comp.flags & COMP_F_MIGRATE))
416  {
417  /* We can end up here from the multi.c call, only print the
418  * note if it is not already enabled */
419  msg(msglevel, "Consider using the '--compress migrate' option.");
420  }
421  return false;
422  }
423 #endif
424 
425  struct gc_arena gc = gc_new();
426  char *tmp_ciphers = string_alloc(o->ncp_ciphers, &gc);
427  const char *token;
428  while ((token = strsep(&tmp_ciphers, ":")))
429  {
431  {
432  msg(msglevel, "Note: cipher '%s' in --data-ciphers is not supported "
433  "by ovpn-dco, disabling data channel offload.", token);
434  gc_free(&gc);
435  return false;
436  }
437  }
438  gc_free(&gc);
439 
440  return true;
441 }
442 
443 bool
444 dco_check_pull_options(int msglevel, const struct options *o)
445 {
446  if (!o->use_peer_id)
447  {
448  msg(msglevel, "OPTIONS IMPORT: Server did not request DATA_V2 packet "
449  "format required for data channel offload");
450  return false;
451  }
452  return true;
453 }
454 
455 int
456 dco_p2p_add_new_peer(struct context *c)
457 {
458  if (!dco_enabled(&c->options))
459  {
460  return 0;
461  }
462 
463  struct link_socket *ls = c->c2.link_socket;
464 
466 
467  struct sockaddr *remoteaddr = &ls->info.lsa->actual.dest.addr.sa;
468  struct tls_multi *multi = c->c2.tls_multi;
469 #ifdef TARGET_FREEBSD
470  /* In Linux in P2P mode the kernel automatically removes an existing peer
471  * when adding a new peer. FreeBSD needs to explicitly be told to do that */
472  if (c->c2.tls_multi->dco_peer_id != -1)
473  {
475  c->c2.tls_multi->dco_peer_id = -1;
476  }
477 #endif
478  int ret = dco_new_peer(&c->c1.tuntap->dco, multi->peer_id,
479  c->c2.link_socket->sd, NULL, remoteaddr, NULL, NULL);
480  if (ret < 0)
481  {
482  return ret;
483  }
484 
485  c->c2.tls_multi->dco_peer_id = multi->peer_id;
486 
487  return 0;
488 }
489 
490 void
491 dco_remove_peer(struct context *c)
492 {
493  if (!dco_enabled(&c->options))
494  {
495  return;
496  }
497 
498  if (c->c1.tuntap && c->c2.tls_multi && c->c2.tls_multi->dco_peer_id != -1)
499  {
501  c->c2.tls_multi->dco_peer_id = -1;
502  }
503 }
504 
505 static bool
506 dco_multi_get_localaddr(struct multi_context *m, struct multi_instance *mi,
507  struct sockaddr_storage *local)
508 {
509 #if ENABLE_IP_PKTINFO
510  struct context *c = &mi->context;
511 
513  {
514  return false;
515  }
516 
517  struct link_socket_actual *actual = &c->c2.link_socket_info->lsa->actual;
518 
519  switch (actual->dest.addr.sa.sa_family)
520  {
521  case AF_INET:
522  {
523  struct sockaddr_in *sock_in4 = (struct sockaddr_in *)local;
524 #if defined(HAVE_IN_PKTINFO) && defined(HAVE_IPI_SPEC_DST)
525  sock_in4->sin_addr = actual->pi.in4.ipi_addr;
526 #elif defined(IP_RECVDSTADDR)
527  sock_in4->sin_addr = actual->pi.in4;
528 #else
529  /* source IP not available on this platform */
530  return false;
531 #endif
532  sock_in4->sin_family = AF_INET;
533  break;
534  }
535 
536  case AF_INET6:
537  {
538  struct sockaddr_in6 *sock_in6 = (struct sockaddr_in6 *)local;
539  sock_in6->sin6_addr = actual->pi.in6.ipi6_addr;
540  sock_in6->sin6_family = AF_INET6;
541  break;
542  }
543 
544  default:
545  ASSERT(false);
546  }
547 
548  return true;
549 #else /* if ENABLE_IP_PKTINFO */
550  return false;
551 #endif /* if ENABLE_IP_PKTINFO */
552 }
553 
554 int
556 {
557  struct context *c = &mi->context;
558 
559  int peer_id = c->c2.tls_multi->peer_id;
560  struct sockaddr *remoteaddr, *localaddr = NULL;
561  struct sockaddr_storage local = { 0 };
562  int sd = c->c2.link_socket->sd;
563 
564 
565  if (c->mode == CM_CHILD_TCP)
566  {
567  /* the remote address will be inferred from the TCP socket endpoint */
568  remoteaddr = NULL;
569  }
570  else
571  {
573  remoteaddr = &c->c2.link_socket_info->lsa->actual.dest.addr.sa;
574  }
575 
576  /* In server mode we need to fetch the remote addresses from the push config */
577  struct in_addr vpn_ip4 = { 0 };
578  struct in_addr *vpn_addr4 = NULL;
579  if (c->c2.push_ifconfig_defined)
580  {
581  vpn_ip4.s_addr = htonl(c->c2.push_ifconfig_local);
582  vpn_addr4 = &vpn_ip4;
583  }
584 
585  struct in6_addr *vpn_addr6 = NULL;
587  {
588  vpn_addr6 = &c->c2.push_ifconfig_ipv6_local;
589  }
590 
591  if (dco_multi_get_localaddr(m, mi, &local))
592  {
593  localaddr = (struct sockaddr *)&local;
594  }
595 
596  int ret = dco_new_peer(&c->c1.tuntap->dco, peer_id, sd, localaddr,
597  remoteaddr, vpn_addr4, vpn_addr6);
598  if (ret < 0)
599  {
600  return ret;
601  }
602 
603  c->c2.tls_multi->dco_peer_id = peer_id;
604 
605  return 0;
606 }
607 
608 void
609 dco_install_iroute(struct multi_context *m, struct multi_instance *mi,
610  struct mroute_addr *addr)
611 {
612 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
613  if (!dco_enabled(&m->top.options))
614  {
615  return;
616  }
617 
618  int addrtype = (addr->type & MR_ADDR_MASK);
619 
620  /* If we do not have local IP addr to install, skip the route */
621  if ((addrtype == MR_ADDR_IPV6 && !mi->context.c2.push_ifconfig_ipv6_defined)
622  || (addrtype == MR_ADDR_IPV4 && !mi->context.c2.push_ifconfig_defined))
623  {
624  return;
625  }
626 
627  struct context *c = &mi->context;
628  const char *dev = c->c1.tuntap->actual_name;
629 
630  if (addrtype == MR_ADDR_IPV6)
631  {
632  net_route_v6_add(&m->top.net_ctx, &addr->v6.addr, addr->netbits,
633  &mi->context.c2.push_ifconfig_ipv6_local, dev, 0,
635  }
636  else if (addrtype == MR_ADDR_IPV4)
637  {
638  in_addr_t dest = htonl(addr->v4.addr);
639  net_route_v4_add(&m->top.net_ctx, &dest, addr->netbits,
640  &mi->context.c2.push_ifconfig_local, dev, 0,
642  }
643 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) */
644 }
645 
646 void
647 dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
648 {
649 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
650  if (!dco_enabled(&m->top.options))
651  {
652  return;
653  }
655 
656  struct context *c = &mi->context;
657  const char *dev = c->c1.tuntap->actual_name;
658 
660  {
661  for (const struct iroute *ir = c->options.iroutes;
662  ir;
663  ir = ir->next)
664  {
665  net_route_v4_del(&m->top.net_ctx, &ir->network, ir->netbits,
666  &mi->context.c2.push_ifconfig_local, dev,
667  0, DCO_IROUTE_METRIC);
668  }
669  }
670 
672  {
673  for (const struct iroute_ipv6 *ir6 = c->options.iroutes_ipv6;
674  ir6;
675  ir6 = ir6->next)
676  {
677  net_route_v6_del(&m->top.net_ctx, &ir6->network, ir6->netbits,
679  0, DCO_IROUTE_METRIC);
680  }
681  }
682 #endif /* if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) */
683 }
684 
685 #endif /* defined(ENABLE_DCO) */
S_GENERATED_KEYS
#define S_GENERATED_KEYS
The data channel keys have been generated The TLS session is fully authenticated when reaching this s...
Definition: ssl_common.h:98
MR_ADDR_MASK
#define MR_ADDR_MASK
Definition: mroute.h:64
dco_check_option
static bool dco_check_option(int msglevel, const struct options *o)
Definition: dco.h:269
multi_instance
Server-mode state structure for one single VPN tunnel.
Definition: multi.h:101
iroute
Definition: route.h:234
D_DCO_DEBUG
#define D_DCO_DEBUG
Definition: errlevel.h:118
openvpn_sockaddr::addr
union openvpn_sockaddr::@14 addr
key_state::dco_status
enum dco_key_status dco_status
Definition: ssl_common.h:259
compress_options::alg
int alg
Definition: comp.h:66
options::use_peer_id
bool use_peer_id
Definition: options.h:683
dco_new_key
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)
Definition: dco_win.c:295
options::enable_ncp_fallback
bool enable_ncp_fallback
If defined fall back to ciphername if NCP fails.
Definition: options.h:558
gc_new
static struct gc_arena gc_new(void)
Definition: buffer.h:1031
dco_get_supported_ciphers
const char * dco_get_supported_ciphers()
Definition: dco_win.c:469
DEV_TYPE_TUN
#define DEV_TYPE_TUN
Definition: proto.h:37
context_2::tls_multi
struct tls_multi * tls_multi
TLS state structure for this VPN tunnel.
Definition: openvpn.h:326
networking.h
IFACE_TYPE_LEN_MAX
#define IFACE_TYPE_LEN_MAX
Definition: networking.h:26
connection_entry::socks_proxy_server
const char * socks_proxy_server
Definition: options.h:114
tls_item_in_cipher_list
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.
Definition: ssl_ncp.c:207
context_1::tuntap
struct tuntap * tuntap
Tun/tap virtual network interface.
Definition: openvpn.h:170
TM_SIZE
#define TM_SIZE
Size of the tls_multi.session array.
Definition: ssl_common.h:530
context
Contains all state information for one tunnel.
Definition: openvpn.h:476
tls_multi::session
struct tls_session session[TM_SIZE]
Array of tls_session objects representing control channel sessions with the remote peer.
Definition: ssl_common.h:672
options::topology
int topology
Definition: options.h:307
options::dev_type
const char * dev_type
Definition: options.h:304
context_2::push_ifconfig_ipv6_local
struct in6_addr push_ifconfig_ipv6_local
Definition: openvpn.h:438
options::iroutes
struct iroute * iroutes
Definition: options.h:495
COMP_F_ALLOW_COMPRESS
#define COMP_F_ALLOW_COMPRESS
Definition: comp.h:36
options::tls_client
bool tls_client
Definition: options.h:575
context_2::push_ifconfig_defined
bool push_ifconfig_defined
Definition: openvpn.h:431
openvpn.h
context_2::push_ifconfig_local
in_addr_t push_ifconfig_local
Definition: openvpn.h:433
options::mode
int mode
Definition: options.h:247
options::ce
struct connection_entry ce
Definition: options.h:275
TOP_SUBNET
#define TOP_SUBNET
Definition: proto.h:45
key_direction_state_init
void key_direction_state_init(struct key_direction_state *kds, int key_direction)
Definition: crypto.c:1478
mroute_addr::netbits
uint8_t netbits
Definition: mroute.h:79
options.h
dco_new_peer
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)
Definition: dco_win.c:248
key::hmac
uint8_t hmac[MAX_HMAC_KEY_LENGTH]
Key material for HMAC operations.
Definition: crypto.h:153
context::mode
int mode
Role of this context within the OpenVPN process.
Definition: openvpn.h:490
context_2::link_socket_info
struct link_socket_info * link_socket_info
This variable is used instead link_socket->info for P2MP UDP childs.
Definition: openvpn.h:244
MODE_SERVER
#define MODE_SERVER
Definition: options.h:246
tls_multi
Security parameter state for a single VPN tunnel.
Definition: ssl_common.h:587
options::tls_server
bool tls_server
Definition: options.h:574
key_state::authenticated
enum ks_auth_state authenticated
Definition: ssl_common.h:247
connection_entry
Definition: options.h:97
tls_multi::dco
dco_context_t * dco
Definition: ssl_common.h:689
key_state
Security parameter state of one TLS and data channel key session.
Definition: ssl_common.h:195
KEY_SCAN_SIZE
#define KEY_SCAN_SIZE
Definition: ssl_common.h:546
key
Container for unidirectional cipher and HMAC key material.
Definition: crypto.h:149
iroute::next
struct iroute * next
Definition: route.h:237
tuntap::actual_name
char * actual_name
Definition: tun.h:186
key_state::crypto_options
struct crypto_options crypto_options
Definition: ssl_common.h:225
TUNNEL_TYPE
#define TUNNEL_TYPE(tt)
Definition: tun.h:173
connection_list::len
int len
Definition: options.h:185
context::c2
struct context_2 c2
Level 2 context.
Definition: openvpn.h:517
MR_ADDR_IPV6
#define MR_ADDR_IPV6
Definition: mroute.h:63
key_ctx_bi
Container for two sets of OpenSSL cipher and/or HMAC contexts for both sending and receiving directio...
Definition: crypto.h:217
string_alloc
char * string_alloc(const char *str, struct gc_arena *gc)
Definition: buffer.c:693
mroute_addr::v4
struct mroute_addr::@1::@3 v4
options::dev
const char * dev
Definition: options.h:303
ASSERT
#define ASSERT(x)
Definition: error.h:201
D_DCO
#define D_DCO
Definition: errlevel.h:94
get_key_scan
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.
Definition: ssl_common.h:696
CM_CHILD_TCP
#define CM_CHILD_TCP
Definition: openvpn.h:489
multi_context::top
struct context top
Storage structure for process-wide configuration.
Definition: multi.h:195
connection_list
Definition: options.h:182
options::windows_driver
enum windows_driver_type windows_driver
Definition: options.h:680
tun.h
openvpn_sockaddr::sa
struct sockaddr sa
Definition: socket.h:69
key_direction_state
Key ordering of the key2.keys array.
Definition: crypto.h:196
COMP_F_MIGRATE
#define COMP_F_MIGRATE
Definition: comp.h:40
options::ncp_ciphers
const char * ncp_ciphers
Definition: options.h:560
options::comp
struct compress_options comp
Definition: options.h:396
tls_session::key
struct key_state key[KS_SIZE]
Definition: ssl_common.h:506
COMP_ALG_UNDEF
#define COMP_ALG_UNDEF
Definition: comp.h:45
WINDOWS_DRIVER_WINTUN
@ WINDOWS_DRIVER_WINTUN
Definition: tun.h:52
context::options
struct options options
Options loaded from command line or configuration file.
Definition: openvpn.h:478
MR_ADDR_IPV4
#define MR_ADDR_IPV4
Definition: mroute.h:62
options
Definition: options.h:236
crypto.h
tls_multi::dco_peer_id
int dco_peer_id
This is the handle that DCO uses to identify this session with the kernel.
Definition: ssl_common.h:687
DCO_INSTALLED_SECONDARY
@ DCO_INSTALLED_SECONDARY
Definition: ssl_common.h:174
multi.h
dco_context_t
void * dco_context_t
Definition: dco.h:254
errlevel.h
dco_p2p_add_new_peer
static int dco_p2p_add_new_peer(struct context *c)
Definition: dco.h:331
OVPN_KEY_SLOT_PRIMARY
@ OVPN_KEY_SLOT_PRIMARY
Definition: ovpn_dco_freebsd.h:48
compress_options::flags
unsigned int flags
Definition: comp.h:67
dco_available
bool dco_available(int msglevel)
Definition: dco_win.c:360
KS_AUTH_TRUE
@ KS_AUTH_TRUE
Key state is authenticated.
Definition: ssl_common.h:147
DCO_IROUTE_METRIC
#define DCO_IROUTE_METRIC
Definition: dco.h:47
dco_remove_peer
static void dco_remove_peer(struct context *c)
Definition: dco.h:344
proto_is_udp
static bool proto_is_udp(int proto)
Returns if the protocol being used is UDP.
Definition: socket.h:573
tls_multi::dco_keys_installed
int dco_keys_installed
Definition: ssl_common.h:679
dco_delete_iroutes
static void dco_delete_iroutes(struct multi_context *m, struct multi_instance *mi)
Definition: dco.h:361
DCO_INSTALLED_PRIMARY
@ DCO_INSTALLED_PRIMARY
Definition: ssl_common.h:173
key_state::state
int state
Definition: ssl_common.h:197
context_2::link_socket
struct link_socket * link_socket
Definition: openvpn.h:240
mroute_addr
Definition: mroute.h:75
syshead.h
connection_list::array
struct connection_entry ** array
Definition: options.h:187
dco_check_startup_option
static bool dco_check_startup_option(int msglevel, const struct options *o)
Definition: dco.h:275
gc_arena
Garbage collection arena used to keep track of dynamically allocated memory.
Definition: buffer.h:116
key_state::key_id
int key_id
Key id for this key_state, inherited from struct tls_session.
Definition: ssl_common.h:205
iroute_ipv6::next
struct iroute_ipv6 * next
Definition: route.h:243
dco_del_peer
int dco_del_peer(dco_context_t *dco, unsigned int peerid)
Definition: dco_win.c:257
connection_entry::http_proxy_options
struct http_proxy_options * http_proxy_options
Definition: options.h:113
multi_context
Main OpenVPN server state structure.
Definition: multi.h:155
dco_enabled
static bool dco_enabled(const struct options *o)
Returns whether the current configuration has dco enabled.
Definition: options.h:908
dco.h
tls_select_encryption_key
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.
Definition: ssl.c:3820
mroute_addr::v6
struct mroute_addr::@1::@4 v6
dco_del_key
int dco_del_key(dco_context_t *dco, unsigned int peerid, dco_key_slot_t slot)
Definition: dco_win.c:336
dco_swap_keys
int dco_swap_keys(dco_context_t *dco, unsigned int peer_id)
Definition: dco_win.c:345
dco_update_keys
static bool dco_update_keys(dco_context_t *dco, struct tls_multi *multi)
Definition: dco.h:324
connection_entry::remote
const char * remote
Definition: options.h:105
tuntap::dco
dco_context_t dco
Definition: tun.h:234
iroute_ipv6
Definition: route.h:240
gc_free
static void gc_free(struct gc_arena *a)
Definition: buffer.h:1039
mroute_addr::type
uint8_t type
Definition: mroute.h:78
options::connection_list
struct connection_list * connection_list
Definition: options.h:276
key::cipher
uint8_t cipher[MAX_CIPHER_KEY_LENGTH]
Key material for cipher operations.
Definition: crypto.h:151
crypto_options::key_ctx_bi
struct key_ctx_bi key_ctx_bi
OpenSSL cipher and HMAC contexts for both sending and receiving directions.
Definition: crypto.h:232
options::sockflags
unsigned int sockflags
Definition: options.h:407
options::username
const char * username
Definition: options.h:360
WINDOWS_DRIVER_TAP_WINDOWS6
@ WINDOWS_DRIVER_TAP_WINDOWS6
Definition: tun.h:51
strsep
char * strsep(char **stringp, const char *delim)
Definition: compat-strsep.c:36
config.h
ssl_ncp.h
ssl_common.h
connection_entry::fragment
int fragment
Definition: options.h:132
tls_multi::peer_id
uint32_t peer_id
Definition: ssl_common.h:663
init_key_dco_bi
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)
Definition: dco.h:316
key2
Container for bidirectional cipher and HMAC key material.
Definition: crypto.h:179
connection_entry::proto
int proto
Definition: options.h:99
OVPN_KEY_SLOT_SECONDARY
@ OVPN_KEY_SLOT_SECONDARY
Definition: ovpn_dco_freebsd.h:49
dco_multi_add_new_peer
static int dco_multi_add_new_peer(struct multi_context *m, struct multi_instance *mi)
Definition: dco.h:349
DCO_NOT_INSTALLED
@ DCO_NOT_INSTALLED
Definition: ssl_common.h:172
context_2::push_ifconfig_ipv6_defined
bool push_ifconfig_ipv6_defined
Definition: openvpn.h:437
options::iroutes_ipv6
struct iroute_ipv6 * iroutes_ipv6
Definition: options.h:496
COMP_F_ALLOW_ASYM
#define COMP_F_ALLOW_ASYM
Definition: comp.h:41
tun_name_is_fixed
bool tun_name_is_fixed(const char *dev)
Definition: tun.c:1881
SF_USE_IP_PKTINFO
#define SF_USE_IP_PKTINFO
Definition: socket.h:204
KS_SIZE
#define KS_SIZE
Size of the tls_session.key array.
Definition: ssl_common.h:448
key2::keys
struct key keys[2]
Two unidirectional sets of key material.
Definition: crypto.h:183
print_windows_driver
const char * print_windows_driver(enum windows_driver_type windows_driver)
Definition: tun.c:7145
options::ciphername
const char * ciphername
Definition: options.h:557
msg
#define msg(flags,...)
Definition: error.h:150
dco_install_iroute
static void dco_install_iroute(struct multi_context *m, struct multi_instance *mi, struct mroute_addr *addr)
Definition: dco.h:355
dco_check_pull_options
static bool dco_check_pull_options(int msglevel, const struct options *o)
Definition: dco.h:281
multi_instance::context
struct context context
The context structure storing state for this VPN tunnel.
Definition: multi.h:136
context::c1
struct context_1 c1
Level 1 context.
Definition: openvpn.h:516
dev_type_enum
int dev_type_enum(const char *dev, const char *dev_type)
Definition: tun.c:436
context::net_ctx
openvpn_net_ctx_t net_ctx
Networking API opaque context.
Definition: openvpn.h:501