Skip to content

Commit c9c1014

Browse files
kaberdavem330
authored andcommitted
[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: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6440be1 commit c9c1014

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎include/linux/rtnetlink.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
740740
extern void rtnl_lock(void);
741741
extern void rtnl_unlock(void);
742742
extern int rtnl_trylock(void);
743+
extern int rtnl_is_locked(void);
743744

744745
extern void rtnetlink_init(void);
745746
extern void __rtnl_unlock(void);
746747

747748
#define ASSERT_RTNL() do { \
748-
if (unlikely(rtnl_trylock())) { \
749-
rtnl_unlock(); \
749+
if (unlikely(!rtnl_is_locked())) { \
750750
printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
751751
__FILE__, __LINE__); \
752752
dump_stack(); \

‎net/core/rtnetlink.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ int rtnl_trylock(void)
8282
return mutex_trylock(&rtnl_mutex);
8383
}
8484

85+
int rtnl_is_locked(void)
86+
{
87+
return mutex_is_locked(&rtnl_mutex);
88+
}
89+
8590
static struct rtnl_link *rtnl_msg_handlers[NPROTO];
8691

8792
static inline int rtm_msgindex(int msgtype)
@@ -1402,6 +1407,7 @@ EXPORT_SYMBOL(rtnetlink_put_metrics);
14021407
EXPORT_SYMBOL(rtnl_lock);
14031408
EXPORT_SYMBOL(rtnl_trylock);
14041409
EXPORT_SYMBOL(rtnl_unlock);
1410+
EXPORT_SYMBOL(rtnl_is_locked);
14051411
EXPORT_SYMBOL(rtnl_unicast);
14061412
EXPORT_SYMBOL(rtnl_notify);
14071413
EXPORT_SYMBOL(rtnl_set_sk_err);

0 commit comments

Comments
 (0)