Commit 9c55d3b5 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

nfnetlink: add nfnl_dereference_protected helper

to avoid overly long line in followup patch.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent c38c4597
...@@ -33,6 +33,10 @@ MODULE_LICENSE("GPL"); ...@@ -33,6 +33,10 @@ MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>"); MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NETFILTER); MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_NETFILTER);
#define nfnl_dereference_protected(id) \
rcu_dereference_protected(table[(id)].subsys, \
lockdep_nfnl_is_held((id)))
static char __initdata nfversion[] = "0.30"; static char __initdata nfversion[] = "0.30";
static struct { static struct {
...@@ -208,8 +212,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -208,8 +212,7 @@ static int nfnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
} else { } else {
rcu_read_unlock(); rcu_read_unlock();
nfnl_lock(subsys_id); nfnl_lock(subsys_id);
if (rcu_dereference_protected(table[subsys_id].subsys, if (nfnl_dereference_protected(subsys_id) != ss ||
lockdep_is_held(&table[subsys_id].mutex)) != ss ||
nfnetlink_find_client(type, ss) != nc) nfnetlink_find_client(type, ss) != nc)
err = -EAGAIN; err = -EAGAIN;
else if (nc->call) else if (nc->call)
...@@ -299,15 +302,13 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, ...@@ -299,15 +302,13 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
skb->sk = oskb->sk; skb->sk = oskb->sk;
nfnl_lock(subsys_id); nfnl_lock(subsys_id);
ss = rcu_dereference_protected(table[subsys_id].subsys, ss = nfnl_dereference_protected(subsys_id);
lockdep_is_held(&table[subsys_id].mutex));
if (!ss) { if (!ss) {
#ifdef CONFIG_MODULES #ifdef CONFIG_MODULES
nfnl_unlock(subsys_id); nfnl_unlock(subsys_id);
request_module("nfnetlink-subsys-%d", subsys_id); request_module("nfnetlink-subsys-%d", subsys_id);
nfnl_lock(subsys_id); nfnl_lock(subsys_id);
ss = rcu_dereference_protected(table[subsys_id].subsys, ss = nfnl_dereference_protected(subsys_id);
lockdep_is_held(&table[subsys_id].mutex));
if (!ss) if (!ss)
#endif #endif
{ {
......
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