From: "cron2 (Code Review)" Date: Wed, 23 Jul 2025 08:18:42 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., antonio@...2726... Message-ID: <405b2fe22f7edffc080fc5ed35d5b0ba197f5271-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="i5FYQPG4bg4="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco_linux: use M_FATAL instead of M_ERR in netlink error code paths List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: plaisthos , flichtenheld , openvpn-devel --i5FYQPG4bg4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/10= 96?usp=3Demail ) Change subject: dco_linux: use M_FATAL instead of M_ERR in netlink error co= de paths ...................................................................... dco_linux: use M_FATAL instead of M_ERR in netlink error code paths Netlink code doesn't set errno upon error (with the exception of any *alloc() function which probably inherits the errno=3DENOMEM from the underlying malloc call), therefore we should not print error messages with M_ERR, but rather rely on M_FATAL. M_ERR is equivalent to M_FATAL with the addition of appending ": $errno" to the error string. Since errno is not meaningful in this context, we can just opt for the less confusing M_FATAL. Change-Id: Ifc442b4426c02de7282d0f69629e8a10b679c589 Signed-off-by: Antonio Quartulli Acked-by: Gert Doering Message-Id: <20250723063039.25449-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg32= 271.html Signed-off-by: Gert Doering --- M src/openvpn/dco_linux.c 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 0a73882..a04a164 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -114,7 +114,7 @@ struct nl_msg *nl_msg =3D nlmsg_alloc(); if (!nl_msg) { - msg(M_ERR, "cannot allocate netlink message"); + msg(M_FATAL, "cannot allocate netlink message"); return NULL; } @@ -140,7 +140,7 @@ break; case -NLE_NOMEM: - msg(M_ERR, "%s: netlink out of memory error", prefix); + msg(M_FATAL, "%s: netlink out of memory error", prefix); break; case -NLE_AGAIN: @@ -148,7 +148,7 @@ break; case -NLE_NODEV: - msg(M_ERR, "%s: netlink reports device not found:", prefix); + msg(M_FATAL, "%s: netlink reports device not found:", prefix); break; case -NLE_OBJ_NOTFOUND: @@ -387,19 +387,19 @@ static void ovpn_dco_init_netlink(dco_context_t *dco) { - dco->ovpn_dco_id =3D resolve_ovpn_netlink_id(M_ERR); + dco->ovpn_dco_id =3D resolve_ovpn_netlink_id(M_FATAL); dco->nl_sock =3D nl_socket_alloc(); if (!dco->nl_sock) { - msg(M_ERR, "Cannot create netlink socket"); + msg(M_FATAL, "Cannot create netlink socket"); } int ret =3D genl_connect(dco->nl_sock); if (ret) { - msg(M_ERR, "Cannot connect to generic netlink: %s", + msg(M_FATAL, "Cannot connect to generic netlink: %s", nl_geterror(ret)); } @@ -415,7 +415,7 @@ dco->nl_cb =3D nl_cb_alloc(NL_CB_DEFAULT); if (!dco->nl_cb) { - msg(M_ERR, "failed to allocate netlink callback"); + msg(M_FATAL, "failed to allocate netlink callback"); } nl_socket_set_cb(dco->nl_sock, dco->nl_cb); @@ -478,7 +478,7 @@ if (dco->ovpn_dco_mcast_id < 0) { - msg(M_ERR, "cannot get mcast group: %s", nl_geterror(dco->ovpn_dc= o_mcast_id)); + msg(M_FATAL, "cannot get mcast group: %s", nl_geterror(dco->ovpn_= dco_mcast_id)); } /* Register for ovpn-dco specific multicast messages that the kernel m= ay @@ -487,7 +487,7 @@ int ret =3D nl_socket_add_membership(dco->nl_sock, dco->ovpn_dco_mcast= _id); if (ret) { - msg(M_ERR, "%s: failed to join groups: %d", __func__, ret); + msg(M_FATAL, "%s: failed to join groups: %d", __func__, ret); } } -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1096?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: Ifc442b4426c02de7282d0f69629e8a10b679c589 Gerrit-Change-Number: 1096 Gerrit-PatchSet: 3 Gerrit-Owner: ordex Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --i5FYQPG4bg4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

dco_linux: use M_FATAL instead of M_ERR in ne=
tlink error code paths

Netlink code doesn't set errno upon error= (with the exception of
any *alloc() function which probably inherits th= e errno=3DENOMEM
from the underlying malloc call), therefore we should n= ot print
error messages with M_ERR, but rather rely on M_FATAL.

M= _ERR is equivalent to M_FATAL with the addition of appending
": $er= rno" to the error string.

Since errno is not meaningful in this= context, we can just opt
for the less confusing M_FATAL.

Change-= Id: Ifc442b4426c02de7282d0f69629e8a10b679c589
Signed-off-by: Antonio Qua= rtulli <antonio@...2726...>
Acked-by: Gert Doering <gert@...1826...= 6...>
Message-Id: <20250723063039.25449-1-gert@...1296...>
U= RL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg322= 71.html
Signed-off-by: Gert Doering <gert@...1296...>
---
M = src/openvpn/dco_linux.c
1 file changed, 9 insertions(+), 9 deletions(-)<= br>
diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.cindex 0a73882..a04a164 100644
--- a/src/openvpn/dco_= linux.c
+++ b/src/openvpn/dco_linux.c
@@ -1= 14,7 +114,7 @@
struct nl_msg *nl_msg =3D nlmsg_alloc()= ;
if (!nl_msg)
{
- msg(M_ERR, "cannot alloca= te netlink message");
+ msg(M_FATAL, "cannot allocate netlink message");
return NULL;
}

@@ -140,7 +140,7 @@
break;<= /span>

case -NLE_NOMEM:
- msg(M_ERR, "%s: netl= ink out of memory error", prefix);

+ msg(M_FATAL, "%s: netlink out of memor= y error", prefix);
break;

case -NLE_AGAIN:
@@ -148,7 +148= ,7 @@
break;

case -NLE_NODEV:
- msg(M_ERR, "%s: netlink reports device not found:&quo= t;, prefix);
+ = msg(M_FATAL, "%s: netlink reports device not found:", prefix= );
break;

= case -NLE_OBJ_NOTFOUND:
@@ -387,19 +387,19 @@=
static void
ovpn_dco_init_netlink(dco_context_t= *dco)
{
- dco->ovpn_dco_id =3D resolve_ovpn_netlink_id(M_ERR);
<= span style=3D"color: hsl(120, 100%, 40%);">+ dco->ovpn_dco_id =3D res= olve_ovpn_netlink_id(M_FATAL);

dco-&= gt;nl_sock =3D nl_socket_alloc();

if= (!dco->nl_sock)
{
- msg(M_ERR, "Cannot create netlink socket&= quot;);
+ msg(= M_FATAL, "Cannot create netlink socket");
}<= /span>

int ret =3D genl_connect(dco->nl_= sock);
if (ret)
{
- msg(M_ERR, "Cannot conne= ct to generic netlink: %s",

+ msg(M_FATAL, "Cannot connect to generic netlink: = %s",
nl_geterror(ret));
= }

@@ -415,7 +415,7 @@
dco->nl_cb =3D nl_cb_alloc(NL_CB_DEFAULT);
if= (!dco->nl_cb)
{
- msg(M_ERR, "failed to allocate netlink call= back");
+ = msg(M_FATAL, "failed to allocate netlink callback");
<= span> }

nl_socket_set_cb(dco->= ;nl_sock, dco->nl_cb);
@@ -478,7 +478,7 @@

if (dco->ovpn_dco_mcast_id < 0)
<= span> {
- ms= g(M_ERR, "cannot get mcast group: %s", nl_geterror(dco->ovpn_= dco_mcast_id));
+ = msg(M_FATAL, "cannot get mcast group: %s", nl_geterror(dco-&= gt;ovpn_dco_mcast_id));
}

= /* Register for ovpn-dco specific multicast messages that the ke= rnel may
@@ -487,7 +487,7 @@
int ret = =3D nl_socket_add_membership(dco->nl_sock, dco->ovpn_dco_mcast_id);
if (ret)
{
- msg(M_ERR, "%s: failed to join= groups: %d", __func__, ret);
+ msg(M_FATAL, "%s: failed to join groups: %d&quo= t;, __func__, ret);
}
}


To view, visit change 1096. To unsubsc= ribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc442b4426c02de7282d0f69629= e8a10b679c589
Gerrit-Change-Number: 1096
Gerrit-PatchSet: 3
Gerrit-Owner: ordex <antonio@...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-MessageType: merged
--i5FYQPG4bg4=--