summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2017-08-09 20:41:52 +0200
committerDavid S. Miller <davem@davemloft.net>2017-08-09 16:57:38 -0700
commit62256f98f244fbb1c7a10465e1ee412f209d8978 (patch)
tree89b1dff314d7b5fd1e10c24ef3971f51abe9c624 /net
parent6853dd488119a42d01ad994060dc10b95c687c76 (diff)
rtnetlink: add RTNL_FLAG_DOIT_UNLOCKED
Allow callers to tell rtnetlink core that its doit callback should be invoked without holding rtnl mutex. Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/rtnetlink.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index d45946177bc8..dd4e50dfa248 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -62,6 +62,7 @@
struct rtnl_link {
rtnl_doit_func doit;
rtnl_dumpit_func dumpit;
+ unsigned int flags;
};
static DEFINE_MUTEX(rtnl_mutex);
@@ -184,6 +185,7 @@ int __rtnl_register(int protocol, int msgtype,
tab[msgindex].doit = doit;
if (dumpit)
tab[msgindex].dumpit = dumpit;
+ tab[msgindex].flags |= flags;
return 0;
}
@@ -233,6 +235,7 @@ int rtnl_unregister(int protocol, int msgtype)
handlers[msgindex].doit = NULL;
handlers[msgindex].dumpit = NULL;
+ handlers[msgindex].flags = 0;
rtnl_unlock();
return 0;
@@ -4143,6 +4146,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct rtnl_link *handlers;
int err = -EOPNOTSUPP;
rtnl_doit_func doit;
+ unsigned int flags;
int kind;
int family;
int type;
@@ -4209,6 +4213,17 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
return err;
}
+ flags = READ_ONCE(handlers[type].flags);
+ if (flags & RTNL_FLAG_DOIT_UNLOCKED) {
+ refcount_inc(&rtnl_msg_handlers_ref[family]);
+ doit = READ_ONCE(handlers[type].doit);
+ rcu_read_unlock();
+ if (doit)
+ err = doit(skb, nlh, extack);
+ refcount_dec(&rtnl_msg_handlers_ref[family]);
+ return err;
+ }
+
rcu_read_unlock();
rtnl_lock();