aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@osdl.org>2006-03-21 01:23:58 -0500
committerDavid S. Miller <davem@davemloft.net>2006-03-21 01:23:58 -0500
commit6756ae4b4e97aba48c042b4aa6b77a18f507d2cb (patch)
tree05bf37711d782fb0089d474716026c44a454f89b
parent253aa11578c1b89757282430891bb66ae5300092 (diff)
[NET]: Convert RTNL to mutex.
This patch turns the RTNL from a semaphore to a new 2.6.16 mutex and gets rid of some of the leftover legacy. Signed-off-by: Stephen Hemminger <shemminger@osdl.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--include/linux/rtnetlink.h20
-rw-r--r--net/core/dev.c8
-rw-r--r--net/core/link_watch.c4
-rw-r--r--net/core/netpoll.c6
-rw-r--r--net/core/rtnetlink.c28
-rw-r--r--net/ipv4/igmp.c24
-rw-r--r--net/ipv4/ipconfig.c10
8 files changed, 51 insertions, 51 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index e58d4c50c2e1..f5ee064ab6b2 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1605,7 +1605,7 @@ static void rtl8139_thread (void *_data)
1605 if (tp->watchdog_fired) { 1605 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0; 1606 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data); 1607 rtl8139_tx_timeout_task(_data);
1608 } else if (rtnl_shlock_nowait() == 0) { 1608 } else if (rtnl_trylock()) {
1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1610 rtnl_unlock (); 1610 rtnl_unlock ();
1611 } else { 1611 } else {
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index edccefb45188..d263853a8f1c 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -907,6 +907,7 @@ struct tcamsg
907#ifdef __KERNEL__ 907#ifdef __KERNEL__
908 908
909#include <linux/config.h> 909#include <linux/config.h>
910#include <linux/mutex.h>
910 911
911extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size); 912extern size_t rtattr_strlcpy(char *dest, const struct rtattr *rta, size_t size);
912static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str) 913static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
@@ -1038,24 +1039,17 @@ __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
1038 1039
1039extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); 1040extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
1040 1041
1041extern struct semaphore rtnl_sem; 1042/* RTNL is used as a global lock for all changes to network configuration */
1042
1043#define rtnl_shlock() down(&rtnl_sem)
1044#define rtnl_shlock_nowait() down_trylock(&rtnl_sem)
1045
1046#define rtnl_shunlock() do { up(&rtnl_sem); \
1047 if (rtnl && rtnl->sk_receive_queue.qlen) \
1048 rtnl->sk_data_ready(rtnl, 0); \
1049 } while(0)
1050
1051extern void rtnl_lock(void); 1043extern void rtnl_lock(void);
1052extern int rtnl_lock_interruptible(void);
1053extern void rtnl_unlock(void); 1044extern void rtnl_unlock(void);
1045extern int rtnl_trylock(void);
1046
1054extern void rtnetlink_init(void); 1047extern void rtnetlink_init(void);
1048extern void __rtnl_unlock(void);
1055 1049
1056#define ASSERT_RTNL() do { \ 1050#define ASSERT_RTNL() do { \
1057 if (unlikely(down_trylock(&rtnl_sem) == 0)) { \ 1051 if (unlikely(rtnl_trylock())) { \
1058 up(&rtnl_sem); \ 1052 rtnl_unlock(); \
1059 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ 1053 printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
1060 __FILE__, __LINE__); \ 1054 __FILE__, __LINE__); \
1061 dump_stack(); \ 1055 dump_stack(); \
diff --git a/net/core/dev.c b/net/core/dev.c
index 8763c99fcb84..be1d896cc5b9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2466,9 +2466,9 @@ int dev_ioctl(unsigned int cmd, void __user *arg)
2466 */ 2466 */
2467 2467
2468 if (cmd == SIOCGIFCONF) { 2468 if (cmd == SIOCGIFCONF) {
2469 rtnl_shlock(); 2469 rtnl_lock();
2470 ret = dev_ifconf((char __user *) arg); 2470 ret = dev_ifconf((char __user *) arg);
2471 rtnl_shunlock(); 2471 rtnl_unlock();
2472 return ret; 2472 return ret;
2473 } 2473 }
2474 if (cmd == SIOCGIFNAME) 2474 if (cmd == SIOCGIFNAME)
@@ -2877,7 +2877,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
2877 rebroadcast_time = warning_time = jiffies; 2877 rebroadcast_time = warning_time = jiffies;
2878 while (atomic_read(&dev->refcnt) != 0) { 2878 while (atomic_read(&dev->refcnt) != 0) {
2879 if (time_after(jiffies, rebroadcast_time + 1 * HZ)) { 2879 if (time_after(jiffies, rebroadcast_time + 1 * HZ)) {
2880 rtnl_shlock(); 2880 rtnl_lock();
2881 2881
2882 /* Rebroadcast unregister notification */ 2882 /* Rebroadcast unregister notification */
2883 notifier_call_chain(&netdev_chain, 2883 notifier_call_chain(&netdev_chain,
@@ -2894,7 +2894,7 @@ static void netdev_wait_allrefs(struct net_device *dev)
2894 linkwatch_run_queue(); 2894 linkwatch_run_queue();
2895 } 2895 }
2896 2896
2897 rtnl_shunlock(); 2897 __rtnl_unlock();
2898 2898
2899 rebroadcast_time = jiffies; 2899 rebroadcast_time = jiffies;
2900 } 2900 }
diff --git a/net/core/link_watch.c b/net/core/link_watch.c
index e82a451d330b..341de44c7ed1 100644
--- a/net/core/link_watch.c
+++ b/net/core/link_watch.c
@@ -139,9 +139,9 @@ static void linkwatch_event(void *dummy)
139 linkwatch_nextevent = jiffies + HZ; 139 linkwatch_nextevent = jiffies + HZ;
140 clear_bit(LW_RUNNING, &linkwatch_flags); 140 clear_bit(LW_RUNNING, &linkwatch_flags);
141 141
142 rtnl_shlock(); 142 rtnl_lock();
143 linkwatch_run_queue(); 143 linkwatch_run_queue();
144 rtnl_shunlock(); 144 rtnl_unlock();
145} 145}
146 146
147 147
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index ea51f8d02eb8..e8e05cebd95a 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -669,14 +669,14 @@ int netpoll_setup(struct netpoll *np)
669 printk(KERN_INFO "%s: device %s not up yet, forcing it\n", 669 printk(KERN_INFO "%s: device %s not up yet, forcing it\n",
670 np->name, np->dev_name); 670 np->name, np->dev_name);
671 671
672 rtnl_shlock(); 672 rtnl_lock();
673 if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) { 673 if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) {
674 printk(KERN_ERR "%s: failed to open %s\n", 674 printk(KERN_ERR "%s: failed to open %s\n",
675 np->name, np->dev_name); 675 np->name, np->dev_name);
676 rtnl_shunlock(); 676 rtnl_unlock();
677 goto release; 677 goto release;
678 } 678 }
679 rtnl_shunlock(); 679 rtnl_unlock();
680 680
681 atleast = jiffies + HZ/10; 681 atleast = jiffies + HZ/10;
682 atmost = jiffies + 4*HZ; 682 atmost = jiffies + 4*HZ;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 1c15a907066f..ae10d3740faa 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -35,6 +35,7 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/init.h> 36#include <linux/init.h>
37#include <linux/security.h> 37#include <linux/security.h>
38#include <linux/mutex.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40#include <asm/system.h> 41#include <asm/system.h>
@@ -51,25 +52,31 @@
51#include <net/pkt_sched.h> 52#include <net/pkt_sched.h>
52#include <net/netlink.h> 53#include <net/netlink.h>
53 54
54DECLARE_MUTEX(rtnl_sem); 55static DEFINE_MUTEX(rtnl_mutex);
55 56
56void rtnl_lock(void) 57void rtnl_lock(void)
57{ 58{
58 rtnl_shlock(); 59 mutex_lock(&rtnl_mutex);
59} 60}
60 61
61int rtnl_lock_interruptible(void) 62void __rtnl_unlock(void)
62{ 63{
63 return down_interruptible(&rtnl_sem); 64 mutex_unlock(&rtnl_mutex);
64} 65}
65 66
66void rtnl_unlock(void) 67void rtnl_unlock(void)
67{ 68{
68 rtnl_shunlock(); 69 mutex_unlock(&rtnl_mutex);
69 70 if (rtnl && rtnl->sk_receive_queue.qlen)
71 rtnl->sk_data_ready(rtnl, 0);
70 netdev_run_todo(); 72 netdev_run_todo();
71} 73}
72 74
75int rtnl_trylock(void)
76{
77 return mutex_trylock(&rtnl_mutex);
78}
79
73int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len) 80int rtattr_parse(struct rtattr *tb[], int maxattr, struct rtattr *rta, int len)
74{ 81{
75 memset(tb, 0, sizeof(struct rtattr*)*maxattr); 82 memset(tb, 0, sizeof(struct rtattr*)*maxattr);
@@ -625,9 +632,9 @@ static void rtnetlink_rcv(struct sock *sk, int len)
625 unsigned int qlen = 0; 632 unsigned int qlen = 0;
626 633
627 do { 634 do {
628 rtnl_lock(); 635 mutex_lock(&rtnl_mutex);
629 netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg); 636 netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg);
630 up(&rtnl_sem); 637 mutex_unlock(&rtnl_mutex);
631 638
632 netdev_run_todo(); 639 netdev_run_todo();
633 } while (qlen); 640 } while (qlen);
@@ -704,6 +711,5 @@ EXPORT_SYMBOL(rtnetlink_links);
704EXPORT_SYMBOL(rtnetlink_put_metrics); 711EXPORT_SYMBOL(rtnetlink_put_metrics);
705EXPORT_SYMBOL(rtnl); 712EXPORT_SYMBOL(rtnl);
706EXPORT_SYMBOL(rtnl_lock); 713EXPORT_SYMBOL(rtnl_lock);
707EXPORT_SYMBOL(rtnl_lock_interruptible); 714EXPORT_SYMBOL(rtnl_trylock);
708EXPORT_SYMBOL(rtnl_sem);
709EXPORT_SYMBOL(rtnl_unlock); 715EXPORT_SYMBOL(rtnl_unlock);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 64ce52bf0485..3ec502f19da0 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1730,7 +1730,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1730 if (!MULTICAST(addr)) 1730 if (!MULTICAST(addr))
1731 return -EINVAL; 1731 return -EINVAL;
1732 1732
1733 rtnl_shlock(); 1733 rtnl_lock();
1734 1734
1735 in_dev = ip_mc_find_dev(imr); 1735 in_dev = ip_mc_find_dev(imr);
1736 1736
@@ -1763,7 +1763,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr)
1763 ip_mc_inc_group(in_dev, addr); 1763 ip_mc_inc_group(in_dev, addr);
1764 err = 0; 1764 err = 0;
1765done: 1765done:
1766 rtnl_shunlock(); 1766 rtnl_unlock();
1767 return err; 1767 return err;
1768} 1768}
1769 1769
@@ -1837,7 +1837,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1837 if (!MULTICAST(addr)) 1837 if (!MULTICAST(addr))
1838 return -EINVAL; 1838 return -EINVAL;
1839 1839
1840 rtnl_shlock(); 1840 rtnl_lock();
1841 1841
1842 imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; 1842 imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr;
1843 imr.imr_address.s_addr = mreqs->imr_interface; 1843 imr.imr_address.s_addr = mreqs->imr_interface;
@@ -1947,7 +1947,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct
1947 ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1, 1947 ip_mc_add_src(in_dev, &mreqs->imr_multiaddr, omode, 1,
1948 &mreqs->imr_sourceaddr, 1); 1948 &mreqs->imr_sourceaddr, 1);
1949done: 1949done:
1950 rtnl_shunlock(); 1950 rtnl_unlock();
1951 if (leavegroup) 1951 if (leavegroup)
1952 return ip_mc_leave_group(sk, &imr); 1952 return ip_mc_leave_group(sk, &imr);
1953 return err; 1953 return err;
@@ -1970,7 +1970,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
1970 msf->imsf_fmode != MCAST_EXCLUDE) 1970 msf->imsf_fmode != MCAST_EXCLUDE)
1971 return -EINVAL; 1971 return -EINVAL;
1972 1972
1973 rtnl_shlock(); 1973 rtnl_lock();
1974 1974
1975 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; 1975 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
1976 imr.imr_address.s_addr = msf->imsf_interface; 1976 imr.imr_address.s_addr = msf->imsf_interface;
@@ -2030,7 +2030,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
2030 pmc->sfmode = msf->imsf_fmode; 2030 pmc->sfmode = msf->imsf_fmode;
2031 err = 0; 2031 err = 0;
2032done: 2032done:
2033 rtnl_shunlock(); 2033 rtnl_unlock();
2034 if (leavegroup) 2034 if (leavegroup)
2035 err = ip_mc_leave_group(sk, &imr); 2035 err = ip_mc_leave_group(sk, &imr);
2036 return err; 2036 return err;
@@ -2050,7 +2050,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2050 if (!MULTICAST(addr)) 2050 if (!MULTICAST(addr))
2051 return -EINVAL; 2051 return -EINVAL;
2052 2052
2053 rtnl_shlock(); 2053 rtnl_lock();
2054 2054
2055 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; 2055 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
2056 imr.imr_address.s_addr = msf->imsf_interface; 2056 imr.imr_address.s_addr = msf->imsf_interface;
@@ -2072,7 +2072,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2072 goto done; 2072 goto done;
2073 msf->imsf_fmode = pmc->sfmode; 2073 msf->imsf_fmode = pmc->sfmode;
2074 psl = pmc->sflist; 2074 psl = pmc->sflist;
2075 rtnl_shunlock(); 2075 rtnl_unlock();
2076 if (!psl) { 2076 if (!psl) {
2077 len = 0; 2077 len = 0;
2078 count = 0; 2078 count = 0;
@@ -2091,7 +2091,7 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2091 return -EFAULT; 2091 return -EFAULT;
2092 return 0; 2092 return 0;
2093done: 2093done:
2094 rtnl_shunlock(); 2094 rtnl_unlock();
2095 return err; 2095 return err;
2096} 2096}
2097 2097
@@ -2112,7 +2112,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2112 if (!MULTICAST(addr)) 2112 if (!MULTICAST(addr))
2113 return -EINVAL; 2113 return -EINVAL;
2114 2114
2115 rtnl_shlock(); 2115 rtnl_lock();
2116 2116
2117 err = -EADDRNOTAVAIL; 2117 err = -EADDRNOTAVAIL;
2118 2118
@@ -2125,7 +2125,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2125 goto done; 2125 goto done;
2126 gsf->gf_fmode = pmc->sfmode; 2126 gsf->gf_fmode = pmc->sfmode;
2127 psl = pmc->sflist; 2127 psl = pmc->sflist;
2128 rtnl_shunlock(); 2128 rtnl_unlock();
2129 count = psl ? psl->sl_count : 0; 2129 count = psl ? psl->sl_count : 0;
2130 copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc; 2130 copycount = count < gsf->gf_numsrc ? count : gsf->gf_numsrc;
2131 gsf->gf_numsrc = count; 2131 gsf->gf_numsrc = count;
@@ -2146,7 +2146,7 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf,
2146 } 2146 }
2147 return 0; 2147 return 0;
2148done: 2148done:
2149 rtnl_shunlock(); 2149 rtnl_unlock();
2150 return err; 2150 return err;
2151} 2151}
2152 2152
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index bb3613ec448c..cb8a92f18ef6 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -186,7 +186,7 @@ static int __init ic_open_devs(void)
186 unsigned short oflags; 186 unsigned short oflags;
187 187
188 last = &ic_first_dev; 188 last = &ic_first_dev;
189 rtnl_shlock(); 189 rtnl_lock();
190 190
191 /* bring loopback device up first */ 191 /* bring loopback device up first */
192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) 192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
@@ -215,7 +215,7 @@ static int __init ic_open_devs(void)
215 continue; 215 continue;
216 } 216 }
217 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) { 217 if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
218 rtnl_shunlock(); 218 rtnl_unlock();
219 return -1; 219 return -1;
220 } 220 }
221 d->dev = dev; 221 d->dev = dev;
@@ -232,7 +232,7 @@ static int __init ic_open_devs(void)
232 dev->name, able, d->xid)); 232 dev->name, able, d->xid));
233 } 233 }
234 } 234 }
235 rtnl_shunlock(); 235 rtnl_unlock();
236 236
237 *last = NULL; 237 *last = NULL;
238 238
@@ -251,7 +251,7 @@ static void __init ic_close_devs(void)
251 struct ic_device *d, *next; 251 struct ic_device *d, *next;
252 struct net_device *dev; 252 struct net_device *dev;
253 253
254 rtnl_shlock(); 254 rtnl_lock();
255 next = ic_first_dev; 255 next = ic_first_dev;
256 while ((d = next)) { 256 while ((d = next)) {
257 next = d->next; 257 next = d->next;
@@ -262,7 +262,7 @@ static void __init ic_close_devs(void)
262 } 262 }
263 kfree(d); 263 kfree(d);
264 } 264 }
265 rtnl_shunlock(); 265 rtnl_unlock();
266} 266}
267 267
268/* 268/*