diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 15:49:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-12-28 15:49:40 -0500 |
commit | 0191b625ca5a46206d2fb862bb08f36f2fcb3b31 (patch) | |
tree | 454d1842b1833d976da62abcbd5c47521ebe9bd7 /drivers/net/tun.c | |
parent | 54a696bd07c14d3b1192d03ce7269bc59b45209a (diff) | |
parent | eb56092fc168bf5af199d47af50c0d84a96db898 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6: (1429 commits)
net: Allow dependancies of FDDI & Tokenring to be modular.
igb: Fix build warning when DCA is disabled.
net: Fix warning fallout from recent NAPI interface changes.
gro: Fix potential use after free
sfc: If AN is enabled, always read speed/duplex from the AN advertising bits
sfc: When disabling the NIC, close the device rather than unregistering it
sfc: SFT9001: Add cable diagnostics
sfc: Add support for multiple PHY self-tests
sfc: Merge top-level functions for self-tests
sfc: Clean up PHY mode management in loopback self-test
sfc: Fix unreliable link detection in some loopback modes
sfc: Generate unique names for per-NIC workqueues
802.3ad: use standard ethhdr instead of ad_header
802.3ad: generalize out mac address initializer
802.3ad: initialize ports LACPDU from const initializer
802.3ad: remove typedef around ad_system
802.3ad: turn ports is_individual into a bool
802.3ad: turn ports is_enabled into a bool
802.3ad: make ntt bool
ixgbe: Fix set_ringparam in ixgbe to use the same memory pools.
...
Fixed trivial IPv4/6 address printing conflicts in fs/cifs/connect.c due
to the conversion to %pI (in this networking merge) and the addition of
doing IPv6 addresses (from the earlier merge of CIFS).
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r-- | drivers/net/tun.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 55dc70c6b4db..666c1d98cdaf 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -305,6 +305,23 @@ tun_net_change_mtu(struct net_device *dev, int new_mtu) | |||
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | static const struct net_device_ops tun_netdev_ops = { | ||
309 | .ndo_open = tun_net_open, | ||
310 | .ndo_stop = tun_net_close, | ||
311 | .ndo_start_xmit = tun_net_xmit, | ||
312 | .ndo_change_mtu = tun_net_change_mtu, | ||
313 | }; | ||
314 | |||
315 | static const struct net_device_ops tap_netdev_ops = { | ||
316 | .ndo_open = tun_net_open, | ||
317 | .ndo_stop = tun_net_close, | ||
318 | .ndo_start_xmit = tun_net_xmit, | ||
319 | .ndo_change_mtu = tun_net_change_mtu, | ||
320 | .ndo_set_multicast_list = tun_net_mclist, | ||
321 | .ndo_set_mac_address = eth_mac_addr, | ||
322 | .ndo_validate_addr = eth_validate_addr, | ||
323 | }; | ||
324 | |||
308 | /* Initialize net device. */ | 325 | /* Initialize net device. */ |
309 | static void tun_net_init(struct net_device *dev) | 326 | static void tun_net_init(struct net_device *dev) |
310 | { | 327 | { |
@@ -312,11 +329,12 @@ static void tun_net_init(struct net_device *dev) | |||
312 | 329 | ||
313 | switch (tun->flags & TUN_TYPE_MASK) { | 330 | switch (tun->flags & TUN_TYPE_MASK) { |
314 | case TUN_TUN_DEV: | 331 | case TUN_TUN_DEV: |
332 | dev->netdev_ops = &tun_netdev_ops; | ||
333 | |||
315 | /* Point-to-Point TUN Device */ | 334 | /* Point-to-Point TUN Device */ |
316 | dev->hard_header_len = 0; | 335 | dev->hard_header_len = 0; |
317 | dev->addr_len = 0; | 336 | dev->addr_len = 0; |
318 | dev->mtu = 1500; | 337 | dev->mtu = 1500; |
319 | dev->change_mtu = tun_net_change_mtu; | ||
320 | 338 | ||
321 | /* Zero header length */ | 339 | /* Zero header length */ |
322 | dev->type = ARPHRD_NONE; | 340 | dev->type = ARPHRD_NONE; |
@@ -325,10 +343,9 @@ static void tun_net_init(struct net_device *dev) | |||
325 | break; | 343 | break; |
326 | 344 | ||
327 | case TUN_TAP_DEV: | 345 | case TUN_TAP_DEV: |
346 | dev->netdev_ops = &tun_netdev_ops; | ||
328 | /* Ethernet TAP Device */ | 347 | /* Ethernet TAP Device */ |
329 | ether_setup(dev); | 348 | ether_setup(dev); |
330 | dev->change_mtu = tun_net_change_mtu; | ||
331 | dev->set_multicast_list = tun_net_mclist; | ||
332 | 349 | ||
333 | random_ether_addr(dev->dev_addr); | 350 | random_ether_addr(dev->dev_addr); |
334 | 351 | ||
@@ -529,7 +546,6 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, | |||
529 | } | 546 | } |
530 | 547 | ||
531 | netif_rx_ni(skb); | 548 | netif_rx_ni(skb); |
532 | tun->dev->last_rx = jiffies; | ||
533 | 549 | ||
534 | tun->dev->stats.rx_packets++; | 550 | tun->dev->stats.rx_packets++; |
535 | tun->dev->stats.rx_bytes += len; | 551 | tun->dev->stats.rx_bytes += len; |
@@ -676,9 +692,6 @@ static void tun_setup(struct net_device *dev) | |||
676 | tun->owner = -1; | 692 | tun->owner = -1; |
677 | tun->group = -1; | 693 | tun->group = -1; |
678 | 694 | ||
679 | dev->open = tun_net_open; | ||
680 | dev->hard_start_xmit = tun_net_xmit; | ||
681 | dev->stop = tun_net_close; | ||
682 | dev->ethtool_ops = &tun_ethtool_ops; | 695 | dev->ethtool_ops = &tun_ethtool_ops; |
683 | dev->destructor = free_netdev; | 696 | dev->destructor = free_netdev; |
684 | dev->features |= NETIF_F_NETNS_LOCAL; | 697 | dev->features |= NETIF_F_NETNS_LOCAL; |
@@ -752,6 +765,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
752 | return -ENOMEM; | 765 | return -ENOMEM; |
753 | 766 | ||
754 | dev_net_set(dev, net); | 767 | dev_net_set(dev, net); |
768 | |||
755 | tun = netdev_priv(dev); | 769 | tun = netdev_priv(dev); |
756 | tun->dev = dev; | 770 | tun->dev = dev; |
757 | tun->flags = flags; | 771 | tun->flags = flags; |
@@ -885,7 +899,6 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, | |||
885 | void __user* argp = (void __user*)arg; | 899 | void __user* argp = (void __user*)arg; |
886 | struct ifreq ifr; | 900 | struct ifreq ifr; |
887 | int ret; | 901 | int ret; |
888 | DECLARE_MAC_BUF(mac); | ||
889 | 902 | ||
890 | if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) | 903 | if (cmd == TUNSETIFF || _IOC_TYPE(cmd) == 0x89) |
891 | if (copy_from_user(&ifr, argp, sizeof ifr)) | 904 | if (copy_from_user(&ifr, argp, sizeof ifr)) |
@@ -1013,8 +1026,8 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file, | |||
1013 | 1026 | ||
1014 | case SIOCSIFHWADDR: | 1027 | case SIOCSIFHWADDR: |
1015 | /* Set hw address */ | 1028 | /* Set hw address */ |
1016 | DBG(KERN_DEBUG "%s: set hw address: %s\n", | 1029 | DBG(KERN_DEBUG "%s: set hw address: %pM\n", |
1017 | tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); | 1030 | tun->dev->name, ifr.ifr_hwaddr.sa_data); |
1018 | 1031 | ||
1019 | rtnl_lock(); | 1032 | rtnl_lock(); |
1020 | ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr); | 1033 | ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr); |