From nobody Tue Sep 27 17:21:57 2022 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 4McRJ60P2Hz4YGFj; Tue, 27 Sep 2022 17:21:58 +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 4McRJ5738nz3vxP; Tue, 27 Sep 2022 17:21:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664299318; 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=t3ynnF6LZAwCr7sEsDpUzInWb/XmIj0elitN9MPDYFo=; b=VbqrvbjW0Aoahbjvw92BNFZi4QAVZKIrjAzUMV9J+mM6euLqy7sQsS44/qiNdsOzZgG6CR vmIlSp0Yt2cSCDa10DyTxoZB1Kr5sUlv7g0SFlvRwLWblbEsHGNNAZyoISQsaJ2xN1+2ZT UXEGF1K6Bm5/jKFUjUmiopetEztPbVuMupJIZID2IDl4CVVUEIcQx1FBf1ZSnx7afFKxq+ 9Hi9G+A2v9XNSzeyO83SqlfK81hmCKbH5CQQs9UBs9jC9x/S9DeYXQqMOykcEagfiW7kui 4laE3OMNMh6kAuxEHwWVfs3Me3j7KwPFZV3p12zjhBk7CWsfIXuDsImNoQycDw== 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 4McRJ55p5rz1Bf8; Tue, 27 Sep 2022 17:21:57 +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 28RHLv7H074544; Tue, 27 Sep 2022 17:21:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28RHLvvr074543; Tue, 27 Sep 2022 17:21:57 GMT (envelope-from git) Date: Tue, 27 Sep 2022 17:21:57 GMT Message-Id: <202209271721.28RHLvvr074543@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Hans Petter Selasky Subject: git: c075ea46bca6 - main - sysctl(3): Implement SYSCTL_FOREACH() to iterate all OIDs in a sysctl list. 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: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c075ea46bca6d48ce9f639e4575077d06d392427 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664299318; 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=t3ynnF6LZAwCr7sEsDpUzInWb/XmIj0elitN9MPDYFo=; b=BSyzD8Utj3oF5OFi5rwv8qWE//rxY1woLo/Nk8gPCWCEBnsruUikYAXYqTd1ft/J1hVUdt XBSIUAV1irVaw8G3+F6TITAuw9268F4P1Yy0O8/bCkYBjvzUuEKcdvIfQuZWJZI2amTN8M kZHc/ouKzrZJ+XfABwzah1IsGIdr6d639DEiTcAywGwk+YRqcT5+sRF0znwUhQJMFBkteU PHB3zQnWrCSyWCJWmZ4UR7VkRmk3URHWIpWLv4frzC+7rI+DWJoRGgrZ9Uid96TOT5Pk/n wXy77pMhwhqEexOhuIHcXceSsveaixNcVhNJPmRWd22A3xASJzqEUUTCRDHWKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664299318; a=rsa-sha256; cv=none; b=JUghQYRHW8ScWr2roX/pRJSY9VRwsoWL/MKrKf4GkXql6pDDOYCVvpqAL6BmmFn+8zIk3Y U1e4v/tAiwLKOIqYqGdpzHiAWkeTYWG9/9TUuN6v7XkOyaYmcQzTlvTkvu3Kxf3T7EcvVU rzkytShn2u2nTvnPaSzK4C3EqNLfz/LVn8I2rs4aOGaJnzbAGXNNT46anBMxiTtfglccZD 8UmXOc9vdPd9mscSM/Sgxgj7TZ0EZeUulc5tGS6xko8B0Gd69wFhYQvr0O70DHi6YTJf9g fTv7lxxVXK/In3pdERR7HELFKuEGWDa/17StfbxwiF7MTq39XmIfRPuan/XP8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=c075ea46bca6d48ce9f639e4575077d06d392427 commit c075ea46bca6d48ce9f639e4575077d06d392427 Author: Hans Petter Selasky AuthorDate: 2022-09-27 13:48:16 +0000 Commit: Hans Petter Selasky CommitDate: 2022-09-27 17:21:21 +0000 sysctl(3): Implement SYSCTL_FOREACH() to iterate all OIDs in a sysctl list. To avoid using the sysctl list macros directly in external kernel modules. Reviewed by: asomers, manu and asiciliano Differential Revision: https://reviews.freebsd.org/D36748 MFC after: 1 week Sponsored by: NVIDIA Networking --- sys/kern/kern_sysctl.c | 6 +++--- sys/sys/sysctl.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index e1cd6ea4bd61..1a3fcbbf8ae0 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -136,7 +136,7 @@ sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) struct sysctl_oid *oidp; SYSCTL_ASSERT_LOCKED(); - RB_FOREACH(oidp, sysctl_oid_list, list) { + SYSCTL_FOREACH(oidp, list) { if (strcmp(oidp->oid_name, name) == 0) { return (oidp); } @@ -1005,7 +1005,7 @@ sysctl_sysctl_debug_dump_node(struct sysctl_oid_list *l, int i) struct sysctl_oid *oidp; SYSCTL_ASSERT_LOCKED(); - RB_FOREACH(oidp, sysctl_oid_list, l) { + SYSCTL_FOREACH(oidp, l) { for (k=0; koid_name) == 0) break; } diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 3bd77cf87243..040012581087 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -918,6 +918,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); NULL); \ }) +#define SYSCTL_FOREACH(oidp, list) \ + RB_FOREACH(oidp, sysctl_oid_list, list) + /* * A macro to generate a read-only sysctl to indicate the presence of optional * kernel features.