From patchwork Mon Oct 5 13:20:15 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5438 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:338d:b0:8d1:cccb:4552 with SMTP id t13csp1204027maf; Mon, 5 Oct 2026 06:20:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBwNLa7S59oD4CN6bwSHPSdzv7+eVJbz7OdPyJ4L7XhZwfa8NKRFGzDdpvw8yQhTMTtzH+wKTYkzllg=@openvpn.net X-Received: by 2002:a05:6820:61b:b0:6d3:abd1:9b91 with SMTP id 006d021491bc7-6ddbcc43e22mr10303414eaf.55.1791206439010; Mon, 05 Oct 2026 06:20:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1791206439; cv=none; d=google.com; s=arc-20260327; b=M48FU1GKwYwZgTeGEbzeCv1gV0+hp6ZBiYySLB7bFST1X2fdP6eqGgJLbv6TTnJNEf lvdCsCEb0sShBmWGlYPSDz2db1/RNAAXmi9nJSdGgI1xf16JSGl4pluRvif8o9sZSYMO CBZ5bXquUSFQmZb/eHUl9MV/s8Lh7u4eZI5jq/MFVwdB9cEldOc0Sp9UJDy+QiP4n3mk m+RwalR7gZuUWuxcScEdYTETslnUfbKjmqji50/s+PJj8jgQL0PA7HgMkoSlgSKg4TIc mAL192mmN4lCkoJjP9jYudp6STj8xLN4vmI2v1UFgamfoCK4OKFAXI+N3ULoNCXOggBC N53g== 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=B9Ta/3SOyQ2I3q7K1dwH3plN5nge8ZTodtWkSMbnmow=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=fg5pASKU9m//a84Z3bSc6ZoF00kg4kFUAVB6u8bGTrk9zdARiTsO4ngrziSpGDttue MRCYq7V5Snfr6eAA/UxbRHbCX4zsyN3NdbZONd3tlaCULrlheCjbIY+fYIzTlrvx18QL WuXxwUKC7QXz/7RsGrzuzCAUlVo1B4w4c3Is5l+3F1EZA/ZSa3enFpyZ9spIPG2+p++1 XwT6AQfOhS2CghEsWLxdiFLrcDmx5yxEBzTBSuI/JzqBF/QT8qpNgAvuB9YhNd+RgpwY 0/mJawWZxTr25hefa4WlApAZ1RY5Rjy5U0XjJcEkPPL6KRmjEIMs3jOF8AmjGDsoO0HP gv1w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=aJt3Saze; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=l7vKuV1t; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="fD/Zb2g+"; 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-823a0d318desi15813258a34.57.2026.10.05.06.20.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Oct 2026 06:20:38 -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=aJt3Saze; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=l7vKuV1t; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="fD/Zb2g+"; 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=B9Ta/3SOyQ2I3q7K1dwH3plN5nge8ZTodtWkSMbnmow=; b=aJt3SazeD5A625GwLDGIrR58z6 Mil4XWzK68qg5/ABJHTHRAOaf7301IE4b738UDdtKLQHVQtG4ykQ/IH0IS/ZMO1VqPYcXTA4wImiF EjQn8kItaJoaQhIMx80Y8QIHXpIKIDswvjtfjuh0WQZSTsdD35vnxqsAruhORv1/9XxQ=; 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.95) (envelope-from ) id 1xDicO-0001Vx-RW; Mon, 05 Oct 2026 13:20:34 +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.95) (envelope-from ) id 1xDicN-0001Vr-UY for openvpn-devel@lists.sourceforge.net; Mon, 05 Oct 2026 13:20:33 +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=Gxuied3QEnKTGhvU6gVekqxP6II6N0nqZlQJdtNB3YE=; b=l7vKuV1tLw1JCkWQxD/Zu8mbfe 2EshH0QLGwnKi6i5mFc6uxxm7PMxp43N0CcrXQ03DSATb6CvNH3L03PsCmCDXp24qCEQVZD7jWPd/ gOKemia/hmXOe+8FJkshDNIQ4Y9JeA433NsmhCU06nTSHpbzfgKyw7Bpejz5lY7u9pQs=; 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=Gxuied3QEnKTGhvU6gVekqxP6II6N0nqZlQJdtNB3YE=; b=fD/Zb2g+NbpZSxkU70zbExGOTy ovnoKhQL93h4b9BcB9Ew8HkFBIX/33v6nPiCUTGKxyVXhN1V6FLkH3EvyAYDxf9DGPXaAsfp4okEx uv9KBe/4j7aJJIRzZYvEdjKiYoIrCnMb9e2DHELxI4LQk4iue/IueTBAf8CfU5/0z8ag=; 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 1xDicJ-00084x-PI for openvpn-devel@lists.sourceforge.net; Mon, 05 Oct 2026 13:20:33 +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 695DKO9f027504 for ; Mon, 5 Oct 2026 15:20:24 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 695DKOZC027503 for openvpn-devel@lists.sourceforge.net; Mon, 5 Oct 2026 15:20:24 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 5 Oct 2026 15:20:15 +0200 Message-ID: <20261005132023.27464-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.53.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 Before the UDP and TCP server loops were merged, each drained the bcast/mcast/client-to-client queue its own way: UDP armed EVENT_WRITE through IOW_MBUF, TCP used the flush loop at the end of multi_io [...] 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: 1xDicJ-00084x-PI Subject: [Openvpn-devel] [PATCH v2] multi_io: drop IOW_MBUF 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: 1878216083155898761 X-GMAIL-MSGID: 1878216083155898761 From: Gianmarco De Gregori Before the UDP and TCP server loops were merged, each drained the bcast/mcast/client-to-client queue its own way: UDP armed EVENT_WRITE through IOW_MBUF, TCP used the flush loop at the end of multi_io_process_io(). The merge kept both, leaving two consumers with different disciplines. The queue mixes instances of both protocols and neither consumer gets to pick: mbuf_peek() and multi_get_queue() hand back whatever sits at the head. The TCP side is prepared for that, testing proto_is_dgram() and tcp_link_out_deferred before writing. The UDP side is not: it writes straight to the instance's own socket, so a TCP instance reaching it skips the deferred queue that carries backpressure. Drain the queue from the flush loop alone and drop the UDP consumer. IOW_MBUF only existed to arm the socket for it, so it goes as well. This leaves the queue drained from one event-driven point: the timeout branch of tunnel_server_loop() does not reach the flush loop, so what multi_io_action(TA_TIMEOUT) manages to queue there waits for the next pass that has events. Acting on the queue only when there is an event to act on is the simpler rule, and the delay is bounded by the next event. Change-Id: I165c632da6a837d0cca55bee4c2cc390b91d1e54 Signed-off-by: Gianmarco De Gregori Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1962 --- 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/+/1962 This mail reflects revision 2 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 1604224..b97fb7a 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2122,14 +2122,6 @@ } /* - * outgoing bcast buffer waiting to be sent? - */ - if (flags & IOW_MBUF) - { - socket |= EVENT_WRITE; - } - - /* * Force wait on TUN input, even if also waiting on TCP/UDP output */ if (flags & IOW_READ_TUN_FORCE) diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 324c0b4..0309725 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -58,7 +58,6 @@ #define IOW_SHAPER (1 << 4) #define IOW_CHECK_RESIDUAL (1 << 5) #define IOW_FRAG (1 << 6) -#define IOW_MBUF (1 << 7) #define IOW_READ_TUN_FORCE (1 << 8) #define IOW_WAIT_SIGNAL (1 << 9) diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 2b08ada..94e03d6 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -451,10 +451,9 @@ static inline void multi_process_outgoing_link(struct multi_context *m, const unsigned int mpp_flags) { - struct multi_instance *mi = multi_process_outgoing_link_pre(m); - if (mi) + if (m->pending) { - multi_process_outgoing_link_dowork(m, mi, mpp_flags); + multi_process_outgoing_link_dowork(m, m->pending, mpp_flags); } } diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index 51c7d31..348e424 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -177,10 +177,6 @@ flags |= IOW_TO_LINK; } } - else if (mbuf_defined(m->mbuf)) - { - flags |= IOW_MBUF; - } else { flags |= IOW_READ; @@ -565,7 +561,7 @@ multi_io->n_esr = 0; /* - * Process queued mbuf packets destined for TCP socket + * Drain the queued mbuf packets, datagram and TCP instances alike */ { struct multi_instance *mi;