Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327592
b: refs/heads/master
c: 0fa7fa9
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Aug 23, 2012
1 parent 8e2f354 commit be97b83
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 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: b32607dd47d456b99f0a16f1c37bc8a0975ffb19
refs/heads/master: 0fa7fa98dbcc2789409ed24e885485e645803d7f
2 changes: 1 addition & 1 deletion trunk/include/net/netns/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <linux/spinlock.h>

struct netns_packet {
spinlock_t sklist_lock;
struct mutex sklist_lock;
struct hlist_head sklist;
};

Expand Down
16 changes: 11 additions & 5 deletions trunk/net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2317,10 +2317,13 @@ static int packet_release(struct socket *sock)
net = sock_net(sk);
po = pkt_sk(sk);

spin_lock_bh(&net->packet.sklist_lock);
mutex_lock(&net->packet.sklist_lock);
sk_del_node_init_rcu(sk);
mutex_unlock(&net->packet.sklist_lock);

preempt_disable();
sock_prot_inuse_add(net, sk->sk_prot, -1);
spin_unlock_bh(&net->packet.sklist_lock);
preempt_enable();

spin_lock(&po->bind_lock);
unregister_prot_hook(sk, false);
Expand Down Expand Up @@ -2519,10 +2522,13 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
register_prot_hook(sk);
}

spin_lock_bh(&net->packet.sklist_lock);
mutex_lock(&net->packet.sklist_lock);
sk_add_node_rcu(sk, &net->packet.sklist);
mutex_unlock(&net->packet.sklist_lock);

preempt_disable();
sock_prot_inuse_add(net, &packet_proto, 1);
spin_unlock_bh(&net->packet.sklist_lock);
preempt_enable();

return 0;
out:
Expand Down Expand Up @@ -3775,7 +3781,7 @@ static const struct file_operations packet_seq_fops = {

static int __net_init packet_net_init(struct net *net)
{
spin_lock_init(&net->packet.sklist_lock);
mutex_init(&net->packet.sklist_lock);
INIT_HLIST_HEAD(&net->packet.sklist);

if (!proc_net_fops_create(net, "packet", 0, &packet_seq_fops))
Expand Down
6 changes: 3 additions & 3 deletions trunk/net/packet/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
net = sock_net(skb->sk);
req = nlmsg_data(cb->nlh);

rcu_read_lock();
sk_for_each_rcu(sk, node, &net->packet.sklist) {
mutex_lock(&net->packet.sklist_lock);
sk_for_each(sk, node, &net->packet.sklist) {
if (!net_eq(sock_net(sk), net))
continue;
if (num < s_num)
Expand All @@ -192,7 +192,7 @@ static int packet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
num++;
}
done:
rcu_read_unlock();
mutex_unlock(&net->packet.sklist_lock);
cb->args[0] = num;

return skb->len;
Expand Down

0 comments on commit be97b83

Please sign in to comment.