From: Jakub Kicinski <kuba@kernel.org>
To: xiangxia.m.yue@gmail.com
Cc: netdev@vger.kernel.org, Luis Chamberlain <mcgrof@kernel.org>,
Kees Cook <keescook@chromium.org>,
Iurii Zaikin <yzaikin@google.com>,
"David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Simon Horman <horms@verge.net.au>, Julian Anastasov <ja@ssi.bg>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
Dmitry Vyukov <dvyukov@google.com>,
Alexei Starovoitov <ast@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Lorenz Bauer <lmb@cloudflare.com>,
Akhmat Karakotov <hmukos@yandex-team.ru>
Subject: Re: [net-next RESEND v2] net: core: use shared sysctl macro
Date: Wed, 6 Apr 2022 12:25:28 -0700 [thread overview]
Message-ID: <20220406122528.1cb94bfb@kernel.org> (raw)
In-Reply-To: <20220406124208.3485-1-xiangxia.m.yue@gmail.com>
On Wed, 6 Apr 2022 20:42:08 +0800 xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
>
> This patch introdues the SYSCTL_THREE, and replace the
> two, three and long_one to SYSCTL_XXX accordingly.
>
> KUnit:
> [23:03:58] ================ sysctl_test (10 subtests) =================
> [23:03:58] [PASSED] sysctl_test_api_dointvec_null_tbl_data
> [23:03:58] [PASSED] sysctl_test_api_dointvec_table_maxlen_unset
> [23:03:58] [PASSED] sysctl_test_api_dointvec_table_len_is_zero
> [23:03:58] [PASSED] sysctl_test_api_dointvec_table_read_but_position_set
> [23:03:58] [PASSED] sysctl_test_dointvec_read_happy_single_positive
> [23:03:58] [PASSED] sysctl_test_dointvec_read_happy_single_negative
> [23:03:58] [PASSED] sysctl_test_dointvec_write_happy_single_positive
> [23:03:58] [PASSED] sysctl_test_dointvec_write_happy_single_negative
> [23:03:58] [PASSED] sysctl_test_api_dointvec_write_single_less_int_min
> [23:03:58] [PASSED] sysctl_test_api_dointvec_write_single_greater_int_max
> [23:03:58] =================== [PASSED] sysctl_test ===================
>
> ./run_kselftest.sh -c sysctl
> ...
> # Running test: sysctl_test_0006 - run #49
> # Checking bitmap handler... ok
> # Wed Mar 16 14:58:41 UTC 2022
> # Running test: sysctl_test_0007 - run #0
> # Boot param test only possible sysctl_test is built-in, not module:
> # CONFIG_TEST_SYSCTL=m
> ok 1 selftests: sysctl: sysctl.sh
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 7d9cfc730bd4..0bdd9249666b 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -26,7 +26,7 @@ static const struct file_operations proc_sys_dir_file_operations;
> static const struct inode_operations proc_sys_dir_operations;
>
> /* shared constants to be used in various sysctls */
> -const int sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX, 65535 };
> +const int sysctl_vals[] = { -1, 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535 };
> EXPORT_SYMBOL(sysctl_vals);
>
> const unsigned long sysctl_long_vals[] = { 0, 1, LONG_MAX };
> diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
> index 6353d6db69b2..b2ac6542455f 100644
> --- a/include/linux/sysctl.h
> +++ b/include/linux/sysctl.h
> @@ -42,12 +42,13 @@ struct ctl_dir;
> #define SYSCTL_ZERO ((void *)&sysctl_vals[1])
> #define SYSCTL_ONE ((void *)&sysctl_vals[2])
> #define SYSCTL_TWO ((void *)&sysctl_vals[3])
> -#define SYSCTL_FOUR ((void *)&sysctl_vals[4])
nit: I vote we move the -1 later in the array, so that for the first
5 "natural" numbers the index matches the value.
> -#define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[5])
> -#define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[6])
> -#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[7])
> -#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[8])
> -#define SYSCTL_INT_MAX ((void *)&sysctl_vals[9])
> +#define SYSCTL_THREE ((void *)&sysctl_vals[4])
> +#define SYSCTL_FOUR ((void *)&sysctl_vals[5])
> +#define SYSCTL_ONE_HUNDRED ((void *)&sysctl_vals[6])
> +#define SYSCTL_TWO_HUNDRED ((void *)&sysctl_vals[7])
> +#define SYSCTL_ONE_THOUSAND ((void *)&sysctl_vals[8])
> +#define SYSCTL_THREE_THOUSAND ((void *)&sysctl_vals[9])
> +#define SYSCTL_INT_MAX ((void *)&sysctl_vals[10])
> @@ -388,7 +384,7 @@ static struct ctl_table net_core_table[] = {
> .extra2 = SYSCTL_ONE,
> # else
> .extra1 = SYSCTL_ZERO,
> - .extra2 = &two,
> + .extra2 = SYSCTL_TWO,
> # endif
> },
> # ifdef CONFIG_HAVE_EBPF_JIT
> @@ -399,7 +395,7 @@ static struct ctl_table net_core_table[] = {
> .mode = 0600,
> .proc_handler = proc_dointvec_minmax_bpf_restricted,
> .extra1 = SYSCTL_ZERO,
> - .extra2 = &two,
> + .extra2 = SYSCTL_TWO,
> },
> {
> .procname = "bpf_jit_kallsyms",
> @@ -417,7 +413,7 @@ static struct ctl_table net_core_table[] = {
> .maxlen = sizeof(long),
> .mode = 0600,
> .proc_handler = proc_dolongvec_minmax_bpf_restricted,
> - .extra1 = &long_one,
> + .extra1 = SYSCTL_LONG_ONE,
Hm, looks like most of the conversions are not to the newly added value
of three. Feels like those should be a separate patch.
next prev parent reply other threads:[~2022-04-06 20:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 12:42 [net-next RESEND v2] net: core: use shared sysctl macro xiangxia.m.yue
2022-04-06 16:20 ` Luis Chamberlain
2022-04-06 19:16 ` Jakub Kicinski
2022-04-06 20:46 ` Luis Chamberlain
2022-04-06 21:06 ` Jakub Kicinski
2022-04-06 21:17 ` Luis Chamberlain
2022-04-06 19:25 ` Jakub Kicinski [this message]
2022-04-07 12:50 ` Alexander Lobakin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220406122528.1cb94bfb@kernel.org \
--to=kuba@kernel.org \
--cc=ast@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=dvyukov@google.com \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=hmukos@yandex-team.ru \
--cc=horms@verge.net.au \
--cc=ja@ssi.bg \
--cc=kadlec@netfilter.org \
--cc=keescook@chromium.org \
--cc=lmb@cloudflare.com \
--cc=mcgrof@kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=xiangxia.m.yue@gmail.com \
--cc=yoshfuji@linux-ipv6.org \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.