]> bbs.cooldavid.org Git - net-next-2.6.git/blame - net/netfilter/xt_NOTRACK.c
[NETFILTER]: Avoid skb_copy/pskb_copy/skb_realloc_headroom
[net-next-2.6.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>
587aa641 8#include <net/netfilter/nf_conntrack.h>
1da177e4 9
2e4e6a17
HW
10MODULE_LICENSE("GPL");
11MODULE_ALIAS("ipt_NOTRACK");
73aaf935 12MODULE_ALIAS("ip6t_NOTRACK");
2e4e6a17 13
1da177e4
LT
14static unsigned int
15target(struct sk_buff **pskb,
16 const struct net_device *in,
17 const struct net_device *out,
18 unsigned int hooknum,
c4986734 19 const struct xt_target *target,
fe1cb108 20 const void *targinfo)
1da177e4
LT
21{
22 /* Previously seen (loopback)? Ignore. */
23 if ((*pskb)->nfct != NULL)
2e4e6a17 24 return XT_CONTINUE;
1da177e4 25
601e68e1
YH
26 /* Attach fake conntrack entry.
27 If there is a real ct entry correspondig to this packet,
1da177e4
LT
28 it'll hang aroun till timing out. We don't deal with it
29 for performance reasons. JK */
587aa641 30 (*pskb)->nfct = &nf_conntrack_untracked.ct_general;
1da177e4
LT
31 (*pskb)->nfctinfo = IP_CT_NEW;
32 nf_conntrack_get((*pskb)->nfct);
33
2e4e6a17 34 return XT_CONTINUE;
1da177e4
LT
35}
36
9f15c530 37static struct xt_target xt_notrack_target[] __read_mostly = {
4470bbc7
PM
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 },
1da177e4
LT
52};
53
65b4b4e8 54static int __init xt_notrack_init(void)
1da177e4 55{
4470bbc7
PM
56 return xt_register_targets(xt_notrack_target,
57 ARRAY_SIZE(xt_notrack_target));
1da177e4
LT
58}
59
65b4b4e8 60static void __exit xt_notrack_fini(void)
1da177e4 61{
4470bbc7 62 xt_unregister_targets(xt_notrack_target, ARRAY_SIZE(xt_notrack_target));
1da177e4
LT
63}
64
65b4b4e8
AM
65module_init(xt_notrack_init);
66module_exit(xt_notrack_fini);