xt_NOTRACK.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include <linux/netfilter/x_tables.h>
  7. #include <net/netfilter/nf_conntrack.h>
  8. MODULE_DESCRIPTION("Xtables: Disabling connection tracking for packets");
  9. MODULE_LICENSE("GPL");
  10. MODULE_ALIAS("ipt_NOTRACK");
  11. MODULE_ALIAS("ip6t_NOTRACK");
  12. static unsigned int
  13. notrack_tg(struct sk_buff *skb, const struct xt_action_param *par)
  14. {
  15. /* Previously seen (loopback)? Ignore. */
  16. if (skb->nfct != NULL)
  17. return XT_CONTINUE;
  18. /* Attach fake conntrack entry.
  19. If there is a real ct entry correspondig to this packet,
  20. it'll hang aroun till timing out. We don't deal with it
  21. for performance reasons. JK */
  22. skb->nfct = &nf_ct_untracked_get()->ct_general;
  23. skb->nfctinfo = IP_CT_NEW;
  24. nf_conntrack_get(skb->nfct);
  25. return XT_CONTINUE;
  26. }
  27. static struct xt_target notrack_tg_reg __read_mostly = {
  28. .name = "NOTRACK",
  29. .revision = 0,
  30. .family = NFPROTO_UNSPEC,
  31. .target = notrack_tg,
  32. .table = "raw",
  33. .me = THIS_MODULE,
  34. };
  35. static int __init notrack_tg_init(void)
  36. {
  37. return xt_register_target(&notrack_tg_reg);
  38. }
  39. static void __exit notrack_tg_exit(void)
  40. {
  41. xt_unregister_target(&notrack_tg_reg);
  42. }
  43. module_init(notrack_tg_init);
  44. module_exit(notrack_tg_exit);