Skip to content

Commit

Permalink
net_ns: add __rcu annotations
Browse files Browse the repository at this point in the history
add __rcu annotation to (struct net)->gen, and use
rcu_dereference_protected() in net_assign_generic()

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 25, 2010
1 parent 6e3f7fa commit 1c87733
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct net {
#ifdef CONFIG_WEXT_CORE
struct sk_buff_head wext_nlevents;
#endif
struct net_generic *gen;
struct net_generic __rcu *gen;

/* Note : following structs are cache line aligned */
#ifdef CONFIG_XFRM
Expand Down
4 changes: 3 additions & 1 deletion net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ static int net_assign_generic(struct net *net, int id, void *data)
BUG_ON(!mutex_is_locked(&net_mutex));
BUG_ON(id == 0);

ng = old_ng = net->gen;
old_ng = rcu_dereference_protected(net->gen,
lockdep_is_held(&net_mutex));
ng = old_ng;
if (old_ng->len >= id)
goto assign;

Expand Down

0 comments on commit 1c87733

Please sign in to comment.