aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-20 01:10:37 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-20 01:42:47 -0500
commit758e43b74c903ad368ceced31601ba5d96f31238 (patch)
tree6942bc3aae54bd1d46067dc9462f8b0eb4dc9c77 /drivers/net/tun.c
parent48dfcde46ef23cfad1e0c0f13d4eae15c7f46efc (diff)
tun: convert to net_device_ops
Convert the TUN/TAP tunnel driver to net_device_ops. Split the ops in two, and retain compatability. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 5a6203072ce7..b4c941444756 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -305,6 +305,22 @@ tun_net_change_mtu(struct net_device *dev, int new_mtu)
305 return 0; 305 return 0;
306} 306}
307 307
308static const struct net_device_ops tun_netdev_ops = {
309 .ndo_open = tun_net_open,
310 .ndo_stop = tun_net_close,
311 .ndo_change_mtu = tun_net_change_mtu,
312
313};
314
315static const struct net_device_ops tap_netdev_ops = {
316 .ndo_open = tun_net_open,
317 .ndo_stop = tun_net_close,
318 .ndo_change_mtu = tun_net_change_mtu,
319 .ndo_set_multicast_list = tun_net_mclist,
320 .ndo_set_mac_address = eth_mac_addr,
321 .ndo_validate_addr = eth_validate_addr,
322};
323
308/* Initialize net device. */ 324/* Initialize net device. */
309static void tun_net_init(struct net_device *dev) 325static void tun_net_init(struct net_device *dev)
310{ 326{
@@ -312,11 +328,12 @@ static void tun_net_init(struct net_device *dev)
312 328
313 switch (tun->flags & TUN_TYPE_MASK) { 329 switch (tun->flags & TUN_TYPE_MASK) {
314 case TUN_TUN_DEV: 330 case TUN_TUN_DEV:
331 dev->netdev_ops = &tun_netdev_ops;
332
315 /* Point-to-Point TUN Device */ 333 /* Point-to-Point TUN Device */
316 dev->hard_header_len = 0; 334 dev->hard_header_len = 0;
317 dev->addr_len = 0; 335 dev->addr_len = 0;
318 dev->mtu = 1500; 336 dev->mtu = 1500;
319 dev->change_mtu = tun_net_change_mtu;
320 337
321 /* Zero header length */ 338 /* Zero header length */
322 dev->type = ARPHRD_NONE; 339 dev->type = ARPHRD_NONE;
@@ -325,10 +342,9 @@ static void tun_net_init(struct net_device *dev)
325 break; 342 break;
326 343
327 case TUN_TAP_DEV: 344 case TUN_TAP_DEV:
345 dev->netdev_ops = &tun_netdev_ops;
328 /* Ethernet TAP Device */ 346 /* Ethernet TAP Device */
329 ether_setup(dev); 347 ether_setup(dev);
330 dev->change_mtu = tun_net_change_mtu;
331 dev->set_multicast_list = tun_net_mclist;
332 348
333 random_ether_addr(dev->dev_addr); 349 random_ether_addr(dev->dev_addr);
334 350
@@ -675,9 +691,7 @@ static void tun_setup(struct net_device *dev)
675 tun->owner = -1; 691 tun->owner = -1;
676 tun->group = -1; 692 tun->group = -1;
677 693
678 dev->open = tun_net_open;
679 dev->hard_start_xmit = tun_net_xmit; 694 dev->hard_start_xmit = tun_net_xmit;
680 dev->stop = tun_net_close;
681 dev->ethtool_ops = &tun_ethtool_ops; 695 dev->ethtool_ops = &tun_ethtool_ops;
682 dev->destructor = free_netdev; 696 dev->destructor = free_netdev;
683 dev->features |= NETIF_F_NETNS_LOCAL; 697 dev->features |= NETIF_F_NETNS_LOCAL;
@@ -749,6 +763,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
749 return -ENOMEM; 763 return -ENOMEM;
750 764
751 dev_net_set(dev, net); 765 dev_net_set(dev, net);
766
752 tun = netdev_priv(dev); 767 tun = netdev_priv(dev);
753 tun->dev = dev; 768 tun->dev = dev;
754 tun->flags = flags; 769 tun->flags = flags;