From: "its_Giaan (Code Review)" Date: Mon, 23 Sep 2024 13:41:19 +0000 References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <21db2574ae6d8f0857e3cfca56b85c0764a45d68-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="TsoxkANZvHo="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: io_work: convert shift argument to uintptr_t List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --TsoxkANZvHo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, ordex, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/759?usp=3Demail to review the following change. Change subject: io_work: convert shift argument to uintptr_t ...................................................................... io_work: convert shift argument to uintptr_t Instead of passing the shift argument as pointer, pass directly its integer value. This will allow the code to distinguish a shift value from a real object pointer, like we already do in multi_tcp_process_io(). This change will allow us later to pass an event_arg object as event handler argument instead of a simple integer value. Change-Id: Ib583bf17e35b14aed78fd8217b6e71e8c2b78089 Signed-off-by: Antonio Quartulli --- M src/openvpn/forward.c 1 file changed, 12 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/759/1 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 16b4497..1247ba3 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2050,20 +2050,18 @@ unsigned int tuntap =3D 0; struct event_set_return esr[4]; - /* These shifts all depend on EVENT_READ (=3D1) and EVENT_WRITE (=3D2) - * and are added to the shift. Check openvpn.h for more details. - */ - static int socket_shift =3D SOCKET_SHIFT; - static int tun_shift =3D TUN_SHIFT; - static int err_shift =3D ERR_SHIFT; + /* These shifts all depend on EVENT_READ and EVENT_WRITE */ + static uintptr_t socket_shift =3D 0; /* depends on SOCKET_READ and S= OCKET_WRITE */ + static uintptr_t tun_shift =3D 2; /* depends on TUN_READ and TUN_= WRITE */ + static uintptr_t err_shift =3D 4; /* depends on ES_ERROR */ #ifdef ENABLE_MANAGEMENT - static int management_shift =3D MANAGEMENT_SHIFT; + static uintptr_t management_shift =3D 6; /* depends on MANAGEMENT_READ= and MANAGEMENT_WRITE */ #endif #ifdef ENABLE_ASYNC_PUSH - static int file_shift =3D FILE_SHIFT; + static uintptr_t file_shift =3D FILE_SHIFT; #endif #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) - static int dco_shift =3D DCO_SHIFT; /* Event from DCO linux kernel = module */ + static uintptr_t dco_shift =3D DCO_SHIFT; /* Event from DCO linux k= ernel module */ #endif /* @@ -2077,7 +2075,7 @@ */ if (flags & IOW_WAIT_SIGNAL) { - wait_signal(c->c2.event_set, (void *)&err_shift); + wait_signal(c->c2.event_set, (void *)err_shift); } /* @@ -2171,7 +2169,7 @@ * Configure event wait based on socket, tuntap flags. */ socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)&socket= _shift, NULL); - tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)&tun_shift, NUL= L); + tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift, NULL= ); #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (socket & EVENT_READ && c->c2.did_open_tun) { @@ -2182,7 +2180,7 @@ #ifdef ENABLE_MANAGEMENT if (management) { - management_socket_set(management, c->c2.event_set, (void *)&manage= ment_shift, NULL); + management_socket_set(management, c->c2.event_set, (void *)managem= ent_shift, NULL); } #endif @@ -2190,7 +2188,7 @@ /* arm inotify watcher */ if (c->options.mode =3D=3D MODE_SERVER) { - event_ctl(c->c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)&= file_shift); + event_ctl(c->c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)f= ile_shift); } #endif @@ -2233,7 +2231,7 @@ for (i =3D 0; i < status; ++i) { const struct event_set_return *e =3D &esr[i]; - c->c2.event_set_status |=3D ((e->rwflags & 3) << *((in= t *)e->arg)); + c->c2.event_set_status |=3D ((e->rwflags & 3) << (uint= ptr_t)e->arg); } } else if (status =3D=3D 0) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/759?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ib583bf17e35b14aed78fd8217b6e71e8c2b78089 Gerrit-Change-Number: 759 Gerrit-PatchSet: 1 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: ordex Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-MessageType: newchange --TsoxkANZvHo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, ordex, plaisthos. <= /p>

its_Giaan would like plaisthos and flichtenheld to review this change.

Vi= ew Change

io_work: convert shift argument to uintptr_t

Instead o= f passing the shift argument as pointer, pass
directly its integer value= . This will allow the code to
distinguish a shift value from a real obje= ct pointer,
like we already do in multi_tcp_process_io().

This ch= ange will allow us later to pass an event_arg
object as event handler ar= gument instead of a simple
integer value.

Change-Id: Ib583bf17e35= b14aed78fd8217b6e71e8c2b78089
Signed-off-by: Antonio Quartulli <a@...493...= 2181...>
---
M src/openvpn/forward.c
1 file changed, 12 inserti= ons(+), 14 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/o=
penvpn refs/changes/59/759/1
diff --git a/src/openvpn/forward.c b/s=
rc/openvpn/forward.c
index 16b4497..1247ba3 100644--- a/src/openvpn/forward.c
+++ b/src/openvpn/forwa= rd.c
@@ -2050,20 +2050,18 @@
unsigned = int tuntap =3D 0;
struct event_set_return esr[4];

- /* T= hese shifts all depend on EVENT_READ (=3D1) and EVENT_WRITE (=3D2)- * and are added to the sh= ift. Check openvpn.h for more details.
- */
- static int tun_shift =3D TUN_SHIFT;- static int err_shift =3D E= RR_SHIFT;
+ /* The= se shifts all depend on EVENT_READ and EVENT_WRITE */
+ static uintptr_t socket_shift =3D 0; = /* depends on SOCKET_READ and SOCKET_WRITE */
+ static uintptr_t tun_shift =3D 2; /* d= epends on TUN_READ and TUN_WRITE */
+ static uintptr_t err_shift =3D 4; /* depends on ES= _ERROR */
#ifdef ENABLE_MANAGEMENT
- static int management_shift =3D MANAGEM= ENT_SHIFT;
+ stati= c uintptr_t management_shift =3D 6; /* depends on MANAGEMENT_READ and MANAG= EMENT_WRITE */
#endif
#ifdef ENABLE_ASYNC= _PUSH
- static int f= ile_shift =3D FILE_SHIFT;
+ static uintptr_t file_shift =3D FILE_SHIFT;
#end= if
#if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
- static int dco_shift= =3D DCO_SHIFT; /* Event from DCO linux kernel module */
+ static uintptr_t dco_shift =3D = DCO_SHIFT; /* Event from DCO linux kernel module */

#en= dif

/*
@@ -2077,7 +2= 075,7 @@
*/
if (flags & IOW_= WAIT_SIGNAL)
{
- wait_signal(c->c2.event_set, (void *)&err_shif= t);
+ wait_sig= nal(c->c2.event_set, (void *)err_shift);
}
/*
@@ -2171,7 +2169,7 @@
* Configure event wait based on socket, tuntap flags.
*/
socket_set(c->c2.link_socket= , c->c2.event_set, socket, (void *)&socket_shift, NULL);
<= span style=3D"color: hsl(0, 100%, 40%);">- tun_set(c->c1.tuntap, c-&g= t;c2.event_set, tuntap, (void *)&tun_shift, NULL);

+ tun_set(c->c1.tuntap, c->c2.ev= ent_set, tuntap, (void *)tun_shift, NULL);
#if defined(TAR= GET_LINUX) || defined(TARGET_FREEBSD)
if (socket &= EVENT_READ && c->c2.did_open_tun)
{=
@@ -2182,7 +2180,7 @@
#ifdef ENABLE_MANAGEMENT
if (management)
{
- management_socket_set(manageme= nt, c->c2.event_set, (void *)&management_shift, NULL);
+ management_socket_set(man= agement, c->c2.event_set, (void *)management_shift, NULL);

}

#endif

@@ -219= 0,7 +2188,7 @@
/* arm inotify watcher */
if (c->options.mode =3D=3D MODE_SERVER)

{
- event_ctl(c->= ;c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)&file_shift);
+ event_ctl(c-&= gt;c2.event_set, c->c2.inotify_fd, EVENT_READ, (void *)file_shift);
}
#endif

@@ -2233,7 +2231,7 @@

for (i =3D 0; i &l= t; status; ++i)
{
= const struct event_set_return *e =3D &esr[i];
- c->c2.event= _set_status |=3D ((e->rwflags & 3) << *((int *)e->arg));
+ c-= >c2.event_set_status |=3D ((e->rwflags & 3) << (uintptr_t)e= ->arg);
}
= }
else if (status =3D=3D 0)

To view, visit change 759. To unsubscribe, or for help writing= mail filters, visit setting= s.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib583bf17e35b14aed78fd8217b6= e71e8c2b78089
Gerrit-Change-Number: 759
Gerrit-PatchSet: 1
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: ordex <a@...2181...>
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: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <a@...2181...> <= /div>
Gerrit-MessageType: newchange
--TsoxkANZvHo=--