aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-10 23:01:30 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-10 23:01:30 -0500
commitc5ce28df0e7c01a1de23c36ebdefcd803f2b6cbb (patch)
tree9830baf38832769e1cf621708889111bbe3c93df /drivers/net/tun.c
parent29afc4e9a408f2304e09c6dd0dbcfbd2356d0faa (diff)
parent9399f0c51489ae8c16d6559b82a452fdc1895e91 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: 1) More iov_iter conversion work from Al Viro. [ The "crypto: switch af_alg_make_sg() to iov_iter" commit was wrong, and this pull actually adds an extra commit on top of the branch I'm pulling to fix that up, so that the pre-merge state is ok. - Linus ] 2) Various optimizations to the ipv4 forwarding information base trie lookup implementation. From Alexander Duyck. 3) Remove sock_iocb altogether, from CHristoph Hellwig. 4) Allow congestion control algorithm selection via routing metrics. From Daniel Borkmann. 5) Make ipv4 uncached route list per-cpu, from Eric Dumazet. 6) Handle rfs hash collisions more gracefully, also from Eric Dumazet. 7) Add xmit_more support to r8169, e1000, and e1000e drivers. From Florian Westphal. 8) Transparent Ethernet Bridging support for GRO, from Jesse Gross. 9) Add BPF packet actions to packet scheduler, from Jiri Pirko. 10) Add support for uniqu flow IDs to openvswitch, from Joe Stringer. 11) New NetCP ethernet driver, from Muralidharan Karicheri and Wingman Kwok. 12) More sanely handle out-of-window dupacks, which can result in serious ACK storms. From Neal Cardwell. 13) Various rhashtable bug fixes and enhancements, from Herbert Xu, Patrick McHardy, and Thomas Graf. 14) Support xmit_more in be2net, from Sathya Perla. 15) Group Policy extensions for vxlan, from Thomas Graf. 16) Remove Checksum Offload support for vxlan, from Tom Herbert. 17) Like ipv4, support lockless transmit over ipv6 UDP sockets. From Vlad Yasevich. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1494+1 commits) crypto: fix af_alg_make_sg() conversion to iov_iter ipv4: Namespecify TCP PMTU mechanism i40e: Fix for stats init function call in Rx setup tcp: don't include Fast Open option in SYN-ACK on pure SYN-data openvswitch: Only set TUNNEL_VXLAN_OPT if VXLAN-GBP metadata is set ipv6: Make __ipv6_select_ident static ipv6: Fix fragment id assignment on LE arches. bridge: Fix inability to add non-vlan fdb entry net: Mellanox: Delete unnecessary checks before the function call "vunmap" cxgb4: Add support in cxgb4 to get expansion rom version via ethtool ethtool: rename reserved1 memeber in ethtool_drvinfo for expansion ROM version net: dsa: Remove redundant phy_attach() IB/mlx4: Reset flow support for IB kernel ULPs IB/mlx4: Always use the correct port for mirrored multicast attachments net/bonding: Fix potential bad memory access during bonding events tipc: remove tipc_snprintf tipc: nl compat add noop and remove legacy nl framework tipc: convert legacy nl stats show to nl compat tipc: convert legacy nl net id get to nl compat tipc: convert legacy nl net id set to nl compat ...
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 10f9e4021b5a..857dca47bf80 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -123,10 +123,9 @@ struct tap_filter {
123 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN]; 123 unsigned char addr[FLT_EXACT_COUNT][ETH_ALEN];
124}; 124};
125 125
126/* DEFAULT_MAX_NUM_RSS_QUEUES were chosen to let the rx/tx queues allocated for 126/* MAX_TAP_QUEUES 256 is chosen to allow rx/tx queues to be equal
127 * the netdevice to be fit in one page. So we can make sure the success of 127 * to max number of VCPUs in guest. */
128 * memory allocation. TODO: increase the limit. */ 128#define MAX_TAP_QUEUES 256
129#define MAX_TAP_QUEUES DEFAULT_MAX_NUM_RSS_QUEUES
130#define MAX_TAP_FLOWS 4096 129#define MAX_TAP_FLOWS 4096
131 130
132#define TUN_FLOW_EXPIRE (3 * HZ) 131#define TUN_FLOW_EXPIRE (3 * HZ)
@@ -257,7 +256,6 @@ static void tun_flow_delete(struct tun_struct *tun, struct tun_flow_entry *e)
257{ 256{
258 tun_debug(KERN_INFO, tun, "delete flow: hash %u index %u\n", 257 tun_debug(KERN_INFO, tun, "delete flow: hash %u index %u\n",
259 e->rxhash, e->queue_index); 258 e->rxhash, e->queue_index);
260 sock_rps_reset_flow_hash(e->rps_rxhash);
261 hlist_del_rcu(&e->hash_link); 259 hlist_del_rcu(&e->hash_link);
262 kfree_rcu(e, rcu); 260 kfree_rcu(e, rcu);
263 --tun->flow_count; 261 --tun->flow_count;
@@ -374,10 +372,8 @@ unlock:
374 */ 372 */
375static inline void tun_flow_save_rps_rxhash(struct tun_flow_entry *e, u32 hash) 373static inline void tun_flow_save_rps_rxhash(struct tun_flow_entry *e, u32 hash)
376{ 374{
377 if (unlikely(e->rps_rxhash != hash)) { 375 if (unlikely(e->rps_rxhash != hash))
378 sock_rps_reset_flow_hash(e->rps_rxhash);
379 e->rps_rxhash = hash; 376 e->rps_rxhash = hash;
380 }
381} 377}
382 378
383/* We try to identify a flow through its rxhash first. The reason that 379/* We try to identify a flow through its rxhash first. The reason that
@@ -1247,7 +1243,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1247 int vlan_hlen = 0; 1243 int vlan_hlen = 0;
1248 int vnet_hdr_sz = 0; 1244 int vnet_hdr_sz = 0;
1249 1245
1250 if (vlan_tx_tag_present(skb)) 1246 if (skb_vlan_tag_present(skb))
1251 vlan_hlen = VLAN_HLEN; 1247 vlan_hlen = VLAN_HLEN;
1252 1248
1253 if (tun->flags & IFF_VNET_HDR) 1249 if (tun->flags & IFF_VNET_HDR)
@@ -1326,7 +1322,7 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1326 } veth; 1322 } veth;
1327 1323
1328 veth.h_vlan_proto = skb->vlan_proto; 1324 veth.h_vlan_proto = skb->vlan_proto;
1329 veth.h_vlan_TCI = htons(vlan_tx_tag_get(skb)); 1325 veth.h_vlan_TCI = htons(skb_vlan_tag_get(skb));
1330 1326
1331 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto); 1327 vlan_offset = offsetof(struct vlan_ethhdr, h_vlan_proto);
1332 1328
@@ -1368,7 +1364,7 @@ static ssize_t tun_do_read(struct tun_struct *tun, struct tun_file *tfile,
1368 skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0, 1364 skb = __skb_recv_datagram(tfile->socket.sk, noblock ? MSG_DONTWAIT : 0,
1369 &peeked, &off, &err); 1365 &peeked, &off, &err);
1370 if (!skb) 1366 if (!skb)
1371 return 0; 1367 return err;
1372 1368
1373 ret = tun_put_user(tun, tfile, skb, to); 1369 ret = tun_put_user(tun, tfile, skb, to);
1374 if (unlikely(ret < 0)) 1370 if (unlikely(ret < 0))
@@ -1489,7 +1485,7 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
1489 goto out; 1485 goto out;
1490 } 1486 }
1491 ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT); 1487 ret = tun_do_read(tun, tfile, &m->msg_iter, flags & MSG_DONTWAIT);
1492 if (ret > total_len) { 1488 if (ret > (ssize_t)total_len) {
1493 m->msg_flags |= MSG_TRUNC; 1489 m->msg_flags |= MSG_TRUNC;
1494 ret = flags & MSG_TRUNC ? ret : total_len; 1490 ret = flags & MSG_TRUNC ? ret : total_len;
1495 } 1491 }
@@ -1554,6 +1550,17 @@ static DEVICE_ATTR(tun_flags, 0444, tun_show_flags, NULL);
1554static DEVICE_ATTR(owner, 0444, tun_show_owner, NULL); 1550static DEVICE_ATTR(owner, 0444, tun_show_owner, NULL);
1555static DEVICE_ATTR(group, 0444, tun_show_group, NULL); 1551static DEVICE_ATTR(group, 0444, tun_show_group, NULL);
1556 1552
1553static struct attribute *tun_dev_attrs[] = {
1554 &dev_attr_tun_flags.attr,
1555 &dev_attr_owner.attr,
1556 &dev_attr_group.attr,
1557 NULL
1558};
1559
1560static const struct attribute_group tun_attr_group = {
1561 .attrs = tun_dev_attrs
1562};
1563
1557static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) 1564static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1558{ 1565{
1559 struct tun_struct *tun; 1566 struct tun_struct *tun;
@@ -1634,6 +1641,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1634 dev_net_set(dev, net); 1641 dev_net_set(dev, net);
1635 dev->rtnl_link_ops = &tun_link_ops; 1642 dev->rtnl_link_ops = &tun_link_ops;
1636 dev->ifindex = tfile->ifindex; 1643 dev->ifindex = tfile->ifindex;
1644 dev->sysfs_groups[0] = &tun_attr_group;
1637 1645
1638 tun = netdev_priv(dev); 1646 tun = netdev_priv(dev);
1639 tun->dev = dev; 1647 tun->dev = dev;
@@ -1669,11 +1677,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1669 err = register_netdevice(tun->dev); 1677 err = register_netdevice(tun->dev);
1670 if (err < 0) 1678 if (err < 0)
1671 goto err_detach; 1679 goto err_detach;
1672
1673 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1674 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
1675 device_create_file(&tun->dev->dev, &dev_attr_group))
1676 pr_err("Failed to create tun sysfs files\n");
1677 } 1680 }
1678 1681
1679 netif_carrier_on(tun->dev); 1682 netif_carrier_on(tun->dev);