From: "its_Giaan (Code Review)" Date: Wed, 22 Apr 2026 08:26:55 +0000 In-Reply-To: References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, antonio@...2726... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="M1fOWKbBl9U="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: Multisocket: use event engine rwflags for UDP I/O List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --M1fOWKbBl9U= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: ordex, plaisthos. Hello ordex, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=3Demail to look at the new patch set (#3). Change subject: Multisocket: use event engine rwflags for UDP I/O ...................................................................... Multisocket: use event engine rwflags for UDP I/O 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 --- M src/openvpn/forward.c M src/openvpn/mudp.c M src/openvpn/mudp.h M src/openvpn/multi_io.c M src/openvpn/multi_io.h 5 files changed, 8 insertions(+), 28 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1635/3 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 unsi= gned int flags, - unsigned int *out_socket, unsigned int *out_tuntap) +multi_io_process_flags(struct context *c, struct event_set *es, const unsi= gned int flags) { unsigned int socket =3D 0; unsigned int tuntap =3D 0; @@ -2130,16 +2129,6 @@ } tun_set(c->c1.tuntap, es, tuntap, (void *)tun_shift, NULL); - - if (out_socket) - { - *out_socket =3D socket; - } - - if (out_tuntap) - { - *out_tuntap =3D tuntap; - } } /* @@ -2150,10 +2139,7 @@ void get_io_flags_udp(struct context *c, struct multi_io *multi_io, const unsig= ned int flags) { - unsigned int out_socket; - - multi_io_process_flags(c, multi_io->es, flags, &out_socket, NULL); - multi_io->udp_flags =3D (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_tu= ntap); + 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, un= signed int rwflags) { - const unsigned int status =3D m->multi_io->udp_flags; const unsigned int mpp_flags =3D (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 =3D 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 *soc= k); +void multi_process_io_udp(struct multi_context *m, struct link_socket *soc= k, 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 =3D 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 -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f Gerrit-Change-Number: 1635 Gerrit-PatchSet: 3 Gerrit-Owner: its_Giaan Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: ordex --M1fOWKbBl9U= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: ordex, plaisthos.

its_Giaan uploaded patch set #3 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/1635?usp=3Demail">View Chan= ge

Multisocket: use event engine rwflags for UDP I/O
udp_flags does not guarantee correct association with the socket bein= g
processed. Use the rwflags delivered by the event engine along with th= e
event to ensure proper per-socket I/O handling.

Remove udp_flag= s entirely.

This change is based on an investigation triggered by a = report from
Joshua Rogers using ZeroPath.

Change-Id: I6b303805a36= 88b6f6363140c76853a58badecd8f
Signed-off-by: Gianmarco De Gregori <gi= anmarco@...2726...>
---
M src/openvpn/forward.c
M src/openvpn/m= udp.c
M src/openvpn/mudp.h
M src/openvpn/multi_io.c
M src/openvpn/= multi_io.h
5 files changed, 8 insertions(+), 28 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/change=
s/35/1635/3
diff --git a/src/openvpn/forward.c b/src/openvpn/forwar=
d.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 i= nt flags,
- = unsigned int *out_socket, unsigned int *out_tuntap)
+multi_io_process_flags(struct co= ntext *c, struct event_set *es, const unsigned int flags)
= {
unsigned int socket =3D 0;
unsi= gned int tuntap =3D 0;
@@ -2130,16 +2129,6 @@
}

tun_set(c->c1.tuntap, e= s, tuntap, (void *)tun_shift, NULL);
-
- if= (out_socket)
- {

- *out_socket =3D = socket;
- }-
- if (out_tuntap)
- {
- *out_tuntap =3D 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-&g= t;udp_flags =3D (out_socket << SOCKET_SHIFT);
+ multi_io_process_flags(c, multi_io-&g= t;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 EVEN= T_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_sock= et *sock)
+multi_proc= ess_io_udp(struct multi_context *m, struct link_socket *sock, unsigned int = rwflags)
{
- const unsigned int status =3D m->multi_io->udp_flags;
const unsigned int mpp_flags =3D (MPP_PRE_SELECT | MPP_CLOS= E_ON_SIGNAL);

/* UDP port ready to a= ccept 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_REA= D)

+ else if (rwfl= ags & 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 =3D ES_ERROR;
}

/*
diff --git a/src/openvpn/mudp.h b/sr= c/openvpn/mudp.h
index 005ee10..1417651 100644
--- a/src/openvpn/mudp.h
+++ b/src/openvpn/mudp.h
@@ -32,7 +32,7 @@

unsigned in= t p2mp_iow_flags(const struct multi_context *m);
-void multi_process_io_udp(stru= ct 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 mul= ti_instance associated with a
diff --git a/src/openvpn/mult= i_io.c b/src/openvpn/multi_io.c
index e6f4e9c..f9af800 1006= 44
--- a/src/openvpn/multi_io.c
+++ b/src/o= penvpn/multi_io.c
@@ -457,7 +457,7 @@
= }
else
{

- multi_process_io_udp(m, ev_arg->u.sock);
+ m= ulti_process_io_udp(m, ev_arg->u.sock, e->rwflags);
= mi =3D m->pending;
= }
/* monitor and/or handle eve= nts that are
diff --git a/src/openvpn/multi_io.h b/src/open= vpn/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;<= /span>
- unsigned int udp_f= lags;
#ifdef ENABLE_MANAGEMENT
unsign= ed int management_persist_flags;
#endif

To view, visit change 1635. To unsubscribe, or for help writi= ng mail filters, visit settings.

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c768= 53a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 3
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: ordex <antonio@...2726...&= gt;
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: ordex <antonio@...2726...= >
= --M1fOWKbBl9U=--