Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 224147
b: refs/heads/master
c: 190683a
h: refs/heads/master
i:
  224145: 399a038
  224143: a6cedc3
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 12, 2010
1 parent baaf242 commit 1c6f726
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e85eb11782259dc39502807f3ec903a7b82b1bab
refs/heads/master: 190683a9d5457e6d962c232ffbecac3ab158dddd
11 changes: 6 additions & 5 deletions trunk/net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static const struct file_operations socket_file_ops = {
*/

static DEFINE_SPINLOCK(net_family_lock);
static const struct net_proto_family *net_families[NPROTO] __read_mostly;
static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;

/*
* Statistics counters of the socket lists
Expand Down Expand Up @@ -1200,7 +1200,7 @@ int __sock_create(struct net *net, int family, int type, int protocol,
* requested real, full-featured networking support upon configuration.
* Otherwise module support will break!
*/
if (net_families[family] == NULL)
if (rcu_access_pointer(net_families[family]) == NULL)
request_module("net-pf-%d", family);
#endif

Expand Down Expand Up @@ -2332,10 +2332,11 @@ int sock_register(const struct net_proto_family *ops)
}

spin_lock(&net_family_lock);
if (net_families[ops->family])
if (rcu_dereference_protected(net_families[ops->family],
lockdep_is_held(&net_family_lock)))
err = -EEXIST;
else {
net_families[ops->family] = ops;
rcu_assign_pointer(net_families[ops->family], ops);
err = 0;
}
spin_unlock(&net_family_lock);
Expand Down Expand Up @@ -2363,7 +2364,7 @@ void sock_unregister(int family)
BUG_ON(family < 0 || family >= NPROTO);

spin_lock(&net_family_lock);
net_families[family] = NULL;
rcu_assign_pointer(net_families[family], NULL);
spin_unlock(&net_family_lock);

synchronize_rcu();
Expand Down

0 comments on commit 1c6f726

Please sign in to comment.