Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: do not acquire rtnl in fib_seq_sum()

After we made sure no fib_seq_read() handlers needs RTNL anymore,
we can remove RTNL from fib_seq_sum().

Note that after RTNL was dropped, fib_seq_sum() result was possibly
outdated anyway.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20241009184405.3752829-6-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
2698acd6 055202b1

+5 -7
+1 -1
include/net/fib_notifier.h
··· 28 28 struct fib_notifier_ops { 29 29 int family; 30 30 struct list_head list; 31 - unsigned int (*fib_seq_read)(struct net *net); 31 + unsigned int (*fib_seq_read)(const struct net *net); 32 32 int (*fib_dump)(struct net *net, struct notifier_block *nb, 33 33 struct netlink_ext_ack *extack); 34 34 struct module *owner;
-2
net/core/fib_notifier.c
··· 43 43 struct fib_notifier_ops *ops; 44 44 unsigned int fib_seq = 0; 45 45 46 - rtnl_lock(); 47 46 rcu_read_lock(); 48 47 list_for_each_entry_rcu(ops, &fn_net->fib_notifier_ops, list) { 49 48 if (!try_module_get(ops->owner)) ··· 51 52 module_put(ops->owner); 52 53 } 53 54 rcu_read_unlock(); 54 - rtnl_unlock(); 55 55 56 56 return fib_seq; 57 57 }
+1 -1
net/ipv4/fib_notifier.c
··· 27 27 return call_fib_notifiers(net, event_type, info); 28 28 } 29 29 30 - static unsigned int fib4_seq_read(struct net *net) 30 + static unsigned int fib4_seq_read(const struct net *net) 31 31 { 32 32 /* Paired with WRITE_ONCE() in call_fib4_notifiers() */ 33 33 return READ_ONCE(net->ipv4.fib_seq) + fib4_rules_seq_read(net);
+1 -1
net/ipv4/ipmr.c
··· 3035 3035 }; 3036 3036 #endif 3037 3037 3038 - static unsigned int ipmr_seq_read(struct net *net) 3038 + static unsigned int ipmr_seq_read(const struct net *net) 3039 3039 { 3040 3040 return READ_ONCE(net->ipv4.ipmr_seq) + ipmr_rules_seq_read(net); 3041 3041 }
+1 -1
net/ipv6/fib6_notifier.c
··· 22 22 return call_fib_notifiers(net, event_type, info); 23 23 } 24 24 25 - static unsigned int fib6_seq_read(struct net *net) 25 + static unsigned int fib6_seq_read(const struct net *net) 26 26 { 27 27 return fib6_tables_seq_read(net) + fib6_rules_seq_read(net); 28 28 }
+1 -1
net/ipv6/ip6mr.c
··· 1260 1260 return NOTIFY_DONE; 1261 1261 } 1262 1262 1263 - static unsigned int ip6mr_seq_read(struct net *net) 1263 + static unsigned int ip6mr_seq_read(const struct net *net) 1264 1264 { 1265 1265 return READ_ONCE(net->ipv6.ipmr_seq) + ip6mr_rules_seq_read(net); 1266 1266 }