Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp184116lqf; Fri, 26 Apr 2024 03:49:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVdGX+Tqs0Uw7AHJfJNSQdRmAx4W6GL+AgPAuj72bRc4Y4vQiWKwn8C6xqv+MqsAYh8eXWORpAfjm7acoMOCTOSMtJgUlqwF3OwccP2Sw== X-Google-Smtp-Source: AGHT+IE14dGr9lNQKRhhQrXSWsHUsKy3BPae3QZEVZgtPbSro9mYmXkhXuRfVKo/WLyICNr4IZQs X-Received: by 2002:a17:902:b184:b0:1e4:911b:7a6b with SMTP id s4-20020a170902b18400b001e4911b7a6bmr2216527plr.61.1714128555612; Fri, 26 Apr 2024 03:49:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714128555; cv=pass; d=google.com; s=arc-20160816; b=rbdKOzkjOOwL50N6CrDtnq7VRcAg/Gs54ivXW3mj+Q267iXkF68XayEDER0MVhi5CG Uixe1Feoc0sc+oaaMExae27m4AwQjMBWBuQdyAVQ4hz3snWZxdlCSEE3K+EvEYiFYKn1 twI04v+us/7YKEFXtYjrm/GToxQaEZEck3S0PeAbe0e7A6w0A5JHZmmrxc8jD5iLX/b1 PdVtJG8V7BrVdNAZNLlA9AFAN0UtOCQHWLa/LQCJky8TTkFbIhfN8ftgLZCetTsllqSY wK4oe+v4nWiV09x+WW3aeqgtGeEIcKUjpmvjYHby31xKxSZKeOjCizzqDMMcDXYkOc8n oAHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=dhcAJR2YS/eC3yZcxLCcALUzLHscgxgvQi6oyDacKbk=; fh=5g1ykxCv7ojYBYHK3aM7cpTkEd6dkeVMOJWUsjMgiIo=; b=R86ptVpnIuiq35dCExhgSi2u+SxjHXJcf0caJGLnotTh/TfCnTOPP+amPOsVlexnrR S34TnAMnPoym7tQ6b6F8ZTOfmPZJzezfrw4PDVHcTh63g1hxb+ueIy39nTr26Xll6+Wc PuwOBy5I/aJ6n28K1zAJd1ZDNxjKTeja/wK2bMrCHWpmQac4vCqbmr+divNhi+TQB8pQ baaFKIA0armWQbhi2x1sRrjDVHrqa61pW81gv5NoYNEI8UaeauWqBBbbT8Y3SbbA5/fP 1jRVwdT/KNRljypYek+Mx1EdOtu3+CC4acHzU4eC8pJAvkJxpAcr0NeehPohPA4rlK+z V1Mg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ltCPGgXe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d17-20020a170903209100b001d9004b68f2si14572316plc.239.2024.04.26.03.49.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:49:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ltCPGgXe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3031-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1FD68283DC5 for ; Fri, 26 Apr 2024 10:48:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0687147C85; Fri, 26 Apr 2024 10:47:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ltCPGgXe" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AECD144D34; Fri, 26 Apr 2024 10:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714128431; cv=none; b=AqAbYmPk0b2f/7Wzls0WzZZ1JAWi/l61OwlJmv4eqKehc4HO+PYj4KF+p8matgLLARgqDmtPfkZQza6CtXhfec1mxSVjogyW97a+QJenD4kx7wrOqcaEqdRU5gBW0SsFLAXViKh342z1Iyp+Lvm2il7nt3OANOGIOoo9/ZR3f9Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714128431; c=relaxed/simple; bh=MLLgeQP7IMlxSSyHDKz7Xc2vb7hwc9bWb8kATLJW89U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=az7r85szahNc48Uz+jxT4GxnK6X5JhTt8g0X8FluvZjjZwIG1L+DBeMIAPd3W69J1X9YkH7+rnUDrtZK5uLKsmELzI1EsABTmEE9rezVHxcqnLFD2Ve2CKBTr9GOVphVORrACtU/jM+wQ8WzqiK51PV3AOa+8U1ObQBhU8bSYto= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ltCPGgXe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 34DEDC4DDE3; Fri, 26 Apr 2024 10:47:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714128431; bh=MLLgeQP7IMlxSSyHDKz7Xc2vb7hwc9bWb8kATLJW89U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=ltCPGgXexeaskdCZL1injktHYjqKtpP1dM5kXi+Sj4ZbiFJSVS/LDTicpnmZ2DwqG eKAStgJQv7fTnaPOH4kv5JhjH2wZsoVRqrZnaM742NQPcCQKbP8sPG7mc2SLjCRHbL DJBhwstjhzGBUUARDuUwti4I7gLjZ4r5Ic9KrFea1UkKc1ogfscNGKdlosVpRo9M7b WyLJkxzOX3Mi4A9xfoSm6KNy/M0/4Q4e/FJ01nVeci8xXHiRJcoRLls2bO1W8mzL9v sGHOEc9sdqN6pdIjshlX9Ak50rBZ90jPM1FYwq6VfO+As/egBoYHS3uvMUUB/eEQJ6 DIqrvhLgnq/xg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2194BC04FFE; Fri, 26 Apr 2024 10:47:11 +0000 (UTC) From: Joel Granados via B4 Relay Date: Fri, 26 Apr 2024 12:46:57 +0200 Subject: [PATCH v5 5/8] net: Remove ctl_table sentinel elements from several networking subsystems Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240426-jag-sysctl_remset_net-v5-5-e3b12f6111a6@samsung.com> References: <20240426-jag-sysctl_remset_net-v5-0-e3b12f6111a6@samsung.com> In-Reply-To: <20240426-jag-sysctl_remset_net-v5-0-e3b12f6111a6@samsung.com> To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexander Aring , Stefan Schmidt , Miquel Raynal , David Ahern , Steffen Klassert , Herbert Xu , Matthieu Baerts , Mat Martineau , Geliang Tang , Ralf Baechle , Remi Denis-Courmont , Allison Henderson , David Howells , Marc Dionne , Marcelo Ricardo Leitner , Xin Long , Wenjia Zhang , Jan Karcher , "D. Wythe" , Tony Lu , Wen Gu , Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jon Maloy , Ying Xue , Martin Schiller , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Roopa Prabhu , Nikolay Aleksandrov , Simon Horman , Julian Anastasov , Joerg Reuter , Luis Chamberlain , Kees Cook Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, dccp@vger.kernel.org, linux-wpan@vger.kernel.org, mptcp@lists.linux.dev, linux-hams@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-afs@lists.infradead.org, linux-sctp@vger.kernel.org, linux-s390@vger.kernel.org, linux-nfs@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-x25@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux.dev, lvs-devel@vger.kernel.org, Joel Granados X-Mailer: b4 0.13-dev-2d940 X-Developer-Signature: v=1; a=openpgp-sha256; l=7509; i=j.granados@samsung.com; h=from:subject:message-id; bh=ECJVmDZTABLmCLI3IvBjvSf32Movt48DJVWRJRYYOH8=; b=owJ4nAHtARL+kA0DAAoBupfNUreWQU8ByyZiAGYrhiql7S6kKE2G3ICFDQaZ+9LtVfFtRHW7/ MzEzHLiYiTX2IkBswQAAQoAHRYhBK5HCVcl5jElzssnkLqXzVK3lkFPBQJmK4YqAAoJELqXzVK3 lkFPPdoL/3i4qlgimmYoLLp1AnkLLP+/jPZbcfd6GZ7UUVxajap9ogymYWg07/JwMTzzaI4V2uh j3VU030STUYTo0rzOB9GhTXr0P/PqShDcdAfkdqBdb9nZ0lcK+PyK+K0ESThoLlQulXES2zVrYU ew+w5Q0MThpdIQIshSG0xFRtddjLZLtjg6WDL8yrLz/SoMAWRpkiIDAKseXRl8nBr/77k+aeBOV 69Zh/CFTtTUFElaVG3ZGHW6Qco39IfYXuTJC6EV6zT4966mHxFSRqcKhAP3RZOKbDaa1W6I2wOd RL0YL/XAXgaDbs3RAXKAqVJozp8DNE1dj3HnwRA69vlwNA4w/shzjiv6Da+dXsinbYoka7aiOYW /7Y4GGqRhp9fT+wfaHJt1xz0mCSqAWv4WUhHhjQ1MvLwDPB6HUbO/ebX4iH5C0S1JU9k3jXHcTS E+7oVDxMrb7KBuM0PXRxCFJ8hWGM6wVluyfRZRVn42vXF6LtpFxHD30V/fyC4SAksNxhb3/nkM6 GI= X-Developer-Key: i=j.granados@samsung.com; a=openpgp; fpr=F1F8E46D30F0F6C4A45FF4465895FAAC338C6E77 X-Endpoint-Received: by B4 Relay for j.granados@samsung.com/default with auth_id=70 X-Original-From: Joel Granados Reply-To: j.granados@samsung.com From: Joel Granados This commit comes at the tail end of a greater effort to remove the empty elements at the end of the ctl_table arrays (sentinels) which will reduce the overall build time size of the kernel and run time memory bloat by ~64 bytes per sentinel (further information Link : https://lore.kernel.org/all/ZO5Yx5JFogGi%2FcBo@bombadil.infradead.org/) To avoid lots of small commits, this commit brings together network changes from (as they appear in MAINTAINERS) LLC, MPTCP, NETROM NETWORK LAYER, PHONET PROTOCOL, ROSE NETWORK LAYER, RXRPC SOCKETS, SCTP PROTOCOL, SHARED MEMORY COMMUNICATIONS (SMC), TIPC NETWORK LAYER and NETWORKING [IPSEC] * Remove sentinel element from ctl_table structs. * Replace empty array registration with the register_net_sysctl_sz call in llc_sysctl_init * Replace the for loop stop condition that tests for procname == NULL with one that depends on array size in sctp_sysctl_net_register * Remove instances where an array element is zeroed out to make it look like a sentinel in xfrm_sysctl_init. This is not longer needed and is safe after commit c899710fe7f9 ("networking: Update to register_net_sysctl_sz") added the array size to the ctl_table registration * Use a table_size variable to keep the value of ARRAY_SIZE Signed-off-by: Joel Granados --- net/llc/sysctl_net_llc.c | 8 ++------ net/mptcp/ctrl.c | 1 - net/netrom/sysctl_net_netrom.c | 1 - net/phonet/sysctl.c | 1 - net/rose/sysctl_net_rose.c | 1 - net/rxrpc/sysctl.c | 1 - net/sctp/sysctl.c | 10 +++------- net/smc/smc_sysctl.c | 1 - net/tipc/sysctl.c | 1 - net/xfrm/xfrm_sysctl.c | 5 +---- 10 files changed, 6 insertions(+), 24 deletions(-) diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c index 8443a6d841b0..72e101135f8c 100644 --- a/net/llc/sysctl_net_llc.c +++ b/net/llc/sysctl_net_llc.c @@ -44,11 +44,6 @@ static struct ctl_table llc2_timeout_table[] = { .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - { }, -}; - -static struct ctl_table llc_station_table[] = { - { }, }; static struct ctl_table_header *llc2_timeout_header; @@ -56,8 +51,9 @@ static struct ctl_table_header *llc_station_header; int __init llc_sysctl_init(void) { + struct ctl_table empty[1] = {}; llc2_timeout_header = register_net_sysctl(&init_net, "net/llc/llc2/timeout", llc2_timeout_table); - llc_station_header = register_net_sysctl(&init_net, "net/llc/station", llc_station_table); + llc_station_header = register_net_sysctl_sz(&init_net, "net/llc/station", empty, 0); if (!llc2_timeout_header || !llc_station_header) { llc_sysctl_exit(); diff --git a/net/mptcp/ctrl.c b/net/mptcp/ctrl.c index 13fe0748dde8..8bf7c26a0878 100644 --- a/net/mptcp/ctrl.c +++ b/net/mptcp/ctrl.c @@ -156,7 +156,6 @@ static struct ctl_table mptcp_sysctl_table[] = { .mode = 0644, .proc_handler = proc_dointvec_jiffies, }, - {} }; static int mptcp_pernet_new_table(struct net *net, struct mptcp_pernet *pernet) diff --git a/net/netrom/sysctl_net_netrom.c b/net/netrom/sysctl_net_netrom.c index 79fb2d3f477b..7dc0fa628f2e 100644 --- a/net/netrom/sysctl_net_netrom.c +++ b/net/netrom/sysctl_net_netrom.c @@ -140,7 +140,6 @@ static struct ctl_table nr_table[] = { .extra1 = &min_reset, .extra2 = &max_reset }, - { } }; int __init nr_register_sysctl(void) diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c index 0d0bf41381c2..82fc22467a09 100644 --- a/net/phonet/sysctl.c +++ b/net/phonet/sysctl.c @@ -81,7 +81,6 @@ static struct ctl_table phonet_table[] = { .mode = 0644, .proc_handler = proc_local_port_range, }, - { } }; int __init phonet_sysctl_init(void) diff --git a/net/rose/sysctl_net_rose.c b/net/rose/sysctl_net_rose.c index d391d7758f52..d801315b7083 100644 --- a/net/rose/sysctl_net_rose.c +++ b/net/rose/sysctl_net_rose.c @@ -112,7 +112,6 @@ static struct ctl_table rose_table[] = { .extra1 = &min_window, .extra2 = &max_window }, - { } }; void __init rose_register_sysctl(void) diff --git a/net/rxrpc/sysctl.c b/net/rxrpc/sysctl.c index c9bedd0e2d86..9bf9a1f6e4cb 100644 --- a/net/rxrpc/sysctl.c +++ b/net/rxrpc/sysctl.c @@ -127,7 +127,6 @@ static struct ctl_table rxrpc_sysctl_table[] = { .extra1 = (void *)SYSCTL_ONE, .extra2 = (void *)&four, }, - { } }; int __init rxrpc_sysctl_init(void) diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index f65d6f92afcb..c00087e01351 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -80,8 +80,6 @@ static struct ctl_table sctp_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - - { /* sentinel */ } }; /* The following index defines are used in sctp_sysctl_net_register(). @@ -384,8 +382,6 @@ static struct ctl_table sctp_net_table[] = { .extra1 = SYSCTL_ZERO, .extra2 = &pf_expose_max, }, - - { /* sentinel */ } }; static int proc_sctp_do_hmac_alg(struct ctl_table *ctl, int write, @@ -597,6 +593,7 @@ static int proc_sctp_do_probe_interval(struct ctl_table *ctl, int write, int sctp_sysctl_net_register(struct net *net) { + size_t table_size = ARRAY_SIZE(sctp_net_table); struct ctl_table *table; int i; @@ -604,7 +601,7 @@ int sctp_sysctl_net_register(struct net *net) if (!table) return -ENOMEM; - for (i = 0; table[i].data; i++) + for (i = 0; i < table_size; i++) table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; table[SCTP_RTO_MIN_IDX].extra2 = &net->sctp.rto_max; @@ -613,8 +610,7 @@ int sctp_sysctl_net_register(struct net *net) table[SCTP_PS_RETRANS_IDX].extra1 = &net->sctp.pf_retrans; net->sctp.sysctl_header = register_net_sysctl_sz(net, "net/sctp", - table, - ARRAY_SIZE(sctp_net_table)); + table, table_size); if (net->sctp.sysctl_header == NULL) { kfree(table); return -ENOMEM; diff --git a/net/smc/smc_sysctl.c b/net/smc/smc_sysctl.c index a5946d1b9d60..bd0b7e2f8824 100644 --- a/net/smc/smc_sysctl.c +++ b/net/smc/smc_sysctl.c @@ -90,7 +90,6 @@ static struct ctl_table smc_table[] = { .extra1 = &conns_per_lgr_min, .extra2 = &conns_per_lgr_max, }, - { } }; int __net_init smc_sysctl_net_init(struct net *net) diff --git a/net/tipc/sysctl.c b/net/tipc/sysctl.c index 9fb65c988f7f..30d2e06e3d8c 100644 --- a/net/tipc/sysctl.c +++ b/net/tipc/sysctl.c @@ -91,7 +91,6 @@ static struct ctl_table tipc_table[] = { .mode = 0644, .proc_handler = proc_doulongvec_minmax, }, - {} }; int tipc_register_sysctl(void) diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c index 7fdeafc838a7..b0f542805e6e 100644 --- a/net/xfrm/xfrm_sysctl.c +++ b/net/xfrm/xfrm_sysctl.c @@ -38,7 +38,6 @@ static struct ctl_table xfrm_table[] = { .mode = 0644, .proc_handler = proc_dointvec }, - {} }; int __net_init xfrm_sysctl_init(struct net *net) @@ -57,10 +56,8 @@ int __net_init xfrm_sysctl_init(struct net *net) table[3].data = &net->xfrm.sysctl_acq_expires; /* Don't export sysctls to unprivileged users */ - if (net->user_ns != &init_user_ns) { - table[0].procname = NULL; + if (net->user_ns != &init_user_ns) table_size = 0; - } net->xfrm.sysctl_hdr = register_net_sysctl_sz(net, "net/core", table, table_size); -- 2.43.0