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