blob: fec1aefb1c326b5bdf2fd2446a3b95931c0a4f65 [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>
Patrick McHardy587aa642007-03-14 16:37:25 -07008#include <net/netfilter/nf_conntrack.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Harald Welte2e4e6a12006-01-12 13:30:04 -080010MODULE_LICENSE("GPL");
11MODULE_ALIAS("ipt_NOTRACK");
Jan Engelhardt73aaf932007-10-11 14:36:40 -070012MODULE_ALIAS("ip6t_NOTRACK");
Harald Welte2e4e6a12006-01-12 13:30:04 -080013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014static unsigned int
15target(struct sk_buff **pskb,
16 const struct net_device *in,
17 const struct net_device *out,
18 unsigned int hooknum,
Patrick McHardyc4986732006-03-20 18:02:56 -080019 const struct xt_target *target,
Patrick McHardyfe1cb102006-08-22 00:35:47 -070020 const void *targinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
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
YOSHIFUJI Hideaki601e68e2007-02-12 11:15:49 -080026 /* Attach fake conntrack entry.
27 If there is a real ct entry correspondig to this packet,
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 it'll hang aroun till timing out. We don't deal with it
29 for performance reasons. JK */
Patrick McHardy587aa642007-03-14 16:37:25 -070030 (*pskb)->nfct = &nf_conntrack_untracked.ct_general;
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 McHardy9f15c532007-07-07 22:22:02 -070037static struct xt_target xt_notrack_target[] __read_mostly = {
Patrick McHardy4470bbc2006-08-22 00:34:04 -070038 {
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);