blob: 77a52bf83225db48f8eaceda0362af0f4cd47dff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This is a module which is used for setting the skb->priority field
3 * of an skb for qdisc classification.
4 */
5
6/* (C) 2001-2002 Patrick McHardy <kaber@trash.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/skbuff.h>
15#include <linux/ip.h>
16#include <net/checksum.h>
17
Patrick McHardy891350c2007-02-12 11:14:43 -080018#include <linux/netfilter_ipv4.h>
19#include <linux/netfilter_ipv6.h>
Harald Welte2e4e6a12006-01-12 13:30:04 -080020#include <linux/netfilter/x_tables.h>
21#include <linux/netfilter/xt_CLASSIFY.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
24MODULE_LICENSE("GPL");
Jan Engelhardt2ae15b62008-01-14 23:42:28 -080025MODULE_DESCRIPTION("Xtables: Qdisc classification");
Harald Welte2e4e6a12006-01-12 13:30:04 -080026MODULE_ALIAS("ipt_CLASSIFY");
Jan Engelhardt73aaf932007-10-11 14:36:40 -070027MODULE_ALIAS("ip6t_CLASSIFY");
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29static unsigned int
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080030classify_tg(struct sk_buff *skb, const struct net_device *in,
31 const struct net_device *out, unsigned int hooknum,
32 const struct xt_target *target, const void *targinfo)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Harald Welte2e4e6a12006-01-12 13:30:04 -080034 const struct xt_classify_target_info *clinfo = targinfo;
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Herbert Xu3db05fe2007-10-15 00:53:15 -070036 skb->priority = clinfo->priority;
Harald Welte2e4e6a12006-01-12 13:30:04 -080037 return XT_CONTINUE;
Linus Torvalds1da177e2005-04-16 15:20:36 -070038}
39
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080040static struct xt_target classify_tg_reg[] __read_mostly = {
Patrick McHardy4470bbc2006-08-22 00:34:04 -070041 {
42 .family = AF_INET,
43 .name = "CLASSIFY",
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080044 .target = classify_tg,
Patrick McHardy4470bbc2006-08-22 00:34:04 -070045 .targetsize = sizeof(struct xt_classify_target_info),
46 .table = "mangle",
Patrick McHardy6e23ae22007-11-19 18:53:30 -080047 .hooks = (1 << NF_INET_LOCAL_OUT) |
48 (1 << NF_INET_FORWARD) |
49 (1 << NF_INET_POST_ROUTING),
Patrick McHardy4470bbc2006-08-22 00:34:04 -070050 .me = THIS_MODULE,
51 },
52 {
53 .name = "CLASSIFY",
54 .family = AF_INET6,
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080055 .target = classify_tg,
Patrick McHardy4470bbc2006-08-22 00:34:04 -070056 .targetsize = sizeof(struct xt_classify_target_info),
57 .table = "mangle",
Patrick McHardy6e23ae22007-11-19 18:53:30 -080058 .hooks = (1 << NF_INET_LOCAL_OUT) |
59 (1 << NF_INET_FORWARD) |
60 (1 << NF_INET_POST_ROUTING),
Patrick McHardy4470bbc2006-08-22 00:34:04 -070061 .me = THIS_MODULE,
62 },
Harald Welte2e4e6a12006-01-12 13:30:04 -080063};
Harald Welte2e4e6a12006-01-12 13:30:04 -080064
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080065static int __init classify_tg_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066{
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080067 return xt_register_targets(classify_tg_reg,
68 ARRAY_SIZE(classify_tg_reg));
Linus Torvalds1da177e2005-04-16 15:20:36 -070069}
70
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080071static void __exit classify_tg_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080073 xt_unregister_targets(classify_tg_reg, ARRAY_SIZE(classify_tg_reg));
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
Jan Engelhardtd3c5ee62007-12-04 23:24:03 -080076module_init(classify_tg_init);
77module_exit(classify_tg_exit);