Pull cpuidle into release branch
[linux-2.6] / net / netfilter / xt_NOTRACK.c
1 /* This is a module which is used for setting up fake conntracks
2  * on packets so that they are not seen by the conntrack/NAT code.
3  */
4 #include <linux/module.h>
5 #include <linux/skbuff.h>
6
7 #include <linux/netfilter/x_tables.h>
8 #include <net/netfilter/nf_conntrack.h>
9
10 MODULE_LICENSE("GPL");
11 MODULE_ALIAS("ipt_NOTRACK");
12 MODULE_ALIAS("ip6t_NOTRACK");
13
14 static unsigned int
15 target(struct sk_buff *skb,
16        const struct net_device *in,
17        const struct net_device *out,
18        unsigned int hooknum,
19        const struct xt_target *target,
20        const void *targinfo)
21 {
22         /* Previously seen (loopback)? Ignore. */
23         if (skb->nfct != NULL)
24                 return XT_CONTINUE;
25
26         /* Attach fake conntrack entry.
27            If there is a real ct entry correspondig to this packet,
28            it'll hang aroun till timing out. We don't deal with it
29            for performance reasons. JK */
30         skb->nfct = &nf_conntrack_untracked.ct_general;
31         skb->nfctinfo = IP_CT_NEW;
32         nf_conntrack_get(skb->nfct);
33
34         return XT_CONTINUE;
35 }
36
37 static struct xt_target xt_notrack_target[] __read_mostly = {
38         {
39                 .name           = "NOTRACK",
40                 .family         = AF_INET,
41                 .target         = target,
42                 .table          = "raw",
43                 .me             = THIS_MODULE,
44         },
45         {
46                 .name           = "NOTRACK",
47                 .family         = AF_INET6,
48                 .target         = target,
49                 .table          = "raw",
50                 .me             = THIS_MODULE,
51         },
52 };
53
54 static int __init xt_notrack_init(void)
55 {
56         return xt_register_targets(xt_notrack_target,
57                                    ARRAY_SIZE(xt_notrack_target));
58 }
59
60 static void __exit xt_notrack_fini(void)
61 {
62         xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
63 }
64
65 module_init(xt_notrack_init);
66 module_exit(xt_notrack_fini);