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

Configure Feed

Select the types of activity you want to include in your feed.

ipmr: use READ_ONCE() to read net->ipv[46].ipmr_seq

mr_call_vif_notifiers() and mr_call_mfc_notifiers() already
uses WRITE_ONCE() on the write side.

Using RTNL to protect the reads seems a big hammer.

Constify 'struct net' argument of ip6mr_rules_seq_read()
and ipmr_rules_seq_read().

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-5-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
055202b1 e60ea454

+6 -10
+3 -5
net/ipv4/ipmr.c
··· 288 288 return fib_rules_dump(net, nb, RTNL_FAMILY_IPMR, extack); 289 289 } 290 290 291 - static unsigned int ipmr_rules_seq_read(struct net *net) 291 + static unsigned int ipmr_rules_seq_read(const struct net *net) 292 292 { 293 293 return fib_rules_seq_read(net, RTNL_FAMILY_IPMR); 294 294 } ··· 346 346 return 0; 347 347 } 348 348 349 - static unsigned int ipmr_rules_seq_read(struct net *net) 349 + static unsigned int ipmr_rules_seq_read(const struct net *net) 350 350 { 351 351 return 0; 352 352 } ··· 3037 3037 3038 3038 static unsigned int ipmr_seq_read(struct net *net) 3039 3039 { 3040 - ASSERT_RTNL(); 3041 - 3042 - return net->ipv4.ipmr_seq + ipmr_rules_seq_read(net); 3040 + return READ_ONCE(net->ipv4.ipmr_seq) + ipmr_rules_seq_read(net); 3043 3041 } 3044 3042 3045 3043 static int ipmr_dump(struct net *net, struct notifier_block *nb,
+3 -5
net/ipv6/ip6mr.c
··· 276 276 return fib_rules_dump(net, nb, RTNL_FAMILY_IP6MR, extack); 277 277 } 278 278 279 - static unsigned int ip6mr_rules_seq_read(struct net *net) 279 + static unsigned int ip6mr_rules_seq_read(const struct net *net) 280 280 { 281 281 return fib_rules_seq_read(net, RTNL_FAMILY_IP6MR); 282 282 } ··· 335 335 return 0; 336 336 } 337 337 338 - static unsigned int ip6mr_rules_seq_read(struct net *net) 338 + static unsigned int ip6mr_rules_seq_read(const struct net *net) 339 339 { 340 340 return 0; 341 341 } ··· 1262 1262 1263 1263 static unsigned int ip6mr_seq_read(struct net *net) 1264 1264 { 1265 - ASSERT_RTNL(); 1266 - 1267 - return net->ipv6.ipmr_seq + ip6mr_rules_seq_read(net); 1265 + return READ_ONCE(net->ipv6.ipmr_seq) + ip6mr_rules_seq_read(net); 1268 1266 } 1269 1267 1270 1268 static int ip6mr_dump(struct net *net, struct notifier_block *nb,