From: "ordex (Code Review)" Date: Tue, 22 Jul 2025 20:22:19 +0000 References: Reply-To: antonio@...2726..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="/HxEsRtsR78="; 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: , To: plaisthos , flichtenheld Cc: openvpn-devel --/HxEsRtsR78= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. Hello plaisthos, flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/1096?usp=3Demail to review the following change. 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 --- M src/openvpn/dco_linux.c 1 file changed, 9 insertions(+), 9 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/96/1096/1 diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index 58051f5..13506a1 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); @@ -484,7 +484,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 @@ -493,7 +493,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: 1 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --/HxEsRtsR78= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

ordex would like plaisthos and flichtenheld to review t= his change.

V= iew Change

dco_linux: use M_FATAL instead of M_ERR in netlink error cod=
e paths

Netlink code doesn't set errno upon error (with the exce= ption of
any *alloc() function which probably inherits the errno=3DENOME= M
from the underlying malloc call), therefore we should not print
err= or messages with M_ERR, but rather rely on M_FATAL.

M_ERR is equival= ent to M_FATAL with the addition of appending
": $errno" to th= e error string.

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

Change-Id: Ifc442b4426= c02de7282d0f69629e8a10b679c589
Signed-off-by: Antonio Quartulli <anto= nio@...2726...>
---
M src/openvpn/dco_linux.c
1 file changed, 9= insertions(+), 9 deletions(-)

git pull ssh://gerrit.openvpn.net:=
29418/openvpn refs/changes/96/1096/1
diff --git a/src/openvpn/dco_l=
inux.c b/src/openvpn/dco_linux.c
index 58051f5..13506a1 100= 644
--- 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_ms= g)
{
- msg(M_ERR, "cannot allocate netlink message");=
+ msg(M_FATAL, "= ;cannot allocate netlink message");
return NU= LL;
}

@@ -140,7 +140= ,7 @@
break;

case -NLE_NOMEM:
- msg(M_ERR, "%s: netlink out of memory error", pr= efix);
+ m= sg(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: netli= nk reports device not found:", prefix);
b= reak;

case -NLE_OBJ_NOTFOUND:
@@ -387,19 +387,19 @@
static void
= ovpn_dco_init_netlink(dco_context_t *dco)
{<= br>- dco->ovpn_dco_id =3D r= esolve_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 netl= ink socket");
}

int ret =3D genl_connect(dco->nl_sock);

if (r= et)
{
- msg(M_ERR, "Cannot connect to generic netlink: %s",<= /span>
+ msg(M_FATAL,= "Cannot connect to generic netlink: %s",
= nl_geterror(ret));
}
@@ -415,7 +415,7 @@
dco->nl_cb =3D nl_cb_all= oc(NL_CB_DEFAULT);
if (!dco->nl_cb)
{

- msg(M_= ERR, "failed to allocate netlink callback");
+ msg(M_FATAL, "failed to all= ocate netlink callback");
}

nl_socket_set_cb(dco->nl_sock, dco->nl_cb);<= br>@@ -484,7 +484,7 @@

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

/* Register for ovpn-d= co specific multicast messages that the kernel may
@@ -493,= 7 +493,7 @@
int ret =3D nl_socket_add_membership(dco-&= gt;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 change 1096. To unsubscribe, or for help writing mail filte= rs, visit settings.

<= div itemscope itemtype=3D"http://schema.org/EmailMessage">
<= meta itemprop=3D"name" content=3D"View Change"/>
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ifc442b4426c02de7282d0f69629= e8a10b679c589
Gerrit-Change-Number: 1096
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <antonio@...2726...>=
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--/HxEsRtsR78=--