2 +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
4 +#ifndef _IPT_CLASSIFY_H
5 +#define _IPT_CLASSIFY_H
7 +struct ipt_classify_target_info {
11 +#endif /*_IPT_CLASSIFY_H */
12 --- a/net/ipv4/netfilter/Config.in
13 +++ b/net/ipv4/netfilter/Config.in
14 @@ -171,6 +171,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ];
15 dep_tristate ' DSCP target support' CONFIG_IP_NF_TARGET_DSCP $CONFIG_IP_NF_MANGLE
17 dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE
18 + dep_tristate ' CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE
19 dep_tristate ' IMQ target support' CONFIG_IP_NF_TARGET_IMQ $CONFIG_IP_NF_MANGLE
21 if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then
23 +++ b/net/ipv4/netfilter/ipt_CLASSIFY.c
26 + * This is a module which is used for setting the skb->priority field
27 + * of an skb for qdisc classification.
30 +#include <linux/module.h>
31 +#include <linux/skbuff.h>
32 +#include <linux/ip.h>
33 +#include <net/checksum.h>
35 +#include <linux/netfilter_ipv4/ip_tables.h>
36 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
38 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
39 +MODULE_LICENSE("GPL");
40 +MODULE_DESCRIPTION("iptables qdisc classification target module");
43 +target(struct sk_buff **pskb,
44 + unsigned int hooknum,
45 + const struct net_device *in,
46 + const struct net_device *out,
47 + const void *targinfo,
50 + const struct ipt_classify_target_info *clinfo = targinfo;
52 + if((*pskb)->priority != clinfo->priority) {
53 + (*pskb)->priority = clinfo->priority;
54 + (*pskb)->nfcache |= NFC_ALTERED;
57 + return IPT_CONTINUE;
61 +checkentry(const char *tablename,
62 + const struct ipt_entry *e,
64 + unsigned int targinfosize,
65 + unsigned int hook_mask)
67 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
68 + printk(KERN_ERR "CLASSIFY: invalid size (%u != %u).\n",
70 + IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
74 + if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
75 + printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
79 + if (strcmp(tablename, "mangle") != 0) {
80 + printk(KERN_WARNING "CLASSIFY: can only be called from "
81 + "\"mangle\" table, not \"%s\".\n",
89 +static struct ipt_target ipt_classify_reg
90 += { { NULL, NULL }, "CLASSIFY", target, checkentry, NULL, THIS_MODULE };
92 +static int __init init(void)
94 + if (ipt_register_target(&ipt_classify_reg))
100 +static void __exit fini(void)
102 + ipt_unregister_target(&ipt_classify_reg);
107 --- a/net/ipv4/netfilter/Makefile
108 +++ b/net/ipv4/netfilter/Makefile
109 @@ -133,6 +133,7 @@ obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_
112 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
113 +obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
114 obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o
115 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
116 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o