From: Sainath Grandhi <sainath.grandhi@intel.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, mahesh@bandewar.net,
linux-kernel@vger.kernel.org, sainath.grandhi@intel.com
Subject: [PATCHv2 6/7] TAP: tap as an independent module
Date: Tue, 17 Jan 2017 16:03:05 -0800 [thread overview]
Message-ID: <1484697786-50323-7-git-send-email-sainath.grandhi@intel.com> (raw)
In-Reply-To: <1484697786-50323-1-git-send-email-sainath.grandhi@intel.com>
This patch makes tap a separate module for other types of virtual interfaces, for example,
ipvlan to use.
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
---
drivers/net/Kconfig | 15 +++++++++++++++
drivers/net/Makefile | 3 +--
drivers/net/{macvtap_main.c => macvtap.c} | 1 -
drivers/net/tap.c | 11 +++++++++++
drivers/vhost/Kconfig | 2 +-
include/linux/if_tap.h | 4 ++--
6 files changed, 30 insertions(+), 6 deletions(-)
rename drivers/net/{macvtap_main.c => macvtap.c} (99%)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 95c32f2..1c88437 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -135,6 +135,7 @@ config MACVTAP
tristate "MAC-VLAN based tap driver"
depends on MACVLAN
depends on INET
+ depends on TAP
help
This adds a specialized tap character device driver that is based
on the MAC-VLAN network interface, called macvtap. A macvtap device
@@ -284,6 +285,20 @@ config TUN
If you don't know what to use this for, you don't need it.
+config TAP
+ tristate "TAP module support for virtual interfaces"
+ ---help---
+ TAP module serves two purposes. This can be used as library of functions
+ for virtual interfaces to implement tap functionality.
+
+ This module also includes character device file and socket operations
+ that can be used by virtual interface implementing tap.
+
+ To compile this driver as a module, choose M here: the module
+ will be called tap.
+
+ If you don't know what to use this for, you don't need it.
+
config TUN_VNET_CROSS_LE
bool "Support for cross-endian vnet headers on little-endian kernels"
default n
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 19b03a9..7dd86ca 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_PHYLIB) += phy/
obj-$(CONFIG_RIONET) += rionet.o
obj-$(CONFIG_NET_TEAM) += team/
obj-$(CONFIG_TUN) += tun.o
+obj-$(CONFIG_TAP) += tap.o
obj-$(CONFIG_VETH) += veth.o
obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
obj-$(CONFIG_VXLAN) += vxlan.o
@@ -29,8 +30,6 @@ obj-$(CONFIG_GTP) += gtp.o
obj-$(CONFIG_NLMON) += nlmon.o
obj-$(CONFIG_NET_VRF) += vrf.o
-macvtap-objs := macvtap_main.o tap.o
-
#
# Networking Drivers
#
diff --git a/drivers/net/macvtap_main.c b/drivers/net/macvtap.c
similarity index 99%
rename from drivers/net/macvtap_main.c
rename to drivers/net/macvtap.c
index 3f047b4..3efed94 100644
--- a/drivers/net/macvtap_main.c
+++ b/drivers/net/macvtap.c
@@ -232,7 +232,6 @@ static int macvtap_init(void)
}
module_init(macvtap_init);
-extern struct idr minor_idr;
static void macvtap_exit(void)
{
rtnl_link_unregister(&macvtap_link_ops);
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 7f38dbe..32066dd 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -311,6 +311,7 @@ void tap_del_queues(struct tap_dev *tap)
/* guarantee that any future tap_set_queue will fail */
tap->numvtaps = MAX_TAP_QUEUES;
}
+EXPORT_SYMBOL_GPL(tap_del_queues);
rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
{
@@ -388,6 +389,7 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
kfree_skb(skb);
return RX_HANDLER_CONSUMED;
}
+EXPORT_SYMBOL_GPL(tap_handle_frame);
static struct major_info *tap_get_major(int major)
{
@@ -422,6 +424,7 @@ int tap_get_minor(dev_t major, struct tap_dev *tap)
mutex_unlock(&tap_major->minor_lock);
return retval < 0 ? retval : 0;
}
+EXPORT_SYMBOL_GPL(tap_get_minor);
void tap_free_minor(dev_t major, struct tap_dev *tap)
{
@@ -438,6 +441,7 @@ void tap_free_minor(dev_t major, struct tap_dev *tap)
}
mutex_unlock(&tap_major->minor_lock);
}
+EXPORT_SYMBOL_GPL(tap_free_minor);
static struct tap_dev *dev_get_by_tap_file(int major, int minor)
{
@@ -1193,6 +1197,7 @@ int tap_queue_resize(struct tap_dev *tap)
kfree(arrays);
return ret;
}
+EXPORT_SYMBOL_GPL(tap_queue_resize);
static int tap_list_add(dev_t major, const char *device_name)
{
@@ -1236,6 +1241,7 @@ int tap_create_cdev(struct cdev *tap_cdev,
out1:
return err;
}
+EXPORT_SYMBOL_GPL(tap_create_cdev);
void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
{
@@ -1249,3 +1255,8 @@ void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
unregister_chrdev_region(major, TAP_NUM_DEVS);
idr_destroy(&tap_major->minor_idr);
}
+EXPORT_SYMBOL_GPL(tap_destroy_cdev);
+
+MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>");
+MODULE_AUTHOR("Sainath Grandhi <sainath.grandhi@intel.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
index 40764ec..cfdecea 100644
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -1,6 +1,6 @@
config VHOST_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
---help---
This kernel module can be loaded in host kernel to accelerate
diff --git a/include/linux/if_tap.h b/include/linux/if_tap.h
index 362e71c..3482c3c 100644
--- a/include/linux/if_tap.h
+++ b/include/linux/if_tap.h
@@ -1,7 +1,7 @@
#ifndef _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 *);
#else
#include <linux/err.h>
@@ -12,7 +12,7 @@ static inline struct socket *tap_get_socket(struct file *f)
{
return ERR_PTR(-EINVAL);
}
-#endif /* CONFIG_MACVTAP */
+#endif /* CONFIG_TAP */
#include <net/sock.h>
#include <linux/skb_array.h>
--
2.7.4
next prev parent reply other threads:[~2017-01-18 0:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-18 0:02 [PATCHv2 0/7] Refactor macvtap to re-use tap functionality by other virtual intefaces Sainath Grandhi
2017-01-18 0:03 ` [PATCHv2 1/7] TAP: Refactoring macvtap.c Sainath Grandhi
2017-01-18 0:03 ` [PATCHv2 2/7] TAP: Renaming tap related APIs, data structures, macros Sainath Grandhi
2017-01-18 0:03 ` [PATCHv2 3/7] TAP: Tap character device creation/destroy API Sainath Grandhi
2017-01-18 21:26 ` David Miller
2017-01-19 23:33 ` Grandhi, Sainath
2017-01-18 0:03 ` [PATCHv2 4/7] TAP: Abstract type of virtual interface from tap implementation Sainath Grandhi
2017-01-18 21:27 ` David Miller
2017-01-18 0:03 ` [PATCHv2 5/7] TAP: Extending tap device create/destroy APIs Sainath Grandhi
2017-01-18 1:00 ` Andy Shevchenko
2017-01-18 0:03 ` Sainath Grandhi [this message]
2017-01-18 0:03 ` [PATCHv2 7/7] IPVTAP: IP-VLAN based tap driver Sainath Grandhi
2017-01-18 21:28 ` David Miller
2017-01-19 23:33 ` Grandhi, Sainath
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484697786-50323-7-git-send-email-sainath.grandhi@intel.com \
--to=sainath.grandhi@intel.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mahesh@bandewar.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox