From patchwork Tue Oct 27 13:07:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5517 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:78dc:b0:8dc:5c83:a4ec with SMTP id e28csp157025max; Tue, 27 Oct 2026 06:08:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBw7fVTOeAugBTKuS1D/GVthRXN6KFJB6W9ZU3fosQW64rKDwffnQa/fsbWDoQb2LCh+A6lH+YlgnjY=@openvpn.net X-Received: by 2002:a05:6820:1508:b0:6dc:3be3:bb81 with SMTP id 006d021491bc7-70ba0e39469mr5675980eaf.35.1793106484174; Tue, 27 Oct 2026 06:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1793106484; cv=none; d=google.com; s=arc-20260327; b=cXtlK05tNKZrnRT+SRHDjI7q3DN4St2ojxOP56gIDq+AUtmwrfH6fQAXZmZDq0rAHe oGFc795bpnSI6XTu9I7/xWCiB1Yn9GshajUp4CvXPxx61b4Ct78vSF7btdEehkTmhdNt 93crF+pwR7DHVSsYtzdYpWh/OWZ6qqUNtT40ZrVxLzLv9XvoySrUyITCB1jdGj9eKWgI H5WVAdFkoM+sCoE4q+U7My044II7kVUKkfHFEh8gHNJw8KmJuX+wH8K4l/+Fo6gr544w CnS+uPaVcBGPuFUvY489XzzfJ1l+gkjQU4Z9VDC7CnNJO3WYEvahbVW+z99ToB3j4fwu C8sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; 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=1tn/BJYp9nx+Esk6S/f3cCOEIJaZZWYB+Z9cU56FbLw=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=cZJhHacSAg1YPBM8GOhw+hfhw/1drkLnUpbLLribaMUdEJ9MahwbZI+35ztwPIWkwh f+iS1/0VI23AkGMvBi+viC0a5ZB04RhA0PYHTwngK6pbBj13h5TES331t1pJ/qHqp0po G2nw1E74ZWEgioAOO2VjCVt7cTP4DXSaFIsITM1Rw+q9rbuBrMQuTNnKkxdi+PGz8gH6 ftI7Q7knPzuLm9Fg6QxbhdkC/QQc1pSjxKCUF370QLGXFTN41vJEt2rbI4iYc35ke5+O V+97whsU3oZsDQfylQXvYUcXnYr7u6bnEiBvzgVqJdEvZ9kLBwMPt15153ik0qG8cidl uEqA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=bgveFJeu; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YIx7Da0b; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eqAR8tpi; 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-4a8433e9328si12283325fac.348.2026.10.27.06.08.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Oct 2026 06:08:04 -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=bgveFJeu; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=YIx7Da0b; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=eqAR8tpi; 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-Unsubscribe-Post: List-Owner; bh=1tn/BJYp9nx+Esk6S/f3cCOEIJaZZWYB+Z9cU56FbLw=; b=bgveFJeu3Er292 ekkgYQII1vnG6WH9Wn483wOWwLY0a64gWDLYT0QU2kDUMCo2lVGjNMygaM3emPPx6RC+BF3j4BAyP CLojWW2PFfhoOCqe8rSxc748h6GLBBC1tjeL/3+cortfu2K1j6WxYEcrhsdrbaPO7C9TfEqlcLovL Vj8=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xLguH-000000000zg-47CY; Tue, 27 Oct 2026 13:08:01 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xLguG-000000000zR-0NPa for openvpn-devel@lists.sourceforge.net; Tue, 27 Oct 2026 13:08:00 +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-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mQi+ihXEeZ5futWRsmYrp290zOj/92Zf4/li7J9Ufng=; b=YIx7Da0bTLkkmlyGS26v+/aY8W RXu1OkmeeBArN6FayhrQHyqlKgVHeWw+QfL/X/xpqOWjMHY5Bi6AJVIgrANmkDjiXvYRKPEhIuF4S b71vKDxakCQ0QMfujgtFaCQgEoZF+P8debMCRn1FX5mdIsBV5fI0RB5W6anb+aaDHJd8=; 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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mQi+ihXEeZ5futWRsmYrp290zOj/92Zf4/li7J9Ufng=; b=eqAR8tpiIw4tGJvITIi4MAsz5t M3mcxsX/5uUBe4rAwo0EgpKi+i3XhBLsIHx285QJa1MW6b+N/5hz0GDHKCCQYK7ggD8JfGo9EcGpm W9DCmu3jpCiEHNcSCKqfx3ZE0Tx6dp+PbfJLK74R2oOFN6apUFGROu5AzFWooB6GrJLg=; 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.100.1) id 1xLguE-000000006Yh-3SR5 for openvpn-devel@lists.sourceforge.net; Tue, 27 Oct 2026 13:07:59 +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 69RD7qSW002964 for ; Tue, 27 Oct 2026 14:07:52 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 69RD7qqO002963 for openvpn-devel@lists.sourceforge.net; Tue, 27 Oct 2026 14:07:52 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 27 Oct 2026 14:07:46 +0100 Message-ID: <20261027130751.2950-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.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-1.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: Gianmarco De Gregori UDP sockets are shared among instances and are already set in multi_io_wait(), so calling socket_set() on them per instance is redundant. On a server with two UDP and one TCP listener this saves about one epoll_ctl() per received packet (syscalls per received packet 5.75 -> 4.61, UDP only 6.82 -> 5.28) and, at saturation, delivers about [...] 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: 1xLguE-000000006Yh-3SR5 Subject: [Openvpn-devel] [PATCH v1] mtcp: make set_global_rw_flags TCP only again 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: 1880208424354123730 X-GMAIL-MSGID: 1880208424354123730 From: Gianmarco De Gregori UDP sockets are shared among instances and are already set in multi_io_wait(), so calling socket_set() on them per instance is redundant. On a server with two UDP and one TCP listener this saves about one epoll_ctl() per received packet (syscalls per received packet 5.75 -> 4.61, UDP only 6.82 -> 5.28) and, at saturation, delivers about 10% more traffic with UDP only. Move the function back to mtcp.c as multi_tcp_set_global_rw_flags() and skip datagram instances. Change-Id: I603585c6bb4e407d0df62f4233ff2c135aa00db0 Signed-off-by: Gianmarco De Gregori Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2041 --- 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/+/2041 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c index c744638..2b5c5b1 100644 --- a/src/openvpn/mtcp.c +++ b/src/openvpn/mtcp.c @@ -115,6 +115,18 @@ multi_io->n_esr = 0; } +void +multi_tcp_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi) +{ + if (mi && !proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto)) + { + mi->socket_set_called = true; + socket_set(mi->context.c2.link_sockets[0], m->multi_io->es, + mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRITE : EVENT_READ, &mi->ev_arg, + &mi->tcp_rwflags); + } +} + bool multi_tcp_process_outgoing_link_ready(struct multi_context *m, struct multi_instance *mi, const unsigned int mpp_flags) diff --git a/src/openvpn/mtcp.h b/src/openvpn/mtcp.h index bb117fa..de9d7ba 100644 --- a/src/openvpn/mtcp.h +++ b/src/openvpn/mtcp.h @@ -39,6 +39,8 @@ void multi_tcp_instance_specific_free(struct multi_instance *mi); +void multi_tcp_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi); + bool multi_tcp_process_outgoing_link(struct multi_context *m, bool defer, const unsigned int mpp_flags); diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index bb5dde58..ebee86c 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -122,28 +122,6 @@ } void -multi_io_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi) -{ - if (!mi) - { - return; - } - - mi->socket_set_called = true; - if (proto_is_dgram(mi->context.c2.link_sockets[0]->info.proto)) - { - socket_set(mi->context.c2.link_sockets[0], m->multi_io->es, EVENT_READ, - &mi->context.c2.link_sockets[0]->ev_arg, NULL); - } - else - { - socket_set(mi->context.c2.link_sockets[0], m->multi_io->es, - mbuf_defined(mi->tcp_link_out_deferred) ? EVENT_WRITE : EVENT_READ, &mi->ev_arg, - &mi->tcp_rwflags); - } -} - -void multi_io_free(struct multi_io *multi_io) { if (multi_io) @@ -378,7 +356,7 @@ case TA_INITIAL: ASSERT(mi); - multi_io_set_global_rw_flags(m, mi); + multi_tcp_set_global_rw_flags(m, mi); multi_process_post(m, mi, mpp_flags); break; @@ -428,7 +406,7 @@ } else { - multi_io_set_global_rw_flags(m, mi); + multi_tcp_set_global_rw_flags(m, mi); } break; diff --git a/src/openvpn/multi_io.h b/src/openvpn/multi_io.h index d6734bd..4299cba 100644 --- a/src/openvpn/multi_io.h +++ b/src/openvpn/multi_io.h @@ -68,8 +68,6 @@ void multi_io_process_io(struct multi_context *m); -void multi_io_set_global_rw_flags(struct multi_context *m, struct multi_instance *mi); - void multi_io_action(struct multi_context *m, struct multi_instance *mi, int action, bool poll); void multi_io_delete_event(struct multi_io *multi_io, event_t event);