From patchwork Wed Apr 22 10:01:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4907 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:66c6:b0:84a:48f:a1fd with SMTP id x6csp2916919mal; Wed, 22 Apr 2026 03:02:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ/aFQpuJj7PlZ3nejPTwaQx/1LxJrhuZeqn46Rl6CWnueuTQKygcXdUD4Kv3kUMDxpLBGX91vv0M4Q=@openvpn.net X-Received: by 2002:a05:6808:4f53:b0:46a:72dc:28cc with SMTP id 5614622812f47-4799c875d25mr11532368b6e.1.1776852141641; Wed, 22 Apr 2026 03:02:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1776852141; cv=none; d=google.com; s=arc-20240605; b=Lcoy8/EDmzrA4+G+o6rkuN+47zG+vuRUo/ZFIv+XpLtuG14Q/jb9nrIOinp6rFnh55 WdXCB2G+df4+NIVqTugaCnHuHT5bp+EqudUzvVv1KNZjEc1r4Y9eIqlCk9QUbkD7ztrY zJ5RzV/td17U6FSCVJn4FCgh7SClw5v6ACPg/qy51+zoJ0JZ7rgn95wLNeaJbHm2rni4 Dbnc+4JUESPgOUw6E5cvwOnXslO8tUuc7miICtUS6m6hq+I82NljzXV3GNlF6BqrNJjS 5n5+rkkm02POQsvHqf5rwPBzEb9aOqDq4uUdRClFA+AwWM2+P01kwgh2emHCvUF96Q96 1Z4Q== 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=REM6eruycLGdu31X6LConY4c4wDYrOq8rx+iyB05vx4=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=lSUxQaTOjKjxT0enRndC9MfoZe+ye+flWz7aXq+qHqNN+UB3qvkrOq8aYMww5TrRrx NMlaEV4pS1peF7SQU2bQsteadtb/zMJj/zKJ5OLY0og8ee38Jpqo+g366DlHphJ7antQ 0VJXkPI/s5hc3YjG+Do15YLVCA+9Sl6cYlgn2LUu3ibEgMEG7O8gwaCJ9d8SNpTqYk9H ERgcIb9zYnVBRqU+UcUm9WJO6Fjb+GsD8REnEiMyTxipTCV1AibwDSvkSogy+ScVuTwe IUEgyF+YV2VWk18ijhTLPHdqWGwmfPZ4LiQaYR4blVhI9i8/OoU+nvqWKpYZxakF2fib 3Kzg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=VkfXGu+o; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="Vg/qJgFM"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HGNxG6yi; 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 5614622812f47-479a0286dd2si9382822b6e.88.2026.04.22.03.02.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Apr 2026 03:02:21 -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=VkfXGu+o; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="Vg/qJgFM"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=HGNxG6yi; 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=REM6eruycLGdu31X6LConY4c4wDYrOq8rx+iyB05vx4=; b=VkfXGu+o4Shsop2IdDFcc95JO3 PU17FCdktEvmrtA5G1782FtI1nhMPoSZSkUccjoueC0TpVMFF3DUZdfZZ1fcYS593B5EGiz/iyZm3 zwM0HP2u217v/Ke5QO01zjJaXhWETeRJlruih5nsGft0kMcNLiRTV5WgpR/lNuts3v2o=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wFUPR-0008CK-SS; Wed, 22 Apr 2026 10:02:17 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wFUPP-0008CC-Sg for openvpn-devel@lists.sourceforge.net; Wed, 22 Apr 2026 10:02:15 +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=6eLyp0VVr/a+luN3uaHxpx52t8/MgZsW7TNTPeWTq7o=; b=Vg/qJgFMKLBph9r1p9uuJ2gffw xtQfDWFaPtegABy+DBklYrO3uNxdiA+XGkHaiPYP6l9fZFKPiIvyAZLPbnuBo+e6SGu3HOy5LCDq4 oPMhMRkBT05AwclpAjruAqQQtqL+7lHvzHgJnXcipqfRzMlt9u0jj7YxXVZHYXM0TQAU=; 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=6eLyp0VVr/a+luN3uaHxpx52t8/MgZsW7TNTPeWTq7o=; b=HGNxG6yi52roawHR9JNcpbJyyv yvRikW70WnW0da4OOlsVlTxHhSi/MC06xnypO14iWF06+h8QFg3r/DcnU4NQU+nzGJ1pp8tvn7kfa H0+TEKZw02ixl0JPbswBuBF8LcLbwdMCPhKUBW4WpIrOo34Hv3k/SbXlMMzKZRCe1aY0=; 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 1wFUPO-0004b0-MG for openvpn-devel@lists.sourceforge.net; Wed, 22 Apr 2026 10:02:15 +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 63MA22o0010481 for ; Wed, 22 Apr 2026 12:02:02 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.1/8.18.1/Submit) id 63MA224c010480 for openvpn-devel@lists.sourceforge.net; Wed, 22 Apr 2026 12:02:02 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 22 Apr 2026 12:01:51 +0200 Message-ID: <20260422100202.10464-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-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_flags does not guarantee correct association with the socket being processed. Use the rwflags delivered by the event engine along with the event to ensure proper per-socket I/O handling. 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: 1wFUPO-0004b0-MG Subject: [Openvpn-devel] [PATCH v3] Multisocket: use event engine rwflags for UDP I/O 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?1863164511644808154?= X-GMAIL-MSGID: =?utf-8?q?1863164511644808154?= From: Gianmarco De Gregori udp_flags does not guarantee correct association with the socket being processed. Use the rwflags delivered by the event engine along with the event to ensure proper per-socket I/O handling. Remove udp_flags entirely. This change is based on an investigation triggered by a report from Joshua Rogers using ZeroPath. Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f Signed-off-by: Gianmarco De Gregori Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1635 --- 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/+/1635 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Gert Doering diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 27cfd36..36597db 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2029,8 +2029,7 @@ } static void -multi_io_process_flags(struct context *c, struct event_set *es, const unsigned int flags, - unsigned int *out_socket, unsigned int *out_tuntap) +multi_io_process_flags(struct context *c, struct event_set *es, const unsigned int flags) { unsigned int socket = 0; unsigned int tuntap = 0; @@ -2130,16 +2129,6 @@ } tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL); - - if (out_socket) - { - *out_socket = socket; - } - - if (out_tuntap) - { - *out_tuntap = tuntap; - } } /* @@ -2150,10 +2139,7 @@ void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsigned int flags) { - unsigned int out_socket; - - multi_io_process_flags(c, multi_io->es, flags, &out_socket, NULL); - multi_io->udp_flags = (out_socket << SOCKET_SHIFT); + multi_io_process_flags(c, multi_io->es, flags); } /* @@ -2163,8 +2149,6 @@ void io_wait(struct context *c, const unsigned int flags) { - unsigned int out_socket; - unsigned int out_tuntap; struct event_set_return esr[4]; /* These shifts all depend on EVENT_READ and EVENT_WRITE */ @@ -2183,7 +2167,7 @@ */ event_reset(c->c2.event_set); - multi_io_process_flags(c, c->c2.event_set, flags, &out_socket, &out_tuntap); + multi_io_process_flags(c, c->c2.event_set, flags); #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (c->c1.tuntap) diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 432c79a..beec57a 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -336,18 +336,17 @@ * Process a UDP socket event. */ void -multi_process_io_udp(struct multi_context *m, struct link_socket *sock) +multi_process_io_udp(struct multi_context *m, struct link_socket *sock, unsigned int rwflags) { - const unsigned int status = m->multi_io->udp_flags; const unsigned int mpp_flags = (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL); /* UDP port ready to accept write */ - if (status & SOCKET_WRITE) + if (rwflags & SOCKET_WRITE) { multi_process_outgoing_link(m, mpp_flags); } /* Incoming data on UDP port */ - else if (status & SOCKET_READ) + else if (rwflags & SOCKET_READ) { read_incoming_link(&m->top, sock); if (!IS_SIG(&m->top)) @@ -355,8 +354,6 @@ multi_process_incoming_link(m, NULL, mpp_flags, sock); } } - - m->multi_io->udp_flags = ES_ERROR; } /* diff --git a/src/openvpn/mudp.h b/src/openvpn/mudp.h index 005ee10..1417651 100644 --- a/src/openvpn/mudp.h +++ b/src/openvpn/mudp.h @@ -32,7 +32,7 @@ unsigned int p2mp_iow_flags(const struct multi_context *m); -void multi_process_io_udp(struct multi_context *m, struct link_socket *sock); +void multi_process_io_udp(struct multi_context *m, struct link_socket *sock, unsigned int rwflags); /**************************************************************************/ /** * Get, and if necessary create, the multi_instance associated with a diff --git a/src/openvpn/multi_io.c b/src/openvpn/multi_io.c index e6f4e9c..f9af800 100644 --- a/src/openvpn/multi_io.c +++ b/src/openvpn/multi_io.c @@ -457,7 +457,7 @@ } else { - multi_process_io_udp(m, ev_arg->u.sock); + multi_process_io_udp(m, ev_arg->u.sock, e->rwflags); mi = m->pending; } /* monitor and/or handle events that are diff --git a/src/openvpn/multi_io.h b/src/openvpn/multi_io.h index 6b2f59a..d6734bd 100644 --- a/src/openvpn/multi_io.h +++ b/src/openvpn/multi_io.h @@ -55,7 +55,6 @@ int n_esr; int maxevents; unsigned int tun_rwflags; - unsigned int udp_flags; #ifdef ENABLE_MANAGEMENT unsigned int management_persist_flags; #endif