Thomas Gleixner | d2912cb | 2019-06-04 10:11:33 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * This is a module which is used for setting the skb->priority field |
| 4 | * of an skb for qdisc classification. |
| 5 | */ |
| 6 | |
| 7 | /* (C) 2001-2002 Patrick McHardy <kaber@trash.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/skbuff.h> |
| 12 | #include <linux/ip.h> |
| 13 | #include <net/checksum.h> |
| 14 | |
Patrick McHardy | 891350c | 2007-02-12 11:14:43 -0800 | [diff] [blame] | 15 | #include <linux/netfilter_ipv4.h> |
| 16 | #include <linux/netfilter_ipv6.h> |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 17 | #include <linux/netfilter/x_tables.h> |
| 18 | #include <linux/netfilter/xt_CLASSIFY.h> |
Frédéric Leroy | 9811600 | 2010-11-15 13:57:56 +0100 | [diff] [blame] | 19 | #include <linux/netfilter_arp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
| 21 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); |
| 22 | MODULE_LICENSE("GPL"); |
Jan Engelhardt | 2ae15b6 | 2008-01-14 23:42:28 -0800 | [diff] [blame] | 23 | MODULE_DESCRIPTION("Xtables: Qdisc classification"); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 24 | MODULE_ALIAS("ipt_CLASSIFY"); |
Jan Engelhardt | 73aaf93 | 2007-10-11 14:36:40 -0700 | [diff] [blame] | 25 | MODULE_ALIAS("ip6t_CLASSIFY"); |
Frédéric Leroy | 9811600 | 2010-11-15 13:57:56 +0100 | [diff] [blame] | 26 | MODULE_ALIAS("arpt_CLASSIFY"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
| 28 | static unsigned int |
Jan Engelhardt | 4b560b4 | 2009-07-05 19:43:26 +0200 | [diff] [blame] | 29 | classify_tg(struct sk_buff *skb, const struct xt_action_param *par) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
Jan Engelhardt | 7eb3558 | 2008-10-08 11:35:19 +0200 | [diff] [blame] | 31 | const struct xt_classify_target_info *clinfo = par->targinfo; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
Herbert Xu | 3db05fea | 2007-10-15 00:53:15 -0700 | [diff] [blame] | 33 | skb->priority = clinfo->priority; |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 34 | return XT_CONTINUE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
| 36 | |
Frédéric Leroy | 9811600 | 2010-11-15 13:57:56 +0100 | [diff] [blame] | 37 | static struct xt_target classify_tg_reg[] __read_mostly = { |
| 38 | { |
| 39 | .name = "CLASSIFY", |
| 40 | .revision = 0, |
| 41 | .family = NFPROTO_UNSPEC, |
| 42 | .hooks = (1 << NF_INET_LOCAL_OUT) | (1 << NF_INET_FORWARD) | |
| 43 | (1 << NF_INET_POST_ROUTING), |
| 44 | .target = classify_tg, |
| 45 | .targetsize = sizeof(struct xt_classify_target_info), |
| 46 | .me = THIS_MODULE, |
| 47 | }, |
| 48 | { |
| 49 | .name = "CLASSIFY", |
| 50 | .revision = 0, |
| 51 | .family = NFPROTO_ARP, |
| 52 | .hooks = (1 << NF_ARP_OUT) | (1 << NF_ARP_FORWARD), |
| 53 | .target = classify_tg, |
| 54 | .targetsize = sizeof(struct xt_classify_target_info), |
| 55 | .me = THIS_MODULE, |
| 56 | }, |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 57 | }; |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 58 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 59 | static int __init classify_tg_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | { |
Frédéric Leroy | 9811600 | 2010-11-15 13:57:56 +0100 | [diff] [blame] | 61 | return xt_register_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 64 | static void __exit classify_tg_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
Frédéric Leroy | 9811600 | 2010-11-15 13:57:56 +0100 | [diff] [blame] | 66 | xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 69 | module_init(classify_tg_init); |
| 70 | module_exit(classify_tg_exit); |