aboutsummaryrefslogtreecommitdiffstats
path: root/net/netfilter
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-07-23 08:04:03 -0400
committerPatrick McHardy <kaber@trash.net>2010-07-23 08:04:03 -0400
commitb0c81aa566cccbe26bd99237873fb8428827d82f (patch)
treebd0c7f6528f1f7283dcc3163929b627e6bb1c756 /net/netfilter
parentf667009ecc3304248727236ff88f9070f918355f (diff)
netfilter: xt_quota: use per-rule spin lock
Use per-rule spin lock to improve the scalability. Signed-off-by: Changli Gao <xiaosuo@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net/netfilter')
-rw-r--r--net/netfilter/xt_quota.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/netfilter/xt_quota.c b/net/netfilter/xt_quota.c
index b4f7dfea598..304b1fda1a0 100644
--- a/net/netfilter/xt_quota.c
+++ b/net/netfilter/xt_quota.c
@@ -11,7 +11,8 @@
11#include <linux/netfilter/xt_quota.h> 11#include <linux/netfilter/xt_quota.h>
12 12
13struct xt_quota_priv { 13struct xt_quota_priv {
14 uint64_t quota; 14 spinlock_t lock;
15 uint64_t quota;
15}; 16};
16 17
17MODULE_LICENSE("GPL"); 18MODULE_LICENSE("GPL");
@@ -20,8 +21,6 @@ MODULE_DESCRIPTION("Xtables: countdown quota match");
20MODULE_ALIAS("ipt_quota"); 21MODULE_ALIAS("ipt_quota");
21MODULE_ALIAS("ip6t_quota"); 22MODULE_ALIAS("ip6t_quota");
22 23
23static DEFINE_SPINLOCK(quota_lock);
24
25static bool 24static bool
26quota_mt(const struct sk_buff *skb, struct xt_action_param *par) 25quota_mt(const struct sk_buff *skb, struct xt_action_param *par)
27{ 26{
@@ -29,7 +28,7 @@ quota_mt(const struct sk_buff *skb, struct xt_action_param *par)
29 struct xt_quota_priv *priv = q->master; 28 struct xt_quota_priv *priv = q->master;
30 bool ret = q->flags & XT_QUOTA_INVERT; 29 bool ret = q->flags & XT_QUOTA_INVERT;
31 30
32 spin_lock_bh(&quota_lock); 31 spin_lock_bh(&priv->lock);
33 if (priv->quota >= skb->len) { 32 if (priv->quota >= skb->len) {
34 priv->quota -= skb->len; 33 priv->quota -= skb->len;
35 ret = !ret; 34 ret = !ret;
@@ -39,7 +38,7 @@ quota_mt(const struct sk_buff *skb, struct xt_action_param *par)
39 } 38 }
40 /* Copy quota back to matchinfo so that iptables can display it */ 39 /* Copy quota back to matchinfo so that iptables can display it */
41 q->quota = priv->quota; 40 q->quota = priv->quota;
42 spin_unlock_bh(&quota_lock); 41 spin_unlock_bh(&priv->lock);
43 42
44 return ret; 43 return ret;
45} 44}
@@ -55,6 +54,7 @@ static int quota_mt_check(const struct xt_mtchk_param *par)
55 if (q->master == NULL) 54 if (q->master == NULL)
56 return -ENOMEM; 55 return -ENOMEM;
57 56
57 spin_lock_init(&q->master->lock);
58 q->master->quota = q->quota; 58 q->master->quota = q->quota;
59 return 0; 59 return 0;
60} 60}