tun.c (debc6a6927dcd833a30750b07a4c2b456b71f1be) tun.c (e36aa25a533962b08402530e8443ac804a454e27)
1/*
2 * TUN - Universal TUN/TAP device driver.
3 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 384 unchanged lines hidden (view full) ---

393 /* Enqueue packet */
394 skb_queue_tail(&tun->readq, skb);
395 dev->trans_start = jiffies;
396
397 /* Notify and wake up reader process */
398 if (tun->flags & TUN_FASYNC)
399 kill_fasync(&tun->fasync, SIGIO, POLL_IN);
400 wake_up_interruptible(&tun->socket.wait);
1/*
2 * TUN - Universal TUN/TAP device driver.
3 * Copyright (C) 1999-2002 Maxim Krasnyansky <maxk@qualcomm.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.

--- 384 unchanged lines hidden (view full) ---

393 /* Enqueue packet */
394 skb_queue_tail(&tun->readq, skb);
395 dev->trans_start = jiffies;
396
397 /* Notify and wake up reader process */
398 if (tun->flags & TUN_FASYNC)
399 kill_fasync(&tun->fasync, SIGIO, POLL_IN);
400 wake_up_interruptible(&tun->socket.wait);
401 return 0;
401 return NETDEV_TX_OK;
402
403drop:
404 dev->stats.tx_dropped++;
405 kfree_skb(skb);
402
403drop:
404 dev->stats.tx_dropped++;
405 kfree_skb(skb);
406 return 0;
406 return NETDEV_TX_OK;
407}
408
409static void tun_net_mclist(struct net_device *dev)
410{
411 /*
412 * This callback is supposed to deal with mc filter in
413 * _rx_ path and has nothing to do with the _tx_ path.
414 * In rx path we always accept everything userspace gives us.

--- 221 unchanged lines hidden (view full) ---

636 pr_debug("GSO!\n");
637 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
638 case VIRTIO_NET_HDR_GSO_TCPV4:
639 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
640 break;
641 case VIRTIO_NET_HDR_GSO_TCPV6:
642 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
643 break;
407}
408
409static void tun_net_mclist(struct net_device *dev)
410{
411 /*
412 * This callback is supposed to deal with mc filter in
413 * _rx_ path and has nothing to do with the _tx_ path.
414 * In rx path we always accept everything userspace gives us.

--- 221 unchanged lines hidden (view full) ---

636 pr_debug("GSO!\n");
637 switch (gso.gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
638 case VIRTIO_NET_HDR_GSO_TCPV4:
639 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
640 break;
641 case VIRTIO_NET_HDR_GSO_TCPV6:
642 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
643 break;
644 case VIRTIO_NET_HDR_GSO_UDP:
645 skb_shinfo(skb)->gso_type = SKB_GSO_UDP;
646 break;
644 default:
645 tun->dev->stats.rx_frame_errors++;
646 kfree_skb(skb);
647 return -EINVAL;
648 }
649
650 if (gso.gso_type & VIRTIO_NET_HDR_GSO_ECN)
651 skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;

--- 69 unchanged lines hidden (view full) ---

721
722 /* This is a hint as to how much should be linear. */
723 gso.hdr_len = skb_headlen(skb);
724 gso.gso_size = sinfo->gso_size;
725 if (sinfo->gso_type & SKB_GSO_TCPV4)
726 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
727 else if (sinfo->gso_type & SKB_GSO_TCPV6)
728 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
647 default:
648 tun->dev->stats.rx_frame_errors++;
649 kfree_skb(skb);
650 return -EINVAL;
651 }
652
653 if (gso.gso_type & VIRTIO_NET_HDR_GSO_ECN)
654 skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;

--- 69 unchanged lines hidden (view full) ---

724
725 /* This is a hint as to how much should be linear. */
726 gso.hdr_len = skb_headlen(skb);
727 gso.gso_size = sinfo->gso_size;
728 if (sinfo->gso_type & SKB_GSO_TCPV4)
729 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
730 else if (sinfo->gso_type & SKB_GSO_TCPV6)
731 gso.gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
732 else if (sinfo->gso_type & SKB_GSO_UDP)
733 gso.gso_type = VIRTIO_NET_HDR_GSO_UDP;
729 else
730 BUG();
731 if (sinfo->gso_type & SKB_GSO_TCP_ECN)
732 gso.gso_type |= VIRTIO_NET_HDR_GSO_ECN;
733 } else
734 gso.gso_type = VIRTIO_NET_HDR_GSO_NONE;
735
736 if (skb->ip_summed == CHECKSUM_PARTIAL) {

--- 255 unchanged lines hidden (view full) ---

992 tun_net_init(dev);
993
994 if (strchr(dev->name, '%')) {
995 err = dev_alloc_name(dev, dev->name);
996 if (err < 0)
997 goto err_free_sk;
998 }
999
734 else
735 BUG();
736 if (sinfo->gso_type & SKB_GSO_TCP_ECN)
737 gso.gso_type |= VIRTIO_NET_HDR_GSO_ECN;
738 } else
739 gso.gso_type = VIRTIO_NET_HDR_GSO_NONE;
740
741 if (skb->ip_summed == CHECKSUM_PARTIAL) {

--- 255 unchanged lines hidden (view full) ---

997 tun_net_init(dev);
998
999 if (strchr(dev->name, '%')) {
1000 err = dev_alloc_name(dev, dev->name);
1001 if (err < 0)
1002 goto err_free_sk;
1003 }
1004
1000 err = -EINVAL;
1001 err = register_netdevice(tun->dev);
1002 if (err < 0)
1003 goto err_free_sk;
1004
1005 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1006 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
1007 device_create_file(&tun->dev->dev, &dev_attr_group))
1008 printk(KERN_ERR "Failed to create tun sysfs files\n");

--- 60 unchanged lines hidden (view full) ---

1069 * privs required. */
1070static int set_offload(struct net_device *dev, unsigned long arg)
1071{
1072 unsigned int old_features, features;
1073
1074 old_features = dev->features;
1075 /* Unset features, set them as we chew on the arg. */
1076 features = (old_features & ~(NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST
1005 err = register_netdevice(tun->dev);
1006 if (err < 0)
1007 goto err_free_sk;
1008
1009 if (device_create_file(&tun->dev->dev, &dev_attr_tun_flags) ||
1010 device_create_file(&tun->dev->dev, &dev_attr_owner) ||
1011 device_create_file(&tun->dev->dev, &dev_attr_group))
1012 printk(KERN_ERR "Failed to create tun sysfs files\n");

--- 60 unchanged lines hidden (view full) ---

1073 * privs required. */
1074static int set_offload(struct net_device *dev, unsigned long arg)
1075{
1076 unsigned int old_features, features;
1077
1078 old_features = dev->features;
1079 /* Unset features, set them as we chew on the arg. */
1080 features = (old_features & ~(NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST
1077 |NETIF_F_TSO_ECN|NETIF_F_TSO|NETIF_F_TSO6));
1081 |NETIF_F_TSO_ECN|NETIF_F_TSO|NETIF_F_TSO6
1082 |NETIF_F_UFO));
1078
1079 if (arg & TUN_F_CSUM) {
1080 features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1081 arg &= ~TUN_F_CSUM;
1082
1083 if (arg & (TUN_F_TSO4|TUN_F_TSO6)) {
1084 if (arg & TUN_F_TSO_ECN) {
1085 features |= NETIF_F_TSO_ECN;
1086 arg &= ~TUN_F_TSO_ECN;
1087 }
1088 if (arg & TUN_F_TSO4)
1089 features |= NETIF_F_TSO;
1090 if (arg & TUN_F_TSO6)
1091 features |= NETIF_F_TSO6;
1092 arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
1093 }
1083
1084 if (arg & TUN_F_CSUM) {
1085 features |= NETIF_F_HW_CSUM|NETIF_F_SG|NETIF_F_FRAGLIST;
1086 arg &= ~TUN_F_CSUM;
1087
1088 if (arg & (TUN_F_TSO4|TUN_F_TSO6)) {
1089 if (arg & TUN_F_TSO_ECN) {
1090 features |= NETIF_F_TSO_ECN;
1091 arg &= ~TUN_F_TSO_ECN;
1092 }
1093 if (arg & TUN_F_TSO4)
1094 features |= NETIF_F_TSO;
1095 if (arg & TUN_F_TSO6)
1096 features |= NETIF_F_TSO6;
1097 arg &= ~(TUN_F_TSO4|TUN_F_TSO6);
1098 }
1099
1100 if (arg & TUN_F_UFO) {
1101 features |= NETIF_F_UFO;
1102 arg &= ~TUN_F_UFO;
1103 }
1094 }
1095
1096 /* This gives the user a way to test for new features in future by
1097 * trying to set them. */
1098 if (arg)
1099 return -EINVAL;
1100
1101 dev->features = features;

--- 398 unchanged lines hidden ---
1104 }
1105
1106 /* This gives the user a way to test for new features in future by
1107 * trying to set them. */
1108 if (arg)
1109 return -EINVAL;
1110
1111 dev->features = features;

--- 398 unchanged lines hidden ---