Commit c9c1014b authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[RTNETLINK]: Fix bogus ASSERT_RTNL warning

ASSERT_RTNL uses mutex_trylock to test whether the rtnl_mutex is
held. This bogus warnings when running in atomic context, which
f.e. happens when adding secondary unicast addresses through
macvlan or vlan or when synchronizing multicast addresses from
wireless devices.

Mid-term we might want to consider moving all address updates
to process context since the locking seems overly complicated,
for now just fix the bogus warning by changing ASSERT_RTNL to
use mutex_is_locked().
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6440be17
...@@ -740,13 +740,13 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change); ...@@ -740,13 +740,13 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
extern void rtnl_lock(void); extern void rtnl_lock(void);
extern void rtnl_unlock(void); extern void rtnl_unlock(void);
extern int rtnl_trylock(void); extern int rtnl_trylock(void);
extern int rtnl_is_locked(void);
extern void rtnetlink_init(void); extern void rtnetlink_init(void);
extern void __rtnl_unlock(void); extern void __rtnl_unlock(void);
#define ASSERT_RTNL() do { \ #define ASSERT_RTNL() do { \
if (unlikely(rtnl_trylock())) { \ if (unlikely(!rtnl_is_locked())) { \
rtnl_unlock(); \
printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \ printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
dump_stack(); \ dump_stack(); \
......
...@@ -82,6 +82,11 @@ int rtnl_trylock(void) ...@@ -82,6 +82,11 @@ int rtnl_trylock(void)
return mutex_trylock(&rtnl_mutex); return mutex_trylock(&rtnl_mutex);
} }
int rtnl_is_locked(void)
{
return mutex_is_locked(&rtnl_mutex);
}
static struct rtnl_link *rtnl_msg_handlers[NPROTO]; static struct rtnl_link *rtnl_msg_handlers[NPROTO];
static inline int rtm_msgindex(int msgtype) static inline int rtm_msgindex(int msgtype)
...@@ -1402,6 +1407,7 @@ EXPORT_SYMBOL(rtnetlink_put_metrics); ...@@ -1402,6 +1407,7 @@ EXPORT_SYMBOL(rtnetlink_put_metrics);
EXPORT_SYMBOL(rtnl_lock); EXPORT_SYMBOL(rtnl_lock);
EXPORT_SYMBOL(rtnl_trylock); EXPORT_SYMBOL(rtnl_trylock);
EXPORT_SYMBOL(rtnl_unlock); EXPORT_SYMBOL(rtnl_unlock);
EXPORT_SYMBOL(rtnl_is_locked);
EXPORT_SYMBOL(rtnl_unicast); EXPORT_SYMBOL(rtnl_unicast);
EXPORT_SYMBOL(rtnl_notify); EXPORT_SYMBOL(rtnl_notify);
EXPORT_SYMBOL(rtnl_set_sk_err); EXPORT_SYMBOL(rtnl_set_sk_err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment