From nobody Mon Jan 20 20:54:06 2025 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 4YcMyQ4RS5z5kwkp; Mon, 20 Jan 2025 20:54:06 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YcMyQ3yS0z44FC; Mon, 20 Jan 2025 20:54:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737406446; 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=n/LE18Pojf6tFa850QAv2j5VJSvQQU8dl79hHE4fUTE=; b=VEpWuCoWxlfMsUsPb1gDyRE8qXC72rlDiSZUBxCdgY0VDL0DcQKyjL7YbIpwMSA3M0R3JI I3fDnp2Y+ztIdsZD+rHEjadQ/jPEoEyJYWrHtJD9P3n2D1cfqoC4so3fqS2mNV+JzhIwfg 3204yRgUiM7Qcb21cC8qmMacCxThlMRn25rcG0qyg6WwDUEB163cDf980vtlnnFQpGquXk IlPPWzRbCIwvVbobKF10Fw20hcXIHWJIrQeJKjvXmuaS+QtgJbr1w61ohQx6TmyeorfRCh E4+lv8HSBwKb0jXDf94w/nxMJAzIyQiqrjMmxOcG8+PKNXKGWFv0VZKf62l3jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737406446; 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=n/LE18Pojf6tFa850QAv2j5VJSvQQU8dl79hHE4fUTE=; b=r+MVCmc4YJ56Sf6YCNVP4FW7Md5FPHLpL27HE6tOAQGyNIiwepnooBd6yeXIfbxfemirY/ wHuL6rmf74sFgmm6QulXelHwM7Ev37e8R6q1RaqVUfAIwBUxbDA6ldLTi2tXzqRAuf3HCF ynicbyjLClorW4AOpU7dc6rt52Tgu4+XQ195MjFmiDMrUCC7VaCKQVn5i31oyitU4hYpgE uqUUAECJh5t2yQtb9uHhlqHlB99floPZBDNF61JN+zmkP4CjNQjR03Qp65Gq7NcTWNvPDe fMvNIIprltJ6fzdHcbB28wZH0PPHN68WhB2pGY5Fu3rlowP3ZLRXnTn1GJmxAA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737406446; a=rsa-sha256; cv=none; b=oIQsTOrLSCTrnoy65g7LPhNXu5q5t85/nVgGgF3wzzZjqvIbxYNdr0mr7YQFirk5AXVh2L K5jSHC1dZ9IVkpSeJ2kzA7mnmbpGNqvsvxJRsHtnlwUFpo2M/XtGWtG+BrMJ1pbqtaO3k6 hi544FmN5++7CCeQv3qqrG+xriQJ/4fJQw4aRGmBxVqo3gyM/k96VXeKPoxb7s2+6GQBJR W92XSeZGgCd5EQeaSd58PLSi47oaHNZ0V2A6+6k3t6/KAP9hF4fOx8PPpAD5djxrbC6iJn IDHD4pfiat2nMJWXIAlWy/hW8YwrpHsLmUOPcab3q+9QiQ5niuBS1QHllEjFdA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YcMyQ2pPtzcC8; Mon, 20 Jan 2025 20:54:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50KKs6f3017491; Mon, 20 Jan 2025 20:54:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50KKs6Mp017488; Mon, 20 Jan 2025 20:54:06 GMT (envelope-from git) Date: Mon, 20 Jan 2025 20:54:06 GMT Message-Id: <202501202054.50KKs6Mp017488@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: fb63082c0cc6 - main - netlink: provide snl(3) API for variable length raw data attribute 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fb63082c0cc6a7da68ff9c5b3a9bd023abafe1d2 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=fb63082c0cc6a7da68ff9c5b3a9bd023abafe1d2 commit fb63082c0cc6a7da68ff9c5b3a9bd023abafe1d2 Author: Gleb Smirnoff AuthorDate: 2025-01-20 20:53:07 +0000 Commit: Gleb Smirnoff CommitDate: 2025-01-20 20:53:07 +0000 netlink: provide snl(3) API for variable length raw data attribute Rename supposedly internal _snl_reserve_msg_attr() into an official snl_reserve_msg_attr_raw(), that would return pointer to a struct nlattr followed by allocated memory. Adjust the snl_reserve_msg_attr() macro to work on top of that function. Reviewed by: melifaro Differential Revision: https://reviews.freebsd.org/D48311 --- sys/netlink/netlink_snl.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/netlink/netlink_snl.h b/sys/netlink/netlink_snl.h index 0f3b3b44622d..44967b6f444a 100644 --- a/sys/netlink/netlink_snl.h +++ b/sys/netlink/netlink_snl.h @@ -1109,20 +1109,22 @@ snl_reserve_msg_data_raw(struct snl_writer *nw, size_t sz) #define snl_reserve_msg_object(_ns, _t) ((_t *)snl_reserve_msg_data_raw(_ns, sizeof(_t))) #define snl_reserve_msg_data(_ns, _sz, _t) ((_t *)snl_reserve_msg_data_raw(_ns, _sz)) -static inline void * -_snl_reserve_msg_attr(struct snl_writer *nw, uint16_t nla_type, uint16_t sz) +static inline struct nlattr * +snl_reserve_msg_attr_raw(struct snl_writer *nw, uint16_t nla_type, uint16_t sz) { - sz += sizeof(struct nlattr); + struct nlattr *nla; - struct nlattr *nla = snl_reserve_msg_data(nw, sz, struct nlattr); + sz += sizeof(struct nlattr); + nla = snl_reserve_msg_data(nw, sz, struct nlattr); if (__predict_false(nla == NULL)) return (NULL); nla->nla_type = nla_type; nla->nla_len = sz; - return ((void *)(nla + 1)); + return (nla); } -#define snl_reserve_msg_attr(_ns, _at, _t) ((_t *)_snl_reserve_msg_attr(_ns, _at, sizeof(_t))) +#define snl_reserve_msg_attr(_ns, _at, _t) \ + ((_t *)(snl_reserve_msg_attr_raw(_ns, _at, sizeof(_t)) + 1)) static inline bool snl_add_msg_attr(struct snl_writer *nw, int attr_type, int attr_len, const void *data)