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

[NETFILTER]: nf_conntrack_core: avoid taking nf_conntrack_lock in nf_conntrack_alter_reply

The conntrack is unconfirmed, so we have an exclusive reference, which
means that the write_lock is definitely unneeded. A read_lock used to
be needed for the helper lookup, but since we're using RCU for helpers
now rcu_read_lock is enough.
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 58a3c9bb
...@@ -729,7 +729,6 @@ void nf_conntrack_alter_reply(struct nf_conn *ct, ...@@ -729,7 +729,6 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
struct nf_conn_help *help = nfct_help(ct); struct nf_conn_help *help = nfct_help(ct);
struct nf_conntrack_helper *helper; struct nf_conntrack_helper *helper;
write_lock_bh(&nf_conntrack_lock);
/* Should be unconfirmed, so not in hash table yet */ /* Should be unconfirmed, so not in hash table yet */
NF_CT_ASSERT(!nf_ct_is_confirmed(ct)); NF_CT_ASSERT(!nf_ct_is_confirmed(ct));
...@@ -738,8 +737,9 @@ void nf_conntrack_alter_reply(struct nf_conn *ct, ...@@ -738,8 +737,9 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply; ct->tuplehash[IP_CT_DIR_REPLY].tuple = *newreply;
if (ct->master || (help && help->expecting != 0)) if (ct->master || (help && help->expecting != 0))
goto out; return;
rcu_read_lock();
helper = __nf_ct_helper_find(newreply); helper = __nf_ct_helper_find(newreply);
if (helper == NULL) { if (helper == NULL) {
if (help) if (help)
...@@ -757,7 +757,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct, ...@@ -757,7 +757,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
rcu_assign_pointer(help->helper, helper); rcu_assign_pointer(help->helper, helper);
out: out:
write_unlock_bh(&nf_conntrack_lock); rcu_read_unlock();
} }
EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply); EXPORT_SYMBOL_GPL(nf_conntrack_alter_reply);
......
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