Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 133880
b: refs/heads/master
c: 36b50ba
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Jan 22, 2009
1 parent 6e7624a commit 9dc54ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 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: 631ab46b79559d6fed784fd7883c0cda4d8cfcfa
refs/heads/master: 36b50bab53207daf34be63ca62fb8b0b08dc6e6b
10 changes: 6 additions & 4 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct tap_filter {

struct tun_file {
struct tun_struct *tun;
struct net *net;
};

struct tun_struct {
Expand Down Expand Up @@ -131,7 +132,6 @@ static int tun_attach(struct tun_struct *tun, struct file *file)

tfile->tun = tun;
tun->tfile = tfile;
get_net(dev_net(tun->dev));

return 0;
}
Expand All @@ -143,7 +143,6 @@ static void __tun_detach(struct tun_struct *tun)
/* Detach from net device */
tfile->tun = NULL;
tun->tfile = NULL;
put_net(dev_net(tun->dev));

/* Drop read queue */
skb_queue_purge(&tun->readq);
Expand Down Expand Up @@ -936,6 +935,7 @@ static int set_offload(struct net_device *dev, unsigned long arg)
static int tun_chr_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct tun_file *tfile = file->private_data;
struct tun_struct *tun;
void __user* argp = (void __user*)arg;
struct ifreq ifr;
Expand All @@ -954,14 +954,14 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
(unsigned int __user*)argp);
}

tun = tun_get(file);
tun = __tun_get(tfile);
if (cmd == TUNSETIFF && !tun) {
int err;

ifr.ifr_name[IFNAMSIZ-1] = '\0';

rtnl_lock();
err = tun_set_iff(current->nsproxy->net_ns, file, &ifr);
err = tun_set_iff(tfile->net, file, &ifr);
rtnl_unlock();

if (err)
Expand Down Expand Up @@ -1125,6 +1125,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
if (!tfile)
return -ENOMEM;
tfile->tun = NULL;
tfile->net = get_net(current->nsproxy->net_ns);
file->private_data = tfile;
return 0;
}
Expand All @@ -1148,6 +1149,7 @@ static int tun_chr_close(struct inode *inode, struct file *file)
rtnl_unlock();
}

put_net(tfile->net);
kfree(tfile);

return 0;
Expand Down

0 comments on commit 9dc54ee

Please sign in to comment.