blob: cab881d4424ca59d01f0fd9428527fd37ea7f7c4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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
Harald Welte2e4e6a12006-01-12 13:30:04 -08007#include <linux/netfilter/x_tables.h>
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -08008#include <net/netfilter/nf_conntrack_compat.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Harald Welte2e4e6a12006-01-12 13:30:04 -080010MODULE_LICENSE("GPL");
11MODULE_ALIAS("ipt_NOTRACK");
12
Linus Torvalds1da177e2005-04-16 15:20:36 -070013static unsigned int
14target(struct sk_buff **pskb,
15 const struct net_device *in,
16 const struct net_device *out,
17 unsigned int hooknum,
Patrick McHardyc4986732006-03-20 18:02:56 -080018 const struct xt_target *target,
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 const void *targinfo,
20 void *userinfo)
21{
22 /* Previously seen (loopback)? Ignore. */
23 if ((*pskb)->nfct != NULL)
Harald Welte2e4e6a12006-01-12 13:30:04 -080024 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
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 */
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080030 nf_ct_untrack(*pskb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 (*pskb)->nfctinfo = IP_CT_NEW;
32 nf_conntrack_get((*pskb)->nfct);
33
Harald Welte2e4e6a12006-01-12 13:30:04 -080034 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035}
36
Patrick McHardy4470bbc2006-08-22 00:34:04 -070037static struct xt_target xt_notrack_target[] = {
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 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070052};
53
Andrew Morton65b4b4e2006-03-28 16:37:06 -080054static int __init xt_notrack_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
Patrick McHardy4470bbc2006-08-22 00:34:04 -070056 return xt_register_targets(xt_notrack_target,
57 ARRAY_SIZE(xt_notrack_target));
Linus Torvalds1da177e2005-04-16 15:20:36 -070058}
59
Andrew Morton65b4b4e2006-03-28 16:37:06 -080060static void __exit xt_notrack_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061{
Patrick McHardy4470bbc2006-08-22 00:34:04 -070062 xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
Linus Torvalds1da177e2005-04-16 15:20:36 -070063}
64
Andrew Morton65b4b4e2006-03-28 16:37:06 -080065module_init(xt_notrack_init);
66module_exit(xt_notrack_fini);