From: "ralf_lici (Code Review)" Date: Sun, 19 Oct 2025 12:05:57 +0000 In-Reply-To: References: Reply-To: ralf@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726..., gert@...1296... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Tve249g0UFo="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco-freebsd: store peer stats directly in c2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --Tve249g0UFo= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: cron2, flichtenheld, ordex, plaisthos. Hello cron2, flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/1275?usp=3Demail to look at the new patch set (#4). Change subject: dco-freebsd: store peer stats directly in c2 ...................................................................... dco-freebsd: store peer stats directly in c2 The dco_context_t structure includes a reference to the general context structure c, which allows us to store dco_read_bytes and dco_write_bytes directly as c2 fields. This aligns the FreeBSD implementation with how we handle DCO peer stats on Linux and Windows. Change-Id: I53dd40fabdeacb9dca843e28fdd3b357711c5a84 Signed-off-by: Ralf Lici --- M src/openvpn/dco_freebsd.c 1 file changed, 16 insertions(+), 19 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/75/1275/4 diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 947a769..e51f8dd 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -564,6 +564,21 @@ return ret; } +static void +dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlis= t_t *nvl) +{ + if (peerid >=3D m->max_clients || !m->instances[peerid]) + { + msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by = kernel", peerid); + return; + } + + struct multi_instance *mi =3D m->instances[peerid]; + + mi->context.c2.dco_read_bytes =3D nvlist_get_number(nvl, "in"); + mi->context.c2.dco_write_bytes =3D nvlist_get_number(nvl, "out"); +} + int dco_do_read(dco_context_t *dco) { @@ -619,10 +634,7 @@ if (nvlist_exists_nvlist(nvl, "bytes")) { - const nvlist_t *bytes =3D nvlist_get_nvlist(nvl, "bytes"); - - dco->dco_read_bytes =3D nvlist_get_number(bytes, "in"); - dco->dco_write_bytes =3D nvlist_get_number(bytes, "out"); + dco_update_peer_stat(dco->c->multi, dco->dco_message_peer_= id, nvlist_get_nvlist(nvl, "bytes")); } dco->dco_message_type =3D OVPN_CMD_DEL_PEER; @@ -777,21 +789,6 @@ nvlist_destroy(nvl); } -static void -dco_update_peer_stat(struct multi_context *m, uint32_t peerid, const nvlis= t_t *nvl) -{ - if (peerid >=3D m->max_clients || !m->instances[peerid]) - { - msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by = kernel", peerid); - return; - } - - struct multi_instance *mi =3D m->instances[peerid]; - - mi->context.c2.dco_read_bytes =3D nvlist_get_number(nvl, "in"); - mi->context.c2.dco_write_bytes =3D nvlist_get_number(nvl, "out"); -} - int dco_get_peer_stats_multi(dco_context_t *dco, const bool raise_sigusr1_on_e= rr) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1275?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: I53dd40fabdeacb9dca843e28fdd3b357711c5a84 Gerrit-Change-Number: 1275 Gerrit-PatchSet: 4 Gerrit-Owner: ralf_lici Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-CC: ordex Gerrit-Attention: plaisthos Gerrit-Attention: cron2 Gerrit-Attention: flichtenheld Gerrit-Attention: ordex --Tve249g0UFo= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

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

ralf_lici uploaded patch set #4 to this change.

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

dco-freebsd: store peer stats directly in c2
The dco_context_t structure includes a reference to the general contextstructure c, which allows us to store dco_read_bytes and dco_write_bytesdirectly as c2 fields. This aligns the FreeBSD implementation with howwe handle DCO peer stats on Linux and Windows.

Change-Id: I53dd40fa= bdeacb9dca843e28fdd3b357711c5a84
Signed-off-by: Ralf Lici <ralf@...1664...= 26...>
---
M src/openvpn/dco_freebsd.c
1 file changed, 16 inser= tions(+), 19 deletions(-)

git pull ssh://gerrit.=
openvpn.net:29418/openvpn refs/changes/75/1275/4
diff --git a/src/o=
penvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index 947a= 769..e51f8dd 100644
--- a/src/openvpn/dco_freebsd.c<= br>+++ b/src/openvpn/dco_freebsd.c
@@ -564,6 +564,21 = @@
return ret;
}

+static void
= +dco_update_peer_stat(struct mu= lti_context *m, uint32_t peerid, const nvlist_t *nvl)
+{
+ if (peerid >=3D m->max_clients || !m->instance= s[peerid])
+ {
+ msg(M_WARN, &qu= ot;dco_update_peer_stat: invalid peer ID %d returned by kernel", peeri= d);
+ return;<= /span>
+ }
+

+ struct multi_instance *mi =3D m->instances[pee= rid];
+
+ mi->context.c2.dco_read_by= tes =3D nvlist_get_number(nvl, "in");

+ mi->context.c2.dco_write_bytes =3D nvlis= t_get_number(nvl, "out");
+}
+
int
dco_do_read(dco_context_t *dco)=
{
@@ -619,10 +634,7 @@
<= br> if (nvlist_exists_nvlist(nvl, "bytes"))
{
- const nvlist_t *bytes =3D nvlist_get_nvlist(nvl, &quo= t;bytes");
-
- dco->dco= _read_bytes =3D nvlist_get_number(bytes, "in");
- dco->dco_write_bytes= =3D nvlist_get_number(bytes, "out");
+ dco_update_peer_stat(dco->c-= >multi, dco->dco_message_peer_id, nvlist_get_nvlist(nvl, "bytes&= quot;));
}

= dco->dco_message_type =3D OVPN_CMD_DEL_PEER;
@@ -777,21 +789,6 @@

nvlist_destroy(nvl);
<= span> }


-static void
-dco_up= date_peer_stat(struct multi_context *m, uint32_t peerid, const nvlist_t *nv= l)
-{
- if (peerid >=3D m->max_client= s || !m->instances[peerid])
- {
- = msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by ker= nel", peerid);
- = return;
- }
-
- struct multi_instance *mi =3D m->ins= tances[peerid];
-
- mi->context.c2.dco_r= ead_bytes =3D nvlist_get_number(nvl, "in");
- mi->context.c2.dco_write_bytes =3D n= vlist_get_number(nvl, "out");
-}
-
int
dco_get_peer_stats_multi(dco_context_t= *dco, const bool raise_sigusr1_on_err)
{
=

To view, visit change 1275. To unsubscribe, or for help wri= ting mail filters, visit settings.

=
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I53dd40fabdeacb9dca843e28fdd= 3b357711c5a84
Gerrit-Change-Number: 1275
Gerrit-PatchSet: 4
Gerrit-Owner: ralf_lici <ralf@...2726...>= ;
Gerrit-Reviewer: cron2 <gert@...1296...>=
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 <antonio@...2726...>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: cron2 <gert@...1296...>= ;
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <antonio@...2726...= >
= --Tve249g0UFo=--