From: "cron2 (Code Review)" Date: Tue, 28 Jan 2025 14:04:35 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641..., a@...2181... Message-ID: <4fdfcc79c1aeb219ee679200c4ec77a91e18ce42-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Chq679o03+8="; 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: , Cc: flichtenheld , plaisthos , openvpn-devel --Chq679o03+8= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/84= 1?usp=3Demail ) 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 Acked-by: Frank Lichtenheld Message-Id: <20250128134454.2888-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30= 658.html Signed-off-by: Gert Doering --- M src/openvpn/dco_linux.c 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b038382..fa7abd3 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. @@ -304,7 +323,7 @@ struct nlmsgerr *err, void *arg) { struct nlmsghdr *nlh =3D (struct nlmsghdr *)err - 1; - struct nlattr *tb_msg[NLMSGERR_ATTR_MAX + 1]; + struct nlattr *tb_msg[OVPN_NLMSGERR_ATTR_MAX + 1]; int len =3D nlh->nlmsg_len; struct nlattr *attrs; int *ret =3D arg; @@ -330,7 +349,7 @@ attrs =3D (void *)((unsigned char *)nlh + ack_len); len -=3D ack_len; - nla_parse(tb_msg, NLMSGERR_ATTR_MAX, attrs, len, NULL); + nla_parse(tb_msg, OVPN_NLMSGERR_ATTR_MAX, attrs, len, NULL); if (tb_msg[NLMSGERR_ATTR_MSG]) { len =3D strnlen((char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG]), @@ -339,6 +358,18 @@ (char *)nla_data(tb_msg[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: 10 Gerrit-Owner: ordex Gerrit-Reviewer: cron2 Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: merged --Chq679o03+8= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 submitted this change.

View Change

dco_linux: extend netlink error cb with extra =
info

A netlink error may contain more specific attributes: i.e.
m= issing attributes or missing neted objects.

Parse and print this inf= ormation too.

Note that we are re-defining some enum entries that ex= ist
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 w= e need for
this patch.

Change-Id: I9e27ff335d892429334137d028f850= 3da4e4ca5b
Signed-off-by: Antonio Quartulli <antonio@...2726...>Acked-by: Frank Lichtenheld <frank@...2641...>
Message-Id: <2= 0250128134454.2888-1-gert@...1296...>
URL: https://www.mail-archive.c= om/openvpn-devel@lists.sourceforge.net/msg30658.html
Signed-off-by: Gert= Doering <gert@...1296...>
---
M src/openvpn/dco_linux.c
1 f= ile changed, 33 insertions(+), 2 deletions(-)

diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.cindex b038382..fa7abd3 100644
--- a/src/openvpn/dco_= linux.c
+++ b/src/openvpn/dco_linux.c
@@ -2= 91,6 +291,25 @@
return NL_SKIP;
}


+/* Th= e 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 defin= ition once we stop supporting those old
+ * distros.
+ *
+ * @N= LMSGERR_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 ne= st 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 i= s used as error callback on the netlink socket.
* When so= mething goes wrong and the kernel returns an error, this function is=
* invoked.
@@ -304,7 +323,7 @@
= struct nlmsgerr *err, void *arg)
{
struct nlmsghdr *nlh =3D (struct nlmsghdr *)err - 1;=
- struct nlattr *tb_msg[NL= MSGERR_ATTR_MAX + 1];
+ struct nlattr *tb_msg[OVPN_NLMSGERR_ATTR_MAX + 1];
= int len =3D nlh->nlmsg_len;
struct nlattr *attrs= ;
int *ret =3D arg;
@@ -330,7 +349,7 @= @
attrs =3D (void *)((unsigned char *)nlh + ack_len);<= /span>
len -=3D ack_len;

- nla_parse(tb_msg, NLMSGERR_ATTR_MAX,= attrs, len, NULL);
+= nla_parse(tb_msg, OVPN_NLMSGERR_ATTR_MAX, attrs, len, NULL);
= if (tb_msg[NLMSGERR_ATTR_MSG])
{
= len =3D strnlen((char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG]),=
@@ -339,6 +358,18 @@
(char *)= nla_data(tb_msg[NLMSGERR_ATTR_MSG]));
}

+ if (tb_msg[O= VPN_NLMSGERR_ATTR_MISS_NEST])
+ {
+ = msg(M_WARN, "kernel error: missing required nesting type %u\n"= ;,
+ nla_g= et_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_NEST]));
+ }
+
+ if= (tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE])
+ {
+ msg(M_WARN, "kernel error: missing required attribute ty= pe %u\n",
+ = nla_get_u32(tb_msg[OVPN_NLMSGERR_ATTR_MISS_TYPE]));
+ }
+
return NL_STOP;
}



To view, visit= change 8= 41. To unsubscribe, 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: 10
Gerrit-Owner: ordex <a@...2181...>
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
--Chq679o03+8=--