From nobody Tue Apr 25 11:15:30 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q5KDL5tW5z473VB; Tue, 25 Apr 2023 11:15:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q5KDL2g32z45Pp; Tue, 25 Apr 2023 11:15:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682421330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzH8OAQwORq4kPx7eXaUpVVRd7YBoqaPNliCVaODMOA=; b=uoDv9uEURpCSwmj0bCfbZfzmdyhyDJVivezUTwqD3/phJ7ZiQZq7BZNQOvJwmVRAFfTaA8 MjlJ6swJAzbOi42WjjPVj1elFCMeedYMa/DEakjW9tgaqM8PNSzwjfGYnnsfJsTK21FanA 0/yIKmznkEdJxKyjn6/5FqGBQ21zjtAzHrsQ0qat/mBl3nb+3fPn5+jOpUFR477CdVEHrv z309Zw9UcgtF3TW3sgbzJp17poM978ldAn9VkzX6R/ZdcFP+/VBtUxIP4ObCpcrLYToA3D uJYNpt34xx+Aw/7EVQgpx6kUY74eV5m+V3TSJLPCY63pflFKAjIGgx1ACZe1dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682421330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yzH8OAQwORq4kPx7eXaUpVVRd7YBoqaPNliCVaODMOA=; b=MzOheDqN3GNNvLh9JJpmmO0oczlFBGJm4YW2eSXBvmX3gebBUHsEi1fQlTF/DtMuMIXLi5 uMZ2yuVxvmKnIk90O3Kw8gfZpV2+OyHgx7+8Y3z/ZTP+BMQCrZvF5E1niaDSRjLyeb7N5Y 3UYS/84+tvRl2fecYVmeyfUUR4hsQPrE4Nn5WapdaIRS/mjjrCssl/0refj+nElyianbWF zubiL/oKijZtJ9b/ZrOoDED/NrTARFVvShnkgxMgkeQihV+QF3ImuyxXbvE5PjWobFlXkm XQD1VhbD7UdQfWazxdIjp8Aac3vjOgU5Q6l3lNJ9VOFmVQVHTgPdv5MCObaFKA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682421330; a=rsa-sha256; cv=none; b=jC3lS/hlG5GWmwvTdYMhVgWcZa7q3L69yxdmmwnRDLvbS7EYeE7pxnXquKlFQtV1sMtkYp n8aErFoGkMk6PCkRiH13ygs2rtPcXqMM0kh5RsEd3HGedHge9Mh7DCcfrOs9BFCpAI4fTX bkLK86N07TVnc8EIZb1XfBFvt2rbT/a4nPxFACmeXfsWEFDByhVqMODIw4ht+ZVjylujnx 7jhYbt1lyYciQG5q/pPbar0L0Z3Mpu8KxX+5j11qV1xms3eOPNYqY9+1kf46sLEDGCaepP F201i1UqkJNrM26UyrqvUaqLFaGWisx/M3jZFbxDj7ADcWekV1PnCigKShZYXQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q5KDL1mNSz14w0; Tue, 25 Apr 2023 11:15:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33PBFUiN012721; Tue, 25 Apr 2023 11:15:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33PBFUZl012720; Tue, 25 Apr 2023 11:15:30 GMT (envelope-from git) Date: Tue, 25 Apr 2023 11:15:30 GMT Message-Id: <202304251115.33PBFUZl012720@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: 70810dc8178c - main - netlink: add nlattr_get_uint8() function to pack u8 attributes. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: melifaro X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 70810dc8178cdc473f31f10bdfaec5de533dd67e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=70810dc8178cdc473f31f10bdfaec5de533dd67e commit 70810dc8178cdc473f31f10bdfaec5de533dd67e Author: Alexander V. Chernikov AuthorDate: 2023-04-25 10:56:42 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-04-25 10:56:42 +0000 netlink: add nlattr_get_uint8() function to pack u8 attributes. MFC after: 2 weeks --- sys/netlink/netlink_message_parser.c | 14 +++++++++++++- sys/netlink/netlink_message_parser.h | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/netlink/netlink_message_parser.c b/sys/netlink/netlink_message_parser.c index d0aaf4301872..c6cd82260e5b 100644 --- a/sys/netlink/netlink_message_parser.c +++ b/sys/netlink/netlink_message_parser.c @@ -314,11 +314,23 @@ nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt, const void *arg, voi } +int +nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target) +{ + if (__predict_false(NLA_DATA_LEN(nla) != sizeof(uint8_t))) { + NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint8", + nla->nla_type, NLA_DATA_LEN(nla)); + return (EINVAL); + } + *((uint16_t *)target) = *((const uint16_t *)NL_RTA_DATA_CONST(nla)); + return (0); +} + int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target) { if (__predict_false(NLA_DATA_LEN(nla) != sizeof(uint16_t))) { - NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint32", + NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not uint16", nla->nla_type, NLA_DATA_LEN(nla)); return (EINVAL); } diff --git a/sys/netlink/netlink_message_parser.h b/sys/netlink/netlink_message_parser.h index 067d25dae7d8..85d1c20557a2 100644 --- a/sys/netlink/netlink_message_parser.h +++ b/sys/netlink/netlink_message_parser.h @@ -169,6 +169,8 @@ int nlattr_get_flag(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_ip(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); +int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, + const void *arg, void *target); int nlattr_get_uint16(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target); int nlattr_get_uint32(struct nlattr *nla, struct nl_pstate *npt,