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 / 616-netfilter_imq.patch
1 Index: linux-2.4.35.4/Documentation/Configure.help
2 ===================================================================
3 --- linux-2.4.35.4.orig/Documentation/Configure.help 2007-12-15 05:20:09.632389161 +0100
4 +++ linux-2.4.35.4/Documentation/Configure.help 2007-12-15 05:20:10.792455269 +0100
5 @@ -3160,6 +3160,22 @@
6 If you want to compile it as a module, say M here and read
7 <file:Documentation/modules.txt>. If unsure, say `N'.
8
9 +IMQ target support
10 +CONFIG_IP_NF_TARGET_IMQ
11 + This option adds a `IMQ' target which is used to specify if and
12 + to which imq device packets should get enqueued/dequeued.
13 +
14 + If you want to compile it as a module, say M here and read
15 + <file:Documentation/modules.txt>. If unsure, say `N'.
16 +
17 +IMQ target support
18 +CONFIG_IP6_NF_TARGET_IMQ
19 + This option adds a `IMQ' target which is used to specify if and
20 + to which imq device packets should get enqueued/dequeued.
21 +
22 + If you want to compile it as a module, say M here and read
23 + <file:Documentation/modules.txt>. If unsure, say `N'.
24 +
25 MARK target support
26 CONFIG_IP_NF_TARGET_MARK
27 This option adds a `MARK' target, which allows you to create rules
28 @@ -9919,6 +9935,20 @@
29 say M here and read <file:Documentation/modules.txt>. The module
30 will be called bonding.o.
31
32 +Intermediate queueing device support
33 +CONFIG_IMQ
34 + The imq device(s) is used as placeholder for QoS queueing disciplines.
35 + Every packet entering/leaving the ip stack can be directed through
36 + the imq device where it's enqueued/dequeued to the attached qdisc.
37 + This allows you to treat network devices as classes and distribute
38 + bandwidth among them. Iptables is used to specify through which imq
39 + device, if any, packets travel.
40 +
41 + If you want to compile this as a module ( = code which ca be
42 + inserted in and removed from the running kernel whenever you want),
43 + say M here and read <file:Documentation/modules.txt>. The module
44 + will be called imq.o
45 +
46 SLIP (serial line) support
47 CONFIG_SLIP
48 Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to
49 Index: linux-2.4.35.4/drivers/net/Config.in
50 ===================================================================
51 --- linux-2.4.35.4.orig/drivers/net/Config.in 2007-12-15 05:19:54.067502171 +0100
52 +++ linux-2.4.35.4/drivers/net/Config.in 2007-12-15 05:20:10.796455498 +0100
53 @@ -7,6 +7,11 @@
54 tristate 'Dummy net driver support' CONFIG_DUMMY
55 tristate 'Bonding driver support' CONFIG_BONDING
56 tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER
57 +if [ "$CONFIG_NETFILTER" = "y" ]; then
58 + tristate 'IMQ (intermediate queueing device) support' CONFIG_IMQ
59 +else
60 + comment 'IMQ needs CONFIG_NETFILTER enabled'
61 +fi
62 tristate 'Universal TUN/TAP device driver support' CONFIG_TUN
63 bool 'Allow Net Devices to contribute to /dev/random' CONFIG_NET_RANDOM
64 if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
65 Index: linux-2.4.35.4/drivers/net/Makefile
66 ===================================================================
67 --- linux-2.4.35.4.orig/drivers/net/Makefile 2007-12-15 05:19:51.931380439 +0100
68 +++ linux-2.4.35.4/drivers/net/Makefile 2007-12-15 05:20:10.804455954 +0100
69 @@ -176,6 +176,7 @@
70
71 obj-$(CONFIG_STRIP) += strip.o
72 obj-$(CONFIG_DUMMY) += dummy.o
73 +obj-$(CONFIG_IMQ) += imq.o
74 obj-$(CONFIG_DE600) += de600.o
75 obj-$(CONFIG_DE620) += de620.o
76 obj-$(CONFIG_AT1500) += lance.o
77 Index: linux-2.4.35.4/drivers/net/imq.c
78 ===================================================================
79 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
80 +++ linux-2.4.35.4/drivers/net/imq.c 2007-12-15 05:20:10.808456180 +0100
81 @@ -0,0 +1,321 @@
82 +/*
83 + * Pseudo-driver for the intermediate queue device.
84 + *
85 + * This program is free software; you can redistribute it and/or
86 + * modify it under the terms of the GNU General Public License
87 + * as published by the Free Software Foundation; either version
88 + * 2 of the License, or (at your option) any later version.
89 + *
90 + * Authors: Patrick McHardy, <kaber@trash.net>
91 + *
92 + * The first version was written by Martin Devera, <devik@cdi.cz>
93 + *
94 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
95 + * - Update patch to 2.4.21
96 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
97 + * - Fix "Dead-loop on netdevice imq"-issue
98 + */
99 +
100 +#include <linux/kernel.h>
101 +#include <linux/module.h>
102 +#include <linux/config.h>
103 +#include <linux/skbuff.h>
104 +#include <linux/netdevice.h>
105 +#include <linux/rtnetlink.h>
106 +#include <linux/if_arp.h>
107 +#include <linux/netfilter.h>
108 +#include <linux/netfilter_ipv4.h>
109 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
110 +#include <linux/netfilter_ipv6.h>
111 +#endif
112 +#include <linux/imq.h>
113 +#include <net/pkt_sched.h>
114 +
115 +static nf_hookfn imq_nf_hook;
116 +
117 +static struct nf_hook_ops imq_ingress_ipv4 = {
118 + { NULL, NULL},
119 + imq_nf_hook,
120 + PF_INET,
121 + NF_IP_PRE_ROUTING,
122 + NF_IP_PRI_MANGLE + 1
123 +};
124 +
125 +static struct nf_hook_ops imq_egress_ipv4 = {
126 + { NULL, NULL},
127 + imq_nf_hook,
128 + PF_INET,
129 + NF_IP_POST_ROUTING,
130 + NF_IP_PRI_LAST
131 +};
132 +
133 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
134 +static struct nf_hook_ops imq_ingress_ipv6 = {
135 + { NULL, NULL},
136 + imq_nf_hook,
137 + PF_INET6,
138 + NF_IP6_PRE_ROUTING,
139 + NF_IP6_PRI_MANGLE + 1
140 +};
141 +
142 +static struct nf_hook_ops imq_egress_ipv6 = {
143 + { NULL, NULL},
144 + imq_nf_hook,
145 + PF_INET6,
146 + NF_IP6_POST_ROUTING,
147 + NF_IP6_PRI_LAST
148 +};
149 +#endif
150 +
151 +static unsigned int numdevs = 2;
152 +
153 +MODULE_PARM(numdevs, "i");
154 +MODULE_PARM_DESC(numdevs, "number of imq devices");
155 +
156 +static struct net_device *imq_devs;
157 +
158 +
159 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
160 +{
161 + return (struct net_device_stats *)dev->priv;
162 +}
163 +
164 +/* called for packets kfree'd in qdiscs at places other than enqueue */
165 +static void imq_skb_destructor(struct sk_buff *skb)
166 +{
167 + struct nf_info *info = skb->nf_info;
168 +
169 + if (info) {
170 + if (info->indev)
171 + dev_put(info->indev);
172 + if (info->outdev)
173 + dev_put(info->outdev);
174 + kfree(info);
175 + }
176 +}
177 +
178 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
179 +{
180 + struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
181 +
182 + stats->tx_bytes += skb->len;
183 + stats->tx_packets++;
184 +
185 + skb->imq_flags = 0;
186 + skb->destructor = NULL;
187 +
188 + dev->trans_start = jiffies;
189 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
190 + return 0;
191 +}
192 +
193 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info,
194 + void *data)
195 +{
196 + struct net_device *dev;
197 + struct net_device_stats *stats;
198 + struct sk_buff *skb2 = NULL;
199 + struct Qdisc *q;
200 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
201 + int ret = -1;
202 +
203 + if (index > numdevs)
204 + return -1;
205 +
206 + dev = imq_devs + index;
207 + if (!(dev->flags & IFF_UP)) {
208 + skb->imq_flags = 0;
209 + nf_reinject(skb, info, NF_ACCEPT);
210 + return 0;
211 + }
212 + dev->last_rx = jiffies;
213 +
214 + if (skb->destructor) {
215 + skb2 = skb;
216 + skb = skb_clone(skb, GFP_ATOMIC);
217 + if (!skb)
218 + return -1;
219 + }
220 + skb->nf_info = info;
221 +
222 + stats = (struct net_device_stats *)dev->priv;
223 + stats->rx_bytes+= skb->len;
224 + stats->rx_packets++;
225 +
226 + spin_lock_bh(&dev->queue_lock);
227 + q = dev->qdisc;
228 + if (q->enqueue) {
229 + q->enqueue(skb_get(skb), q);
230 + if (skb_shared(skb)) {
231 + skb->destructor = imq_skb_destructor;
232 + kfree_skb(skb);
233 + ret = 0;
234 + }
235 + }
236 + if (spin_is_locked(&dev->xmit_lock))
237 + netif_schedule(dev);
238 + else
239 + qdisc_run(dev);
240 + spin_unlock_bh(&dev->queue_lock);
241 +
242 + if (skb2)
243 + kfree_skb(ret ? skb : skb2);
244 +
245 + return ret;
246 +}
247 +
248 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
249 + const struct net_device *indev,
250 + const struct net_device *outdev,
251 + int (*okfn)(struct sk_buff *))
252 +{
253 + if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
254 + return NF_QUEUE;
255 +
256 + return NF_ACCEPT;
257 +}
258 +
259 +
260 +static int __init imq_init_hooks(void)
261 +{
262 + int err;
263 +
264 + if ((err = nf_register_queue_handler(PF_INET, imq_nf_queue, NULL)))
265 + goto err1;
266 + if ((err = nf_register_hook(&imq_ingress_ipv4)))
267 + goto err2;
268 + if ((err = nf_register_hook(&imq_egress_ipv4)))
269 + goto err3;
270 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
271 + if ((err = nf_register_queue_handler(PF_INET6, imq_nf_queue, NULL)))
272 + goto err4;
273 + if ((err = nf_register_hook(&imq_ingress_ipv6)))
274 + goto err5;
275 + if ((err = nf_register_hook(&imq_egress_ipv6)))
276 + goto err6;
277 +#endif
278 +
279 + return 0;
280 +
281 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
282 +err6:
283 + nf_unregister_hook(&imq_ingress_ipv6);
284 +err5:
285 + nf_unregister_queue_handler(PF_INET6);
286 +err4:
287 + nf_unregister_hook(&imq_egress_ipv4);
288 +#endif
289 +err3:
290 + nf_unregister_hook(&imq_ingress_ipv4);
291 +err2:
292 + nf_unregister_queue_handler(PF_INET);
293 +err1:
294 + return err;
295 +}
296 +
297 +static void __exit imq_unhook(void)
298 +{
299 + nf_unregister_hook(&imq_ingress_ipv4);
300 + nf_unregister_hook(&imq_egress_ipv4);
301 + nf_unregister_queue_handler(PF_INET);
302 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
303 + nf_unregister_hook(&imq_ingress_ipv6);
304 + nf_unregister_hook(&imq_egress_ipv6);
305 + nf_unregister_queue_handler(PF_INET6);
306 +#endif
307 +}
308 +
309 +static int __init imq_dev_init(struct net_device *dev)
310 +{
311 + dev->hard_start_xmit = imq_dev_xmit;
312 + dev->type = ARPHRD_VOID;
313 + dev->mtu = 1500;
314 + dev->tx_queue_len = 30;
315 + dev->flags = IFF_NOARP;
316 + dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
317 + if (dev->priv == NULL)
318 + return -ENOMEM;
319 + memset(dev->priv, 0, sizeof(struct net_device_stats));
320 + dev->get_stats = imq_get_stats;
321 +
322 + return 0;
323 +}
324 +
325 +static void imq_dev_uninit(struct net_device *dev)
326 +{
327 + kfree(dev->priv);
328 +}
329 +
330 +static int __init imq_init_devs(void)
331 +{
332 + struct net_device *dev;
333 + int i;
334 +
335 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
336 + printk(KERN_ERR "numdevs has to be betweed 1 and %u\n",
337 + IMQ_MAX_DEVS);
338 + return -EINVAL;
339 + }
340 +
341 + imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
342 + if (!imq_devs)
343 + return -ENOMEM;
344 + memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
345 +
346 + /* we start counting at zero */
347 + numdevs--;
348 +
349 + for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
350 + SET_MODULE_OWNER(dev);
351 + strcpy(dev->name, "imq%d");
352 + dev->init = imq_dev_init;
353 + dev->uninit = imq_dev_uninit;
354 +
355 + if (register_netdev(dev) < 0)
356 + goto err_register;
357 + }
358 + return 0;
359 +
360 +err_register:
361 + for (; i; i--)
362 + unregister_netdev(--dev);
363 + kfree(imq_devs);
364 + return -EIO;
365 +}
366 +
367 +static void imq_cleanup_devs(void)
368 +{
369 + int i;
370 + struct net_device *dev = imq_devs;
371 +
372 + for (i = 0; i <= numdevs; i++)
373 + unregister_netdev(dev++);
374 +
375 + kfree(imq_devs);
376 +}
377 +
378 +static int __init imq_init_module(void)
379 +{
380 + int err;
381 +
382 + if ((err = imq_init_devs()))
383 + return err;
384 + if ((err = imq_init_hooks())) {
385 + imq_cleanup_devs();
386 + return err;
387 + }
388 +
389 + printk(KERN_INFO "imq driver loaded.\n");
390 +
391 + return 0;
392 +}
393 +
394 +static void __exit imq_cleanup_module(void)
395 +{
396 + imq_unhook();
397 + imq_cleanup_devs();
398 +}
399 +
400 +module_init(imq_init_module);
401 +module_exit(imq_cleanup_module);
402 +MODULE_LICENSE("GPL");
403 Index: linux-2.4.35.4/include/linux/imq.h
404 ===================================================================
405 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
406 +++ linux-2.4.35.4/include/linux/imq.h 2007-12-15 05:20:10.808456180 +0100
407 @@ -0,0 +1,9 @@
408 +#ifndef _IMQ_H
409 +#define _IMQ_H
410 +
411 +#define IMQ_MAX_DEVS 16
412 +
413 +#define IMQ_F_IFMASK 0x7f
414 +#define IMQ_F_ENQUEUE 0x80
415 +
416 +#endif /* _IMQ_H */
417 Index: linux-2.4.35.4/include/linux/netfilter_ipv4/ipt_IMQ.h
418 ===================================================================
419 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
420 +++ linux-2.4.35.4/include/linux/netfilter_ipv4/ipt_IMQ.h 2007-12-15 05:20:10.808456180 +0100
421 @@ -0,0 +1,8 @@
422 +#ifndef _IPT_IMQ_H
423 +#define _IPT_IMQ_H
424 +
425 +struct ipt_imq_info {
426 + unsigned int todev; /* target imq device */
427 +};
428 +
429 +#endif /* _IPT_IMQ_H */
430 Index: linux-2.4.35.4/include/linux/netfilter_ipv6/ip6t_IMQ.h
431 ===================================================================
432 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
433 +++ linux-2.4.35.4/include/linux/netfilter_ipv6/ip6t_IMQ.h 2007-12-15 05:20:10.808456180 +0100
434 @@ -0,0 +1,8 @@
435 +#ifndef _IP6T_IMQ_H
436 +#define _IP6T_IMQ_H
437 +
438 +struct ip6t_imq_info {
439 + unsigned int todev; /* target imq device */
440 +};
441 +
442 +#endif /* _IP6T_IMQ_H */
443 Index: linux-2.4.35.4/include/linux/skbuff.h
444 ===================================================================
445 --- linux-2.4.35.4.orig/include/linux/skbuff.h 2007-12-15 05:20:05.060128604 +0100
446 +++ linux-2.4.35.4/include/linux/skbuff.h 2007-12-15 05:20:10.808456180 +0100
447 @@ -93,6 +93,9 @@
448 struct nf_conntrack *master;
449 };
450 #endif
451 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
452 +struct nf_info;
453 +#endif
454
455 struct sk_buff_head {
456 /* These two members must be first. */
457 @@ -182,7 +185,7 @@
458 unsigned int len; /* Length of actual data */
459 unsigned int data_len;
460 unsigned int csum; /* Checksum */
461 - unsigned char __unused, /* Dead field, may be reused */
462 + unsigned char imq_flags, /* intermediate queueing device */
463 cloned, /* head may be cloned (check refcnt to be sure). */
464 pkt_type, /* Packet class */
465 ip_summed; /* Driver fed us an IP checksum */
466 @@ -219,6 +222,9 @@
467 #ifdef CONFIG_NET_SCHED
468 __u32 tc_index; /* traffic control index */
469 #endif
470 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
471 + struct nf_info *nf_info;
472 +#endif
473 };
474
475 #ifdef __KERNEL__
476 Index: linux-2.4.35.4/net/core/skbuff.c
477 ===================================================================
478 --- linux-2.4.35.4.orig/net/core/skbuff.c 2007-12-15 05:19:37.174539496 +0100
479 +++ linux-2.4.35.4/net/core/skbuff.c 2007-12-15 05:20:10.812456409 +0100
480 @@ -202,6 +202,10 @@
481 /* Set up other state */
482 skb->len = 0;
483 skb->cloned = 0;
484 +#if defined(CONFIG_IMQ) || defined (CONFIG_IMQ_MODULE)
485 + skb->imq_flags = 0;
486 + skb->nf_info = NULL;
487 +#endif
488 skb->data_len = 0;
489
490 atomic_set(&skb->users, 1);
491 @@ -250,6 +254,10 @@
492 #ifdef CONFIG_NET_SCHED
493 skb->tc_index = 0;
494 #endif
495 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
496 + skb->imq_flags = 0;
497 + skb->nf_info = NULL;
498 +#endif
499 }
500
501 static void skb_drop_fraglist(struct sk_buff *skb)
502 @@ -400,6 +408,10 @@
503 #ifdef CONFIG_NET_SCHED
504 C(tc_index);
505 #endif
506 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
507 + C(imq_flags);
508 + C(nf_info);
509 +#endif
510
511 atomic_inc(&(skb_shinfo(skb)->dataref));
512 skb->cloned = 1;
513 @@ -444,6 +456,10 @@
514 #ifdef CONFIG_NET_SCHED
515 new->tc_index = old->tc_index;
516 #endif
517 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
518 + new->imq_flags=old->imq_flags;
519 + new->nf_info=old->nf_info;
520 +#endif
521 }
522
523 /**
524 Index: linux-2.4.35.4/net/ipv4/netfilter/Config.in
525 ===================================================================
526 --- linux-2.4.35.4.orig/net/ipv4/netfilter/Config.in 2007-12-15 05:20:10.504438857 +0100
527 +++ linux-2.4.35.4/net/ipv4/netfilter/Config.in 2007-12-15 05:20:10.812456409 +0100
528 @@ -171,6 +171,7 @@
529 dep_tristate ' DSCP target support' CONFIG_IP_NF_TARGET_DSCP $CONFIG_IP_NF_MANGLE
530
531 dep_tristate ' MARK target support' CONFIG_IP_NF_TARGET_MARK $CONFIG_IP_NF_MANGLE
532 + dep_tristate ' IMQ target support' CONFIG_IP_NF_TARGET_IMQ $CONFIG_IP_NF_MANGLE
533 fi
534 if [ "$CONFIG_IP_NF_CONNTRACK_MARK" != "n" ]; then
535 dep_tristate ' CONNMARK target support' CONFIG_IP_NF_TARGET_CONNMARK $CONFIG_IP_NF_IPTABLES
536 Index: linux-2.4.35.4/net/ipv4/netfilter/Makefile
537 ===================================================================
538 --- linux-2.4.35.4.orig/net/ipv4/netfilter/Makefile 2007-12-15 05:20:10.508439083 +0100
539 +++ linux-2.4.35.4/net/ipv4/netfilter/Makefile 2007-12-15 05:20:10.812456409 +0100
540 @@ -138,6 +138,7 @@
541 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
542 obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
543 obj-$(CONFIG_IP_NF_TARGET_MARK) += ipt_MARK.o
544 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
545 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
546 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
547 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
548 Index: linux-2.4.35.4/net/ipv4/netfilter/ipt_IMQ.c
549 ===================================================================
550 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
551 +++ linux-2.4.35.4/net/ipv4/netfilter/ipt_IMQ.c 2007-12-15 05:20:10.812456409 +0100
552 @@ -0,0 +1,78 @@
553 +/* This target marks packets to be enqueued to an imq device */
554 +#include <linux/module.h>
555 +#include <linux/skbuff.h>
556 +#include <linux/netfilter_ipv4/ip_tables.h>
557 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
558 +#include <linux/imq.h>
559 +
560 +static unsigned int imq_target(struct sk_buff **pskb,
561 + unsigned int hooknum,
562 + const struct net_device *in,
563 + const struct net_device *out,
564 + const void *targinfo,
565 + void *userinfo)
566 +{
567 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
568 +
569 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
570 + (*pskb)->nfcache |= NFC_ALTERED;
571 +
572 + return IPT_CONTINUE;
573 +}
574 +
575 +static int imq_checkentry(const char *tablename,
576 + const struct ipt_entry *e,
577 + void *targinfo,
578 + unsigned int targinfosize,
579 + unsigned int hook_mask)
580 +{
581 + struct ipt_imq_info *mr;
582 +
583 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) {
584 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
585 + return 0;
586 + }
587 + mr = (struct ipt_imq_info*)targinfo;
588 +
589 + if (strcmp(tablename, "mangle") != 0) {
590 + printk(KERN_WARNING
591 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
592 + tablename);
593 + return 0;
594 + }
595 +
596 + if (mr->todev > IMQ_MAX_DEVS) {
597 + printk(KERN_WARNING
598 + "IMQ: invalid device specified, highest is %u\n",
599 + IMQ_MAX_DEVS);
600 + return 0;
601 + }
602 +
603 + return 1;
604 +}
605 +
606 +static struct ipt_target ipt_imq_reg = {
607 + { NULL, NULL},
608 + "IMQ",
609 + imq_target,
610 + imq_checkentry,
611 + NULL,
612 + THIS_MODULE
613 +};
614 +
615 +static int __init init(void)
616 +{
617 + if (ipt_register_target(&ipt_imq_reg))
618 + return -EINVAL;
619 +
620 + return 0;
621 +}
622 +
623 +static void __exit fini(void)
624 +{
625 + ipt_unregister_target(&ipt_imq_reg);
626 +}
627 +
628 +module_init(init);
629 +module_exit(fini);
630 +MODULE_LICENSE("GPL");
631 Index: linux-2.4.35.4/net/ipv6/netfilter/Config.in
632 ===================================================================
633 --- linux-2.4.35.4.orig/net/ipv6/netfilter/Config.in 2007-12-15 05:20:09.300370243 +0100
634 +++ linux-2.4.35.4/net/ipv6/netfilter/Config.in 2007-12-15 05:20:10.816456638 +0100
635 @@ -72,6 +72,7 @@
636 if [ "$CONFIG_IP6_NF_MANGLE" != "n" ]; then
637 # dep_tristate ' TOS target support' CONFIG_IP6_NF_TARGET_TOS $CONFIG_IP_NF_MANGLE
638 dep_tristate ' MARK target support' CONFIG_IP6_NF_TARGET_MARK $CONFIG_IP6_NF_MANGLE
639 + dep_tristate ' IMQ target support' CONFIG_IP6_NF_TARGET_IMQ $CONFIG_IP6_NF_MANGLE
640 fi
641 #dep_tristate ' LOG target support' CONFIG_IP6_NF_TARGET_LOG $CONFIG_IP6_NF_IPTABLES
642 fi
643 Index: linux-2.4.35.4/net/ipv6/netfilter/Makefile
644 ===================================================================
645 --- linux-2.4.35.4.orig/net/ipv6/netfilter/Makefile 2007-12-15 05:20:09.304370470 +0100
646 +++ linux-2.4.35.4/net/ipv6/netfilter/Makefile 2007-12-15 05:20:10.816456638 +0100
647 @@ -29,6 +29,7 @@
648 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
649 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
650 obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o
651 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
652 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
653 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
654 obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o
655 Index: linux-2.4.35.4/net/ipv6/netfilter/ip6t_IMQ.c
656 ===================================================================
657 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
658 +++ linux-2.4.35.4/net/ipv6/netfilter/ip6t_IMQ.c 2007-12-15 05:20:10.816456638 +0100
659 @@ -0,0 +1,78 @@
660 +/* This target marks packets to be enqueued to an imq device */
661 +#include <linux/module.h>
662 +#include <linux/skbuff.h>
663 +#include <linux/netfilter_ipv6/ip6_tables.h>
664 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
665 +#include <linux/imq.h>
666 +
667 +static unsigned int imq_target(struct sk_buff **pskb,
668 + unsigned int hooknum,
669 + const struct net_device *in,
670 + const struct net_device *out,
671 + const void *targinfo,
672 + void *userinfo)
673 +{
674 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
675 +
676 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
677 + (*pskb)->nfcache |= NFC_ALTERED;
678 +
679 + return IP6T_CONTINUE;
680 +}
681 +
682 +static int imq_checkentry(const char *tablename,
683 + const struct ip6t_entry *e,
684 + void *targinfo,
685 + unsigned int targinfosize,
686 + unsigned int hook_mask)
687 +{
688 + struct ip6t_imq_info *mr;
689 +
690 + if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) {
691 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
692 + return 0;
693 + }
694 + mr = (struct ip6t_imq_info*)targinfo;
695 +
696 + if (strcmp(tablename, "mangle") != 0) {
697 + printk(KERN_WARNING
698 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
699 + tablename);
700 + return 0;
701 + }
702 +
703 + if (mr->todev > IMQ_MAX_DEVS) {
704 + printk(KERN_WARNING
705 + "IMQ: invalid device specified, highest is %u\n",
706 + IMQ_MAX_DEVS);
707 + return 0;
708 + }
709 +
710 + return 1;
711 +}
712 +
713 +static struct ip6t_target ip6t_imq_reg = {
714 + { NULL, NULL},
715 + "IMQ",
716 + imq_target,
717 + imq_checkentry,
718 + NULL,
719 + THIS_MODULE
720 +};
721 +
722 +static int __init init(void)
723 +{
724 + if (ip6t_register_target(&ip6t_imq_reg))
725 + return -EINVAL;
726 +
727 + return 0;
728 +}
729 +
730 +static void __exit fini(void)
731 +{
732 + ip6t_unregister_target(&ip6t_imq_reg);
733 +}
734 +
735 +module_init(init);
736 +module_exit(fini);
737 +MODULE_LICENSE("GPL");
738 Index: linux-2.4.35.4/net/sched/sch_generic.c
739 ===================================================================
740 --- linux-2.4.35.4.orig/net/sched/sch_generic.c 2007-12-15 05:19:37.226542457 +0100
741 +++ linux-2.4.35.4/net/sched/sch_generic.c 2007-12-15 05:20:10.816456638 +0100
742 @@ -29,6 +29,9 @@
743 #include <linux/skbuff.h>
744 #include <linux/rtnetlink.h>
745 #include <linux/init.h>
746 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
747 +#include <linux/imq.h>
748 +#endif
749 #include <linux/list.h>
750 #include <net/sock.h>
751 #include <net/pkt_sched.h>
752 @@ -90,7 +93,11 @@
753 spin_unlock(&dev->queue_lock);
754
755 if (!netif_queue_stopped(dev)) {
756 - if (netdev_nit)
757 + if (netdev_nit
758 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
759 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
760 +#endif
761 + )
762 dev_queue_xmit_nit(skb, dev);
763
764 if (dev->hard_start_xmit(skb, dev) == 0) {