aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-18 19:41:13 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-18 19:41:13 -0500
commit00c845dbfe2e966a2efd3818e40f46e286ca1ae6 (patch)
tree67d0f5d066b963e596126155a4da513d7b0550da /drivers/net/tun.c
parent28ee5809ff7365d935d217c387ba959b8aa7182f (diff)
parent86c8fc4bbe14b8950e62d379bb57722427ad3d67 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Pull networking fixes from David Miller: 1) Fix NBMA tunnel mac header handling in GRE, from Timo Teräs. 2) Fix a NAPI race in the fec driver, from Nimrod Andy. 3) The new IFF_VNET_LE bit is outside the size of the flags member it is stored in (which is 16-bits), store the state locally in the drivers. From Michael S Tsirkin. 4) We are kicking the tires with the new wireless maintainership situation. Bluetooth fixes via Johan Hedberg, and mac80211 fixes from Johannes Berg. 5) Fix locking and leaks in geneve driver, from Jesse Gross. 6) Make netlink TX mmap code always copy, so we don't have to be potentially exposed to the user changing the underlying contents from underneath us. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net: (63 commits) be2net: Fix incorrect setting of tunnel offload flag in netdev features bnx2x: fix typos in "configure" xen-netback: support frontends without feature-rx-notify again MAINTAINERS: changes for wireless cxgb4: Fix decoding QSA module for ethtool get settings geneve: Fix races between socket add and release. geneve: Remove socket and offload handlers at destruction. netlink: Don't reorder loads/stores before marking mmap netlink frame as available netlink: Always copy on mmap TX. Bluetooth: Fix bug with filter in service discovery optimization mac80211: free management frame keys when removing station net: Disallow providing non zero VLAN ID for NIC drivers FDB add flow net/mlx4: Cache line CQE/EQE stride fixes net: fec: Fix NAPI race xen-netfront: use napi_complete() correctly to prevent Rx stalling ip_tunnel: Add missing validation of encap type to ip_tunnel_encap_setup() ip_tunnel: Add sanity checks to ip_tunnel_encap_add_ops() net: Allow FIXED_PHY to be modular. if_tun: drop broken IFF_VNET_LE macvtap: drop broken IFF_VNET_LE ...
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a5cbf67517f0..8c8dc16839a7 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -110,9 +110,11 @@ do { \
110 * overload it to mean fasync when stored there. 110 * overload it to mean fasync when stored there.
111 */ 111 */
112#define TUN_FASYNC IFF_ATTACH_QUEUE 112#define TUN_FASYNC IFF_ATTACH_QUEUE
113/* High bits in flags field are unused. */
114#define TUN_VNET_LE 0x80000000
113 115
114#define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \ 116#define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \
115 IFF_VNET_LE | IFF_MULTI_QUEUE) 117 IFF_MULTI_QUEUE)
116#define GOODCOPY_LEN 128 118#define GOODCOPY_LEN 128
117 119
118#define FLT_EXACT_COUNT 8 120#define FLT_EXACT_COUNT 8
@@ -208,12 +210,12 @@ struct tun_struct {
208 210
209static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 val) 211static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 val)
210{ 212{
211 return __virtio16_to_cpu(tun->flags & IFF_VNET_LE, val); 213 return __virtio16_to_cpu(tun->flags & TUN_VNET_LE, val);
212} 214}
213 215
214static inline __virtio16 cpu_to_tun16(struct tun_struct *tun, u16 val) 216static inline __virtio16 cpu_to_tun16(struct tun_struct *tun, u16 val)
215{ 217{
216 return __cpu_to_virtio16(tun->flags & IFF_VNET_LE, val); 218 return __cpu_to_virtio16(tun->flags & TUN_VNET_LE, val);
217} 219}
218 220
219static inline u32 tun_hashfn(u32 rxhash) 221static inline u32 tun_hashfn(u32 rxhash)
@@ -1843,6 +1845,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
1843 int sndbuf; 1845 int sndbuf;
1844 int vnet_hdr_sz; 1846 int vnet_hdr_sz;
1845 unsigned int ifindex; 1847 unsigned int ifindex;
1848 int le;
1846 int ret; 1849 int ret;
1847 1850
1848 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) { 1851 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
@@ -2042,6 +2045,23 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
2042 tun->vnet_hdr_sz = vnet_hdr_sz; 2045 tun->vnet_hdr_sz = vnet_hdr_sz;
2043 break; 2046 break;
2044 2047
2048 case TUNGETVNETLE:
2049 le = !!(tun->flags & TUN_VNET_LE);
2050 if (put_user(le, (int __user *)argp))
2051 ret = -EFAULT;
2052 break;
2053
2054 case TUNSETVNETLE:
2055 if (get_user(le, (int __user *)argp)) {
2056 ret = -EFAULT;
2057 break;
2058 }
2059 if (le)
2060 tun->flags |= TUN_VNET_LE;
2061 else
2062 tun->flags &= ~TUN_VNET_LE;
2063 break;
2064
2045 case TUNATTACHFILTER: 2065 case TUNATTACHFILTER:
2046 /* Can be set only for TAPs */ 2066 /* Can be set only for TAPs */
2047 ret = -EINVAL; 2067 ret = -EINVAL;