From nobody Sat Apr 8 19:44:45 2023 X-Original-To: dev-commits-src-branches@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 4Pv5Kn6kSfz44nsG; Sat, 8 Apr 2023 19:44:45 +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 4Pv5Kn5Qwnz43lV; Sat, 8 Apr 2023 19:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680983085; 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=fFiutqTA5sdHgTJr8MKc5bJusp3ZMHxDZ9Q+xoWHeXk=; b=sA/hdGy6NzlV88EsnmqG5lpOECc9Q2K17ZziGvu9VXhFH1uSmgXam7I22rg/H6wR5a5UMO usnbk7fqr9ypVZYjxXDsof3fzrnhPjGBUv7Zr+Bre3gNhXgCVXOPVsZxbUvIeTPyirHp0Q H0VznCL0adIza9Yv4MraeGL+/kygq1bF+KLHtk0R4MUJzSOHUYvoP6WdPdouTnCDsxDv7O R1iaFjZnN8TCOffku2rZOmoaWsPSFPaNdNpY5axTYsCngcM3n6Zsj6JAlXy6c3bW1cVttu TRsbTyEydhZa4ZC4eErn2yLaS1U2S0hGbaNM7gQYo6zXYnH+RSXUQT5o3dLZag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680983085; 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=fFiutqTA5sdHgTJr8MKc5bJusp3ZMHxDZ9Q+xoWHeXk=; b=Mom34rPu9FO9Jta/RjYzheIxM84itgEYAJJW/DGxziNpXIy3B+1MoDD6qlLccmFJAgIl7z 8KmQLMQQhnNA34FPiTwhQubguQMxUziBlneOz/kO1MpEBU9yYoLEJpQZmTE7GBkisG2wdw WSgaUpzx0n1BC+mclBaEw/euOBXnIydYgbpuHJMPGayO6fpFKH2n7xzChs0BhnWlzpkStJ uwCQJb6r++clbAT5tC0QBp1CuT7rMyNb71GVFNfA1ch+S2ZF3mEoZcWAMO491XTBHeIipR 7wk4ibO8tokX2+XhvtHYarH9ALMQGHsS10/7wP+WMFy8sOwfD1ymlzfO34WuUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680983085; a=rsa-sha256; cv=none; b=hDOoTSliHrC0vI4ZThNYRG+ycm9Sgq+oZjmU58pEMbG8dVOzwZqatHgdJtQq/tbhVVLxU9 JdJ2l+lTOuBZex/ZffLdV9PfmOXQcnnDHer5a2w6hqxrOsY55EH/HyXNiReTWkTiDV4Keo MkBDK34jV9aP70yvjmh87QbeeRepUJw8YNtr5a58ZzAFgu0k8FjJ+GwXrmmiEuAZWDQ7Kg i+JTjJxC+SKse8Ny7RHQL9zbpWx2M+HxHfxKhe6J8655ox4AfzgQI6hLxSpxOmdKL+9w5A nimL5e0I2onVeylEDjo2FKTnTN+6ta6CxwtqLcP49e9ZrmqJetqaW5KjPDMgFQ== 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 4Pv5Kn4Brvzfnl; Sat, 8 Apr 2023 19:44:45 +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 338JijmV018602; Sat, 8 Apr 2023 19:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 338Jij82018601; Sat, 8 Apr 2023 19:44:45 GMT (envelope-from git) Date: Sat, 8 Apr 2023 19:44:45 GMT Message-Id: <202304081944.338Jij82018601@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Alexander V. Chernikov" Subject: git: f2743786e9a7 - stable/13 - netlink: add u8/u64 attribute fetcher accessors to snl(3). List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: f2743786e9a76d16a14e145eee72f77594e4d237 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=f2743786e9a76d16a14e145eee72f77594e4d237 commit f2743786e9a76d16a14e145eee72f77594e4d237 Author: Alexander V. Chernikov AuthorDate: 2023-03-03 14:05:40 +0000 Commit: Alexander V. Chernikov CommitDate: 2023-04-08 19:03:23 +0000 netlink: add u8/u64 attribute fetcher accessors to snl(3). MFC after: 2 weeks (cherry picked from commit 61507ae30b9096eaa0d44fec71211f3843d546eb) --- share/man/man3/snl.3 | 8 ++++++++ sys/netlink/netlink_snl.h | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/share/man/man3/snl.3 b/share/man/man3/snl.3 index 78a6b67e88a9..2f328aadd023 100644 --- a/share/man/man3/snl.3 +++ b/share/man/man3/snl.3 @@ -75,10 +75,14 @@ .Ft "bool" .Fn snl_attr_get_flag "struct snl_state *ss" "struct nlattr *nla" "void *target" .Ft "bool" +.Fn snl_attr_get_uint8 "struct snl_state *ss" "struct nlattr *nla" "void *target" +.Ft "bool" .Fn snl_attr_get_uint16 "struct snl_state *ss" "struct nlattr *nla" "void *target" .Ft "bool" .Fn snl_attr_get_uint32 "struct snl_state *ss" "struct nlattr *nla" "void *target" .Ft "bool" +.Fn snl_attr_get_uint64 "struct snl_state *ss" "struct nlattr *nla" "void *target" +.Ft "bool" .Fn snl_attr_get_string "struct snl_state *ss" "struct nlattr *nla" "void *target" .Ft "bool" .Fn snl_attr_get_stringn "struct snl_state *ss" "struct nlattr *nla" "void *target" @@ -181,10 +185,14 @@ A number of predefined getters for the common data types exist. .Fn snl_attr_get_flag converts a flag-type attribute to an uint8_t value of 1 or 0, depending on the attribute presence. +.Fn snl_attr_get_uint8 +stores a uint8_t type attribute into the uint8_t target field. .Fn snl_attr_get_uint16 stores a uint16_t type attribute into the uint16_t target field. .Fn snl_attr_get_uint32 stores a uint32_t type attribute into the uint32_t target field. +.Fn snl_attr_get_uint64 +stores a uint64_t type attribute into the uint64_t target field. .Fn snl_attr_get_ip and .Fn snl_attr_get_ipvia diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index 6e2c4b89a7c4..d88808ea6d3b 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -355,6 +355,17 @@ snl_attr_get_flag(struct snl_state *ss __unused, struct nlattr *nla, void *targe return (false); } +static inline bool +snl_attr_get_uint8(struct snl_state *ss __unused, struct nlattr *nla, + const void *arg __unused, void *target) +{ + if (NLA_DATA_LEN(nla) == sizeof(uint8_t)) { + *((uint8_t *)target) = *((const uint8_t *)NLA_DATA_CONST(nla)); + return (true); + } + return (false); +} + static inline bool snl_attr_get_uint16(struct snl_state *ss __unused, struct nlattr *nla, const void *arg __unused, void *target) @@ -377,6 +388,17 @@ snl_attr_get_uint32(struct snl_state *ss __unused, struct nlattr *nla, return (false); } +static inline bool +snl_attr_get_uint64(struct snl_state *ss __unused, struct nlattr *nla, + const void *arg __unused, void *target) +{ + if (NLA_DATA_LEN(nla) == sizeof(uint64_t)) { + memcpy(target, NLA_DATA_CONST(nla), sizeof(uint64_t)); + return (true); + } + return (false); +} + static inline bool snl_attr_get_string(struct snl_state *ss __unused, struct nlattr *nla, const void *arg __unused, void *target) @@ -416,7 +438,8 @@ snl_attr_get_nested(struct snl_state *ss, struct nlattr *nla, const void *arg, v } static inline bool -snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, void *target) +snl_attr_get_nla(struct snl_state *ss __unused, struct nlattr *nla, + const void *arg __unused, void *target) { *((struct nlattr **)target) = nla; return (true);