From: "cron2 (Code Review)" Date: Mon, 15 Dec 2025 15:42:01 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <839b104bfba77cfedd186042b845839a479144cf-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="R/Tvjm/ke/Q="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: multi: Fix type handling for hashes, mostly inotify_watchers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --R/Tvjm/ke/Q= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#10) to the change originally created b= y flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1312?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: multi: Fix type handling for hashes, mostly inotify_watchers ...................................................................... multi: Fix type handling for hashes, mostly inotify_watchers Change-Id: Idede28c850def5e3b4a17dcbd0a5771f15cfc668 Signed-off-by: Frank Lichtenheld Acked-by: Gert Doering Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1312 Message-Id: <20251215145528.18047-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg35= 072.html Signed-off-by: Gert Doering --- M src/openvpn/multi.c 1 file changed, 15 insertions(+), 14 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/12/1312/10 diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index d9cb3a9..20d72c1 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -257,7 +257,7 @@ */ int_hash_function(const void *key, uint32_t iv) { - return (unsigned long)key; + return (uint32_t)(uintptr_t)key; } static bool @@ -295,22 +295,23 @@ * to determine which client sent an incoming packet * which is seen on the TCP/UDP socket. */ - m->hash =3D hash_init(t->options.real_hash_size, get_random(), mroute_= addr_hash_function, - mroute_addr_compare_function); + m->hash =3D hash_init(t->options.real_hash_size, (uint32_t)get_random(= ), + mroute_addr_hash_function, mroute_addr_compare_fun= ction); /* * Virtual address hash table. Used to determine * which client to route a packet to. */ - m->vhash =3D hash_init(t->options.virtual_hash_size, get_random(), mro= ute_addr_hash_function, - mroute_addr_compare_function); + m->vhash =3D hash_init(t->options.virtual_hash_size, (uint32_t)get_ran= dom(), + mroute_addr_hash_function, mroute_addr_compare_fu= nction); /* * This hash table is a clone of m->hash but with a * bucket size of one so that it can be used * for fast iteration through the list. */ - m->iter =3D hash_init(1, get_random(), mroute_addr_hash_function, mrou= te_addr_compare_function); + m->iter =3D hash_init(1, (uint32_t)get_random(), mroute_addr_hash_func= tion, + mroute_addr_compare_function); #ifdef ENABLE_MANAGEMENT m->cid_hash =3D hash_init(t->options.real_hash_size, 0, cid_hash_funct= ion, cid_compare_function); @@ -321,8 +322,8 @@ * Mapping between inotify watch descriptors and * multi_instances. */ - m->inotify_watchers =3D - hash_init(t->options.real_hash_size, get_random(), int_hash_functi= on, int_compare_function); + m->inotify_watchers =3D hash_init(t->options.real_hash_size, (uint32_t= )get_random(), + int_hash_function, int_compare_functio= n); #endif /* @@ -609,7 +610,7 @@ #ifdef ENABLE_ASYNC_PUSH if (mi->inotify_watch !=3D -1) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)mi->in= otify_watch); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inotif= y_watch); mi->inotify_watch =3D -1; } #endif @@ -2821,7 +2822,7 @@ msg(D_MULTI_DEBUG, "MULTI: modified fd %d, mask %d", pevent->wd, p= event->mask); struct multi_instance *mi =3D - hash_lookup(m->inotify_watchers, (void *)(unsigned long)pevent= ->wd); + hash_lookup(m->inotify_watchers, (void *)(uintptr_t)pevent->wd= ); if (pevent->mask & IN_CLOSE_WRITE) { @@ -2840,7 +2841,7 @@ /* this event is _always_ fired when watch is removed or file = is deleted */ if (mi) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)pe= vent->wd); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)pevent= ->wd); mi->inotify_watch =3D -1; } } @@ -2978,14 +2979,14 @@ const char *file) { /* watch acf file */ - long watch_descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE= _WRITE | IN_ONESHOT); + int watch_descriptor =3D inotify_add_watch(inotify_fd, file, IN_CLOSE_= WRITE | IN_ONESHOT); if (watch_descriptor >=3D 0) { if (mi->inotify_watch !=3D -1) { - hash_remove(m->inotify_watchers, (void *)(unsigned long)mi->in= otify_watch); + hash_remove(m->inotify_watchers, (void *)(uintptr_t)mi->inotif= y_watch); } - hash_add(m->inotify_watchers, (const uintptr_t *)watch_descriptor,= mi, true); + hash_add(m->inotify_watchers, (void *)(uintptr_t)watch_descriptor,= mi, true); mi->inotify_watch =3D watch_descriptor; } else -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1312?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: Idede28c850def5e3b4a17dcbd0a5771f15cfc668 Gerrit-Change-Number: 1312 Gerrit-PatchSet: 10 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --R/Tvjm/ke/Q= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 upl= oaded patch set #10 to the change originally created by flichtenhe= ld.

View Change

The following approvals got outdated and were remov= ed: Code-Review+2 by cron2

multi: Fix type handling for hashes=
, mostly inotify_watchers

Change-Id: Idede28c850def5e3b4a17dcbd0a577= 1f15cfc668
Signed-off-by: Frank Lichtenheld <frank@...2641...>
= Acked-by: Gert Doering <gert@...1296...>
Gerrit URL: https://gerri= t.openvpn.net/c/openvpn/+/1312
Message-Id: <20251215145528.18047-1-ge= rt@...1296...>
URL: https://www.mail-archive.com/openvpn-devel@...1199...= sourceforge.net/msg35072.html
Signed-off-by: Gert Doering <gert@...1711...= 96...>
---
M src/openvpn/multi.c
1 file changed, 15 insertions(= +), 14 deletions(-)

git pull ssh://gerrit.openvp=
n.net:29418/openvpn refs/changes/12/1312/10
diff --git a/src/openvp=
n/multi.c b/src/openvpn/multi.c
index d9cb3a9..20d72c1 1006= 44
--- a/src/openvpn/multi.c
+++ b/src/open= vpn/multi.c
@@ -257,7 +257,7 @@
*/=
int_hash_function(const void *key, uint32_t iv)
= {
- return (unsigne= d long)key;
+ retu= rn (uint32_t)(uintptr_t)key;
}
static bool
@@ -295,22 +295,23 @@
= * to determine which client sent an incoming packet
= * which is seen on the TCP/UDP socket.
*/<= br>- m->hash =3D hash_init(= t->options.real_hash_size, get_random(), mroute_addr_hash_function,
- mr= oute_addr_compare_function);
+ m->hash =3D hash_init(t->options.real_hash_size, (uint32= _t)get_random(),
+ = mroute_addr_hash_function, mroute_addr_compare_functio= n);

/*
* Virtu= al address hash table. Used to determine
* which cli= ent to route a packet to.
*/
- m->vhash =3D hash_init(t->options.vi= rtual_hash_size, get_random(), mroute_addr_hash_function,
- mroute_addr_co= mpare_function);
+ = m->vhash =3D hash_init(t->options.virtual_hash_size, (uint32_t)get_r= andom(),
+ = mroute_addr_hash_function, mroute_addr_compare_function);

/*
* This hash ta= ble is a clone of m->hash but with a
* bucket size= of one so that it can be used
* for fast iteration t= hrough the list.
*/
- m->iter =3D hash_init(1, get_random(), mroute_ad= dr_hash_function, mroute_addr_compare_function);
+ m->iter =3D hash_init(1, (uint32_t)get_= random(), mroute_addr_hash_function,
+ mroute_addr_compare_function);

#ifdef ENABLE_MANAGEMENT
= m->cid_hash =3D hash_init(t->options.real_hash_size, 0, cid_hash_f= unction, cid_compare_function);
@@ -321,8 +322,8 @@<= br> * Mapping between inotify watch descriptors and
* multi_instances.

*/
- m->inotify_watchers =3D
- hash_init(t->options.re= al_hash_size, get_random(), int_hash_function, int_compare_function);
+ m->inotify_watcher= s =3D hash_init(t->options.real_hash_size, (uint32_t)get_random(),
+ = int_hash_function, int_compare_function);
#endi= f

/*
@@ -609,7 +610,= 7 @@
#ifdef ENABLE_ASYNC_PUSH
if = (mi->inotify_watch !=3D -1)
{
- hash_remove(m->inotify_w= atchers, (void *)(unsigned long)mi->inotify_watch);
+ hash_remove(m->inotify_wa= tchers, (void *)(uintptr_t)mi->inotify_watch);
= mi->inotify_watch =3D -1;
}
#endif

@@ -2821,7 +2822,7 @@
msg= (D_MULTI_DEBUG, "MULTI: modified fd %d, mask %d", pevent->wd, = pevent->mask);

struct multi_i= nstance *mi =3D
- = hash_lookup(m->inotify_watchers, (void *)(unsigned long)pevent->= ;wd);
+ ha= sh_lookup(m->inotify_watchers, (void *)(uintptr_t)pevent->wd);=

if (pevent->mask & IN_CLOSE_WRI= TE)
{
@@ -2840,7 +2841,7 @@=
/* this event is _always_ fired when watch is remove= d or file is deleted */
if (mi)
{

- = hash_remove(m->inotify_watchers, (void *)(unsigned long)peven= t->wd);
+ = hash_remove(m->inotify_watchers, (void *)(uintptr_t)pevent->wd= );
mi->inotify_watch =3D -1;
= }
}
@@ -2978,14= +2979,14 @@
const char *file)
{
/* watch acf file */
- long watch_descriptor =3D inotify_ad= d_watch(inotify_fd, file, IN_CLOSE_WRITE | IN_ONESHOT);
+ int watch_descriptor =3D inotify_ad= d_watch(inotify_fd, file, IN_CLOSE_WRITE | IN_ONESHOT);
= if (watch_descriptor >=3D 0)
{
= if (mi->inotify_watch !=3D -1)
{<= br>- hash_remove(m->= ;inotify_watchers, (void *)(unsigned long)mi->inotify_watch);
= + hash_remove(m->= inotify_watchers, (void *)(uintptr_t)mi->inotify_watch);
}

- ha= sh_add(m->inotify_watchers, (const uintptr_t *)watch_descriptor, mi, tru= e);
+ hash_add= (m->inotify_watchers, (void *)(uintptr_t)watch_descriptor, mi, true);
mi->inotify_watch =3D watch_descriptor; }
else

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

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Idede28c850def5e3b4a17dcbd0a= 5771f15cfc668
Gerrit-Change-Number: 1312
Gerrit-PatchSet: 10
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
= --R/Tvjm/ke/Q=--