Skip to content

Commit dfcb7a1

Browse files
committed
Merge branch 'ipvtap'
Sainath Grandhi says: ==================== Refactor macvtap to re-use tap functionality by other virtual intefaces Tap character devices can be implemented on other virtual interfaces like ipvlan, similar to macvtap. Source code for tap functionality in macvtap can be re-used for this purpose. This patch series splits macvtap source into two modules, macvtap and tap. This patch series also includes a patch for implementing tap character device driver based on the IP-VLAN network interface, called ipvtap. These patches are tested on x86 platform. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 35eeacf + 235a9d8 commit dfcb7a1

File tree

14 files changed

+1706
-1208
lines changed

14 files changed

+1706
-1208
lines changed

drivers/net/Kconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ config MACVTAP
135135
tristate "MAC-VLAN based tap driver"
136136
depends on MACVLAN
137137
depends on INET
138+
select TAP
138139
help
139140
This adds a specialized tap character device driver that is based
140141
on the MAC-VLAN network interface, called macvtap. A macvtap device
@@ -165,6 +166,19 @@ config IPVLAN
165166
To compile this driver as a module, choose M here: the module
166167
will be called ipvlan.
167168

169+
config IPVTAP
170+
tristate "IP-VLAN based tap driver"
171+
depends on IPVLAN
172+
depends on INET
173+
select TAP
174+
---help---
175+
This adds a specialized tap character device driver that is based
176+
on the IP-VLAN network interface, called ipvtap. An ipvtap device
177+
can be added in the same way as a ipvlan device, using 'type
178+
ipvtap', and then be accessed through the tap user space interface.
179+
180+
To compile this driver as a module, choose M here: the module
181+
will be called ipvtap.
168182

169183
config VXLAN
170184
tristate "Virtual eXtensible Local Area Network (VXLAN)"
@@ -287,6 +301,12 @@ config TUN
287301

288302
If you don't know what to use this for, you don't need it.
289303

304+
config TAP
305+
tristate
306+
---help---
307+
This option is selected by any driver implementing tap user space
308+
interface for a virtual interface to re-use core tap functionality.
309+
290310
config TUN_VNET_CROSS_LE
291311
bool "Support for cross-endian vnet headers on little-endian kernels"
292312
default n

drivers/net/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
obj-$(CONFIG_BONDING) += bonding/
99
obj-$(CONFIG_IPVLAN) += ipvlan/
10+
obj-$(CONFIG_IPVTAP) += ipvlan/
1011
obj-$(CONFIG_DUMMY) += dummy.o
1112
obj-$(CONFIG_EQUALIZER) += eql.o
1213
obj-$(CONFIG_IFB) += ifb.o
@@ -21,6 +22,7 @@ obj-$(CONFIG_PHYLIB) += phy/
2122
obj-$(CONFIG_RIONET) += rionet.o
2223
obj-$(CONFIG_NET_TEAM) += team/
2324
obj-$(CONFIG_TUN) += tun.o
25+
obj-$(CONFIG_TAP) += tap.o
2426
obj-$(CONFIG_VETH) += veth.o
2527
obj-$(CONFIG_VIRTIO_NET) += virtio_net.o
2628
obj-$(CONFIG_VXLAN) += vxlan.o

drivers/net/ipvlan/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
#
44

55
obj-$(CONFIG_IPVLAN) += ipvlan.o
6+
obj-$(CONFIG_IPVTAP) += ipvtap.o
67

78
ipvlan-objs := ipvlan_core.o ipvlan_main.o

drivers/net/ipvlan/ipvlan.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,11 @@ struct sk_buff *ipvlan_l3_rcv(struct net_device *dev, struct sk_buff *skb,
135135
u16 proto);
136136
unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb,
137137
const struct nf_hook_state *state);
138+
void ipvlan_count_rx(const struct ipvl_dev *ipvlan,
139+
unsigned int len, bool success, bool mcast);
140+
int ipvlan_link_new(struct net *src_net, struct net_device *dev,
141+
struct nlattr *tb[], struct nlattr *data[]);
142+
void ipvlan_link_delete(struct net_device *dev, struct list_head *head);
143+
void ipvlan_link_setup(struct net_device *dev);
144+
int ipvlan_link_register(struct rtnl_link_ops *ops);
138145
#endif /* __IPVLAN_H */

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void ipvlan_init_secret(void)
1616
net_get_random_once(&ipvlan_jhash_secret, sizeof(ipvlan_jhash_secret));
1717
}
1818

19-
static void ipvlan_count_rx(const struct ipvl_dev *ipvlan,
19+
void ipvlan_count_rx(const struct ipvl_dev *ipvlan,
2020
unsigned int len, bool success, bool mcast)
2121
{
2222
if (likely(success)) {
@@ -33,6 +33,7 @@ static void ipvlan_count_rx(const struct ipvl_dev *ipvlan,
3333
this_cpu_inc(ipvlan->pcpu_stats->rx_errs);
3434
}
3535
}
36+
EXPORT_SYMBOL_GPL(ipvlan_count_rx);
3637

3738
static u8 ipvlan_get_v6_hash(const void *iaddr)
3839
{

drivers/net/ipvlan/ipvlan_main.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ static int ipvlan_nl_fillinfo(struct sk_buff *skb,
496496
return ret;
497497
}
498498

499-
static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
500-
struct nlattr *tb[], struct nlattr *data[])
499+
int ipvlan_link_new(struct net *src_net, struct net_device *dev,
500+
struct nlattr *tb[], struct nlattr *data[])
501501
{
502502
struct ipvl_dev *ipvlan = netdev_priv(dev);
503503
struct ipvl_port *port;
@@ -594,8 +594,9 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
594594
ipvlan_port_destroy(phy_dev);
595595
return err;
596596
}
597+
EXPORT_SYMBOL_GPL(ipvlan_link_new);
597598

598-
static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
599+
void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
599600
{
600601
struct ipvl_dev *ipvlan = netdev_priv(dev);
601602
struct ipvl_addr *addr, *next;
@@ -611,8 +612,9 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
611612
unregister_netdevice_queue(dev, head);
612613
netdev_upper_dev_unlink(ipvlan->phy_dev, dev);
613614
}
615+
EXPORT_SYMBOL_GPL(ipvlan_link_delete);
614616

615-
static void ipvlan_link_setup(struct net_device *dev)
617+
void ipvlan_link_setup(struct net_device *dev)
616618
{
617619
ether_setup(dev);
618620

@@ -623,6 +625,7 @@ static void ipvlan_link_setup(struct net_device *dev)
623625
dev->header_ops = &ipvlan_header_ops;
624626
dev->ethtool_ops = &ipvlan_ethtool_ops;
625627
}
628+
EXPORT_SYMBOL_GPL(ipvlan_link_setup);
626629

627630
static const struct nla_policy ipvlan_nl_policy[IFLA_IPVLAN_MAX + 1] =
628631
{
@@ -633,22 +636,22 @@ static struct rtnl_link_ops ipvlan_link_ops = {
633636
.kind = "ipvlan",
634637
.priv_size = sizeof(struct ipvl_dev),
635638

636-
.get_size = ipvlan_nl_getsize,
637-
.policy = ipvlan_nl_policy,
638-
.validate = ipvlan_nl_validate,
639-
.fill_info = ipvlan_nl_fillinfo,
640-
.changelink = ipvlan_nl_changelink,
641-
.maxtype = IFLA_IPVLAN_MAX,
642-
643639
.setup = ipvlan_link_setup,
644640
.newlink = ipvlan_link_new,
645641
.dellink = ipvlan_link_delete,
646642
};
647643

648-
static int ipvlan_link_register(struct rtnl_link_ops *ops)
644+
int ipvlan_link_register(struct rtnl_link_ops *ops)
649645
{
646+
ops->get_size = ipvlan_nl_getsize;
647+
ops->policy = ipvlan_nl_policy;
648+
ops->validate = ipvlan_nl_validate;
649+
ops->fill_info = ipvlan_nl_fillinfo;
650+
ops->changelink = ipvlan_nl_changelink;
651+
ops->maxtype = IFLA_IPVLAN_MAX;
650652
return rtnl_link_register(ops);
651653
}
654+
EXPORT_SYMBOL_GPL(ipvlan_link_register);
652655

653656
static int ipvlan_device_event(struct notifier_block *unused,
654657
unsigned long event, void *ptr)

0 commit comments

Comments
 (0)