mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-13 14:24:11 +08:00
net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu()
Make the net pointer stored in possible_net_t structure annotated as an RCU pointer. Change the access helpers to treat it as such. Introduce read_pnet_rcu() helper to allow caller to dereference the net pointer under RCU read lock. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
ee2a35fedb
commit
2034d90ae4
@ -368,21 +368,30 @@ static inline void put_net_track(struct net *net, netns_tracker *tracker)
|
||||
|
||||
typedef struct {
|
||||
#ifdef CONFIG_NET_NS
|
||||
struct net *net;
|
||||
struct net __rcu *net;
|
||||
#endif
|
||||
} possible_net_t;
|
||||
|
||||
static inline void write_pnet(possible_net_t *pnet, struct net *net)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
pnet->net = net;
|
||||
rcu_assign_pointer(pnet->net, net);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline struct net *read_pnet(const possible_net_t *pnet)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
return pnet->net;
|
||||
return rcu_dereference_protected(pnet->net, true);
|
||||
#else
|
||||
return &init_net;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline struct net *read_pnet_rcu(possible_net_t *pnet)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
return rcu_dereference(pnet->net);
|
||||
#else
|
||||
return &init_net;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user