ipv6: anycast: complete RCU handling of struct ifacaddr6
Subsystems (3)
PATCH 1/1 ipv6: anycast: complete RCU handling of struct ifacaddr6
struct ifacaddr6 are already freed after RCU grace period.
Add __rcu qualifier to aca_next pointer, and idev->ac_list
Add relevant rcu_assign_pointer() and dereference accessors.
ipv6_chk_acast_dev() no longer needs to acquire idev->lock.
/proc/net/anycast6 is now purely RCU protected, it no longer acquires idev->lock.
Similarly in6_dump_addrs() can use RCU protection to iterate through anycast addresses. It was relying on a mixture of RCU and RTNL but next patches will get rid of RTNL there.
--- include/net/if_inet6.h | 4 +-- net/ipv6/addrconf.c | 4 +-- net/ipv6/anycast.c | 61 ++++++++++++++++-------------------------- 3 files changed, 27 insertions(+), 42 deletions(-)
include/net/if_inet6.h +2 -2
@@ -144,7 +144,7 @@ struct ipv6_ac_socklist {struct ifacaddr6 {struct in6_addr aca_addr;struct fib6_info *aca_rt; -struct ifacaddr6 *aca_next; +struct ifacaddr6 __rcu *aca_next;struct hlist_node aca_addr_lst;int aca_users;refcount_t aca_refcnt;
@@ -196,7 +196,7 @@ struct inet6_dev {spinlock_t mc_report_lock;/* mld query report lock */ struct mutex mc_lock;/* mld global lock */ -struct ifacaddr6 *ac_list; +struct ifacaddr6 __rcu *ac_list;rwlock_t lock;refcount_t refcnt;__u32 if_flags;
net/ipv6/addrconf.c +2 -2
@@ -5313,8 +5313,8 @@ static int in6_dump_addrs(struct inet6_dev *idev, struct sk_buff *skb,case ANYCAST_ADDR : fillargs->event =RTM_GETANYCAST ;/* anycast address */ -for (ifaca = idev->ac_list; ifaca; - ifaca = ifaca->aca_next, ip_idx++) { +for (ifaca =rcu_dereference (idev->ac_list); ifaca; + ifaca =rcu_dereference (ifaca->aca_next), ip_idx++) {if (ip_idx < s_ip_idx)continue ; err =inet6_fill_ifacaddr (skb, ifaca, fillargs);
net/ipv6/anycast.c +23 -38
142 lines not on this page · raw message
Signature · 1 line
2.44.0.rc1.240.g4c46232300-goog
Quoted 8 lines · Fri, Feb 23, 2024 at 09:10:54PM CET, [email protected] wrote:
struct ifacaddr6 are already freed after RCU grace period.
Add
__rcuqualifier toaca_nextpointer, andidev->ac_listAdd relevant
rcu_assign_pointer()and dereference accessors.
ipv6_chk_acast_dev()no longer needs to acquireidev->lock.
Quoted 8 lines
/proc/net/anycast6is now purely RCU protected, it no longer acquiresidev->lock.Similarly
in6_dump_addrs()can use RCU protection to iterate through anycast addresses. It was relying on a mixture of RCU and RTNL but next patches will get rid of RTNL there.Signed-off-by Eric Dumazet <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Fri, 23 Feb 2024 20:10:54 +0000 you wrote:
struct ifacaddr6 are already freed after RCU grace period.
Add
__rcuqualifier toaca_nextpointer, andidev->ac_listAdd relevant
rcu_assign_pointer()and dereference accessors.
ipv6_chk_acast_dev()no longer needs to acquireidev->lock.[...]
Here is the summary with links:
- [net-next] ipv6: anycast: complete RCU handling of struct ifacaddr6
https://git.kernel.org/netdev/net-next/c/c3718936ec47
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html