From: "ordex (Code Review)" Date: Mon, 27 Jan 2025 11:02:33 +0000 In-Reply-To: References: Reply-To: a@...2181..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <849a797133d6282a2132971d58e96df69e01ddbc-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="0p7nPnXxUho="; 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 --0p7nPnXxUho= 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 (#8). 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, 32 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/841/8 diff --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c index b038382..abfd3b4 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. @@ -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: 8 Gerrit-Owner: ordex Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-Attention: ordex Gerrit-MessageType: newpatchset --0p7nPnXxUho= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, ordex.

ordex uploaded patch set #8 to this change.

View Change

git pu=
ll ssh://gerrit.openvpn.net:29418/openvpn refs/changes/41/841/8
dif=
f --git a/src/openvpn/dco_linux.c b/src/openvpn/dco_linux.c
index b038382..abfd3b4 100644
--- a/src/openvpn/dco_linux.= c
+++ b/src/openvpn/dco_linux.c
@@ -291,6 += 291,25 @@
return NL_SKIP;
}
+/* The foll= owing 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.
+ *
+ * @NLMSGER= R_ATTR_MISS_TYPE: type of a missing required attribute,
+ * %NLMSGERR_ATTR_MISS_NEST will not b= e present if the attribute was
+ * missing at the message level
+ * @NLMSGERR_ATTR_MISS_NEST: offset of the nest whe= re attribute was missing
+ */
+enum ovpn_n= lmsgerr_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.
@@ -330,7 +349,7 @@
= attrs =3D (void *)((unsigned char *)nlh + ack_len);
le= n -=3D ack_len;

- nla_parse(tb_msg, NLMSGERR_ATTR_MAX, attrs, len, NULL);
+ nla_parse(tb_msg, O= VPN_NLMSGERR_ATTR_MAX, attrs, len, NULL);
if (tb_msg[N= LMSGERR_ATTR_MSG])
{
len =3D = strnlen((char *)nla_data(tb_msg[NLMSGERR_ATTR_MSG]),
@@ -33= 9,6 +358,18 @@
(char *)nla_data(tb_msg[NLMSGER= R_ATTR_MSG]));
}

+ if (tb_msg[OVPN_NLMSGERR_ATTR_MISS_= NEST])
+ {<= br>+ msg(M_WARN, "k= ernel error: missing required nesting type %u\n",
+ nla_get_u32(tb_msg[OVPN_NLMS= GERR_ATTR_MISS_NEST]));
+ }
++ if (tb_msg[OVPN_NLMSGERR_= ATTR_MISS_TYPE])
+ = {
+ msg(M_WAR= N, "kernel error: missing required attribute type %u\n",+ nla_get_u32(tb_m= sg[OVPN_NLMSGERR_ATTR_MISS_TYPE]));
+ }
+
return NL_STOP;
}
=

To view, visit change 841. 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: 8
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
--0p7nPnXxUho=--