netfilter: xtables: move extension arguments into compound structure (4/6)
[safe/jmp/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_DESCRIPTION("Xtables: Disabling connection tracking for packets");
11 MODULE_LICENSE("GPL");
12 MODULE_ALIAS("ipt_NOTRACK");
13 MODULE_ALIAS("ip6t_NOTRACK");
14
15 static unsigned int
16 notrack_tg(struct sk_buff *skb, const struct xt_target_param *par)
17 {
18         /* Previously seen (loopback)? Ignore. */
19         if (skb->nfct != NULL)
20                 return XT_CONTINUE;
21
22         /* Attach fake conntrack entry.
23            If there is a real ct entry correspondig to this packet,
24            it'll hang aroun till timing out. We don't deal with it
25            for performance reasons. JK */
26         skb->nfct = &nf_conntrack_untracked.ct_general;
27         skb->nfctinfo = IP_CT_NEW;
28         nf_conntrack_get(skb->nfct);
29
30         return XT_CONTINUE;
31 }
32
33 static struct xt_target notrack_tg_reg[] __read_mostly = {
34         {
35                 .name           = "NOTRACK",
36                 .family         = NFPROTO_IPV4,
37                 .target         = notrack_tg,
38                 .table          = "raw",
39                 .me             = THIS_MODULE,
40         },
41         {
42                 .name           = "NOTRACK",
43                 .family         = NFPROTO_IPV6,
44                 .target         = notrack_tg,
45                 .table          = "raw",
46                 .me             = THIS_MODULE,
47         },
48 };
49
50 static int __init notrack_tg_init(void)
51 {
52         return xt_register_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg));
53 }
54
55 static void __exit notrack_tg_exit(void)
56 {
57         xt_unregister_targets(notrack_tg_reg, ARRAY_SIZE(notrack_tg_reg));
58 }
59
60 module_init(notrack_tg_init);
61 module_exit(notrack_tg_exit);