From patchwork Mon Apr 20 16:59:17 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4902 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:66c6:b0:84a:48f:a1fd with SMTP id x6csp1775978mal; Mon, 20 Apr 2026 09:59:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ/ABaIgH3RVS0s5lOkhos9Hgb6ZrziGnsz+xKrfVSY874NGB2fBDKq8HxPRV1H/SjrEIdn64Qv3A8o=@openvpn.net X-Received: by 2002:a05:6808:d54:b0:467:237e:ba47 with SMTP id 5614622812f47-4799c870d9bmr7685987b6e.1.1776704383686; Mon, 20 Apr 2026 09:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776704383; cv=none; d=google.com; s=arc-20240605; b=feYculArh37PFUIq23rXaT35XJzyt3GLDR0SAmAqhyfNSJu0rtCm2yJ+vJ424U1hVk 8IvQ/iJbaQoQz3kLL1Y7AksG71mBXoa7u5DbLHJpk84sZaxbtKzvdmQ8Mi0leaWWqO9U ti+UUnRs9y0qnKXx3dkyg9P7vJZGuTPDU7cn69NXWCweO7HnzM4+lj/g7M+uOjppH0Cx ehK8kf2ceKu0/aVUEBNiCjndeuB0+MAfL/R6II3aTKXhwNoaXW+FYqF4ZRRUjnjvdx/n c7v/83hrSIj3MgvLl7abWvWVfc/y04/Xm8MQU7IdIlrFrIAkISaEj2s4s4hl4WrRCeqX djuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=gn2w8aHFHIyfLY4GN2/I5ED1HPH03aLlhggMR32vv6M=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=MWIWGcj/52Gt31Q9OjAA75Za0y5yanZpOrvi8qxkjJiO8PEIM+c5kG5BsIjxwb5xou JujQt6XhL+nydTNDv7+qF/hVAB8+/QSDZyEnUjnz7pOTSfaorcGITdIGjRtmK+Kypc46 Bmp0wv7yHavQDxnFibpIwH0/5Txu3Frq7eGMiI9hUHLAN7zt0QMMG2ItYxeu4AtZOPjg cqIGq8h7H1KOfs8t2Comnk44NYUcL8lt/+HLdnPB22izozR39Et6DTFqiFCJUoaDPR/t YCv2sZHNshMI4/0W/NObEXwSJZH3cEmDXlHwyOVD+ZNUy6HG5gAi3xKntufLjYTDJuc3 lIIg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=lCawidJY; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=CIH7EEdW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=iPK1oWpN; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 46e09a7af769-7dcce4629b3si848263a34.118.2026.04.20.09.59.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Apr 2026 09:59:43 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=lCawidJY; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=CIH7EEdW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=iPK1oWpN; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gn2w8aHFHIyfLY4GN2/I5ED1HPH03aLlhggMR32vv6M=; b=lCawidJYJf0cRErxNewXyP66xF D9Ml/98Fl7OT3ZuY3fIhDw7n7cJ+E6DCec0bb8sQYkDw4ndmJP48sMraeZd5+SogFEsQFEa9hsNaV M/jPvU+RVqzcxvrEBcJFz3T7USDatpefVIMniBW4rxwYvRp376lzWJNaiYMHDYU/lu8c=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wEryD-0008Ij-QQ; Mon, 20 Apr 2026 16:59:37 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wEryC-0008Id-R1 for openvpn-devel@lists.sourceforge.net; Mon, 20 Apr 2026 16:59:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Ov4245u4xCl3pJVWXSOVQOuAVGkhs9lajRRPRN2Z0C0=; b=CIH7EEdWxiLs64oxqSCNmwbgo0 kKzmZmj1OrRhuq0b+JVk1TRaR/k0zq73bLN4m1uy3RH12ms3d+odXpZ+3sZLPZLUkjwEUpvEIYdb5 NrM4F074sA6QkaxjjyCkzDDkflnVpcY9a6lHLoxLJf34UQL19/TlsCv8Ln39AJiyDXTQ=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Ov4245u4xCl3pJVWXSOVQOuAVGkhs9lajRRPRN2Z0C0=; b=iPK1oWpNMeypy4XKn5UO2ilz1c vS+jrVKajisPIdkfVxkzqT9aNhWjCzaQ3YD4mrgMgUzj6xYpI+A5cC7clthQiTs3cyssDKIz4D39b skWYnJnyPyshliVC5XPadZmd2E9yDIraEuX9Z9+WwF1+SnzkPZdx70GxMDXrA9HyFLtA=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wEryB-00079Q-Hn for openvpn-devel@lists.sourceforge.net; Mon, 20 Apr 2026 16:59:36 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 63KGxNPh014239 for ; Mon, 20 Apr 2026 18:59:23 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 63KGxNlX014238 for openvpn-devel@lists.sourceforge.net; Mon, 20 Apr 2026 18:59:23 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 20 Apr 2026 18:59:17 +0200 Message-ID: <20260420165923.14226-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Ralf Lici 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 [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wEryB-00079Q-Hn Subject: [Openvpn-devel] [PATCH v1] dco: port core/context infrastructure needed for backport of commit 7791f53 X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1863009575814844904?= X-GMAIL-MSGID: =?utf-8?q?1863009575814844904?= From: Ralf Lici 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 commit 7791f53 ("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 . Change-Id: I974e10ec91a0b63f52387f1406ce1b49145eb0be Signed-off-by: Ralf Lici Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to release/2.6. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1631 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h index 50ebb35..334d468 100644 --- a/src/openvpn/dco.h +++ b/src/openvpn/dco.h @@ -104,11 +104,10 @@ /** * 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 @@ } static inline bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { return true; } diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 15add74..b164bd3 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -220,9 +220,11 @@ } 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; diff --git a/src/openvpn/dco_freebsd.h b/src/openvpn/dco_freebsd.h index ab5891e8..e8f723e 100644 --- a/src/openvpn/dco_freebsd.h +++ b/src/openvpn/dco_freebsd.h @@ -57,6 +57,7 @@ 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; diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b2584b9..493fce6 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -391,9 +391,11 @@ } 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 @@ 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; } diff --git a/src/openvpn/dco_linux.h b/src/openvpn/dco_linux.h index 5179912..cf6bdd4 100644 --- a/src/openvpn/dco_linux.h +++ b/src/openvpn/dco_linux.h @@ -43,6 +43,8 @@ struct nl_cb *nl_cb; int status; + struct context *c; + enum ovpn_mode ifmode; int ovpn_dco_id; diff --git a/src/openvpn/dco_win.c b/src/openvpn/dco_win.c index 0b8f831..bc465db 100644 --- a/src/openvpn/dco_win.c +++ b/src/openvpn/dco_win.c @@ -53,7 +53,7 @@ } bool -ovpn_dco_init(int mode, dco_context_t *dco) +ovpn_dco_init(struct context *c) { return true; } diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 1476737..c2cfd24 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -1882,7 +1882,7 @@ #endif if (dco_enabled(&c->options)) { - ovpn_dco_init(c->mode, &c->c1.tuntap->dco); + ovpn_dco_init(c); } /* open the tun device */ diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index 3e33b15..38c938e 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -792,6 +792,7 @@ int status; top->mode = CM_TOP; + top->multi = &multi; context_clear_2(top); /* initialize top-tunnel instance */ diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index f7c9ffd..8cc717b 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -466,6 +466,7 @@ struct multi_context multi; top->mode = CM_TOP; + top->multi = &multi; context_clear_2(top); /* initialize top-tunnel instance */ diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index 9cba1c5..3879772 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -492,6 +492,9 @@ * 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. */