X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=net%2Fnetfilter%2Fxt_NOTRACK.c;fp=net%2Fnetfilter%2Fxt_NOTRACK.c;h=98f4b5363ce8e8e4adcce549cfe63119c24db610;hb=16cf0ec7408f389279d413869e94c1a351392f97;hp=0000000000000000000000000000000000000000;hpb=65da6b7c3bf0bd6a149128079565e5f4efec28ac;p=linux-2.6.git diff --git a/net/netfilter/xt_NOTRACK.c b/net/netfilter/xt_NOTRACK.c new file mode 100644 index 000000000..98f4b5363 --- /dev/null +++ b/net/netfilter/xt_NOTRACK.c @@ -0,0 +1,77 @@ +/* This is a module which is used for setting up fake conntracks + * on packets so that they are not seen by the conntrack/NAT code. + */ +#include +#include + +#include +#include + +MODULE_LICENSE("GPL"); +MODULE_ALIAS("ipt_NOTRACK"); + +static unsigned int +target(struct sk_buff **pskb, + const struct net_device *in, + const struct net_device *out, + unsigned int hooknum, + const struct xt_target *target, + const void *targinfo, + void *userinfo) +{ + /* Previously seen (loopback)? Ignore. */ + if ((*pskb)->nfct != NULL) + return XT_CONTINUE; + + /* Attach fake conntrack entry. + If there is a real ct entry correspondig to this packet, + it'll hang aroun till timing out. We don't deal with it + for performance reasons. JK */ + nf_ct_untrack(*pskb); + (*pskb)->nfctinfo = IP_CT_NEW; + nf_conntrack_get((*pskb)->nfct); + + return XT_CONTINUE; +} + +static struct xt_target notrack_reg = { + .name = "NOTRACK", + .target = target, + .targetsize = 0, + .table = "raw", + .family = AF_INET, + .me = THIS_MODULE, +}; + +static struct xt_target notrack6_reg = { + .name = "NOTRACK", + .target = target, + .targetsize = 0, + .table = "raw", + .family = AF_INET6, + .me = THIS_MODULE, +}; + +static int __init xt_notrack_init(void) +{ + int ret; + + ret = xt_register_target(¬rack_reg); + if (ret) + return ret; + + ret = xt_register_target(¬rack6_reg); + if (ret) + xt_unregister_target(¬rack_reg); + + return ret; +} + +static void __exit xt_notrack_fini(void) +{ + xt_unregister_target(¬rack6_reg); + xt_unregister_target(¬rack_reg); +} + +module_init(xt_notrack_init); +module_exit(xt_notrack_fini);