LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

[PATCH v2 13/14] sysctl: SIZE_MAX->ARRAY_SIZE in register_net_sysctl

To: mcgrof@xxxxxxxxxx
Subject: [PATCH v2 13/14] sysctl: SIZE_MAX->ARRAY_SIZE in register_net_sysctl
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>, Iurii Zaikin <yzaikin@xxxxxxxxxx>, Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx>, Sven Schnelle <svens@xxxxxxxxxxxxx>, Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx>, Steffen Klassert <steffen.klassert@xxxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, "D. Wythe" <alibuda@xxxxxxxxxxxxxxxxx>, mptcp@xxxxxxxxxxxxxxx, Jakub Kicinski <kuba@xxxxxxxxxx>, Vasily Gorbik <gor@xxxxxxxxxxxxx>, Paolo Abeni <pabeni@xxxxxxxxxx>, coreteam@xxxxxxxxxxxxx, Jan Karcher <jaka@xxxxxxxxxxxxx>, Alexander Aring <alex.aring@xxxxxxxxx>, Will Deacon <will@xxxxxxxxxx>, Stefan Schmidt <stefan@xxxxxxxxxxxxxxxxxx>, Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx>, bridge@xxxxxxxxxxxxxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, Joerg Reuter <jreuter@xxxxxxxx>, Julian Anastasov <ja@xxxxxx>, David Ahern <dsahern@xxxxxxxxxx>, netfilter-devel@xxxxxxxxxxxxxxx, Wen Gu <guwen@xxxxxxxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, Santosh Shilimkar <santosh.shilimkar@xxxxxxxxxx>, linux-wpan@xxxxxxxxxxxxxxx, lvs-devel@xxxxxxxxxxxxxxx, Karsten Graul <kgraul@xxxxxxxxxxxxx>, Miquel Raynal <miquel.raynal@xxxxxxxxxxx>, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, linux-sctp@xxxxxxxxxxxxxxx, Tony Lu <tonylu@xxxxxxxxxxxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, Ralf Baechle <ralf@xxxxxxxxxxxxxx>, Florian Westphal <fw@xxxxxxxxx>, willy@xxxxxxxxxxxxx, Heiko Carstens <hca@xxxxxxxxxxxxx>, "David S. Miller" <davem@xxxxxxxxxxxxx>, linux-rdma@xxxxxxxxxxxxxxx, Roopa Prabhu <roopa@xxxxxxxxxx>, Alexander Gordeev <agordeev@xxxxxxxxxxxxx>, Simon Horman <horms@xxxxxxxxxxxx>, Mat Martineau <martineau@xxxxxxxxxx>, josh@xxxxxxxxxxxxxxxx, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Eric Dumazet <edumazet@xxxxxxxxxx>, linux-hams@xxxxxxxxxxxxxxx, Wenjia Zhang <wenjia@xxxxxxxxxxxxx>, linux-fsdevel@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, Xin Long <lucien.xin@xxxxxxxxx>, Nikolay Aleksandrov <razor@xxxxxxxxxxxxx>, netdev@xxxxxxxxxxxxxxx, rds-devel@xxxxxxxxxxxxxx, Joel Granados <j.granados@xxxxxxxxxxx>, Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>
From: Joel Granados <joel.granados@xxxxxxxxx>
Date: Mon, 31 Jul 2023 09:17:27 +0200
Replace SIZE_MAX with ARRAY_SIZE in the register_net_sysctl macro. Now
that all the callers to register_net_sysctl are actual arrays, we can
call ARRAY_SIZE() without any compilation warnings. By calculating the
actual array size, this commit is making sure that register_net_sysctl
and all its callers forward the table_size into sysctl backend for when
the sentinel elements in the ctl_table arrays (last empty markers) are
removed. Without it the removal would fail lacking a stopping criteria
for traversing the ctl_table arrays.

Stopping condition continues to be based on both table size and the
procname null test. This is needed in order to allow for the systematic
removal al the sentinel element in subsequent commits: Before removing
sentinel the stopping criteria will be the last null element. When the
sentinel is removed then the (correct) size will take over.

Signed-off-by: Joel Granados <j.granados@xxxxxxxxxxx>
Suggested-by: Jani Nikula <jani.nikula@xxxxxxxxxxxxxxx>
---
 include/net/net_namespace.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index e4e5fe75a281..75dba309e043 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -470,7 +470,7 @@ void unregister_pernet_device(struct pernet_operations *);
 struct ctl_table;
 
 #define register_net_sysctl(net, path, table)  \
-       register_net_sysctl_sz(net, path, table, SIZE_MAX)
+       register_net_sysctl_sz(net, path, table, ARRAY_SIZE(table))
 #ifdef CONFIG_SYSCTL
 int net_sysctl_init(void);
 struct ctl_table_header *register_net_sysctl_sz(struct net *net, const char 
*path,
-- 
2.30.2


<Prev in Thread] Current Thread [Next in Thread>