merge 3G usb serial card patches and move it at 802
[openwrt/svn-archive/archive.git] / target / linux / generic-2.4 / patches / 619-netfilter_classify.patch
1 diff -uprN linux-2.4.32.reference/include/linux/netfilter_ipv4/ipt_CLASSIFY.h linux-2.4.32/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
2 --- linux-2.4.32.reference/include/linux/netfilter_ipv4/ipt_CLASSIFY.h 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.4.32/include/linux/netfilter_ipv4/ipt_CLASSIFY.h 2006-08-17 12:33:08.000000000 +0200
4 @@ -0,0 +1,8 @@
5 +#ifndef _IPT_CLASSIFY_H
6 +#define _IPT_CLASSIFY_H
7 +
8 +struct ipt_classify_target_info {
9 + u_int32_t priority;
10 +};
11 +
12 +#endif /*_IPT_CLASSIFY_H */
13 diff -uprN linux-2.4.32.reference/net/ipv4/netfilter/Config.in linux-2.4.32/net/ipv4/netfilter/Config.in
14 --- linux-2.4.32.reference/net/ipv4/netfilter/Config.in 2006-08-17 12:28:16.000000000 +0200
15 +++ linux-2.4.32/net/ipv4/netfilter/Config.in 2006-08-17 12:33:08.000000000 +0200
16 @@ -172,6 +172,7 @@ if [ "$CONFIG_IP_NF_IPTABLES" != "n" ];
17 dep_tristate ' DSCP target support' CONFIG_IP_NF_TARGET_DSCP $CONFIG_IP_NF_MANGLE
18
19 dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE
20 + dep_tristate ' CLASSIFY target support (EXPERIMENTAL)' CONFIG_IP_NF_TARGET_CLASSIFY $CONFIG_IP_NF_MANGLE
21 dep_tristate ' IMQ target support' CONFIG_IP_NF_TARGET_IMQ $CONFIG_IP_NF_MANGLE
22 fi
23 if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then
24 diff -uprN linux-2.4.32.reference/net/ipv4/netfilter/ipt_CLASSIFY.c linux-2.4.32/net/ipv4/netfilter/ipt_CLASSIFY.c
25 --- linux-2.4.32.reference/net/ipv4/netfilter/ipt_CLASSIFY.c 1970-01-01 01:00:00.000000000 +0100
26 +++ linux-2.4.32/net/ipv4/netfilter/ipt_CLASSIFY.c 2006-08-17 12:33:08.000000000 +0200
27 @@ -0,0 +1,82 @@
28 +/*
29 + * This is a module which is used for setting the skb->priority field
30 + * of an skb for qdisc classification.
31 + */
32 +
33 +#include <linux/module.h>
34 +#include <linux/skbuff.h>
35 +#include <linux/ip.h>
36 +#include <net/checksum.h>
37 +
38 +#include <linux/netfilter_ipv4/ip_tables.h>
39 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
40 +
41 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
42 +MODULE_LICENSE("GPL");
43 +MODULE_DESCRIPTION("iptables qdisc classification target module");
44 +
45 +static unsigned int
46 +target(struct sk_buff **pskb,
47 + unsigned int hooknum,
48 + const struct net_device *in,
49 + const struct net_device *out,
50 + const void *targinfo,
51 + void *userinfo)
52 +{
53 + const struct ipt_classify_target_info *clinfo = targinfo;
54 +
55 + if((*pskb)->priority != clinfo->priority) {
56 + (*pskb)->priority = clinfo->priority;
57 + (*pskb)->nfcache |= NFC_ALTERED;
58 + }
59 +
60 + return IPT_CONTINUE;
61 +}
62 +
63 +static int
64 +checkentry(const char *tablename,
65 + const struct ipt_entry *e,
66 + void *targinfo,
67 + unsigned int targinfosize,
68 + unsigned int hook_mask)
69 +{
70 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
71 + printk(KERN_ERR "CLASSIFY: invalid size (%u != %u).\n",
72 + targinfosize,
73 + IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
74 + return 0;
75 + }
76 +
77 + if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
78 + printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
79 + return 0;
80 + }
81 +
82 + if (strcmp(tablename, "mangle") != 0) {
83 + printk(KERN_WARNING "CLASSIFY: can only be called from "
84 + "\"mangle\" table, not \"%s\".\n",
85 + tablename);
86 + return 0;
87 + }
88 +
89 + return 1;
90 +}
91 +
92 +static struct ipt_target ipt_classify_reg
93 += { { NULL, NULL }, "CLASSIFY", target, checkentry, NULL, THIS_MODULE };
94 +
95 +static int __init init(void)
96 +{
97 + if (ipt_register_target(&ipt_classify_reg))
98 + return -EINVAL;
99 +
100 + return 0;
101 +}
102 +
103 +static void __exit fini(void)
104 +{
105 + ipt_unregister_target(&ipt_classify_reg);
106 +}
107 +
108 +module_init(init);
109 +module_exit(fini);
110 diff -uprN linux-2.4.32.reference/net/ipv4/netfilter/Makefile linux-2.4.32/net/ipv4/netfilter/Makefile
111 --- linux-2.4.32.reference/net/ipv4/netfilter/Makefile 2006-08-17 12:28:16.000000000 +0200
112 +++ linux-2.4.32/net/ipv4/netfilter/Makefile 2006-08-17 12:33:08.000000000 +0200
113 @@ -134,6 +134,7 @@ obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_
114
115 # targets
116 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
117 +obj-$(CONFIG_IP_NF_TARGET_CLASSIFY) += ipt_CLASSIFY.o
118 obj-$(CONFIG_IP_NF_TARGET_MIRROR) += ipt_MIRROR.o
119 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
120 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o