[kernel] brcm47xx: make input support modular (closes: #5174)
[openwrt/svn-archive/archive.git] / target / linux / generic-2.4 / patches / 619-netfilter_classify.patch
1 --- /dev/null
2 +++ b/include/linux/netfilter_ipv4/ipt_CLASSIFY.h
3 @@ -0,0 +1,8 @@
4 +#ifndef _IPT_CLASSIFY_H
5 +#define _IPT_CLASSIFY_H
6 +
7 +struct ipt_classify_target_info {
8 + u_int32_t priority;
9 +};
10 +
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
16
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
20 fi
21 if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then
22 --- /dev/null
23 +++ b/net/ipv4/netfilter/ipt_CLASSIFY.c
24 @@ -0,0 +1,82 @@
25 +/*
26 + * This is a module which is used for setting the skb->priority field
27 + * of an skb for qdisc classification.
28 + */
29 +
30 +#include <linux/module.h>
31 +#include <linux/skbuff.h>
32 +#include <linux/ip.h>
33 +#include <net/checksum.h>
34 +
35 +#include <linux/netfilter_ipv4/ip_tables.h>
36 +#include <linux/netfilter_ipv4/ipt_CLASSIFY.h>
37 +
38 +MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>");
39 +MODULE_LICENSE("GPL");
40 +MODULE_DESCRIPTION("iptables qdisc classification target module");
41 +
42 +static unsigned int
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,
48 + void *userinfo)
49 +{
50 + const struct ipt_classify_target_info *clinfo = targinfo;
51 +
52 + if((*pskb)->priority != clinfo->priority) {
53 + (*pskb)->priority = clinfo->priority;
54 + (*pskb)->nfcache |= NFC_ALTERED;
55 + }
56 +
57 + return IPT_CONTINUE;
58 +}
59 +
60 +static int
61 +checkentry(const char *tablename,
62 + const struct ipt_entry *e,
63 + void *targinfo,
64 + unsigned int targinfosize,
65 + unsigned int hook_mask)
66 +{
67 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_classify_target_info))){
68 + printk(KERN_ERR "CLASSIFY: invalid size (%u != %u).\n",
69 + targinfosize,
70 + IPT_ALIGN(sizeof(struct ipt_classify_target_info)));
71 + return 0;
72 + }
73 +
74 + if (hook_mask & ~(1 << NF_IP_POST_ROUTING)) {
75 + printk(KERN_ERR "CLASSIFY: only valid in POST_ROUTING.\n");
76 + return 0;
77 + }
78 +
79 + if (strcmp(tablename, "mangle") != 0) {
80 + printk(KERN_WARNING "CLASSIFY: can only be called from "
81 + "\"mangle\" table, not \"%s\".\n",
82 + tablename);
83 + return 0;
84 + }
85 +
86 + return 1;
87 +}
88 +
89 +static struct ipt_target ipt_classify_reg
90 += { { NULL, NULL }, "CLASSIFY", target, checkentry, NULL, THIS_MODULE };
91 +
92 +static int __init init(void)
93 +{
94 + if (ipt_register_target(&ipt_classify_reg))
95 + return -EINVAL;
96 +
97 + return 0;
98 +}
99 +
100 +static void __exit fini(void)
101 +{
102 + ipt_unregister_target(&ipt_classify_reg);
103 +}
104 +
105 +module_init(init);
106 +module_exit(fini);
107 --- a/net/ipv4/netfilter/Makefile
108 +++ b/net/ipv4/netfilter/Makefile
109 @@ -133,6 +133,7 @@ obj-$(CONFIG_IP_NF_MATCH_LAYER7) += ipt_
110
111 # targets
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