Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 348630
b: refs/heads/master
c: b8deabd
h: refs/heads/master
v: v3
  • Loading branch information
Jason Wang authored and David S. Miller committed Jan 12, 2013
1 parent 634a000 commit 3b8b070
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 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: d07d7507bfb4e23735c9b83e397c43e1e8a173e8
refs/heads/master: b8deabd3eebaa96cf8d6e290d67b03f36c7f7a41
27 changes: 10 additions & 17 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
struct tun_struct *tun;
struct net_device *dev;

tun = rcu_dereference_protected(tfile->tun,
lockdep_rtnl_is_held());
tun = rtnl_dereference(tfile->tun);

if (tun) {
u16 index = tfile->queue_index;
BUG_ON(index >= tun->numqueues);
Expand All @@ -414,8 +414,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
rcu_assign_pointer(tun->tfiles[index],
tun->tfiles[tun->numqueues - 1]);
rcu_assign_pointer(tfile->tun, NULL);
ntfile = rcu_dereference_protected(tun->tfiles[index],
lockdep_rtnl_is_held());
ntfile = rtnl_dereference(tun->tfiles[index]);
ntfile->queue_index = index;

--tun->numqueues;
Expand Down Expand Up @@ -458,8 +457,7 @@ static void tun_detach_all(struct net_device *dev)
int i, n = tun->numqueues;

for (i = 0; i < n; i++) {
tfile = rcu_dereference_protected(tun->tfiles[i],
lockdep_rtnl_is_held());
tfile = rtnl_dereference(tun->tfiles[i]);
BUG_ON(!tfile);
wake_up_all(&tfile->wq.wait);
rcu_assign_pointer(tfile->tun, NULL);
Expand All @@ -469,8 +467,7 @@ static void tun_detach_all(struct net_device *dev)

synchronize_net();
for (i = 0; i < n; i++) {
tfile = rcu_dereference_protected(tun->tfiles[i],
lockdep_rtnl_is_held());
tfile = rtnl_dereference(tun->tfiles[i]);
/* Drop read queue */
skb_queue_purge(&tfile->sk.sk_receive_queue);
sock_put(&tfile->sk);
Expand All @@ -489,7 +486,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
int err;

err = -EINVAL;
if (rcu_dereference_protected(tfile->tun, lockdep_rtnl_is_held()))
if (rtnl_dereference(tfile->tun))
goto out;
if (tfile->detached && tun != tfile->detached)
goto out;
Expand Down Expand Up @@ -1740,8 +1737,7 @@ static void tun_detach_filter(struct tun_struct *tun, int n)
struct tun_file *tfile;

for (i = 0; i < n; i++) {
tfile = rcu_dereference_protected(tun->tfiles[i],
lockdep_rtnl_is_held());
tfile = rtnl_dereference(tun->tfiles[i]);
sk_detach_filter(tfile->socket.sk);
}

Expand All @@ -1754,8 +1750,7 @@ static int tun_attach_filter(struct tun_struct *tun)
struct tun_file *tfile;

for (i = 0; i < tun->numqueues; i++) {
tfile = rcu_dereference_protected(tun->tfiles[i],
lockdep_rtnl_is_held());
tfile = rtnl_dereference(tun->tfiles[i]);
ret = sk_attach_filter(&tun->fprog, tfile->socket.sk);
if (ret) {
tun_detach_filter(tun, i);
Expand All @@ -1773,8 +1768,7 @@ static void tun_set_sndbuf(struct tun_struct *tun)
int i;

for (i = 0; i < tun->numqueues; i++) {
tfile = rcu_dereference_protected(tun->tfiles[i],
lockdep_rtnl_is_held());
tfile = rtnl_dereference(tun->tfiles[i]);
tfile->socket.sk->sk_sndbuf = tun->sndbuf;
}
}
Expand All @@ -1794,8 +1788,7 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
else
ret = tun_attach(tun, file);
} else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
tun = rcu_dereference_protected(tfile->tun,
lockdep_rtnl_is_held());
tun = rtnl_dereference(tfile->tun);
if (!tun || !(tun->flags & TUN_TAP_MQ))
ret = -EINVAL;
else
Expand Down

0 comments on commit 3b8b070

Please sign in to comment.