From patchwork Tue Jan 28 13:44:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 4095 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:6a49:b0:5e7:b9eb:58e8 with SMTP id v9csp436328mat; Tue, 28 Jan 2025 05:45:10 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW9YJ+r9gwPoJ5icL3sTAzgT6KwZdfjG8Tcp4pUc9HwTN1MeciVx4NxHGB9xglxeHdHUzwGfTY7js0=@openvpn.net X-Google-Smtp-Source: AGHT+IHNrvlq5gJmn7vWuVkWZv8vuidlJ5oJaOFXimAgdFTMvt9bd7wsWEBeozWAiI1sDzh5h4U4 X-Received: by 2002:a05:6808:22a4:b0:3eb:75b2:1e1d with SMTP id 5614622812f47-3f19fc1a040mr27259441b6e.12.1738071909865; Tue, 28 Jan 2025 05:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1738071909; cv=none; d=google.com; s=arc-20240605; b=Tz+3vbkMRy6VgwaoNi1hUbmC9HT7N2nhWuy1yOTtGpm2lKb+2yxbfu7lv0nvSIFoZ+ FYmiCeMnhE0iLr/mBd1VdPGluewbiTMtpJNCO2OIY5eDy+SLrpCG8LnNkGS8dhmeskcK ABifNyw2CjcMQOq1bw6ikeYUXrl1OZ9soksMGeJx+Tb4zUuw2L+VV0CN9Z3j+5j0eGCZ PIknP986fXbRineMe7GEkbtmtKX4z4z6mb/bZikRNt86w/JBhdMM2HV7pogZcVcHCuA7 76RCEVrApchv1ZnLP+pR7Y/pRNbLGh8tM1xW6XbrkcsfCAPVBOPfrMJbciA5CHusPOZ8 5p3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature; bh=zCKjdqEAjFXnyx/V97cfR6OMm5+mwZjAn9UTqeJYr1E=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=GjKgtiX8v7WlRJQ3Q3pyYHkYTyAXnTLRwxqXBQn/InEx06mpgpovOoFbfzDbv7qvJY l+dsRk6peOt5m4O/hJPjkS7++1tJQPxNv9W7Ll/C6U/+AiXiKF69tvPHbRajpHOt9VPK +OZj76DgLo7yUeNicz5LYrBHNKHE5kcqL9ufWC/1m3Ygla43i8+AnvSyLkB7tdZK1Uag YV1UiduuhYp309XuTjOyCLQTOzZePxHQsiY5T4uH24fzpfd7sAyebE75XTFtGRmF0gIC FOtwuiDuhnXD1C+Xf/KUpfBmEkbbnNAXY6mhY5t8ir2EX3ni6wzgQTvRqVnsOmZqDvhb 8j5Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=bAMTZdcy; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=A9KRX1Dh; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-3f1f09cb475si7073222b6e.195.2025.01.28.05.45.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2025 05:45:09 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=bAMTZdcy; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=A9KRX1Dh; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tcltp-0006UC-7K; Tue, 28 Jan 2025 13:45:05 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tclto-0006U4-6e for openvpn-devel@lists.sourceforge.net; Tue, 28 Jan 2025 13:45:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=tcvSB6egiIBHeazYRf8jJfucDCsae4C3I84WMlU9Sqs=; b=bAMTZdcySAiAex9a02yUmjgpn9 /h60ri3Rej67puWIrju9SNpbr5dtujTcc3HnwsdW7vv6gBSKas05aYTMHoQ2MUAUk/GI2SSfiFD9L YbIM3cNELlfMUzJMxaY8OadhejdAm2EHXW17WGUWMvPBr1YN4kjThx9/SJ7nIlKfroDU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tcvSB6egiIBHeazYRf8jJfucDCsae4C3I84WMlU9Sqs=; b=A9KRX1Dh+f8Cci9jC3M211NP6m s4NdXi1OGHrZsF0oA8/7KA+lDnBQMSFi/VO/dNhLd3OSID/4D+h88GRm4R7BDzMlAkInACRkAlexk U4OKjMvcXZApumODu8gaijdxogfivAgi+dpJu3qewyXt18gF6D1MLMOF6QXC9sG4uEBI=; Received: from dhcp-174.greenie.muc.de ([193.149.48.174] helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tcltm-0005pw-F8 for openvpn-devel@lists.sourceforge.net; Tue, 28 Jan 2025 13:45:04 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.17.1.9/8.17.1.9) with ESMTP id 50SDit2O002899 for ; Tue, 28 Jan 2025 14:44:55 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.17.1.9/8.17.1.9/Submit) id 50SDit71002898 for openvpn-devel@lists.sourceforge.net; Tue, 28 Jan 2025 14:44:55 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Tue, 28 Jan 2025 14:44:54 +0100 Message-ID: <20250128134454.2888-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: -0.0 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-2.v13.lw.sourceforge.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Antonio Quartulli A netlink error may contain more specific attributes: i.e. missing attributes or missing neted objects. Parse and print this information too. Content analysis details: (-0.0 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in sa-trusted.bondedsender.org] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [193.149.48.174 listed in bl.score.senderscore.com] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Headers-End: 1tcltm-0005pw-F8 Subject: [Openvpn-devel] [PATCH v9] dco_linux: extend netlink error cb with extra info X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1822404657697128076?= X-GMAIL-MSGID: =?utf-8?q?1822500490547656622?= From: Antonio Quartulli 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 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/841 This mail reflects revision 9 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld 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 = 5, + OVPN_NLMSGERR_ATTR_MISS_NEST = 6, + OVPN_NLMSGERR_ATTR_MAX = 6, +}; + /* This function is used as error callback on the netlink socket. * When something goes wrong and the kernel returns an error, this function is * invoked. @@ -304,7 +323,7 @@ struct nlmsgerr *err, void *arg) { struct nlmsghdr *nlh = (struct nlmsghdr *)err - 1; - struct nlattr *tb_msg[NLMSGERR_ATTR_MAX + 1]; + struct nlattr *tb_msg[OVPN_NLMSGERR_ATTR_MAX + 1]; int len = nlh->nlmsg_len; struct nlattr *attrs; int *ret = arg; @@ -330,7 +349,7 @@ attrs = (void *)((unsigned char *)nlh + ack_len); len -= 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 = 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; }