From: "cron2 (Code Review)" Date: Fri, 7 Nov 2025 17:06:58 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <3477763c1de74a8df9f956d6a62558160671b9b6-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="S8vlKtP5qvI="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco_freebsd.c: add D_DCO_DEBUG messages for counters and notifications List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: flichtenheld , plaisthos , openvpn-devel --S8vlKtP5qvI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/13= 49?usp=3Demail ) Change subject: dco_freebsd.c: add D_DCO_DEBUG messages for counters and no= tifications ...................................................................... dco_freebsd.c: add D_DCO_DEBUG messages for counters and notifications Some of these debug messages only existed on Linux, and made debugging DCO issues on FreeBSD more difficult. Add them, using the same style as used for dco_linux.c While at it, change all format strings for "peerid" to "%u" (wherever appropriate, dco->dco_message_peer_id is an "int" today and changing this to uint32_t is out of scope for "make better logging") Change-Id: Ife55cb78401dad921b75f6c86d9bd0642f6a6e83 Signed-off-by: Gert Doering Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1349 Message-Id: <20251107165038.26171-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34= 250.html Signed-off-by: Gert Doering --- M src/openvpn/dco_freebsd.c 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c index 3521fca..f80b6df 100644 --- a/src/openvpn/dco_freebsd.c +++ b/src/openvpn/dco_freebsd.c @@ -147,7 +147,7 @@ nvl =3D nvlist_create(0); - msg(D_DCO_DEBUG, "%s: peer-id %d, fd %d", __func__, peerid, sd); + msg(D_DCO_DEBUG, "%s: peer-id %u, fd %d", __func__, peerid, sd); if (localaddr) { @@ -363,7 +363,7 @@ nvlist_t *nvl; int ret; - msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peerid); + msg(D_DCO_DEBUG, "%s: peer-id %u", __func__, peerid); nvl =3D nvlist_create(0); nvlist_add_number(nvl, "peerid", peerid); @@ -392,7 +392,7 @@ nvlist_t *nvl; int ret; - msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peerid); + msg(D_DCO_DEBUG, "%s: peer-id %u", __func__, peerid); nvl =3D nvlist_create(0); nvlist_add_number(nvl, "peerid", peerid); @@ -421,7 +421,7 @@ nvlist_t *nvl; int ret; - msg(D_DCO_DEBUG, "%s: peer-id %d, slot %d", __func__, peerid, slot); + msg(D_DCO_DEBUG, "%s: peer-id %u, slot %d", __func__, peerid, slot); nvl =3D nvlist_create(0); nvlist_add_number(nvl, "slot", slot); @@ -493,7 +493,7 @@ nvlist_t *nvl, *encrypt_nvl, *decrypt_nvl; int ret; - msg(D_DCO_DEBUG, "%s: slot %d, key-id %d, peer-id %d, cipher %s, epoch= %d", __func__, slot, keyid, peerid, + msg(D_DCO_DEBUG, "%s: slot %d, key-id %d, peer-id %u, cipher %s, epoch= %d", __func__, slot, keyid, peerid, ciphername, epoch); nvl =3D nvlist_create(0); @@ -539,7 +539,7 @@ nvlist_t *nvl; int ret; - msg(D_DCO_DEBUG, "%s: peer-id %d, ping interval %d, ping timeout %d", = __func__, peerid, + msg(D_DCO_DEBUG, "%s: peer-id %u, ping interval %d, ping timeout %d", = __func__, peerid, keepalive_interval, keepalive_timeout); nvl =3D nvlist_create(0); @@ -569,7 +569,7 @@ { if (peerid >=3D m->max_clients || !m->instances[peerid]) { - msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by = kernel", peerid); + msg(M_WARN, "dco_update_peer_stat: invalid peer ID %u returned by = kernel", peerid); return; } @@ -577,6 +577,9 @@ mi->context.c2.dco_read_bytes =3D nvlist_get_number(nvl, "in"); mi->context.c2.dco_write_bytes =3D nvlist_get_number(nvl, "out"); + + msg(D_DCO_DEBUG, "%s: peer-id %u, dco_read_bytes: " counter_format " d= co_write_bytes: " counter_format, + __func__, peerid, mi->context.c2.dco_read_bytes, mi->context.c2.dc= o_write_bytes); } int @@ -614,6 +617,7 @@ dco->dco_message_peer_id =3D nvlist_get_number(nvl, "peerid"); type =3D nvlist_get_number(nvl, "notification"); + switch (type) { case OVPN_NOTIF_DEL_PEER: @@ -631,6 +635,8 @@ dco->dco_del_peer_reason =3D OVPN_DEL_PEER_REASON_USER= SPACE; } } + msg(D_DCO_DEBUG, "%s: received NOTIF_DEL_PEER for peer-id=3D%d= , reason=3D%d", __func__, + dco->dco_message_peer_id, dco->dco_del_peer_reason); if (nvlist_exists_nvlist(nvl, "bytes")) { @@ -651,6 +657,8 @@ break; case OVPN_NOTIF_ROTATE_KEY: + msg(D_DCO_DEBUG, "%s: received NOTIF_ROTATE_KEY for peer-id=3D= %d", __func__, + dco->dco_message_peer_id); dco->dco_message_type =3D OVPN_CMD_SWAP_KEYS; break; @@ -670,12 +678,14 @@ msg(M_WARN, "Failed to parse float notification"); break; } + msg(D_DCO_DEBUG, "%s: received NOTIF_FLOAT for peer-id=3D%d", = __func__, + dco->dco_message_peer_id); dco->dco_message_type =3D OVPN_CMD_FLOAT_PEER; break; } default: - msg(M_WARN, "Unknown kernel notification %d", type); + msg(M_WARN, "%s: unknown kernel notification %d", __func__, ty= pe); break; } @@ -815,6 +825,8 @@ return 0; } + msg(D_DCO_DEBUG, __func__); + CLEAR(drv); snprintf(drv.ifd_name, IFNAMSIZ, "%s", dco->ifname); drv.ifd_cmd =3D OVPN_GET_PEER_STATS; @@ -873,6 +885,7 @@ int dco_get_peer_stats(struct context *c, const bool raise_sigusr1_on_err) { + msg(D_DCO_DEBUG, __func__); /* Not implemented. */ return 0; } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1349?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ife55cb78401dad921b75f6c86d9bd0642f6a6e83 Gerrit-Change-Number: 1349 Gerrit-PatchSet: 4 Gerrit-Owner: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel --S8vlKtP5qvI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 sub= mitted this change.

View Change

dco_freebsd.c: add D_DCO_DEBUG messages for coun=
ters and notifications

Some of these debug messages only existed on = Linux, and made debugging
DCO issues on FreeBSD more difficult. Add the= m, using the same style as
used for dco_linux.c

While at it, chan= ge all format strings for "peerid" to "%u" (whereverappropriate, dco->dco_message_peer_id is an "int" today and c= hanging
this to uint32_t is out of scope for "make better logging&q= uot;)

Change-Id: Ife55cb78401dad921b75f6c86d9bd0642f6a6e83
Signed= -off-by: Gert Doering <gert@...1296...>
Acked-by: Frank Lichtenhel= d <frank@...2641...>
Gerrit URL: https://gerrit.openvpn.net/c/open= vpn/+/1349
Message-Id: <20251107165038.26171-1-gert@...1296...>URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg3= 4250.html
Signed-off-by: Gert Doering <gert@...1296...>
---
= M src/openvpn/dco_freebsd.c
1 file changed, 21 insertions(+), 8 deletion= s(-)

diff --git a/src/openvpn/dco_freebsd.c b/src/openvpn/dco_freebsd.c
index 3521fca..f80b6df 100644
--- a/src/openvpn/= dco_freebsd.c
+++ b/src/openvpn/dco_freebsd.c
@@ -147,7 +147,7 @@

nvl =3D nvlis= t_create(0);

- msg(D_DCO_DEBUG, "%s: peer-id %d, fd %d", __func__, = peerid, sd);
+ msg= (D_DCO_DEBUG, "%s: peer-id %u, fd %d", __func__, peerid, sd);


if (localaddr)
{
@@ -363,7 +363,7 @@
nvlist_t *nvl;
int ret;

- msg(D_DCO_DEBUG, "%s: peer-id %d", __fu= nc__, peerid);
+ m= sg(D_DCO_DEBUG, "%s: peer-id %u", __func__, peerid);

nvl =3D nvlist_create(0);
n= vlist_add_number(nvl, "peerid", peerid);
@@ -392,= 7 +392,7 @@
nvlist_t *nvl;
int re= t;

- = msg(D_DCO_DEBUG, "%s: peer-id %d", __func__, peerid);+ msg(D_DCO_DEBUG, "%= s: peer-id %u", __func__, peerid);

= nvl =3D nvlist_create(0);
nvlist_add_number(nvl, &= quot;peerid", peerid);
@@ -421,7 +421,7 @@
<= span> nvlist_t *nvl;

int ret;

- msg(D_DCO_DEBUG, &qu= ot;%s: peer-id %d, slot %d", __func__, peerid, slot);
+ msg(D_DCO_DEBUG, "%s: peer-= id %u, slot %d", __func__, peerid, slot);

= nvl =3D nvlist_create(0);
nvlist_add_number= (nvl, "slot", slot);
@@ -493,7 +493,7 @@ nvlist_t *nvl, *encrypt_nvl, *decrypt_nvl;
= int ret;

- msg(D_DCO_DEBUG, "%s: slot %d, key-id %d, peer-id %d, ciphe= r %s, epoch %d", __func__, slot, keyid, peerid,
+ msg(D_DCO_DEBUG, "%s: slot %d, k= ey-id %d, peer-id %u, cipher %s, epoch %d", __func__, slot, keyid, pee= rid,
ciphername, epoch);
<= br> nvl =3D nvlist_create(0);
@@ -539,7 +539,7 @@=
nvlist_t *nvl;
int ret;
- msg(D_DC= O_DEBUG, "%s: peer-id %d, ping interval %d, ping timeout %d", __f= unc__, peerid,
+ m= sg(D_DCO_DEBUG, "%s: peer-id %u, ping interval %d, ping timeout %d&quo= t;, __func__, peerid,
keepalive_interval, keepaliv= e_timeout);

nvl =3D nvlist_create(0)= ;
@@ -569,7 +569,7 @@
{
= if (peerid >=3D m->max_clients || !m->instances[peerid])=
{
- = msg(M_WARN, "dco_update_peer_stat: invalid peer ID %d returned by k= ernel", peerid);
+ msg(M_WARN, "dco_update_peer_stat: invalid peer ID %u return= ed by kernel", peerid);
return;
}


@@ -577,6 +577,9 @@
<= span>
mi->context.c2.dco_read_bytes =3D nvlist_get= _number(nvl, "in");
mi->context.c2.dco_wr= ite_bytes =3D nvlist_get_number(nvl, "out");
+
+ msg(D_DCO_DEBUG, "%s: peer-id %u, dco_read_bytes: = " counter_format " dco_write_bytes: " counter_format,=
+ __func__, peerid, = mi->context.c2.dco_read_bytes, mi->context.c2.dco_write_bytes);
}

int
@@ -61= 4,6 +617,7 @@
dco->dco_message_peer_id =3D nvlist_g= et_number(nvl, "peerid");

= type =3D nvlist_get_number(nvl, "notification");
+
switch (type)<= /span>
{
case OVPN_NOTIF_DEL_PEER:
@@ -631,6 +635,8 @@
dco= ->dco_del_peer_reason =3D OVPN_DEL_PEER_REASON_USERSPACE;
}

}
+ msg(D_DCO_DEBUG, "%s: re= ceived NOTIF_DEL_PEER for peer-id=3D%d, reason=3D%d", __func__,=
+ dco->dc= o_message_peer_id, dco->dco_del_peer_reason);
if (nvlist_exists_nvlist(nvl, "bytes"))
{
@@ -651,6 +657,8 @@
break;


case OVP= N_NOTIF_ROTATE_KEY:
+= msg(D_DCO_DEBUG, "%s: received NOTIF_ROTATE_KEY for peer-i= d=3D%d", __func__,
+ dco->dco_message_peer_id);
= dco->dco_message_type =3D OVPN_CMD_SWAP_KEYS;
= break;

@@ -670,12 +678,14 @@
msg(M_WARN, "Failed to parse float notific= ation");
break;
= }
+ = msg(D_DCO_DEBUG, "%s: received NOTIF_FLOAT for peer-id=3D%d", _= _func__,
+ = dco->dco_message_peer_id);
dco->dco= _message_type =3D OVPN_CMD_FLOAT_PEER;
break;<= /span>
}

defau= lt:
- msg(M_= WARN, "Unknown kernel notification %d", type);
+ msg(M_WARN, "%s: unkn= own kernel notification %d", __func__, type);
= break;
}

@@ -81= 5,6 +825,8 @@
return 0;
}


+ m= sg(D_DCO_DEBUG, __func__);
+
CLEAR(drv);
snprintf(drv.= ifd_name, IFNAMSIZ, "%s", dco->ifname);
d= rv.ifd_cmd =3D OVPN_GET_PEER_STATS;
@@ -873,6 +885,7 @@
int
dco_get_peer_stats(struct context *c, co= nst bool raise_sigusr1_on_err)
{
+ msg(D_DCO_DEBUG, __func__);
/* Not implemented. */

return 0;
}

To view, visit change 1349. To unsubs= cribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ife55cb78401dad921b75f6c86d9= bd0642f6a6e83
Gerrit-Change-Number: 1349
Gerrit-PatchSet: 4
Gerrit-Owner: 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>
= --S8vlKtP5qvI=--