Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 108807
b: refs/heads/master
c: e3b9955
h: refs/heads/master
i:
  108805: 429548f
  108803: 1966608
  108799: b3dd26f
v: v3
  • Loading branch information
Mark McLoughlin authored and David S. Miller committed Aug 16, 2008
1 parent a6014e3 commit 99f11bd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 04a0551c87363f100b04d28d7a15a632b70e18e7
refs/heads/master: e3b99556975907530aeb9745e7b3945a0da48f17
39 changes: 39 additions & 0 deletions trunk/drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,36 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
return err;
}

static int tun_get_iff(struct net *net, struct file *file, struct ifreq *ifr)
{
struct tun_struct *tun = file->private_data;

if (!tun)
return -EBADFD;

DBG(KERN_INFO "%s: tun_get_iff\n", tun->dev->name);

strcpy(ifr->ifr_name, tun->dev->name);

ifr->ifr_flags = 0;

if (ifr->ifr_flags & TUN_TUN_DEV)
ifr->ifr_flags |= IFF_TUN;
else
ifr->ifr_flags |= IFF_TAP;

if (tun->flags & TUN_NO_PI)
ifr->ifr_flags |= IFF_NO_PI;

if (tun->flags & TUN_ONE_QUEUE)
ifr->ifr_flags |= IFF_ONE_QUEUE;

if (tun->flags & TUN_VNET_HDR)
ifr->ifr_flags |= IFF_VNET_HDR;

return 0;
}

/* This is like a cut-down ethtool ops, except done via tun fd so no
* privs required. */
static int set_offload(struct net_device *dev, unsigned long arg)
Expand Down Expand Up @@ -833,6 +863,15 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->dev->name, cmd);

switch (cmd) {
case TUNGETIFF:
ret = tun_get_iff(current->nsproxy->net_ns, file, &ifr);
if (ret)
return ret;

if (copy_to_user(argp, &ifr, sizeof(ifr)))
return -EFAULT;
break;

case TUNSETNOCSUM:
/* Disable/Enable checksum */
if (arg)
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/if_tun.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#define TUNGETFEATURES _IOR('T', 207, unsigned int)
#define TUNSETOFFLOAD _IOW('T', 208, unsigned int)
#define TUNSETTXFILTER _IOW('T', 209, unsigned int)
#define TUNGETIFF _IOR('T', 210, unsigned int)

/* TUNSETIFF ifr flags */
#define IFF_TUN 0x0001
Expand Down

0 comments on commit 99f11bd

Please sign in to comment.