From: "its_Giaan (Code Review)" Date: Wed, 23 Oct 2024 11:04:53 +0000 In-Reply-To: References: Reply-To: gianmarco@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <24290c8f5eaa13a2d588aca513ca77de019769d0-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="wHscPk1baZI="; 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 --wHscPk1baZI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: its_Giaan, plaisthos. Hello flichtenheld, ordex, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/759?usp=3Demail to look at the new patch set (#6). The change is no longer submittable: checks~ChecksSubmitRule is unsatisfied= now. 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 Signed-off-by: Gianmarco De Gregori --- M src/openvpn/forward.c 1 file changed, 14 insertions(+), 16 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/59/759/6 diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 6f279ec..66e5be1 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -2065,20 +2065,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 SOCKET_SHIFT; /* depends on SOCKET= _READ and SOCKET_WRITE */ + static uintptr_t tun_shift =3D TUN_SHIFT; /* depends on TUN_READ = and TUN_WRITE */ + static uintptr_t err_shift =3D ERR_SHIFT; /* depends on ES_ERROR = */ #ifdef ENABLE_MANAGEMENT - static int management_shift =3D MANAGEMENT_SHIFT; + static uintptr_t management_shift =3D MANAGEMENT_SHIFT; /* 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 /* @@ -2092,7 +2090,7 @@ */ if (flags & IOW_WAIT_SIGNAL) { - wait_signal(c->c2.event_set, (void *)&err_shift); + wait_signal(c->c2.event_set, (void *)err_shift); } /* @@ -2185,19 +2183,19 @@ /* * 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); + 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, NULL= ); #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD) if (socket & EVENT_READ && c->c2.did_open_tun) { - dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (void *)&dco_sh= ift); + dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (void *)dco_shi= ft); } #endif =20 #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 @@ -2205,7 +2203,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 @@ -2248,7 +2246,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: 6 Gerrit-Owner: its_Giaan Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-CC: ordex Gerrit-Attention: plaisthos Gerrit-Attention: its_Giaan Gerrit-MessageType: newpatchset --wHscPk1baZI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: its_Giaan, plaisthos.

its_Giaan uploaded patch set #6 to this change.

<= a href=3D"http://gerrit.openvpn.net/c/openvpn/+/759?usp=3Demail">View Chang= e

The change is no longer submittable: checks~ChecksSubmitRule is= unsatisfied now.

io_work: convert shift argument to uintptr_t

Inste= ad of passing the shift argument as pointer, pass
directly its integer v= alue. This will allow the code to
distinguish a shift value from a real = object pointer,
like we already do in multi_tcp_process_io().

Thi= s change will allow us later to pass an event_arg
object as event handle= r argument instead of a simple
integer value.

Change-Id: Ib583bf1= 7e35b14aed78fd8217b6e71e8c2b78089
Signed-off-by: Antonio Quartulli <a= @...2181...>
Signed-off-by: Gianmarco De Gregori <gianmarco@...2788...= 6...>
---
M src/openvpn/forward.c
1 file changed, 14 insertions= (+), 16 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/open=
vpn refs/changes/59/759/6
diff --git a/src/openvpn/forward.c b/src/=
openvpn/forward.c
index 6f279ec..66e5be1 100644
<= span>--- a/src/openvpn/forward.c
+++ b/src/openvpn/forward.= c
@@ -2065,20 +2065,18 @@
unsigned int= tuntap =3D 0;
struct event_set_return esr[4];<= br>
- /* Thes= e shifts all depend on EVENT_READ (=3D1) and EVENT_WRITE (=3D2)
<= span style=3D"color: hsl(0, 100%, 40%);">- * 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;
<= span style=3D"color: hsl(0, 100%, 40%);">- static int err_shift =3D ERR_= SHIFT;
+ /* These = shifts all depend on EVENT_READ and EVENT_WRITE */
+ static uintptr_t socket_shift =3D SOCKET= _SHIFT; /* depends on SOCKET_READ and SOCKET_WRITE */
+ static uintptr_t tun_shift =3D TUN_= SHIFT; /* depends on TUN_READ and TUN_WRITE */
+ static uintptr_t err_shift =3D ERR_SH= IFT; /* depends on ES_ERROR */
#ifdef ENABLE_MANAGEME= NT
- static int mana= gement_shift =3D MANAGEMENT_SHIFT;
+ static uintptr_t management_shift =3D MANAGEMENT_SHIFT; = /* depends on MANAGEMENT_READ and MANAGEMENT_WRITE */
#end= if
#ifdef ENABLE_ASYNC_PUSH
- static int file_shift =3D FILE_SHIFT;
= + static uintptr_t file_shif= t =3D FILE_SHIFT;
#endif
#if defined(TARG= ET_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 linu= x kernel module */
#endif

/*
@@ -2092,7 +2090,7 @@
*/
if (flags & IOW_WAIT_SIGNAL)
{<= /span>
- wait_signal(c-= >c2.event_set, (void *)&err_shift);
+ wait_signal(c->c2.event_set, (void *)err_= shift);
}

/*
@@ -2185,19 +2183,19 @@
/*
* Configure event wait based on socket, tuntap flags.

*/

- socke= t_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, N= ULL);
+ socket_set= (c->c2.link_socket, c->c2.event_set, socket, (void *)socket_shift, NU= LL);
+ tun_set(c-&= gt;c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift, NULL);<= br> #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
if (socket & EVENT_READ && c->c2.did_open_tun)

{
- = dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (void = *)&dco_shift);
+ = dco_event_set(&c->c1.tuntap->dco, c->c2.event_set, (voi= d *)dco_shift);
}
#endif

#ifdef ENABLE_MANAGEMENT
if (ma= nagement)
{
- management_socket_set(management, c->c2.event_set, (v= oid *)&management_shift, NULL);
+ management_socket_set(management, c->c2.event_se= t, (void *)management_shift, NULL);
}
= #endif

@@ -2205,7 +2203,7 @@
<= span> /* arm inotify watcher */
if (c->options.= mode =3D=3D MODE_SERVER)
{
- event_ctl(c->c2.event_set, c->c2.in= otify_fd, EVENT_READ, (void *)&file_shift);
+ event_ctl(c->c2.event_set, c->c2.= inotify_fd, EVENT_READ, (void *)file_shift);
}<= br> #endif

@@ -2248,7 +2246,7 @@

for (i =3D 0; i < status; ++i)
= {
const struct = event_set_return *e =3D &esr[i];
- c->c2.event_set_status |=3D ((e->r= wflags & 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 c= hange 759. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib583bf17e35b14aed78fd8217b6= e71e8c2b78089
Gerrit-Change-Number: 759
Gerrit-PatchSet: 6
Gerrit-Owner: its_Giaan <gianmarco@...2786...= ..>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-CC: ordex <a@...2181...>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: its_Giaan <gianmarco@...1665...= 726...>
Gerrit-MessageType: newpatchset
--wHscPk1baZI=--