xt_CLASSIFY.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * This is a module which is used for setting the skb->priority field
  4. * of an skb for qdisc classification.
  5. */
  6. /* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/skbuff.h>
  10. #include <linux/ip.h>
  11. #include <net/checksum.h>
  12. #include <linux/netfilter_ipv4.h>
  13. #include <linux/netfilter_ipv6.h>
  14. #include <linux/netfilter/x_tables.h>
  15. #include <linux/netfilter/xt_CLASSIFY.h>
  16. #include <linux/netfilter_arp.h>
  17. MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
  18. MODULE_LICENSE("GPL");
  19. MODULE_DESCRIPTION("Xtables: Qdisc classification");
  20. MODULE_ALIAS("ipt_CLASSIFY");
  21. MODULE_ALIAS("ip6t_CLASSIFY");
  22. MODULE_ALIAS("arpt_CLASSIFY");
  23. static unsigned int
  24. classify_tg(struct sk_buff *skb, const struct xt_action_param *par)
  25. {
  26. const struct xt_classify_target_info *clinfo = par->targinfo;
  27. skb->priority = clinfo->priority;
  28. return XT_CONTINUE;
  29. }
  30. static struct xt_target classify_tg_reg[] __read_mostly = {
  31. {
  32. .name = "CLASSIFY",
  33. .revision = 0,
  34. .family = NFPROTO_UNSPEC,
  35. .hooks = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) |
  36. (1 << NF_INET_POST_ROUTING),
  37. .target = classify_tg,
  38. .targetsize = sizeof(struct xt_classify_target_info),
  39. .me = THIS_MODULE,
  40. },
  41. {
  42. .name = "CLASSIFY",
  43. .revision = 0,
  44. .family = NFPROTO_ARP,
  45. .hooks = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD),
  46. .target = classify_tg,
  47. .targetsize = sizeof(struct xt_classify_target_info),
  48. .me = THIS_MODULE,
  49. },
  50. };
  51. static int __init classify_tg_init(void)
  52. {
  53. return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
  54. }
  55. static void __exit classify_tg_exit(void)
  56. {
  57. xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
  58. }
  59. module_init(classify_tg_init);
  60. module_exit(classify_tg_exit);