net-timestamp: namespacify the sysctl_tstamp_allow_data
Subsystems (3)
PATCH v3 1/1 net-timestamp: namespacify the sysctl_tstamp_allow_data
From: Jason Xing <[email protected]>
Let it be tuned in per netns by admins.
---
v3
1. move sysctl_tstamp_allow_data after sysctl_txrehash (Eric)
v2
1. remove the static global from sock.c
2. reorder the tests
3. I removed the patch [1/3] because I made one mistake
4. I also removed the patch [2/3] because Willem soon will propose a packetdrill test that is better.
Now, I only need to write this standalone patch.
--- include/net/netns/core.h | 1 + include/net/sock.h | 2 -- net/core/net_namespace.c | 1 + net/core/skbuff.c | 2 +- net/core/sock.c | 2 -- net/core/sysctl_net_core.c | 18 +++++++++--------- 6 files changed, 12 insertions(+), 14 deletions(-)
include/net/netns/core.h +1 -0
@@ -15,6 +15,7 @@ struct netns_core {int sysctl_somaxconn;int sysctl_optmem_max;u8 sysctl_txrehash; +int sysctl_tstamp_allow_data;#ifdef CONFIG_PROC_FS struct prot_inuse __percpu *prot_inuse;
include/net/sock.h +0 -2
@@ -2808,8 +2808,6 @@ void sk_get_meminfo(const struct sock *sk, u32 *meminfo);extern __u32 sysctl_wmem_max;extern __u32 sysctl_rmem_max; -extern int sysctl_tstamp_allow_data; -extern __u32 sysctl_wmem_default;extern __u32 sysctl_rmem_default;
net/core/net_namespace.c +1 -0
@@ -317,6 +317,7 @@ static __net_init void preinit_net_sysctl(struct net *net)*/ net->core.sysctl_optmem_max =128 *1024 ; net->core.sysctl_txrehash =SOCK_TXREHASH_ENABLED ; + net->core.sysctl_tstamp_allow_data =1 ; }/* init code that must occur even if setup_net() is not called. */
net/core/skbuff.c +1 -1
@@ -5506,7 +5506,7 @@ static bool skb_may_tx_timestamp(struct sock *sk, bool tsonly) {bool ret; -if (likely (READ_ONCE (sysctl_tstamp_allow_data) || tsonly)) +if (likely (tsonly ||READ_ONCE (sock_net (sk)->core.sysctl_tstamp_allow_data)))return true;read_lock_bh (&sk->sk_callback_lock);
net/core/sock.c +0 -2
@@ -286,8 +286,6 @@ EXPORT_SYMBOL(sysctl_rmem_max);__u32 sysctl_wmem_default__read_mostly =SK_WMEM_MAX ;__u32 sysctl_rmem_default__read_mostly =SK_RMEM_MAX ; -int sysctl_tstamp_allow_data__read_mostly =1 ; -DEFINE_STATIC_KEY_FALSE (memalloc_socks_key);EXPORT_SYMBOL_GPL (memalloc_socks_key);
net/core/sysctl_net_core.c +9 -9
@@ -491,15 +491,6 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { - .procname = "tstamp_allow_data", - .data = &sysctl_tstamp_allow_data, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE - },#ifdef CONFIG_RPS { .procname = "rps_sock_flow_entries",
@@ -665,6 +656,15 @@ static struct ctl_table netns_core_table[] = { .extra2 = SYSCTL_ONE, .proc_handler = proc_dou8vec_minmax, }, + { + .procname = "tstamp_allow_data", + .data = &init_net.core.sysctl_tstamp_allow_data, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 =SYSCTL_ONE + },/* sysctl_core_net_init() will set the values after this * to readonly in network namespaces */
Signature · 1 line
2.37.3
From: Jason Xing <[email protected]>
Date: Thu, 3 Oct 2024 19:40:35 +0900
Quoted 22 lines
net/core/sysctl_net_core.c +0
-9@@ -491,15 +491,6 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { - .procname = "tstamp_allow_data", - .data = &sysctl_tstamp_allow_data, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE - },#ifdef CONFIG_RPS { .procname = "rps_sock_flow_entries",@@ -665,6 +656,15 @@ static struct ctl_table netns_core_table[] = { .extra2 = SYSCTL_ONE,
net/core/sysctl_net_core.c static struct ctl_table netns_core_table[] = { · line 666
Quoted 10 lines
net/core/sysctl_net_core.c +8
-0.proc_handler = proc_dou8vec_minmax, }, + { + .procname = "tstamp_allow_data", + .data = &init_net.core.sysctl_tstamp_allow_data, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 = SYSCTL_ONE
It's already limited to [0, 1], so you can use u8 and save 3 bytes.
grep -rnI proc_dou8vec_minmax.
Quoted 38 lines · Kuniyuki Iwashima
From: Jason Xing <[email protected]>
Date: Thu, 3 Oct 2024 19:40:35 +0900Quoted 22 lines
net/core/sysctl_net_core.c +0
-9@@ -491,15 +491,6 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { - .procname = "tstamp_allow_data", - .data = &sysctl_tstamp_allow_data, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE - },#ifdef CONFIG_RPS { .procname = "rps_sock_flow_entries",@@ -665,6 +656,15 @@ static struct ctl_table netns_core_table[] = { .extra2 = SYSCTL_ONE,net/core/sysctl_net_core.c static struct ctl_table netns_core_table[] = { · line 666
Quoted 10 lines
net/core/sysctl_net_core.c +8
-0.proc_handler = proc_dou8vec_minmax, }, + { + .procname = "tstamp_allow_data", + .data = &init_net.core.sysctl_tstamp_allow_data, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 =SYSCTL_ZERO , + .extra2 = SYSCTL_ONEIt's already limited to [0, 1], so you can use u8 and save 3 bytes.
Quoted 1 line
grep -rnI
proc_dou8vec_minmax.
Thanks for your advice. I will update it soon.
Thanks,
Jason