blob: 6d00dcaed2385b4dfddbcab61b37bef2a90d59ea [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,
Patrick McHardyfe1cb102006-08-22 00:35:47 -070019 const void *targinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
21 /* Previously seen (loopback)? Ignore. */
22 if ((*pskb)->nfct != NULL)
Harald Welte2e4e6a12006-01-12 13:30:04 -080023 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
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 */
Yasuyuki Kozakai9fb9cbb2005-11-09 16:38:16 -080029 nf_ct_untrack(*pskb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 (*pskb)->nfctinfo = IP_CT_NEW;
31 nf_conntrack_get((*pskb)->nfct);
32
Harald Welte2e4e6a12006-01-12 13:30:04 -080033 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
35
Patrick McHardy4470bbc2006-08-22 00:34:04 -070036static struct xt_target xt_notrack_target[] = {
37 {
38 .name = "NOTRACK",
39 .family = AF_INET,
40 .target = target,
41 .table = "raw",
42 .me = THIS_MODULE,
43 },
44 {
45 .name = "NOTRACK",
46 .family = AF_INET6,
47 .target = target,
48 .table = "raw",
49 .me = THIS_MODULE,
50 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070051};
52
Andrew Morton65b4b4e2006-03-28 16:37:06 -080053static int __init xt_notrack_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054{
Patrick McHardy4470bbc2006-08-22 00:34:04 -070055 return xt_register_targets(xt_notrack_target,
56 ARRAY_SIZE(xt_notrack_target));
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
58
Andrew Morton65b4b4e2006-03-28 16:37:06 -080059static void __exit xt_notrack_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Patrick McHardy4470bbc2006-08-22 00:34:04 -070061 xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
Linus Torvalds1da177e2005-04-16 15:20:36 -070062}
63
Andrew Morton65b4b4e2006-03-28 16:37:06 -080064module_init(xt_notrack_init);
65module_exit(xt_notrack_fini);