From: "its_Giaan (Code Review)" Date: Tue, 21 Apr 2026 14:51:42 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <8b237e22b9e1b58305c1b46916b62e0dcc83f3b6-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="2Zlrur+TsDE="; 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 --2Zlrur+TsDE= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: plaisthos. Hello plaisthos, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1635?usp=3Demail to review the following change. 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 returned by the event engine together 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, 4 insertions(+), 8 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/35/1635/1 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 27cfd36..3937942 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2153,7 +2153,6 @@ 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); } /* diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 432c79a..1acfffc 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -336,9 +336,9 @@ * 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 status =3D rwflags; const unsigned int mpp_flags =3D (MPP_PRE_SELECT | MPP_CLOSE_ON_SIGNAL= ); /* UDP port ready to accept write */ @@ -355,8 +355,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: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I6b303805a3688b6f6363140c76853a58badecd8f Gerrit-Change-Number: 1635 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --2Zlrur+TsDE= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

its_Giaan would like plaisthos to review this change.

V= iew Change

Multisocket: use event engine rwflags for U=
DP I/O

udp_flags does not guarantee correct association with the soc= ket being
processed. Use the rwflags returned by the event engine togeth= er with the
event to ensure proper per-socket I/O handling.

Remov= e udp_flags entirely.

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

Change-Id: I6= b303805a3688b6f6363140c76853a58badecd8f
Signed-off-by: Gianmarco De Greg= ori <gianmarco@...2726...>
---
M src/openvpn/forward.c
M src= /openvpn/mudp.c
M src/openvpn/mudp.h
M src/openvpn/multi_io.c
M sr= c/openvpn/multi_io.h
5 files changed, 4 insertions(+), 8 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn re=
fs/changes/35/1635/1
diff --git a/src/openvpn/forward.c b/src/openv=
pn/forward.c
index 27cfd36..3937942 100644
= --- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.c
@@ -2153,7 +2153,6 @@
unsigned int out_so= cket;

multi_io_process_flags(c, mult= i_io->es, flags, &out_socket, NULL);
- multi_io->udp_flags =3D (out_socket << S= OCKET_SHIFT);
}

/*
diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c
= index 432c79a..1acfffc 100644
--- a/src/openvpn/mudp.= c
+++ b/src/openvpn/mudp.c
@@ -336,9 +336,9= @@
* Process a UDP socket event.
*/
void
-mu= lti_process_io_udp(struct multi_context *m, struct link_socket *sock)
+multi_process_io_udp(stru= ct multi_context *m, struct link_socket *sock, unsigned int rwflags)=
{
- const= unsigned int status =3D m->multi_io->udp_flags;
+ const unsigned int status =3D rwflag= s;
const unsigned int mpp_flags =3D (MPP_PRE_SELECT | = MPP_CLOSE_ON_SIGNAL);

/* UDP port re= ady to accept write */
@@ -355,8 +355,6 @@
= multi_process_incoming_link(m, NULL, mpp_flags, sock);<= br> }
}
-
-= 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 @@

unsig= ned int p2mp_iow_flags(const struct multi_context *m);

-void multi_process_io_ud= p(struct multi_context *m, struct link_socket *sock);
+void multi_process_io_udp(struct multi_co= ntext *m, struct link_socket *sock, unsigned int rwflags);
= /*************************************************************************= */
/**
* Get, and if necessary create, t= he multi_instance associated with a
diff --git a/src/openvp= n/multi_io.c b/src/openvpn/multi_io.c
index e6f4e9c..f9af80= 0 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);
<= span> mi =3D m->pending;

= }
/* monitor and/or hand= le events that are
diff --git a/src/openvpn/multi_io.h b/sr= c/openvpn/multi_io.h
index 6b2f59a..d6734bd 100644--- a/src/openvpn/multi_io.h
+++ b/src/openvpn/mult= i_io.h
@@ -55,7 +55,6 @@
int n_esr;
int maxevents;
unsigned int tun_rwf= lags;
- unsigned int= udp_flags;
#ifdef ENABLE_MANAGEMENT
= unsigned int management_persist_flags;
#endif

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

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6b303805a3688b6f6363140c768= 53a58badecd8f
Gerrit-Change-Number: 1635
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --2Zlrur+TsDE=--