[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240227150200.2814664-4-edumazet@google.com>
Date: Tue, 27 Feb 2024 15:01:48 +0000
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: David Ahern <dsahern@...nel.org>, Jiri Pirko <jiri@...dia.com>, netdev@...r.kernel.org,
eric.dumazet@...il.com, Eric Dumazet <edumazet@...gle.com>
Subject: [PATCH v2 net-next 03/15] ipv6: addrconf_disable_ipv6() optimizations
Writing over /proc/sys/net/ipv6/conf/default/disable_ipv6
does not need to hold RTNL.
When changing /proc/sys/net/ipv6/conf/all/disable_ipv6,
the generic WRITE_ONCE(*p, newf) is enough, no need
to repeat it.
Signed-off-by: Eric Dumazet <edumazet@...gle.com>
---
net/ipv6/addrconf.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9c1d141a9a343b45225658ce75f23893ff6c7426..88b129b7884564876a51b359137c33e9b75ee9de 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -6398,25 +6398,23 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int newf)
{
- struct net *net;
+ struct net *net = (struct net *)table->extra2;
int old;
+ if (p == &net->ipv6.devconf_dflt->disable_ipv6) {
+ WRITE_ONCE(*p, newf);
+ return 0;
+ }
+
if (!rtnl_trylock())
return restart_syscall();
- net = (struct net *)table->extra2;
old = *p;
WRITE_ONCE(*p, newf);
- if (p == &net->ipv6.devconf_dflt->disable_ipv6) {
- rtnl_unlock();
- return 0;
- }
-
- if (p == &net->ipv6.devconf_all->disable_ipv6) {
- WRITE_ONCE(net->ipv6.devconf_dflt->disable_ipv6, newf);
+ if (p == &net->ipv6.devconf_all->disable_ipv6)
addrconf_disable_change(net, newf);
- } else if ((!newf) ^ (!old))
+ else if ((!newf) ^ (!old))
dev_disable_change((struct inet6_dev *)table->extra1);
rtnl_unlock();
--
2.44.0.rc1.240.g4c46232300-goog
Powered by blists - more mailing lists