From: "ordex (Code Review)" Date: Mon, 27 Jan 2025 11:01:18 +0000 In-Reply-To: References: Reply-To: a@...2181..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <88b3466589265ed5bcbe644e7551792dcda7a7b7-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="G+Z6EEQYk80="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dco_linux: extend netlink error cb with extra info List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos , flichtenheld Cc: openvpn-devel --G+Z6EEQYk80= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, ordex. Hello flichtenheld, plaisthos, I'd like you to reexamine a change. Please visit http://gerrit.openvpn.net/c/openvpn/+/841?usp=3Demail to look at the new patch set (#7). Change subject: dco_linux: extend netlink error cb with extra info ...................................................................... dco_linux: extend netlink error cb with extra info A netlink error may contain more specific attributes: i.e. missing attributes or missing neted objects. Parse and print this information too. Note that we are re-defining some enum entries that exist in netlink.h starting with linux-6.1. Since we do support distros not shipping an up-to-date netlink.h, we had to re-define the entries we need for this patch. Change-Id: I9e27ff335d892429334137d028f8503da4e4ca5b Signed-off-by: Antonio Quartulli --- M src/openvpn/dco_linux.c 1 file changed, 35 insertions(+), 4 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/841/7 diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b038382..34f48f2 100644 --- a/src/openvpn/dco_linux.c +++ b/src/openvpn/dco_linux.c @@ -291,6 +291,25 @@ return NL_SKIP; } +/* The following enum members exist in netlink.h since linux-6.1. + * However, some distro we support still ship an old header, thus + * failing the OpenVPN compilation. + * + * For the time being we add the needed defines manually. + * We will drop this definition once we stop supporting those old + * distros. + * + * @NLMSGERR_ATTR_MISS_TYPE: type of a missing required attribute, + * %NLMSGERR_ATTR_MISS_NEST will not be present if the attribute was + * missing at the message level + * @NLMSGERR_ATTR_MISS_NEST: offset of the nest where attribute was missing + */ +enum ovpn_nlmsgerr_attrs { + OVPN_NLMSGERR_ATTR_MISS_TYPE =3D 5, + OVPN_NLMSGERR_ATTR_MISS_NEST =3D 6, + OVPN_NLMSGERR_ATTR_MAX =3D 6, +}; + /* This function is used as error callback on the netlink socket. * When something goes wrong and the kernel returns an error, this functio= n is * invoked. @@ -331,12 +350,24 @@ len -=3D ack_len; nla_parse(tb_msg, NLMSGERR_ATTR_MAX, attrs, len, NULL); - if (tb_msg[NLMSGERR_ATTR_MSG]) + if (tb_msg[OVPN_NLMSGERR_ATTR_MSG]) { - len =3D strnlen((char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG]), - nla_len(tb_msg[NLMSGERR_ATTR_MSG])); + len =3D strnlen((char *)nla_data(tb_msg[OVPN_NLMSGERR_ATTR_MSG]), + nla_len(tb_msg[OVPN_NLMSGERR_ATTR_MSG])); msg(M_WARN, "kernel error: %*s\n", len, - (char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG])); + (char *)nla_data(tb_msg[OVPN_NLMSGERR_ATTR_MSG])); + } + + if (tb_msg[OVPN_NLMSGERR_ATTR_MISS_NEST]) + { + msg(M_WARN, "kernel error: missing required nesting type %u\n", + nla_get_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_NEST])); + } + + if (tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE]) + { + msg(M_WARN, "kernel error: missing required attribute type %u\n", + nla_get_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE])); } return NL_STOP; -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/841?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: I9e27ff335d892429334137d028f8503da4e4ca5b Gerrit-Change-Number: 841 Gerrit-PatchSet: 7 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-MessageType: newpatchset --G+Z6EEQYk80= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, ordex.

ordex uploaded patch set #7 to this change.

View Change

git p=
ull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/841/7
di=
ff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index b038382..34f48f2 100644
--- a/src/openvpn/dco_linux= .c
+++ b/src/openvpn/dco_linux.c
@@ -291,6 = +291,25 @@
return NL_SKIP;
}
+/* The fol= lowing enum members exist in netlink.h since linux-6.1.
+ * However, some distro we support stil= l ship an old header, thus
+ * failing the OpenVPN compilation.
+ *
+ * For the time being we add the needed defines manually.
<= span style=3D"color: hsl(120, 100%, 40%);">+ * We will drop this definition= once we stop supporting those old
+ * distros.
+ *
+ * @NLMSGE= RR_ATTR_MISS_TYPE: type of a missing required attribute,
+ * %NLMSGERR_ATTR_MISS_NEST will not = be present if the attribute was
+ * missing at the message level
+ * @NLMSGERR_ATTR_MISS_NEST: offset of the nest wh= ere attribute was missing
+ */
+enum ovpn_= nlmsgerr_attrs {
+ = OVPN_NLMSGERR_ATTR_MISS_TYPE =3D 5,
+ OVPN_NLMSGERR_ATTR_MISS_NEST =3D 6,
+ OVPN_NLMSGERR_ATTR_MAX =3D 6,

+};
+
/* This function is use= d as error callback on the netlink socket.
* When somethi= ng goes wrong and the kernel returns an error, this function is
<= span> * invoked.
@@ -331,12 +350,24 @@
= len -=3D ack_len;

nla_parse(tb_msg= , NLMSGERR_ATTR_MAX, attrs, len, NULL);
- if (tb_msg[NLMSGERR_ATTR_MSG])
+ if (tb_msg[OVPN_NLMSGERR_ATTR_MSG])
{
-= len =3D strnlen((char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG]),=
- nla_le= n(tb_msg[NLMSGERR_ATTR_MSG]));
+ len =3D strnlen((char *)nla_data(tb_msg[OVPN_NLMSGERR_AT= TR_MSG]),
+ = nla_len(tb_msg[OVPN_NLMSGERR_ATTR_MSG]));
= msg(M_WARN, "kernel error: %*s\n", len,
- (char *)nla_data(tb_msg[NLMSGER= R_ATTR_MSG]));
+ = (char *)nla_data(tb_msg[OVPN_NLMSGERR_ATTR_MSG]));
+ }
+
+ if (tb_msg[OVPN_NLMSGERR_ATTR_MISS_NEST])
+ {
+ msg(M_WARN, "kernel error: missing required n= esting type %u\n",
+ nla_get_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_NEST]));<= br>+ }
+
+ if (tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE])
+ {

+ msg(M_WARN, "kernel error: missing = required attribute type %u\n",
+ nla_get_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE= ]));
}

return N= L_STOP;

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

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I9e27ff335d892429334137d028f= 8503da4e4ca5b
Gerrit-Change-Number: 841
Gerrit-PatchSet: 7
Gerrit-Owner: ordex <a@...2181...>
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: flichtenheld <frank@...2375...= 41...>
Gerrit-Attention: ordex <a@...2181...> <= /div>
Gerrit-MessageType: newpatchset
--G+Z6EEQYk80=--