Skip to content

Commit 6510a3d

Browse files
committed
net: treat possible_net_t net pointer as an RCU one and add read_pnet_rcu()
jira LE-3467 Rebuild_History Non-Buildable kernel-4.18.0-553.58.1.el8_10 commit-author Jiri Pirko <jiri@nvidia.com> commit 2034d90 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> (cherry picked from commit 2034d90) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent b93e9c7 commit 6510a3d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

include/net/net_namespace.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,21 +342,30 @@ static inline int check_net(const struct net *net)
342342

343343
typedef struct {
344344
#ifdef CONFIG_NET_NS
345-
struct net *net;
345+
struct net __rcu *net;
346346
#endif
347347
} possible_net_t;
348348

349349
static inline void write_pnet(possible_net_t *pnet, struct net *net)
350350
{
351351
#ifdef CONFIG_NET_NS
352-
pnet->net = net;
352+
rcu_assign_pointer(pnet->net, net);
353353
#endif
354354
}
355355

356356
static inline struct net *read_pnet(const possible_net_t *pnet)
357357
{
358358
#ifdef CONFIG_NET_NS
359-
return pnet->net;
359+
return rcu_dereference_protected(pnet->net, true);
360+
#else
361+
return &init_net;
362+
#endif
363+
}
364+
365+
static inline struct net *read_pnet_rcu(possible_net_t *pnet)
366+
{
367+
#ifdef CONFIG_NET_NS
368+
return rcu_dereference(pnet->net);
360369
#else
361370
return &init_net;
362371
#endif

0 commit comments

Comments
 (0)