From nobody Tue Oct 04 14:50:20 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 4Mhgbw3Lnpz4f22K; Tue, 4 Oct 2022 14:50:20 +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 4Mhgbw2qp7z3px6; Tue, 4 Oct 2022 14:50:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664895020; 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=mMULaGFrGag8B9mBJkE5v74760YujfZVML+TU219NBs=; b=UpBZhibPZNCtSnp1c/3iow/4d7IRH4dVXH9PMZURGNeKrputO5SpBqK6PBaYrExrdYYRka F9btn+7BlB6HMhzGHUzFkfoll1wG8jVP3ubgmqPuyruQ4P5+ftVgBCI7o/UsyhctUf40Ar JJ6Fq4PgzoJCiU1HDF3H/dPpXLgg7PZIiTKKzaG9YCnkGruf53NgpjAaY4yGUIkyULIduI XNXSadL/D0RZ5RciNfd23IsyVdxiBU2RUeAZ82vjQGdOvEWIaZLD4lHgjucM1R/8U0YVTB BhV5INxKg2xtc1BY3Qq/byPk3OYYioO4+/+PEiY2boxAMlC42i9TyurcaNZd3g== 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 4Mhgbw1xd8zbb2; Tue, 4 Oct 2022 14:50:20 +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 294EoKvO030278; Tue, 4 Oct 2022 14:50:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 294EoKMJ030275; Tue, 4 Oct 2022 14:50:20 GMT (envelope-from git) Date: Tue, 4 Oct 2022 14:50:20 GMT Message-Id: <202210041450.294EoKMJ030275@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 80c0c83b5d77 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 80c0c83b5d77d22b7556ba6cba20401692897d6e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664895020; 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=mMULaGFrGag8B9mBJkE5v74760YujfZVML+TU219NBs=; b=oiDMECQq4hVqhG5fqM7YaqRHCpK0rZoXWSXl7Qce8qwrvopGLla/kWOenZBbZKNnHfgiuX 8L0coj/AXBaL3l4UwOo4LDj277caLsEJG4xckFBwbr52HPrJRQn6qj1uyvS3Q+lxT7gLTM J7DNSaOmtaL4bO5Xm2n0HDHKGfHUyzB4I3eqvkCln/pYQ4LIrsgM660MT9DK/mFnp3FXg5 IZzKeHiihCtAss1orf/xyBNlw1d9Bo9L+OuNN8Fex5IGtke6DimIEGRpQGxKWnHCUD4T2b hGuQbglqxw/YKjMqMPDPkzNxXUc47J8fvkVDRJhXiEOjTPadj47/OuZvRXqjEA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664895020; a=rsa-sha256; cv=none; b=EWIu3tpCV5+XIgPZpS3twmG22BcAcTmA03esgeauojrOVCBv0x+JlUQZ49jrdmZTHIYkR6 gX1bwtB1FysCUlSXE3T322jDZSuT/QnxtKb/TdMWJOXq0LUukvlAeXug02L/9ERESHME1K P5hMLllX2KLa+17oTtXE9im7vmwDYMF9kUfZ9DRgDp3/lKa4YrNyH4QqPICzpqPbTy3qNT imY9k1nz7J/qWPdL8HkUUhhh+kNGhKkdUyBJos6CexaIt7hWlrtNpt69no7UWsEf5HYfTA Uu17uyrR3N8dEUHiUWOUVBvejg97iDehtkgZ5wmsn7LN/LTtDvl2iLxjWtlPfg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=80c0c83b5d77d22b7556ba6cba20401692897d6e commit 80c0c83b5d77d22b7556ba6cba20401692897d6e Author: Hans Petter Selasky AuthorDate: 2022-09-27 13:48:16 +0000 Commit: Hans Petter Selasky CommitDate: 2022-10-04 14:40:53 +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 Sponsored by: NVIDIA Networking (cherry picked from commit c075ea46bca6d48ce9f639e4575077d06d392427) --- sys/kern/kern_sysctl.c | 11 +++++------ sys/sys/sysctl.h | 3 +++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index ade5eed8edc3..6718f77ee75b 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -134,7 +134,7 @@ sysctl_find_oidname(const char *name, struct sysctl_oid_list *list) struct sysctl_oid *oidp; SYSCTL_ASSERT_LOCKED(); - SLIST_FOREACH(oidp, list, oid_link) { + SYSCTL_FOREACH(oidp, list) { if (strcmp(oidp->oid_name, name) == 0) { return (oidp); } @@ -1016,7 +1016,7 @@ sysctl_sysctl_debug_dump_node(struct sysctl_oid_list *l, int i) struct sysctl_oid *oidp; SYSCTL_ASSERT_LOCKED(); - SLIST_FOREACH(oidp, l, oid_link) { + SYSCTL_FOREACH(oidp, l) { for (k=0; koid_name) == 0) break; } + if (oidp == NULL) + return (ENOENT); *oid++ = oidp->oid_number; (*len)++; diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 8f7741eb0b4c..ecf40cc1bfb5 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -905,6 +905,9 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry); NULL); \ }) +#define SYSCTL_FOREACH(oidp, list) \ + SLIST_FOREACH(oidp, list, oid_link) + /* * A macro to generate a read-only sysctl to indicate the presence of optional * kernel features.