Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[linux-block.git] / net / netfilter / xt_NOTRACK.c
CommitLineData
1da177e4
LT
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
2e4e6a17 7#include <linux/netfilter/x_tables.h>
9fb9cbb1 8#include <net/netfilter/nf_conntrack_compat.h>
1da177e4 9
2e4e6a17
HW
10MODULE_LICENSE("GPL");
11MODULE_ALIAS("ipt_NOTRACK");
12
1da177e4
LT
13static unsigned int
14target(struct sk_buff **pskb,
15 const struct net_device *in,
16 const struct net_device *out,
17 unsigned int hooknum,
c4986734 18 const struct xt_target *target,
1da177e4
LT
19 const void *targinfo,
20 void *userinfo)
21{
22 /* Previously seen (loopback)? Ignore. */
23 if ((*pskb)->nfct != NULL)
2e4e6a17 24 return XT_CONTINUE;
1da177e4
LT
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 */
9fb9cbb1 30 nf_ct_untrack(*pskb);
1da177e4
LT
31 (*pskb)->nfctinfo = IP_CT_NEW;
32 nf_conntrack_get((*pskb)->nfct);
33
2e4e6a17 34 return XT_CONTINUE;
1da177e4
LT
35}
36
5d04bff0
PM
37static struct xt_target notrack_reg = {
38 .name = "NOTRACK",
39 .target = target,
40 .targetsize = 0,
41 .table = "raw",
a45049c5 42 .family = AF_INET,
5d04bff0 43 .me = THIS_MODULE,
2e4e6a17 44};
5d04bff0
PM
45
46static struct xt_target notrack6_reg = {
47 .name = "NOTRACK",
48 .target = target,
49 .targetsize = 0,
50 .table = "raw",
a45049c5 51 .family = AF_INET6,
5d04bff0 52 .me = THIS_MODULE,
1da177e4
LT
53};
54
65b4b4e8 55static int __init xt_notrack_init(void)
1da177e4 56{
2e4e6a17
HW
57 int ret;
58
a45049c5 59 ret = xt_register_target(&notrack_reg);
2e4e6a17
HW
60 if (ret)
61 return ret;
1da177e4 62
a45049c5 63 ret = xt_register_target(&notrack6_reg);
2e4e6a17 64 if (ret)
a45049c5 65 xt_unregister_target(&notrack_reg);
2e4e6a17
HW
66
67 return ret;
1da177e4
LT
68}
69
65b4b4e8 70static void __exit xt_notrack_fini(void)
1da177e4 71{
a45049c5
PNA
72 xt_unregister_target(&notrack6_reg);
73 xt_unregister_target(&notrack_reg);
1da177e4
LT
74}
75
65b4b4e8
AM
76module_init(xt_notrack_init);
77module_exit(xt_notrack_fini);