From nobody Wed Feb 28 22:27:13 2024 X-Original-To: dev-commits-src-main@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 4TlTVn5JWCz5CXSp; Wed, 28 Feb 2024 22:27:13 +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 4TlTVn4Z2zz4nK9; Wed, 28 Feb 2024 22:27:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709159233; 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=QXc38HIo3QWqFm/lvX66ruzjpcwrhsCI9Yo6t37fG+0=; b=LE+WFUQ8W5dzw+y1X7kzE9HVE4M54aRdJ+3aIabq60GSBRw6tb0P4txO9WFYvHa8Dw6TBM 9pwX5OZHSRVoM29iCpo0BOkJ5BWam+a+NG2L6YcHgXehISelVtAuLv/UZTVDJvI8UgfLBh i6gy/PW/Y6f0n3Jh36Z8Mm6Wd5bBPmmYWUJ9f1LTh5wMSCi1z3uPTyBbTHP+R9G1mlP6T+ gcBnm6WE1GNLLCAqXijyFq1kOYy/9oeRV49HR3i8lrLVcbRIl1qu3WZpENGutsfGsyIjX/ nF4NbMZNe3cYW6eBv8y0z2TLaxBP1n5NXE37Gs851DkbUKeM+Vc6GM+j4s0ZyQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709159233; a=rsa-sha256; cv=none; b=i6WFhaXtxq1DqbqMGA9BL2XF/nrekcJf1spADQMyzTqXrrlXeC547xHMpedB/BH11pKwAc ve+kvvrMtCDtilEZ0wBSIybXjyZQbUGrntM0MNtwSACs9MuwH3GS/VQO7ZAGsJIpnCglTY ZMQptmrmHrRL7tygO2GzKNwzqW+7u6z0AroKSFZpe6WvGjOJEJNQ9OMWcOC1HwZSLf8uLJ wtnA/75D+vY9EMVPmRwC6bmisKuY5v/yaJEAA/7K6v9Fms7ekZ9nTXKzAYuF2g7wJ4fD9H aY7ZUdcFLXELroHqJ3olCth3ICr29LDJRJWST6H/Znd0ej2JF457y34YzCynsg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709159233; 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=QXc38HIo3QWqFm/lvX66ruzjpcwrhsCI9Yo6t37fG+0=; b=C46LNUL6/OREjMe0JMJu4vkYIszVvTblxqfmYw90kO6bVOjFxf/qFfgCsnNON2WN7XpzQJ koKSH+rR/MrrbE2tKPmNuM1a7DjIcYCuhqhAciOtKCwjajehYQy5jszXapn75lzotAO7AN 2XCKG5sXVF60ow5fNYpn3IO7UTztFxxubdYwehqFHbaDJglHEGQWQnac/QAULBVYqa85SW kbGxaM6FpcBn9TTGjUoOT1NkK0EkB5IcifZc0sPaT5tv2g0tfTQX6H4dIffVxQVh1Sjh5J 3wxTKmdVOJoX8/dtTq3GJ8RfUVdAQfHw9TY52WYpOTSPWxPTSLG+d0BOwm8N9Q== 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 4TlTVn3v62zFtX; Wed, 28 Feb 2024 22:27:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41SMRD57094322; Wed, 28 Feb 2024 22:27:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41SMRDV3094320; Wed, 28 Feb 2024 22:27:13 GMT (envelope-from git) Date: Wed, 28 Feb 2024 22:27:13 GMT Message-Id: <202402282227.41SMRDV3094320@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: dfed87b5ce9c - main - netlink: add bool type support List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfed87b5ce9c4e82b0227c14a3ed0cafeb814b16 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=dfed87b5ce9c4e82b0227c14a3ed0cafeb814b16 commit dfed87b5ce9c4e82b0227c14a3ed0cafeb814b16 Author: Kristof Provost AuthorDate: 2024-02-26 10:19:28 +0000 Commit: Kristof Provost CommitDate: 2024-02-28 22:26:18 +0000 netlink: add bool type support Reviewed by: melifaro Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D44089 --- sys/netlink/netlink_message_parser.c | 11 +++++++++++ sys/netlink/netlink_message_parser.h | 2 ++ sys/netlink/netlink_snl.h | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/sys/netlink/netlink_message_parser.c b/sys/netlink/netlink_message_parser.c index 8caa13fbf3ce..eafc2d83cbfb 100644 --- a/sys/netlink/netlink_message_parser.c +++ b/sys/netlink/netlink_message_parser.c @@ -312,6 +312,17 @@ nlattr_get_ipvia(struct nlattr *nla, struct nl_pstate *npt, const void *arg, voi return (error); } +int +nlattr_get_bool(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target) +{ + if (__predict_false(NLA_DATA_LEN(nla) != sizeof(bool))) { + NLMSG_REPORT_ERR_MSG(npt, "nla type %d size(%u) is not bool", + nla->nla_type, NLA_DATA_LEN(nla)); + return (EINVAL); + } + *((bool *)target) = *((const bool *)NL_RTA_DATA_CONST(nla)); + return (0); +} int nlattr_get_uint8(struct nlattr *nla, struct nl_pstate *npt, const void *arg, void *target) diff --git a/sys/netlink/netlink_message_parser.h b/sys/netlink/netlink_message_parser.h index 7a417c00fc46..49bec646b29e 100644 --- a/sys/netlink/netlink_message_parser.h +++ b/sys/netlink/netlink_message_parser.h @@ -173,6 +173,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_bool(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, diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index 89ba5b5aef5d..6553a391a8f5 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -1147,6 +1147,12 @@ snl_add_msg_attr_raw(struct snl_writer *nw, const struct nlattr *nla_src) return (snl_add_msg_attr(nw, nla_src->nla_type, attr_len, (const void *)(nla_src + 1))); } +static inline bool +snl_add_msg_attr_bool(struct snl_writer *nw, int attrtype, bool value) +{ + return (snl_add_msg_attr(nw, attrtype, sizeof(bool), &value)); +} + static inline bool snl_add_msg_attr_u8(struct snl_writer *nw, int attrtype, uint8_t value) {