aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-04-24 11:40:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-24 11:40:34 -0400
commitd02aacff4467806ee56f147ac8eff6911d95811a (patch)
tree3bc6197f735f18dd4c3cd7c77f2a45bb9b8fac16 /drivers/net/tun.c
parente270b51df657011983241ec61a1fc7de186e16cd (diff)
parent9edb74cc6ccb3a893c3d40727b7003c3c16f85a0 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: (22 commits) tun: Multicast handling in tun_chr_ioctl() needs proper locking. [NET]: Fix heavy stack usage in seq_file output routines. [AF_UNIX] Initialise UNIX sockets before general device initcalls [RTNETLINK]: Fix bogus ASSERT_RTNL warning iwlwifi: Fix built-in compilation of iwlcore (part 2) tun: Fix minor race in TUNSETLINK ioctl handling. ppp_generic: use stats from net_device structure iwlwifi: Don't unlock priv->mutex if it isn't locked wireless: rndis_wlan: modparam_workaround_interval is never below 0. prism54: prism54_get_encode() test below 0 on unsigned index mac80211: update mesh EID values b43: Workaround DMA quirks mac80211: fix use before check of Qdisc length net/mac80211/rx.c: fix off-by-one mac80211: Fix race between ieee80211_rx_bss_put and lookup routines. ath5k: Fix radio identification on AR5424/2424 ssb: Fix all-ones boardflags b43: Add more btcoexist workarounds b43: Fix HostFlags data types b43: Workaround invalid bluetooth settings ...
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d91856b19f6f..0ce07a339c7e 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -668,16 +668,23 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
668 break; 668 break;
669 669
670 case TUNSETLINK: 670 case TUNSETLINK:
671 {
672 int ret;
673
671 /* Only allow setting the type when the interface is down */ 674 /* Only allow setting the type when the interface is down */
675 rtnl_lock();
672 if (tun->dev->flags & IFF_UP) { 676 if (tun->dev->flags & IFF_UP) {
673 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", 677 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
674 tun->dev->name); 678 tun->dev->name);
675 return -EBUSY; 679 ret = -EBUSY;
676 } else { 680 } else {
677 tun->dev->type = (int) arg; 681 tun->dev->type = (int) arg;
678 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); 682 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
683 ret = 0;
679 } 684 }
680 break; 685 rtnl_unlock();
686 return ret;
687 }
681 688
682#ifdef TUN_DEBUG 689#ifdef TUN_DEBUG
683 case TUNSETDEBUG: 690 case TUNSETDEBUG:
@@ -734,7 +741,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
734 case SIOCADDMULTI: 741 case SIOCADDMULTI:
735 /** Add the specified group to the character device's multicast filter 742 /** Add the specified group to the character device's multicast filter
736 * list. */ 743 * list. */
744 rtnl_lock();
745 netif_tx_lock_bh(tun->dev);
737 add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data); 746 add_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
747 netif_tx_unlock_bh(tun->dev);
748 rtnl_unlock();
749
738 DBG(KERN_DEBUG "%s: add multi: %s\n", 750 DBG(KERN_DEBUG "%s: add multi: %s\n",
739 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); 751 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
740 return 0; 752 return 0;
@@ -742,7 +754,12 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
742 case SIOCDELMULTI: 754 case SIOCDELMULTI:
743 /** Remove the specified group from the character device's multicast 755 /** Remove the specified group from the character device's multicast
744 * filter list. */ 756 * filter list. */
757 rtnl_lock();
758 netif_tx_lock_bh(tun->dev);
745 del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data); 759 del_multi(tun->chr_filter, ifr.ifr_hwaddr.sa_data);
760 netif_tx_unlock_bh(tun->dev);
761 rtnl_unlock();
762
746 DBG(KERN_DEBUG "%s: del multi: %s\n", 763 DBG(KERN_DEBUG "%s: del multi: %s\n",
747 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data)); 764 tun->dev->name, print_mac(mac, ifr.ifr_hwaddr.sa_data));
748 return 0; 765 return 0;