ia64/linux-2.6.18-xen.hg

view net/netfilter/xt_quota.c @ 871:9cbcc9008446

xen/x86: don't initialize cpu_data[]'s apicid field on generic code

Afaict, this is not only redundant with the intialization done in
drivers/xen/core/smpboot.c, but actually results - at least for
secondary CPUs - in the Xen-specific value written to be later
overwritten with whatever the generic code determines (with no
guarantee that the two values are identical).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu May 14 10:09:15 2009 +0100 (2009-05-14)
parents 831230e53067
children
line source
1 /*
2 * netfilter module to enforce network quotas
3 *
4 * Sam Johnston <samj@samj.net>
5 */
6 #include <linux/skbuff.h>
7 #include <linux/spinlock.h>
9 #include <linux/netfilter/x_tables.h>
10 #include <linux/netfilter/xt_quota.h>
12 MODULE_LICENSE("GPL");
13 MODULE_AUTHOR("Sam Johnston <samj@samj.net>");
14 MODULE_ALIAS("ipt_quota");
15 MODULE_ALIAS("ip6t_quota");
17 static DEFINE_SPINLOCK(quota_lock);
19 static int
20 match(const struct sk_buff *skb,
21 const struct net_device *in, const struct net_device *out,
22 const struct xt_match *match, const void *matchinfo,
23 int offset, unsigned int protoff, int *hotdrop)
24 {
25 struct xt_quota_info *q = ((struct xt_quota_info *)matchinfo)->master;
26 int ret = q->flags & XT_QUOTA_INVERT ? 1 : 0;
28 spin_lock_bh(&quota_lock);
29 if (q->quota >= skb->len) {
30 q->quota -= skb->len;
31 ret ^= 1;
32 } else {
33 /* we do not allow even small packets from now on */
34 q->quota = 0;
35 }
36 spin_unlock_bh(&quota_lock);
38 return ret;
39 }
41 static int
42 checkentry(const char *tablename, const void *entry,
43 const struct xt_match *match, void *matchinfo,
44 unsigned int matchsize, unsigned int hook_mask)
45 {
46 struct xt_quota_info *q = (struct xt_quota_info *)matchinfo;
48 if (q->flags & ~XT_QUOTA_MASK)
49 return 0;
50 /* For SMP, we only want to use one set of counters. */
51 q->master = q;
52 return 1;
53 }
55 static struct xt_match quota_match = {
56 .name = "quota",
57 .family = AF_INET,
58 .match = match,
59 .matchsize = sizeof(struct xt_quota_info),
60 .checkentry = checkentry,
61 .me = THIS_MODULE
62 };
64 static struct xt_match quota_match6 = {
65 .name = "quota",
66 .family = AF_INET6,
67 .match = match,
68 .matchsize = sizeof(struct xt_quota_info),
69 .checkentry = checkentry,
70 .me = THIS_MODULE
71 };
73 static int __init xt_quota_init(void)
74 {
75 int ret;
77 ret = xt_register_match(&quota_match);
78 if (ret)
79 goto err1;
80 ret = xt_register_match(&quota_match6);
81 if (ret)
82 goto err2;
83 return ret;
85 err2:
86 xt_unregister_match(&quota_match);
87 err1:
88 return ret;
89 }
91 static void __exit xt_quota_fini(void)
92 {
93 xt_unregister_match(&quota_match6);
94 xt_unregister_match(&quota_match);
95 }
97 module_init(xt_quota_init);
98 module_exit(xt_quota_fini);