From patchwork Wed Jul 23 06:10:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4320 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:9111:b0:671:5a2c:6455 with SMTP id h17csp750856maf; Tue, 22 Jul 2025 23:10:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTsObD1m0zheuGFp591tEAlL1xFH2HYRo2mRK+0s7ohmOowrDwC4k66es7zVmDZQIA+MKmLYj788k=@openvpn.net X-Google-Smtp-Source: AGHT+IGdqZN15qYQwsVVwExn0B4KF4cSy7LgTHoA/jWEWww0+Cn3KPFj2J2ktWsfvnNFPCE8JW2I X-Received: by 2002:a05:6870:a550:b0:2e8:7953:ece7 with SMTP id 586e51a60fabf-306c72032afmr1081074fac.24.1753251050029; Tue, 22 Jul 2025 23:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1753251050; cv=none; d=google.com; s=arc-20240605; b=BuvuX/z9GDasRRfL0OutqVvQWhyJBa2jofLGL/bO1oTCV761NuPtf184bVac1PpPZk oWNlcD3SDMyUgiQE4RtzlrTMqyeSH8Z7I+0wSVgboCULpZUudGLho4oDQIJW/37qIjJo PyVTCdNcKy4GIkfwTHXwe25kTPofLcu8mTlBtpBOgIh5RbVjQ7sjXhFpvLIhzu0MUX/Y gxOH5nbJX8Tdnyra5TKxdldnxfQCyDlwkZaWz+CeAd+IAFpECz1EwFgzktJ/AZpsyDID f7Zxnmk+AbjjVgAsQhYQ6fHRjOspd7fLuyeCkfCzy5wFCWhrdEiMLJujn7PjL743F2/Q ZTvQ== 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=/m5hhZhlrtR5eNZMm1MFT4Gk7Cf6K5w7unkTht4w4C4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=AMRHFy5tc9V/xaZa6Mz4o1UqJ5QJijcemTI9nICD5512gKPUWuG2Vc1/HUBL/LJNyA UcpbO0H+hATViqFTmcpId05sxS/dWmoOF4QnlZ06FD25aUAazi7FroXv2OEmSHuFZ2Qx dvtgYYNjv+vDpOuA7kNTunZbGxyzQMRQklGzFpCjdu0F1JGS3ezrjWwLQb2VjvMtcoQW 1z7GtHXBDQKGNno92VhnA3wHsUPJ5vK8gx8yKHRgchjnq6Uaks27eNvET86O64rpIPPf 5Dix4NkTei0o9qlyO5urmpb2lJzfsQpA4RelpkzXlWkKVtqOlf08H/jxPjeZ2482Z+Oy y/Xw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="fRadU22/"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=hFAzHnkd; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EZnmeI0x; 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 586e51a60fabf-3010168e75bsi5795849fac.53.2025.07.22.23.10.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jul 2025 23:10:50 -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="fRadU22/"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=hFAzHnkd; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=EZnmeI0x; 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=/m5hhZhlrtR5eNZMm1MFT4Gk7Cf6K5w7unkTht4w4C4=; b=fRadU22/vUrF7Yl0HqaCX8RW+n XoejiFVNstnECnClcXBhdUTU/R51jI6cDfDnKbaajxnuDR6x9UkEzRxNsD7cklBWgu2j8k5BkCJ68 eCShyX1AM8KmH4R4Ielbu6E8mH4ZkmWv5Jeaff0P9WePM6sZcSR34bwFiMebEDsjA8+Q=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1ueSgh-0007Ka-34; Wed, 23 Jul 2025 06:10:47 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ueSgg-0007KM-4A for openvpn-devel@lists.sourceforge.net; Wed, 23 Jul 2025 06:10:46 +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=DuavzjRYWP+oEgmRnDbEKTGcGK+1aEWnu+s9sUcTsro=; b=hFAzHnkdnvXRyxaeeYzOBMMb7v ebhTHP9jzNM4QalMw8CcvuAxlv57ZRLU19GhtyIoRVR4H9neNNv+Mv1NF/16BC3JAdLO16m0Jh2si dBsfiKvzZqUUu0jxlOQbZScgy0RifikTlGGFLG2Lx/yt2ZYgn1PNkZkV4jYq0YhpnBMg=; 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=DuavzjRYWP+oEgmRnDbEKTGcGK+1aEWnu+s9sUcTsro=; b=EZnmeI0xERyAVG0D6xWCa4XAjn qB+Jw9SCtLLc8hZ1P+P/rTPIf0EXY83lwCyHfLYm7OPbYR2SyG7CiTiV7kg2zGTaw7QnRc6hg7Mho qvb9PHZJVT0zg2Xblq9d6OANW6rAdKonGgWPeqkDu9Rba/aFGcXI2OOSik99HNHAzVOo=; Received: from [193.149.48.143] (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 1ueSgg-00070c-3p for openvpn-devel@lists.sourceforge.net; Wed, 23 Jul 2025 06:10:46 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 56N6AYd6020280 for ; Wed, 23 Jul 2025 08:10:34 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 56N6AYXw020279 for openvpn-devel@lists.sourceforge.net; Wed, 23 Jul 2025 08:10:34 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 23 Jul 2025 08:10:25 +0200 Message-ID: <20250723061034.20240-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.49.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: Antonio Quartulli Future modifications to DCO require accessing the server multi_context object. Since it is currently a stack variable that is pointed by no one, we'd need to pass it to all kind of functions to ensure it can reach the DCO code. 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: 1ueSgg-00070c-3p Subject: [Openvpn-devel] [PATCH v1] multi: store multi_context address inside top instance 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?1838416973323517186?= X-GMAIL-MSGID: =?utf-8?q?1838416973323517186?= From: Antonio Quartulli Future modifications to DCO require accessing the server multi_context object. Since it is currently a stack variable that is pointed by no one, we'd need to pass it to all kind of functions to ensure it can reach the DCO code. To make the implementation simpler, it is preferable to simply assign its address to a struct context's field. While at it, make some multi_* functions static as they used only inside multi.c, where they are defined. Change-Id: Ibf64c681e02ac572d339d4d98e75ceb0cd417c45 Signed-off-by: Antonio Quartulli Acked-by: Gert Doering --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1093 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 4696686..ec260a2 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -290,9 +290,10 @@ /* * Main initialization function, init multi_context object. */ -void -multi_init(struct multi_context *m, struct context *t) +static void +multi_init(struct context *t) { + struct multi_context *m = t->multi; int dev = DEV_TYPE_UNDEF; msg(D_MULTI_LOW, "MULTI: multi_init called, r=%d v=%d", @@ -706,7 +707,7 @@ /* * Called on shutdown or restart. */ -void +static void multi_uninit(struct multi_context *m) { if (m->hash) @@ -3922,14 +3923,14 @@ } } -void -multi_top_init(struct multi_context *m, struct context *top) +static void +multi_top_init(struct context *top) { - inherit_context_top(&m->top, top); - m->top.c2.buffers = init_context_buffers(&top->c2.frame); + inherit_context_top(&top->multi->top, top); + top->multi->top.c2.buffers = init_context_buffers(&top->c2.frame); } -void +static void multi_top_free(struct multi_context *m) { close_context(&m->top, -1, CC_GC_FREE); @@ -4324,6 +4325,7 @@ struct multi_context multi; top->mode = CM_TOP; + top->multi = &multi; context_clear_2(top); /* initialize top-tunnel instance */ @@ -4334,10 +4336,10 @@ } /* initialize global multi_context object */ - multi_init(&multi, top); + multi_init(top); /* initialize our cloned top object */ - multi_top_init(&multi, top); + multi_top_init(top); /* initialize management interface */ init_management_callback_multi(&multi); diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index fe9e847..8b2704c 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -263,14 +263,6 @@ * Called by mtcp.c, mudp.c, or other (to be written) protocol drivers */ -void multi_init(struct multi_context *m, struct context *t); - -void multi_uninit(struct multi_context *m); - -void multi_top_init(struct multi_context *m, struct context *top); - -void multi_top_free(struct multi_context *m); - struct multi_instance *multi_create_instance(struct multi_context *m, const struct mroute_addr *real, struct link_socket *sock); diff --git a/src/openvpn/openvpn.h b/src/openvpn/openvpn.h index 3c8ce39..7d48888 100644 --- a/src/openvpn/openvpn.h +++ b/src/openvpn/openvpn.h @@ -491,6 +491,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. */