From owner-svn-src-head@freebsd.org Fri Nov 22 20:22:30 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 179F41C0BD7; Fri, 22 Nov 2019 20:22:30 +0000 (UTC) (envelope-from cem@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47KSXP6Bjfz4CmJ; Fri, 22 Nov 2019 20:22:29 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B8B0FF51; Fri, 22 Nov 2019 20:22:29 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAMKMTQ0021217; Fri, 22 Nov 2019 20:22:29 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAMKMTFW021216; Fri, 22 Nov 2019 20:22:29 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201911222022.xAMKMTFW021216@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Fri, 22 Nov 2019 20:22:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355020 - head/sys/dev/random X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: head/sys/dev/random X-SVN-Commit-Revision: 355020 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Nov 2019 20:22:30 -0000 Author: cem Date: Fri Nov 22 20:22:29 2019 New Revision: 355020 URL: https://svnweb.freebsd.org/changeset/base/355020 Log: random(4): Use ordinary sysctl definitions There's no need to dynamically populate them; the SYSCTL_ macros take care of load/unload appropriately already (and random_harvestq is 'standard' and cannot be unloaded anyway). Approved by: csprng(delphij, markm) Differential Revision: https://reviews.freebsd.org/D22484 Modified: head/sys/dev/random/random_harvestq.c Modified: head/sys/dev/random/random_harvestq.c ============================================================================== --- head/sys/dev/random/random_harvestq.c Fri Nov 22 20:22:16 2019 (r355019) +++ head/sys/dev/random/random_harvestq.c Fri Nov 22 20:22:29 2019 (r355020) @@ -80,9 +80,6 @@ static void random_sources_feed(void); static u_int read_rate; -/* List for the dynamic sysctls */ -static struct sysctl_ctx_list random_clist; - /* * How many events to queue up. We create this many items in * an 'empty' queue, then transfer them to the 'harvest' queue with @@ -101,6 +98,9 @@ volatile int random_kthread_control; */ __read_frequently u_int hc_source_mask; +SYSCTL_NODE(_kern_random, OID_AUTO, harvest, CTLFLAG_RW, 0, + "Entropy Device Parameters"); + /* * Put all the harvest queue context stuff in one place. * this make is a bit easier to lock and protect. @@ -292,6 +292,8 @@ random_check_uint_harvestmask(SYSCTL_HANDLER_ARGS) (orig_value & user_immutable_mask); return (0); } +SYSCTL_PROC(_kern_random_harvest, OID_AUTO, mask, CTLTYPE_UINT | CTLFLAG_RW, + NULL, 0, random_check_uint_harvestmask, "IU", "Entropy harvesting mask"); /* ARGSUSED */ static int @@ -310,6 +312,9 @@ random_print_harvestmask(SYSCTL_HANDLER_ARGS) } return (error); } +SYSCTL_PROC(_kern_random_harvest, OID_AUTO, mask_bin, + CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, random_print_harvestmask, "A", + "Entropy harvesting mask (printable)"); static const char *random_source_descr[ENTROPYSOURCE] = { [RANDOM_CACHED] = "CACHED", @@ -367,6 +372,9 @@ random_print_harvestmask_symbolic(SYSCTL_HANDLER_ARGS) } return (error); } +SYSCTL_PROC(_kern_random_harvest, OID_AUTO, mask_symbolic, + CTLTYPE_STRING | CTLFLAG_RD, NULL, 0, random_print_harvestmask_symbolic, + "A", "Entropy harvesting mask (symbolic)"); /* ARGSUSED */ static void @@ -376,26 +384,7 @@ random_harvestq_init(void *unused __unused) (((1 << (RANDOM_ENVIRONMENTAL_END + 1)) - 1) & ~_RANDOM_HARVEST_ETHER_OFF & ~_RANDOM_HARVEST_UMA_OFF); - struct sysctl_oid *random_sys_o; - - random_sys_o = SYSCTL_ADD_NODE(&random_clist, - SYSCTL_STATIC_CHILDREN(_kern_random), - OID_AUTO, "harvest", CTLFLAG_RW, 0, - "Entropy Device Parameters"); hc_source_mask = almost_everything_mask; - SYSCTL_ADD_PROC(&random_clist, - SYSCTL_CHILDREN(random_sys_o), - OID_AUTO, "mask", CTLTYPE_UINT | CTLFLAG_RW, - NULL, 0, random_check_uint_harvestmask, "IU", - "Entropy harvesting mask"); - SYSCTL_ADD_PROC(&random_clist, - SYSCTL_CHILDREN(random_sys_o), - OID_AUTO, "mask_bin", CTLTYPE_STRING | CTLFLAG_RD, - NULL, 0, random_print_harvestmask, "A", "Entropy harvesting mask (printable)"); - SYSCTL_ADD_PROC(&random_clist, - SYSCTL_CHILDREN(random_sys_o), - OID_AUTO, "mask_symbolic", CTLTYPE_STRING | CTLFLAG_RD, - NULL, 0, random_print_harvestmask_symbolic, "A", "Entropy harvesting mask (symbolic)"); RANDOM_HARVEST_INIT_LOCK(); harvest_context.hc_entropy_ring.in = harvest_context.hc_entropy_ring.out = 0; } @@ -487,7 +476,6 @@ random_harvestq_deinit(void *unused __unused) random_kthread_control = 0; while (random_kthread_control >= 0) tsleep(&harvest_context.hc_kthread_proc, 0, "harvqterm", hz/5); - sysctl_ctx_free(&random_clist); } SYSUNINIT(random_device_h_init, SI_SUB_RANDOM, SI_ORDER_SECOND, random_harvestq_deinit, NULL);