From: Gao feng <gaofeng@cn.fujitsu.com>
To: netfilter-devel@vger.kernel.org
Cc: Gao feng <gaofeng@cn.fujitsu.com>
Subject: [PATCH 2/2] netfilter: ipt_ULOG: make spinlock per nlgroup
Date: Tue, 5 Feb 2013 10:48:37 +0800 [thread overview]
Message-ID: <1360032517-3785-1-git-send-email-gaofeng@cn.fujitsu.com> (raw)
In-Reply-To: <1360029450-6673-1-git-send-email-gaofeng@cn.fujitsu.com>
This patch uses the spin lock per group instead of
global spin lock,just like ebt_ulog.
Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
---
net/ipv4/netfilter/ipt_ULOG.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
index b390002..09a03e4 100644
--- a/net/ipv4/netfilter/ipt_ULOG.c
+++ b/net/ipv4/netfilter/ipt_ULOG.c
@@ -76,12 +76,12 @@ typedef struct {
struct nlmsghdr *lastnlh; /* netlink header of last msg in skb */
struct sk_buff *skb; /* the pre-allocated skb */
struct timer_list timer; /* the timer function */
+ spinlock_t lock; /* the pre-queue lock */
} ulog_buff_t;
static ulog_buff_t ulog_buffers[ULOG_MAXNLGROUPS]; /* array of buffers */
static struct sock *nflognl; /* our socket */
-static DEFINE_SPINLOCK(ulog_lock); /* spinlock */
/* send one ulog_buff_t to userspace */
static void ulog_send(unsigned int nlgroupnum)
@@ -120,9 +120,9 @@ static void ulog_timer(unsigned long data)
/* lock to protect against somebody modifying our structure
* from ipt_ulog_target at the same time */
- spin_lock_bh(&ulog_lock);
+ spin_lock_bh(&ulog_buffers[data].lock);
ulog_send(data);
- spin_unlock_bh(&ulog_lock);
+ spin_unlock_bh(&ulog_buffers[data].lock);
}
static struct sk_buff *ulog_alloc_skb(unsigned int size)
@@ -178,7 +178,7 @@ static void ipt_ulog_packet(unsigned int hooknum,
ub = &ulog_buffers[groupnum];
- spin_lock_bh(&ulog_lock);
+ spin_lock_bh(&ub->lock);
if (!ub->skb) {
if (!(ub->skb = ulog_alloc_skb(size)))
@@ -265,13 +265,13 @@ static void ipt_ulog_packet(unsigned int hooknum,
ulog_send(groupnum);
}
out_unlock:
- spin_unlock_bh(&ulog_lock);
+ spin_unlock_bh(&ub->lock);
return;
alloc_failure:
pr_debug("Error building netlink message\n");
- spin_unlock_bh(&ulog_lock);
+ spin_unlock_bh(&ub->lock);
}
static unsigned int
@@ -393,8 +393,10 @@ static int __init ulog_tg_init(void)
}
/* initialize ulog_buffers */
- for (i = 0; i < ULOG_MAXNLGROUPS; i++)
+ for (i = 0; i < ULOG_MAXNLGROUPS; i++) {
setup_timer(&ulog_buffers[i].timer, ulog_timer, i);
+ spin_lock_init(&ulog_buffers[i].lock);
+ }
nflognl = netlink_kernel_create(&init_net, NETLINK_NFLOG, &cfg);
if (!nflognl)
@@ -430,12 +432,12 @@ static void __exit ulog_tg_exit(void)
pr_debug("timer was pending, deleting\n");
del_timer(&ub->timer);
}
- spin_lock_bh(&ulog_lock);
+ spin_lock_bh(&ub->lock);
if (ub->skb) {
kfree_skb(ub->skb);
ub->skb = NULL;
}
- spin_unlock_bh(&ulog_lock);
+ spin_unlock_bh(&ub->lock);
}
}
--
1.7.11.7
next prev parent reply other threads:[~2013-02-05 2:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-05 1:57 [PATCH] ulog: add protection when remove ipt_ULOG Gao feng
2013-02-05 2:48 ` Gao feng [this message]
2013-03-15 11:51 ` [PATCH 2/2] netfilter: ipt_ULOG: make spinlock per nlgroup Pablo Neira Ayuso
2013-03-18 9:11 ` Gao feng
2013-02-07 18:27 ` [PATCH] ulog: add protection when remove ipt_ULOG Pablo Neira Ayuso
2013-02-18 3:57 ` Gao feng
2013-02-18 16:52 ` Pablo Neira Ayuso
2013-02-19 1:09 ` Gao feng
2013-03-15 11:49 ` Pablo Neira Ayuso
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=1360032517-3785-1-git-send-email-gaofeng@cn.fujitsu.com \
--to=gaofeng@cn.fujitsu.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).