From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: [PATCH 3/3] netfilter: ctnetlink: move event reporting for new entries outside the lock
Date: Thu, 05 Mar 2009 17:07:59 +0100 [thread overview]
Message-ID: <20090305160759.13755.64802.stgit@Decadence> (raw)
In-Reply-To: <20090305160714.13755.83435.stgit@Decadence>
This patch moves the event reporting outside the lock section. With
this patch, the creation and update of entries is homogeneous from
the event reporting perspective. Moreover, as the event reporting is
done outside the lock section, the netlink broadcast delivery can
benefit of the yield() call under congestion.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 41 +++++++++++++++++++---------------
1 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index d229370..fa5b23f 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1234,12 +1234,10 @@ ctnetlink_event_report(struct nf_conn *ct, u32 pid, int report)
report);
}
-static int
+static struct nf_conn *
ctnetlink_create_conntrack(struct nlattr *cda[],
struct nf_conntrack_tuple *otuple,
struct nf_conntrack_tuple *rtuple,
- u32 pid,
- int report,
u8 u3)
{
struct nf_conn *ct;
@@ -1248,7 +1246,7 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
ct = nf_conntrack_alloc(&init_net, otuple, rtuple, GFP_ATOMIC);
if (IS_ERR(ct))
- return -ENOMEM;
+ return ERR_PTR(-ENOMEM);
if (!cda[CTA_TIMEOUT])
goto err;
@@ -1371,18 +1369,14 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
ct->master = master_ct;
}
- nf_conntrack_get(&ct->ct_general);
add_timer(&ct->timeout);
nf_conntrack_hash_insert(ct);
rcu_read_unlock();
- ctnetlink_event_report(ct, pid, report);
- nf_ct_put(ct);
-
- return 0;
+ return ct;
err:
nf_conntrack_free(ct);
- return err;
+ return ERR_PTR(err);
}
static int
@@ -1415,14 +1409,25 @@ ctnetlink_new_conntrack(struct sock *ctnl, struct sk_buff *skb,
if (h == NULL) {
err = -ENOENT;
- if (nlh->nlmsg_flags & NLM_F_CREATE)
- err = ctnetlink_create_conntrack(cda,
- &otuple,
- &rtuple,
- NETLINK_CB(skb).pid,
- nlmsg_report(nlh),
- u3);
- spin_unlock_bh(&nf_conntrack_lock);
+ if (nlh->nlmsg_flags & NLM_F_CREATE) {
+ struct nf_conn *ct;
+
+ ct = ctnetlink_create_conntrack(cda, &otuple,
+ &rtuple, u3);
+ if (IS_ERR(ct)) {
+ err = PTR_ERR(ct);
+ goto out_unlock;
+ }
+ err = 0;
+ nf_conntrack_get(&ct->ct_general);
+ spin_unlock_bh(&nf_conntrack_lock);
+ ctnetlink_event_report(ct,
+ NETLINK_CB(skb).pid,
+ nlmsg_report(nlh));
+ nf_ct_put(ct);
+ } else
+ spin_unlock_bh(&nf_conntrack_lock);
+
return err;
}
/* implicit 'else' */
next prev parent reply other threads:[~2009-03-05 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-05 16:07 [PATCH 1/3] netfilter: ctnetlink: cleanup master conntrack assignation Pablo Neira Ayuso
2009-03-05 16:07 ` [PATCH 2/3] netfilter: ctnetlink: cleanup conntrack update preliminary checkings Pablo Neira Ayuso
2009-03-16 14:27 ` Patrick McHardy
2009-03-05 16:07 ` Pablo Neira Ayuso [this message]
2009-03-16 14:23 ` [PATCH 3/3] netfilter: ctnetlink: move event reporting for new entries outside the lock Patrick McHardy
2009-03-16 14:24 ` Patrick McHardy
2009-03-16 14:28 ` Patrick McHardy
2009-03-16 14:26 ` [PATCH 1/3] netfilter: ctnetlink: cleanup master conntrack assignation Patrick McHardy
2009-03-18 16:42 ` Patrick McHardy
2009-03-18 22:26 ` Pablo Neira Ayuso
2009-03-18 22:35 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090305160759.13755.64802.stgit@Decadence \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.