[PATCH] fix build on x86_64 with !CONFIG_HOTPLUG_CPU
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / net / netfilter / xt_NOTRACK.c
blob24d477afa9398b2e92d1cf3c29e79960bef7ebbd
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>
7 #include <linux/netfilter/x_tables.h>
8 #include <net/netfilter/nf_conntrack_compat.h>
10 MODULE_LICENSE("GPL");
11 MODULE_ALIAS("ipt_NOTRACK");
13 static unsigned int
14 target(struct sk_buff **pskb,
15 const struct net_device *in,
16 const struct net_device *out,
17 unsigned int hooknum,
18 const void *targinfo,
19 void *userinfo)
21 /* Previously seen (loopback)? Ignore. */
22 if ((*pskb)->nfct != NULL)
23 return XT_CONTINUE;
25 /* Attach fake conntrack entry.
26 If there is a real ct entry correspondig to this packet,
27 it'll hang aroun till timing out. We don't deal with it
28 for performance reasons. JK */
29 nf_ct_untrack(*pskb);
30 (*pskb)->nfctinfo = IP_CT_NEW;
31 nf_conntrack_get((*pskb)->nfct);
33 return XT_CONTINUE;
36 static int
37 checkentry(const char *tablename,
38 const void *entry,
39 void *targinfo,
40 unsigned int targinfosize,
41 unsigned int hook_mask)
43 if (targinfosize != 0) {
44 printk(KERN_WARNING "NOTRACK: targinfosize %u != 0\n",
45 targinfosize);
46 return 0;
49 if (strcmp(tablename, "raw") != 0) {
50 printk(KERN_WARNING "NOTRACK: can only be called from \"raw\" table, not \"%s\"\n", tablename);
51 return 0;
54 return 1;
57 static struct xt_target notrack_reg = {
58 .name = "NOTRACK",
59 .target = target,
60 .checkentry = checkentry,
61 .me = THIS_MODULE,
63 static struct xt_target notrack6_reg = {
64 .name = "NOTRACK",
65 .target = target,
66 .checkentry = checkentry,
67 .me = THIS_MODULE,
70 static int __init init(void)
72 int ret;
74 ret = xt_register_target(AF_INET, &notrack_reg);
75 if (ret)
76 return ret;
78 ret = xt_register_target(AF_INET6, &notrack6_reg);
79 if (ret)
80 xt_unregister_target(AF_INET, &notrack_reg);
82 return ret;
85 static void __exit fini(void)
87 xt_unregister_target(AF_INET6, &notrack6_reg);
88 xt_unregister_target(AF_INET, &notrack_reg);
91 module_init(init);
92 module_exit(fini);