mirror of
https://github.com/OpenVPN/openvpn.git
synced 2026-05-28 04:03:29 -04:00
dco: port core/context infrastructure needed for backport of commit 7791f53
Some checks are pending
Build / Check code style with Uncrustify (push) Waiting to run
Build / gcc-mingw - x64 - OSSL (push) Waiting to run
Build / gcc-mingw - x86 - OSSL (push) Waiting to run
Build / mingw unittest argv - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest auth_token - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest buffer - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest crypto - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest cryptoapi - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest misc - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest ncp - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest packet_id - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest pkt - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest provider - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest tls_crypt - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest argv - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest auth_token - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest buffer - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest crypto - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest cryptoapi - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest misc - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest ncp - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest packet_id - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest pkt - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest provider - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest tls_crypt - x86 - OSSL (push) Blocked by required conditions
Build / gcc - ubuntu-24.04 - OpenSSL 3.0.13 --enable-pkcs11 (push) Waiting to run
Build / gcc - ubuntu-22.04 - OpenSSL 3.0.2 --enable-pkcs11 (push) Waiting to run
Build / gcc - ubuntu-22.04 - mbed TLS 2.28.0 (push) Waiting to run
Build / clang-asan - ubuntu-22.04 - mbedtls (push) Waiting to run
Build / clang-asan - ubuntu-22.04 - openssl (push) Waiting to run
Build / clang-asan - ubuntu-24.04 - mbedtls (push) Waiting to run
Build / clang-asan - ubuntu-24.04 - openssl (push) Waiting to run
Build / macos-13 - libressl - asan (push) Waiting to run
Build / macos-13 - openssl@1.1 - asan (push) Waiting to run
Build / macos-13 - openssl@3 - asan (push) Waiting to run
Build / macos-14 - libressl - asan (push) Waiting to run
Build / macos-14 - openssl@1.1 - asan (push) Waiting to run
Build / macos-14 - openssl@3 - asan (push) Waiting to run
Build / macos-15 - libressl - asan (push) Waiting to run
Build / macos-15 - openssl@1.1 - asan (push) Waiting to run
Build / macos-15 - openssl@3 - asan (push) Waiting to run
Build / macos-13 - libressl - normal (push) Waiting to run
Build / macos-13 - openssl@1.1 - normal (push) Waiting to run
Build / macos-13 - openssl@3 - normal (push) Waiting to run
Build / macos-14 - libressl - normal (push) Waiting to run
Build / macos-14 - openssl@1.1 - normal (push) Waiting to run
Build / macos-14 - openssl@3 - normal (push) Waiting to run
Build / macos-15 - libressl - normal (push) Waiting to run
Build / macos-15 - openssl@1.1 - normal (push) Waiting to run
Build / macos-15 - openssl@3 - normal (push) Waiting to run
Build / msbuild - amd64 - openssl (push) Waiting to run
Build / msbuild - arm64 - openssl (push) Waiting to run
Build / msbuild - x86 - openssl (push) Waiting to run
Build / clang asan - ubuntu-22.04 - libressl (push) Waiting to run
Build / gcc normal - ubuntu-22.04 - libressl (push) Waiting to run
Some checks are pending
Build / Check code style with Uncrustify (push) Waiting to run
Build / gcc-mingw - x64 - OSSL (push) Waiting to run
Build / gcc-mingw - x86 - OSSL (push) Waiting to run
Build / mingw unittest argv - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest auth_token - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest buffer - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest crypto - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest cryptoapi - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest misc - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest ncp - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest packet_id - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest pkt - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest provider - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest tls_crypt - x64 - OSSL (push) Blocked by required conditions
Build / mingw unittest argv - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest auth_token - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest buffer - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest crypto - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest cryptoapi - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest misc - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest ncp - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest packet_id - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest pkt - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest provider - x86 - OSSL (push) Blocked by required conditions
Build / mingw unittest tls_crypt - x86 - OSSL (push) Blocked by required conditions
Build / gcc - ubuntu-24.04 - OpenSSL 3.0.13 --enable-pkcs11 (push) Waiting to run
Build / gcc - ubuntu-22.04 - OpenSSL 3.0.2 --enable-pkcs11 (push) Waiting to run
Build / gcc - ubuntu-22.04 - mbed TLS 2.28.0 (push) Waiting to run
Build / clang-asan - ubuntu-22.04 - mbedtls (push) Waiting to run
Build / clang-asan - ubuntu-22.04 - openssl (push) Waiting to run
Build / clang-asan - ubuntu-24.04 - mbedtls (push) Waiting to run
Build / clang-asan - ubuntu-24.04 - openssl (push) Waiting to run
Build / macos-13 - libressl - asan (push) Waiting to run
Build / macos-13 - openssl@1.1 - asan (push) Waiting to run
Build / macos-13 - openssl@3 - asan (push) Waiting to run
Build / macos-14 - libressl - asan (push) Waiting to run
Build / macos-14 - openssl@1.1 - asan (push) Waiting to run
Build / macos-14 - openssl@3 - asan (push) Waiting to run
Build / macos-15 - libressl - asan (push) Waiting to run
Build / macos-15 - openssl@1.1 - asan (push) Waiting to run
Build / macos-15 - openssl@3 - asan (push) Waiting to run
Build / macos-13 - libressl - normal (push) Waiting to run
Build / macos-13 - openssl@1.1 - normal (push) Waiting to run
Build / macos-13 - openssl@3 - normal (push) Waiting to run
Build / macos-14 - libressl - normal (push) Waiting to run
Build / macos-14 - openssl@1.1 - normal (push) Waiting to run
Build / macos-14 - openssl@3 - normal (push) Waiting to run
Build / macos-15 - libressl - normal (push) Waiting to run
Build / macos-15 - openssl@1.1 - normal (push) Waiting to run
Build / macos-15 - openssl@3 - normal (push) Waiting to run
Build / msbuild - amd64 - openssl (push) Waiting to run
Build / msbuild - arm64 - openssl (push) Waiting to run
Build / msbuild - x86 - openssl (push) Waiting to run
Build / clang asan - ubuntu-22.04 - libressl (push) Waiting to run
Build / gcc normal - ubuntu-22.04 - libressl (push) Waiting to run
Change ovpn_dco_init() to take a reference to struct context, add a backlink from the platform DCO contexts to the owning openvpn context, and store the top multi context in struct context for server mode. This prepares the tree for the follow-up backend changes from commit7791f53("dco: process messages immediately after read") where Linux and FreeBSD process DCO notifications directly from their backend read paths. It is part of a reworked backport of PR #945 originally proposed by Nikolai Shelekhov <nickshv13@icloud.com>. The original commits in master are commita699681bb8Author: Antonio Quartulli <antonio@mandelbit.com> Date: Wed Jul 23 15:39:11 2025 +0200 dco: only pass struct context to init function commit7f5a6deae3Author: Antonio Quartulli <antonio@mandelbit.com> Date: Wed Jul 23 08:10:25 2025 +0200 multi: store multi_context address inside top instance Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Signed-off-by: Ralf Lici <ralf@mandelbit.com> Acked-by: Gert Doering <gert@greenie.muc.de> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631 Message-Id: <20260420165923.14226-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg36691.html Signed-off-by: Gert Doering <gert@greenie.muc.de>
This commit is contained in:
parent
219b8b3b30
commit
876a8cf5fd
10 changed files with 25 additions and 10 deletions
|
|
@ -104,11 +104,10 @@ bool dco_check_pull_options(int msglevel, const struct options *o);
|
|||
/**
|
||||
* Initialize the DCO context
|
||||
*
|
||||
* @param mode the instance operating mode (P2P or multi-peer)
|
||||
* @param dco the context to initialize
|
||||
* @param c the main instance context
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool ovpn_dco_init(int mode, dco_context_t *dco);
|
||||
bool ovpn_dco_init(struct context *c);
|
||||
|
||||
/**
|
||||
* Open/create a DCO interface
|
||||
|
|
@ -284,7 +283,7 @@ dco_check_pull_options(int msglevel, const struct options *o)
|
|||
}
|
||||
|
||||
static inline bool
|
||||
ovpn_dco_init(int mode, dco_context_t *dco)
|
||||
ovpn_dco_init(struct context *c)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,9 +220,11 @@ close_fd(dco_context_t *dco)
|
|||
}
|
||||
|
||||
bool
|
||||
ovpn_dco_init(int mode, dco_context_t *dco)
|
||||
ovpn_dco_init(struct context *c)
|
||||
{
|
||||
if (open_fd(dco) < 0)
|
||||
c->c1.tuntap->dco.c = c;
|
||||
|
||||
if (open_fd(&c->c1.tuntap->dco) < 0)
|
||||
{
|
||||
msg(M_ERR, "Failed to open socket");
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ typedef struct dco_context {
|
|||
int dco_message_peer_id;
|
||||
int dco_del_peer_reason;
|
||||
struct sockaddr_storage dco_float_peer_ss;
|
||||
struct context *c;
|
||||
uint64_t dco_read_bytes;
|
||||
uint64_t dco_write_bytes;
|
||||
} dco_context_t;
|
||||
|
|
|
|||
|
|
@ -391,9 +391,11 @@ ovpn_dco_init_netlink(dco_context_t *dco)
|
|||
}
|
||||
|
||||
bool
|
||||
ovpn_dco_init(int mode, dco_context_t *dco)
|
||||
ovpn_dco_init(struct context *c)
|
||||
{
|
||||
switch (mode)
|
||||
dco_context_t *dco = &c->c1.tuntap->dco;
|
||||
|
||||
switch (c->mode)
|
||||
{
|
||||
case CM_TOP:
|
||||
dco->ifmode = OVPN_MODE_MP;
|
||||
|
|
@ -407,6 +409,10 @@ ovpn_dco_init(int mode, dco_context_t *dco)
|
|||
ASSERT(false);
|
||||
}
|
||||
|
||||
/* store pointer to context as it may be required by message
|
||||
* parsing routines
|
||||
*/
|
||||
dco->c = c;
|
||||
ovpn_dco_init_netlink(dco);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ typedef struct
|
|||
struct nl_cb *nl_cb;
|
||||
int status;
|
||||
|
||||
struct context *c;
|
||||
|
||||
enum ovpn_mode ifmode;
|
||||
|
||||
int ovpn_dco_id;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ create_dco_handle(const char *devname, struct gc_arena *gc)
|
|||
}
|
||||
|
||||
bool
|
||||
ovpn_dco_init(int mode, dco_context_t *dco)
|
||||
ovpn_dco_init(struct context *c)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1882,7 +1882,7 @@ do_open_tun(struct context *c, int *error_flags)
|
|||
#endif
|
||||
if (dco_enabled(&c->options))
|
||||
{
|
||||
ovpn_dco_init(c->mode, &c->c1.tuntap->dco);
|
||||
ovpn_dco_init(c);
|
||||
}
|
||||
|
||||
/* open the tun device */
|
||||
|
|
|
|||
|
|
@ -792,6 +792,7 @@ tunnel_server_tcp(struct context *top)
|
|||
int status;
|
||||
|
||||
top->mode = CM_TOP;
|
||||
top->multi = &multi;
|
||||
context_clear_2(top);
|
||||
|
||||
/* initialize top-tunnel instance */
|
||||
|
|
|
|||
|
|
@ -466,6 +466,7 @@ tunnel_server_udp(struct context *top)
|
|||
struct multi_context multi;
|
||||
|
||||
top->mode = CM_TOP;
|
||||
top->multi = &multi;
|
||||
context_clear_2(top);
|
||||
|
||||
/* initialize top-tunnel instance */
|
||||
|
|
|
|||
|
|
@ -492,6 +492,9 @@ struct context
|
|||
* CM_P2P, \c CM_TOP, \c CM_TOP_CLONE,
|
||||
* \c CM_CHILD_UDP, and \c CM_CHILD_TCP. */
|
||||
|
||||
struct multi_context *multi; /**< Pointer to the main P2MP context.
|
||||
* Non-NULL only when mode == CM_TOP. */
|
||||
|
||||
struct gc_arena gc; /**< Garbage collection arena for
|
||||
* allocations done in the scope of this
|
||||
* context structure. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue