aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-11-19 08:17:31 -0500
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:05:30 -0500
commit40630b82c20b7d800ea52919093cb7f0e3b03e3e (patch)
tree34e54a5388d52b48cf7110d92c76665f3b07743f
parent031f5e0338ef672e728c878129fa044e8830c31a (diff)
tun: drop most type defines
It's just as easy to use IFF_ flags directly, there's no point in adding our own defines. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/net/tun.c62
1 files changed, 28 insertions, 34 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index b4e4ca01facc..36be4fd0cd23 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -109,12 +109,6 @@ do { \
109 * overload it to mean fasync when stored there. 109 * overload it to mean fasync when stored there.
110 */ 110 */
111#define TUN_FASYNC IFF_ATTACH_QUEUE 111#define TUN_FASYNC IFF_ATTACH_QUEUE
112#define TUN_NO_PI IFF_NO_PI
113/* This flag has no real effect */
114#define TUN_ONE_QUEUE IFF_ONE_QUEUE
115#define TUN_PERSIST IFF_PERSIST
116#define TUN_VNET_HDR IFF_VNET_HDR
117#define TUN_TAP_MQ IFF_MULTI_QUEUE
118 112
119#define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \ 113#define TUN_FEATURES (IFF_NO_PI | IFF_ONE_QUEUE | IFF_VNET_HDR | \
120 IFF_MULTI_QUEUE) 114 IFF_MULTI_QUEUE)
@@ -487,7 +481,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
487 if (tun && tun->numqueues == 0 && tun->numdisabled == 0) { 481 if (tun && tun->numqueues == 0 && tun->numdisabled == 0) {
488 netif_carrier_off(tun->dev); 482 netif_carrier_off(tun->dev);
489 483
490 if (!(tun->flags & TUN_PERSIST) && 484 if (!(tun->flags & IFF_PERSIST) &&
491 tun->dev->reg_state == NETREG_REGISTERED) 485 tun->dev->reg_state == NETREG_REGISTERED)
492 unregister_netdevice(tun->dev); 486 unregister_netdevice(tun->dev);
493 } 487 }
@@ -538,7 +532,7 @@ static void tun_detach_all(struct net_device *dev)
538 } 532 }
539 BUG_ON(tun->numdisabled != 0); 533 BUG_ON(tun->numdisabled != 0);
540 534
541 if (tun->flags & TUN_PERSIST) 535 if (tun->flags & IFF_PERSIST)
542 module_put(THIS_MODULE); 536 module_put(THIS_MODULE);
543} 537}
544 538
@@ -556,7 +550,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file, bool skip_filte
556 goto out; 550 goto out;
557 551
558 err = -EBUSY; 552 err = -EBUSY;
559 if (!(tun->flags & TUN_TAP_MQ) && tun->numqueues == 1) 553 if (!(tun->flags & IFF_MULTI_QUEUE) && tun->numqueues == 1)
560 goto out; 554 goto out;
561 555
562 err = -E2BIG; 556 err = -E2BIG;
@@ -935,7 +929,7 @@ static void tun_net_init(struct net_device *dev)
935 struct tun_struct *tun = netdev_priv(dev); 929 struct tun_struct *tun = netdev_priv(dev);
936 930
937 switch (tun->flags & TUN_TYPE_MASK) { 931 switch (tun->flags & TUN_TYPE_MASK) {
938 case TUN_TUN_DEV: 932 case IFF_TUN:
939 dev->netdev_ops = &tun_netdev_ops; 933 dev->netdev_ops = &tun_netdev_ops;
940 934
941 /* Point-to-Point TUN Device */ 935 /* Point-to-Point TUN Device */
@@ -949,7 +943,7 @@ static void tun_net_init(struct net_device *dev)
949 dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */ 943 dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */
950 break; 944 break;
951 945
952 case TUN_TAP_DEV: 946 case IFF_TAP:
953 dev->netdev_ops = &tap_netdev_ops; 947 dev->netdev_ops = &tap_netdev_ops;
954 /* Ethernet TAP Device */ 948 /* Ethernet TAP Device */
955 ether_setup(dev); 949 ether_setup(dev);
@@ -1040,7 +1034,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1040 int err; 1034 int err;
1041 u32 rxhash; 1035 u32 rxhash;
1042 1036
1043 if (!(tun->flags & TUN_NO_PI)) { 1037 if (!(tun->flags & IFF_NO_PI)) {
1044 if (len < sizeof(pi)) 1038 if (len < sizeof(pi))
1045 return -EINVAL; 1039 return -EINVAL;
1046 len -= sizeof(pi); 1040 len -= sizeof(pi);
@@ -1050,7 +1044,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1050 offset += sizeof(pi); 1044 offset += sizeof(pi);
1051 } 1045 }
1052 1046
1053 if (tun->flags & TUN_VNET_HDR) { 1047 if (tun->flags & IFF_VNET_HDR) {
1054 if (len < tun->vnet_hdr_sz) 1048 if (len < tun->vnet_hdr_sz)
1055 return -EINVAL; 1049 return -EINVAL;
1056 len -= tun->vnet_hdr_sz; 1050 len -= tun->vnet_hdr_sz;
@@ -1067,7 +1061,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1067 offset += tun->vnet_hdr_sz; 1061 offset += tun->vnet_hdr_sz;
1068 } 1062 }
1069 1063
1070 if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) { 1064 if ((tun->flags & TUN_TYPE_MASK) == IFF_TAP) {
1071 align += NET_IP_ALIGN; 1065 align += NET_IP_ALIGN;
1072 if (unlikely(len < ETH_HLEN || 1066 if (unlikely(len < ETH_HLEN ||
1073 (gso.hdr_len && gso.hdr_len < ETH_HLEN))) 1067 (gso.hdr_len && gso.hdr_len < ETH_HLEN)))
@@ -1130,8 +1124,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1130 } 1124 }
1131 1125
1132 switch (tun->flags & TUN_TYPE_MASK) { 1126 switch (tun->flags & TUN_TYPE_MASK) {
1133 case TUN_TUN_DEV: 1127 case IFF_TUN:
1134 if (tun->flags & TUN_NO_PI) { 1128 if (tun->flags & IFF_NO_PI) {
1135 switch (skb->data[0] & 0xf0) { 1129 switch (skb->data[0] & 0xf0) {
1136 case 0x40: 1130 case 0x40:
1137 pi.proto = htons(ETH_P_IP); 1131 pi.proto = htons(ETH_P_IP);
@@ -1150,7 +1144,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1150 skb->protocol = pi.proto; 1144 skb->protocol = pi.proto;
1151 skb->dev = tun->dev; 1145 skb->dev = tun->dev;
1152 break; 1146 break;
1153 case TUN_TAP_DEV: 1147 case IFF_TAP:
1154 skb->protocol = eth_type_trans(skb, tun->dev); 1148 skb->protocol = eth_type_trans(skb, tun->dev);
1155 break; 1149 break;
1156 } 1150 }
@@ -1256,10 +1250,10 @@ static ssize_t tun_put_user(struct tun_struct *tun,
1256 if (vlan_tx_tag_present(skb)) 1250 if (vlan_tx_tag_present(skb))
1257 vlan_hlen = VLAN_HLEN; 1251 vlan_hlen = VLAN_HLEN;
1258 1252
1259 if (tun->flags & TUN_VNET_HDR) 1253 if (tun->flags & IFF_VNET_HDR)
1260 vnet_hdr_sz = tun->vnet_hdr_sz; 1254 vnet_hdr_sz = tun->vnet_hdr_sz;
1261 1255
1262 if (!(tun->flags & TUN_NO_PI)) { 1256 if (!(tun->flags & IFF_NO_PI)) {
1263 if ((len -= sizeof(pi)) < 0) 1257 if ((len -= sizeof(pi)) < 0)
1264 return -EINVAL; 1258 return -EINVAL;
1265 1259
@@ -1592,7 +1586,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1592 return -EINVAL; 1586 return -EINVAL;
1593 1587
1594 if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) != 1588 if (!!(ifr->ifr_flags & IFF_MULTI_QUEUE) !=
1595 !!(tun->flags & TUN_TAP_MQ)) 1589 !!(tun->flags & IFF_MULTI_QUEUE))
1596 return -EINVAL; 1590 return -EINVAL;
1597 1591
1598 if (tun_not_capable(tun)) 1592 if (tun_not_capable(tun))
@@ -1605,7 +1599,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1605 if (err < 0) 1599 if (err < 0)
1606 return err; 1600 return err;
1607 1601
1608 if (tun->flags & TUN_TAP_MQ && 1602 if (tun->flags & IFF_MULTI_QUEUE &&
1609 (tun->numqueues + tun->numdisabled > 1)) { 1603 (tun->numqueues + tun->numdisabled > 1)) {
1610 /* One or more queue has already been attached, no need 1604 /* One or more queue has already been attached, no need
1611 * to initialize the device again. 1605 * to initialize the device again.
@@ -1628,11 +1622,11 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1628 /* Set dev type */ 1622 /* Set dev type */
1629 if (ifr->ifr_flags & IFF_TUN) { 1623 if (ifr->ifr_flags & IFF_TUN) {
1630 /* TUN device */ 1624 /* TUN device */
1631 flags |= TUN_TUN_DEV; 1625 flags |= IFF_TUN;
1632 name = "tun%d"; 1626 name = "tun%d";
1633 } else if (ifr->ifr_flags & IFF_TAP) { 1627 } else if (ifr->ifr_flags & IFF_TAP) {
1634 /* TAP device */ 1628 /* TAP device */
1635 flags |= TUN_TAP_DEV; 1629 flags |= IFF_TAP;
1636 name = "tap%d"; 1630 name = "tap%d";
1637 } else 1631 } else
1638 return -EINVAL; 1632 return -EINVAL;
@@ -1825,7 +1819,7 @@ static int tun_set_queue(struct file *file, struct ifreq *ifr)
1825 ret = tun_attach(tun, file, false); 1819 ret = tun_attach(tun, file, false);
1826 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) { 1820 } else if (ifr->ifr_flags & IFF_DETACH_QUEUE) {
1827 tun = rtnl_dereference(tfile->tun); 1821 tun = rtnl_dereference(tfile->tun);
1828 if (!tun || !(tun->flags & TUN_TAP_MQ) || tfile->detached) 1822 if (!tun || !(tun->flags & IFF_MULTI_QUEUE) || tfile->detached)
1829 ret = -EINVAL; 1823 ret = -EINVAL;
1830 else 1824 else
1831 __tun_detach(tfile, false); 1825 __tun_detach(tfile, false);
@@ -1929,12 +1923,12 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
1929 /* Disable/Enable persist mode. Keep an extra reference to the 1923 /* Disable/Enable persist mode. Keep an extra reference to the
1930 * module to prevent the module being unprobed. 1924 * module to prevent the module being unprobed.
1931 */ 1925 */
1932 if (arg && !(tun->flags & TUN_PERSIST)) { 1926 if (arg && !(tun->flags & IFF_PERSIST)) {
1933 tun->flags |= TUN_PERSIST; 1927 tun->flags |= IFF_PERSIST;
1934 __module_get(THIS_MODULE); 1928 __module_get(THIS_MODULE);
1935 } 1929 }
1936 if (!arg && (tun->flags & TUN_PERSIST)) { 1930 if (!arg && (tun->flags & IFF_PERSIST)) {
1937 tun->flags &= ~TUN_PERSIST; 1931 tun->flags &= ~IFF_PERSIST;
1938 module_put(THIS_MODULE); 1932 module_put(THIS_MODULE);
1939 } 1933 }
1940 1934
@@ -1992,7 +1986,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
1992 case TUNSETTXFILTER: 1986 case TUNSETTXFILTER:
1993 /* Can be set only for TAPs */ 1987 /* Can be set only for TAPs */
1994 ret = -EINVAL; 1988 ret = -EINVAL;
1995 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) 1989 if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP)
1996 break; 1990 break;
1997 ret = update_filter(&tun->txflt, (void __user *)arg); 1991 ret = update_filter(&tun->txflt, (void __user *)arg);
1998 break; 1992 break;
@@ -2051,7 +2045,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
2051 case TUNATTACHFILTER: 2045 case TUNATTACHFILTER:
2052 /* Can be set only for TAPs */ 2046 /* Can be set only for TAPs */
2053 ret = -EINVAL; 2047 ret = -EINVAL;
2054 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) 2048 if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP)
2055 break; 2049 break;
2056 ret = -EFAULT; 2050 ret = -EFAULT;
2057 if (copy_from_user(&tun->fprog, argp, sizeof(tun->fprog))) 2051 if (copy_from_user(&tun->fprog, argp, sizeof(tun->fprog)))
@@ -2063,7 +2057,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
2063 case TUNDETACHFILTER: 2057 case TUNDETACHFILTER:
2064 /* Can be set only for TAPs */ 2058 /* Can be set only for TAPs */
2065 ret = -EINVAL; 2059 ret = -EINVAL;
2066 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) 2060 if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP)
2067 break; 2061 break;
2068 ret = 0; 2062 ret = 0;
2069 tun_detach_filter(tun, tun->numqueues); 2063 tun_detach_filter(tun, tun->numqueues);
@@ -2071,7 +2065,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
2071 2065
2072 case TUNGETFILTER: 2066 case TUNGETFILTER:
2073 ret = -EINVAL; 2067 ret = -EINVAL;
2074 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) 2068 if ((tun->flags & TUN_TYPE_MASK) != IFF_TAP)
2075 break; 2069 break;
2076 ret = -EFAULT; 2070 ret = -EFAULT;
2077 if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog))) 2071 if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog)))
@@ -2264,10 +2258,10 @@ static void tun_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
2264 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 2258 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
2265 2259
2266 switch (tun->flags & TUN_TYPE_MASK) { 2260 switch (tun->flags & TUN_TYPE_MASK) {
2267 case TUN_TUN_DEV: 2261 case IFF_TUN:
2268 strlcpy(info->bus_info, "tun", sizeof(info->bus_info)); 2262 strlcpy(info->bus_info, "tun", sizeof(info->bus_info));
2269 break; 2263 break;
2270 case TUN_TAP_DEV: 2264 case IFF_TAP:
2271 strlcpy(info->bus_info, "tap", sizeof(info->bus_info)); 2265 strlcpy(info->bus_info, "tap", sizeof(info->bus_info));
2272 break; 2266 break;
2273 } 2267 }