sysctl: Add size to register_net_sysctl function
authorJoel Granados <joel.granados@gmail.com>
Wed, 9 Aug 2023 10:50:00 +0000 (12:50 +0200)
committerLuis Chamberlain <mcgrof@kernel.org>
Tue, 15 Aug 2023 22:26:17 +0000 (15:26 -0700)
commit95d4977876d6658fdee58be8c8668aac68c25dd2
tree6d100d3ef40dcce07dbe56cb76de6832f44cc983
parent3bc269cfd3e119be84b69d95aec3a9e147016bb2
sysctl: Add size to register_net_sysctl function

This commit adds size to the register_net_sysctl indirection function to
facilitate the removal of the sentinel elements (last empty markers)
from the ctl_table arrays. Though we don't actually remove any sentinels
in this commit, register_net_sysctl* now has the capability of
forwarding table_size for when that happens.

We create a new function register_net_sysctl_sz with an extra size
argument. A macro replaces the existing register_net_sysctl. The size in
the macro is SIZE_MAX instead of ARRAY_SIZE to avoid compilation errors
while we systematically migrate to register_net_sysctl_sz. Will change
to ARRAY_SIZE in subsequent commits.

Care is taken to add table_size to the stopping criteria in such a way
that when we remove the empty sentinel element, it will continue
stopping in the last element of the ctl_table array.

Signed-off-by: Joel Granados <j.granados@samsung.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
include/net/net_namespace.h
net/sysctl_net.c