Commit 9a393b5d authored by Sainath Grandhi's avatar Sainath Grandhi Committed by David S. Miller

tap: tap as an independent module

This patch makes tap a separate module for other types of virtual interfaces, for example,
ipvlan to use.
Signed-off-by: default avatarSainath Grandhi <sainath.grandhi@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9f1f61c
...@@ -135,6 +135,7 @@ config MACVTAP ...@@ -135,6 +135,7 @@ config MACVTAP
tristate "MAC-VLAN based tap driver" tristate "MAC-VLAN based tap driver"
depends on MACVLAN depends on MACVLAN
depends on INET depends on INET
select TAP
help help
This adds a specialized tap character device driver that is based This adds a specialized tap character device driver that is based
on the MAC-VLAN network interface, called macvtap. A macvtap device on the MAC-VLAN network interface, called macvtap. A macvtap device
...@@ -287,6 +288,12 @@ config TUN ...@@ -287,6 +288,12 @@ config TUN
If you don't know what to use this for, you don't need it. If you don't know what to use this for, you don't need it.
config TAP
tristate
---help---
This option is selected by any driver implementing tap user space
interface for a virtual interface to re-use core tap functionality.
config TUN_VNET_CROSS_LE config TUN_VNET_CROSS_LE
bool "Support for cross-endian vnet headers on little-endian kernels" bool "Support for cross-endian vnet headers on little-endian kernels"
default n default n
......
...@@ -21,6 +21,7 @@ obj-$(CONFIG_PHYLIB) += phy/ ...@@ -21,6 +21,7 @@ obj-$(CONFIG_PHYLIB) += phy/
obj-$(CONFIG_RIONET) += rionet.o obj-$(CONFIG_RIONET) += rionet.o
obj-$(CONFIG_NET_TEAM) += team/ obj-$(CONFIG_NET_TEAM) += team/
obj-$(CONFIG_TUN) += tun.o obj-$(CONFIG_TUN) += tun.o
obj-$(CONFIG_TAP) += tap.o
obj-$(CONFIG_VETH) += veth.o obj-$(CONFIG_VETH) += veth.o
obj-$(CONFIG_VIRTIO_NET) += virtio_net.o obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
obj-$(CONFIG_VXLAN) += vxlan.o obj-$(CONFIG_VXLAN) += vxlan.o
...@@ -29,8 +30,6 @@ obj-$(CONFIG_GTP) += gtp.o ...@@ -29,8 +30,6 @@ obj-$(CONFIG_GTP) += gtp.o
obj-$(CONFIG_NLMON) += nlmon.o obj-$(CONFIG_NLMON) += nlmon.o
obj-$(CONFIG_NET_VRF) += vrf.o obj-$(CONFIG_NET_VRF) += vrf.o
macvtap-objs := macvtap_main.o tap.o
# #
# Networking Drivers # Networking Drivers
# #
......
...@@ -312,6 +312,7 @@ void tap_del_queues(struct tap_dev *tap) ...@@ -312,6 +312,7 @@ void tap_del_queues(struct tap_dev *tap)
/* guarantee that any future tap_set_queue will fail */ /* guarantee that any future tap_set_queue will fail */
tap->numvtaps = MAX_TAP_QUEUES; tap->numvtaps = MAX_TAP_QUEUES;
} }
EXPORT_SYMBOL_GPL(tap_del_queues);
rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
{ {
...@@ -389,6 +390,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb) ...@@ -389,6 +390,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
kfree_skb(skb); kfree_skb(skb);
return RX_HANDLER_CONSUMED; return RX_HANDLER_CONSUMED;
} }
EXPORT_SYMBOL_GPL(tap_handle_frame);
static struct major_info *tap_get_major(int major) static struct major_info *tap_get_major(int major)
{ {
...@@ -428,6 +430,7 @@ int tap_get_minor(dev_t major, struct tap_dev *tap) ...@@ -428,6 +430,7 @@ int tap_get_minor(dev_t major, struct tap_dev *tap)
rcu_read_unlock(); rcu_read_unlock();
return retval < 0 ? retval : 0; return retval < 0 ? retval : 0;
} }
EXPORT_SYMBOL_GPL(tap_get_minor);
void tap_free_minor(dev_t major, struct tap_dev *tap) void tap_free_minor(dev_t major, struct tap_dev *tap)
{ {
...@@ -449,6 +452,7 @@ void tap_free_minor(dev_t major, struct tap_dev *tap) ...@@ -449,6 +452,7 @@ void tap_free_minor(dev_t major, struct tap_dev *tap)
unlock: unlock:
rcu_read_unlock(); rcu_read_unlock();
} }
EXPORT_SYMBOL_GPL(tap_free_minor);
static struct tap_dev *dev_get_by_tap_file(int major, int minor) static struct tap_dev *dev_get_by_tap_file(int major, int minor)
{ {
...@@ -1210,6 +1214,7 @@ int tap_queue_resize(struct tap_dev *tap) ...@@ -1210,6 +1214,7 @@ int tap_queue_resize(struct tap_dev *tap)
kfree(arrays); kfree(arrays);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(tap_queue_resize);
static int tap_list_add(dev_t major, const char *device_name) static int tap_list_add(dev_t major, const char *device_name)
{ {
...@@ -1257,6 +1262,7 @@ int tap_create_cdev(struct cdev *tap_cdev, ...@@ -1257,6 +1262,7 @@ int tap_create_cdev(struct cdev *tap_cdev,
out1: out1:
return err; return err;
} }
EXPORT_SYMBOL_GPL(tap_create_cdev);
void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev) void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
{ {
...@@ -1272,3 +1278,8 @@ void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev) ...@@ -1272,3 +1278,8 @@ void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
} }
} }
} }
EXPORT_SYMBOL_GPL(tap_destroy_cdev);
MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
MODULE_AUTHOR("Sainath Grandhi <sainath.grandhi@intel.com>");
MODULE_LICENSE("GPL");
config VHOST_NET config VHOST_NET
tristate "Host kernel accelerator for virtio net" tristate "Host kernel accelerator for virtio net"
depends on NET && EVENTFD && (TUN || !TUN) && (MACVTAP || !MACVTAP) depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
select VHOST select VHOST
---help--- ---help---
This kernel module can be loaded in host kernel to accelerate This kernel module can be loaded in host kernel to accelerate
......
#ifndef _LINUX_IF_TAP_H_ #ifndef _LINUX_IF_TAP_H_
#define _LINUX_IF_TAP_H_ #define _LINUX_IF_TAP_H_
#if IS_ENABLED(CONFIG_MACVTAP) #if IS_ENABLED(CONFIG_TAP)
struct socket *tap_get_socket(struct file *); struct socket *tap_get_socket(struct file *);
#else #else
#include <linux/err.h> #include <linux/err.h>
...@@ -12,7 +12,7 @@ static inline struct socket *tap_get_socket(struct file *f) ...@@ -12,7 +12,7 @@ static inline struct socket *tap_get_socket(struct file *f)
{ {
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
#endif /* CONFIG_MACVTAP */ #endif /* CONFIG_TAP */
#include <net/sock.h> #include <net/sock.h>
#include <linux/skb_array.h> #include <linux/skb_array.h>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment