upgrade to Linux 2.6.16, yay
[openwrt/openwrt.git] / openwrt / target / linux / generic-2.6 / patches / 106-netfilter_imq.patch
1 diff -Nur linux-2.6.16/drivers/net/imq.c linux-2.6.16-owrt/drivers/net/imq.c
2 --- linux-2.6.16/drivers/net/imq.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.16-owrt/drivers/net/imq.c 2006-03-20 12:59:23.000000000 +0100
4 @@ -0,0 +1,403 @@
5 +/*
6 + * Pseudo-driver for the intermediate queue device.
7 + *
8 + * This program is free software; you can redistribute it and/or
9 + * modify it under the terms of the GNU General Public License
10 + * as published by the Free Software Foundation; either version
11 + * 2 of the License, or (at your option) any later version.
12 + *
13 + * Authors: Patrick McHardy, <kaber@trash.net>
14 + *
15 + * The first version was written by Martin Devera, <devik@cdi.cz>
16 + *
17 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
18 + * - Update patch to 2.4.21
19 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
20 + * - Fix "Dead-loop on netdevice imq"-issue
21 + * Marcel Sebek <sebek64@post.cz>
22 + * - Update to 2.6.2-rc1
23 + *
24 + * After some time of inactivity there is a group taking care
25 + * of IMQ again: http://www.linuximq.net
26 + *
27 + *
28 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
29 + * the following changes:
30 + *
31 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
32 + * - Correction of imq_init_devs() issue that resulted in
33 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
34 + * - Addition of functionality to choose number of IMQ devices
35 + * during kernel config (Andre Correa)
36 + * - Addition of functionality to choose how IMQ hooks on
37 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
38 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
39 + *
40 + *
41 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
42 + * released with almost no problems. 2.6.14-x was released
43 + * with some important changes: nfcache was removed; After
44 + * some weeks of trouble we figured out that some IMQ fields
45 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
46 + * These functions are correctly patched by this new patch version.
47 + *
48 + * Thanks for all who helped to figure out all the problems with
49 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
50 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
51 + * I didn't forget anybody). I apologize again for my lack of time.
52 + *
53 + * More info at: http://www.linuximq.net/ (Andre Correa)
54 + */
55 +
56 +#include <linux/config.h>
57 +#include <linux/module.h>
58 +#include <linux/kernel.h>
59 +#include <linux/moduleparam.h>
60 +#include <linux/skbuff.h>
61 +#include <linux/netdevice.h>
62 +#include <linux/rtnetlink.h>
63 +#include <linux/if_arp.h>
64 +#include <linux/netfilter.h>
65 +#include <linux/netfilter_ipv4.h>
66 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
67 + #include <linux/netfilter_ipv6.h>
68 +#endif
69 +#include <linux/imq.h>
70 +#include <net/pkt_sched.h>
71 +
72 +static nf_hookfn imq_nf_hook;
73 +
74 +static struct nf_hook_ops imq_ingress_ipv4 = {
75 + .hook = imq_nf_hook,
76 + .owner = THIS_MODULE,
77 + .pf = PF_INET,
78 + .hooknum = NF_IP_PRE_ROUTING,
79 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
80 + .priority = NF_IP_PRI_MANGLE + 1
81 +#else
82 + .priority = NF_IP_PRI_NAT_DST + 1
83 +#endif
84 +};
85 +
86 +static struct nf_hook_ops imq_egress_ipv4 = {
87 + .hook = imq_nf_hook,
88 + .owner = THIS_MODULE,
89 + .pf = PF_INET,
90 + .hooknum = NF_IP_POST_ROUTING,
91 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
92 + .priority = NF_IP_PRI_LAST
93 +#else
94 + .priority = NF_IP_PRI_NAT_SRC - 1
95 +#endif
96 +};
97 +
98 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
99 +static struct nf_hook_ops imq_ingress_ipv6 = {
100 + .hook = imq_nf_hook,
101 + .owner = THIS_MODULE,
102 + .pf = PF_INET6,
103 + .hooknum = NF_IP6_PRE_ROUTING,
104 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
105 + .priority = NF_IP6_PRI_MANGLE + 1
106 +#else
107 + .priority = NF_IP6_PRI_NAT_DST + 1
108 +#endif
109 +};
110 +
111 +static struct nf_hook_ops imq_egress_ipv6 = {
112 + .hook = imq_nf_hook,
113 + .owner = THIS_MODULE,
114 + .pf = PF_INET6,
115 + .hooknum = NF_IP6_POST_ROUTING,
116 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
117 + .priority = NF_IP6_PRI_LAST
118 +#else
119 + .priority = NF_IP6_PRI_NAT_SRC - 1
120 +#endif
121 +};
122 +#endif
123 +
124 +#if defined(CONFIG_IMQ_NUM_DEVS)
125 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
126 +#else
127 +static unsigned int numdevs = 2;
128 +#endif
129 +
130 +static struct net_device *imq_devs;
131 +
132 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
133 +{
134 + return (struct net_device_stats *)dev->priv;
135 +}
136 +
137 +/* called for packets kfree'd in qdiscs at places other than enqueue */
138 +static void imq_skb_destructor(struct sk_buff *skb)
139 +{
140 + struct nf_info *info = skb->nf_info;
141 +
142 + if (info) {
143 + if (info->indev)
144 + dev_put(info->indev);
145 + if (info->outdev)
146 + dev_put(info->outdev);
147 + kfree(info);
148 + }
149 +}
150 +
151 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
152 +{
153 + struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
154 +
155 + stats->tx_bytes += skb->len;
156 + stats->tx_packets++;
157 +
158 + skb->imq_flags = 0;
159 + skb->destructor = NULL;
160 +
161 + dev->trans_start = jiffies;
162 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
163 + return 0;
164 +}
165 +
166 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
167 +{
168 + struct net_device *dev;
169 + struct net_device_stats *stats;
170 + struct sk_buff *skb2 = NULL;
171 + struct Qdisc *q;
172 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
173 + int ret = -1;
174 +
175 + if (index > numdevs)
176 + return -1;
177 +
178 + dev = imq_devs + index;
179 + if (!(dev->flags & IFF_UP)) {
180 + skb->imq_flags = 0;
181 + nf_reinject(skb, info, NF_ACCEPT);
182 + return 0;
183 + }
184 + dev->last_rx = jiffies;
185 +
186 + if (skb->destructor) {
187 + skb2 = skb;
188 + skb = skb_clone(skb, GFP_ATOMIC);
189 + if (!skb)
190 + return -1;
191 + }
192 + skb->nf_info = info;
193 +
194 + stats = (struct net_device_stats *)dev->priv;
195 + stats->rx_bytes+= skb->len;
196 + stats->rx_packets++;
197 +
198 + spin_lock_bh(&dev->queue_lock);
199 + q = dev->qdisc;
200 + if (q->enqueue) {
201 + q->enqueue(skb_get(skb), q);
202 + if (skb_shared(skb)) {
203 + skb->destructor = imq_skb_destructor;
204 + kfree_skb(skb);
205 + ret = 0;
206 + }
207 + }
208 + if (spin_is_locked(&dev->xmit_lock))
209 + netif_schedule(dev);
210 + else
211 +
212 + while (!netif_queue_stopped(dev) &&
213 + qdisc_restart(dev)<0)
214 + /* NOTHING */;
215 +
216 + spin_unlock_bh(&dev->queue_lock);
217 +
218 + if (skb2)
219 + kfree_skb(ret ? skb : skb2);
220 +
221 + return ret;
222 +}
223 +
224 +static struct nf_queue_handler nfqh = {
225 + .name = "imq",
226 + .outfn = imq_nf_queue,
227 +};
228 +
229 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
230 + const struct net_device *indev,
231 + const struct net_device *outdev,
232 + int (*okfn)(struct sk_buff *))
233 +{
234 + if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
235 + return NF_QUEUE;
236 +
237 + return NF_ACCEPT;
238 +}
239 +
240 +
241 +static int __init imq_init_hooks(void)
242 +{
243 + int err;
244 +
245 + err = nf_register_queue_handler(PF_INET, &nfqh);
246 + if (err > 0)
247 + goto err1;
248 + if ((err = nf_register_hook(&imq_ingress_ipv4)))
249 + goto err2;
250 + if ((err = nf_register_hook(&imq_egress_ipv4)))
251 + goto err3;
252 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
253 + if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
254 + goto err4;
255 + if ((err = nf_register_hook(&imq_ingress_ipv6)))
256 + goto err5;
257 + if ((err = nf_register_hook(&imq_egress_ipv6)))
258 + goto err6;
259 +#endif
260 +
261 + return 0;
262 +
263 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
264 +err6:
265 + nf_unregister_hook(&imq_ingress_ipv6);
266 +err5:
267 + nf_unregister_queue_handler(PF_INET6);
268 +err4:
269 + nf_unregister_hook(&imq_egress_ipv6);
270 +#endif
271 +err3:
272 + nf_unregister_hook(&imq_ingress_ipv4);
273 +err2:
274 + nf_unregister_queue_handler(PF_INET);
275 +err1:
276 + return err;
277 +}
278 +
279 +static void __exit imq_unhook(void)
280 +{
281 + nf_unregister_hook(&imq_ingress_ipv4);
282 + nf_unregister_hook(&imq_egress_ipv4);
283 + nf_unregister_queue_handler(PF_INET);
284 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
285 + nf_unregister_hook(&imq_ingress_ipv6);
286 + nf_unregister_hook(&imq_egress_ipv6);
287 + nf_unregister_queue_handler(PF_INET6);
288 +#endif
289 +}
290 +
291 +static int __init imq_dev_init(struct net_device *dev)
292 +{
293 + dev->hard_start_xmit = imq_dev_xmit;
294 + dev->type = ARPHRD_VOID;
295 + dev->mtu = 1500;
296 + dev->tx_queue_len = 30;
297 + dev->flags = IFF_NOARP;
298 + dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
299 + if (dev->priv == NULL)
300 + return -ENOMEM;
301 + memset(dev->priv, 0, sizeof(struct net_device_stats));
302 + dev->get_stats = imq_get_stats;
303 +
304 + return 0;
305 +}
306 +
307 +static void imq_dev_uninit(struct net_device *dev)
308 +{
309 + kfree(dev->priv);
310 +}
311 +
312 +static int __init imq_init_devs(void)
313 +{
314 + struct net_device *dev;
315 + int i,j;
316 + j = numdevs;
317 +
318 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
319 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
320 + IMQ_MAX_DEVS);
321 + return -EINVAL;
322 + }
323 +
324 + imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
325 + if (!imq_devs)
326 + return -ENOMEM;
327 + memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
328 +
329 + /* we start counting at zero */
330 + numdevs--;
331 +
332 + for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
333 + SET_MODULE_OWNER(dev);
334 + strcpy(dev->name, "imq%d");
335 + dev->init = imq_dev_init;
336 + dev->uninit = imq_dev_uninit;
337 +
338 + if (register_netdev(dev) < 0)
339 + goto err_register;
340 + }
341 + printk(KERN_INFO "IMQ starting with %u devices...\n", j);
342 + return 0;
343 +
344 +err_register:
345 + for (; i; i--)
346 + unregister_netdev(--dev);
347 + kfree(imq_devs);
348 + return -EIO;
349 +}
350 +
351 +static void imq_cleanup_devs(void)
352 +{
353 + int i;
354 + struct net_device *dev = imq_devs;
355 +
356 + for (i = 0; i <= numdevs; i++)
357 + unregister_netdev(dev++);
358 +
359 + kfree(imq_devs);
360 +}
361 +
362 +static int __init imq_init_module(void)
363 +{
364 + int err;
365 +
366 + if ((err = imq_init_devs())) {
367 + printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
368 + return err;
369 + }
370 + if ((err = imq_init_hooks())) {
371 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
372 + imq_cleanup_devs();
373 + return err;
374 + }
375 +
376 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
377 +
378 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
379 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
380 +#else
381 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
382 +#endif
383 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
384 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
385 +#else
386 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
387 +#endif
388 +
389 + return 0;
390 +}
391 +
392 +static void __exit imq_cleanup_module(void)
393 +{
394 + imq_unhook();
395 + imq_cleanup_devs();
396 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
397 +}
398 +
399 +
400 +module_init(imq_init_module);
401 +module_exit(imq_cleanup_module);
402 +
403 +module_param(numdevs, int, 0);
404 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
405 +MODULE_AUTHOR("http://www.linuximq.net");
406 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
407 +MODULE_LICENSE("GPL");
408 diff -Nur linux-2.6.16/drivers/net/Kconfig linux-2.6.16-owrt/drivers/net/Kconfig
409 --- linux-2.6.16/drivers/net/Kconfig 2006-03-20 06:53:29.000000000 +0100
410 +++ linux-2.6.16-owrt/drivers/net/Kconfig 2006-03-20 12:59:23.000000000 +0100
411 @@ -93,6 +93,129 @@
412 To compile this driver as a module, choose M here: the module
413 will be called eql. If unsure, say N.
414
415 +config IMQ
416 + tristate "IMQ (intermediate queueing device) support"
417 + depends on NETDEVICES && NETFILTER
418 + ---help---
419 + The IMQ device(s) is used as placeholder for QoS queueing disciplines.
420 + Every packet entering/leaving the IP stack can be directed through
421 + the IMQ device where it's enqueued/dequeued to the attached qdisc.
422 + This allows you to treat network devices as classes and distribute
423 + bandwidth among them. Iptables is used to specify through which IMQ
424 + device, if any, packets travel.
425 +
426 + More information at: http://www.linuximq.net/
427 +
428 + To compile this driver as a module, choose M here: the module
429 + will be called imq. If unsure, say N.
430 +
431 +choice
432 + prompt "IMQ behavior (PRE/POSTROUTING)"
433 + depends on IMQ
434 + default IMQ_BEHAVIOR_BA
435 + help
436 +
437 + This settings defines how IMQ behaves in respect to its
438 + hooking in PREROUTING and POSTROUTING.
439 +
440 + IMQ can work in any of the following ways:
441 +
442 + PREROUTING | POSTROUTING
443 + -----------------|-------------------
444 + #1 After NAT | After NAT
445 + #2 After NAT | Before NAT
446 + #3 Before NAT | After NAT
447 + #4 Before NAT | Before NAT
448 +
449 + The default behavior is to hook before NAT on PREROUTING
450 + and after NAT on POSTROUTING (#3).
451 +
452 + This settings are specially usefull when trying to use IMQ
453 + to shape NATed clients.
454 +
455 + More information can be found at: www.linuximq.net
456 +
457 + If not sure leave the default settings alone.
458 +
459 +config IMQ_BEHAVIOR_AA
460 + bool "IMQ AA"
461 + help
462 + This settings defines how IMQ behaves in respect to its
463 + hooking in PREROUTING and POSTROUTING.
464 +
465 + Choosing this option will make IMQ hook like this:
466 +
467 + PREROUTING: After NAT
468 + POSTROUTING: After NAT
469 +
470 + More information can be found at: www.linuximq.net
471 +
472 + If not sure leave the default settings alone.
473 +
474 +config IMQ_BEHAVIOR_AB
475 + bool "IMQ AB"
476 + help
477 + This settings defines how IMQ behaves in respect to its
478 + hooking in PREROUTING and POSTROUTING.
479 +
480 + Choosing this option will make IMQ hook like this:
481 +
482 + PREROUTING: After NAT
483 + POSTROUTING: Before NAT
484 +
485 + More information can be found at: www.linuximq.net
486 +
487 + If not sure leave the default settings alone.
488 +
489 +config IMQ_BEHAVIOR_BA
490 + bool "IMQ BA"
491 + help
492 + This settings defines how IMQ behaves in respect to its
493 + hooking in PREROUTING and POSTROUTING.
494 +
495 + Choosing this option will make IMQ hook like this:
496 +
497 + PREROUTING: Before NAT
498 + POSTROUTING: After NAT
499 +
500 + More information can be found at: www.linuximq.net
501 +
502 + If not sure leave the default settings alone.
503 +
504 +config IMQ_BEHAVIOR_BB
505 + bool "IMQ BB"
506 + help
507 + This settings defines how IMQ behaves in respect to its
508 + hooking in PREROUTING and POSTROUTING.
509 +
510 + Choosing this option will make IMQ hook like this:
511 +
512 + PREROUTING: Before NAT
513 + POSTROUTING: Before NAT
514 +
515 + More information can be found at: www.linuximq.net
516 +
517 + If not sure leave the default settings alone.
518 +
519 +endchoice
520 +
521 +config IMQ_NUM_DEVS
522 +
523 + int "Number of IMQ devices"
524 + range 2 8
525 + depends on IMQ
526 + default "2"
527 + help
528 +
529 + This settings defines how many IMQ devices will be
530 + created.
531 +
532 + The default value is 2.
533 +
534 + More information can be found at: www.linuximq.net
535 +
536 + If not sure leave the default settings alone.
537 +
538 config TUN
539 tristate "Universal TUN/TAP device driver support"
540 select CRC32
541 diff -Nur linux-2.6.16/drivers/net/Makefile linux-2.6.16-owrt/drivers/net/Makefile
542 --- linux-2.6.16/drivers/net/Makefile 2006-03-20 06:53:29.000000000 +0100
543 +++ linux-2.6.16-owrt/drivers/net/Makefile 2006-03-20 13:00:13.000000000 +0100
544 @@ -125,6 +125,7 @@
545 endif
546
547 obj-$(CONFIG_DUMMY) += dummy.o
548 +obj-$(CONFIG_IMQ) += imq.o
549 obj-$(CONFIG_IFB) += ifb.o
550 obj-$(CONFIG_DE600) += de600.o
551 obj-$(CONFIG_DE620) += de620.o
552 diff -Nur linux-2.6.16/include/linux/imq.h linux-2.6.16-owrt/include/linux/imq.h
553 --- linux-2.6.16/include/linux/imq.h 1970-01-01 01:00:00.000000000 +0100
554 +++ linux-2.6.16-owrt/include/linux/imq.h 2006-03-20 12:59:23.000000000 +0100
555 @@ -0,0 +1,9 @@
556 +#ifndef _IMQ_H
557 +#define _IMQ_H
558 +
559 +#define IMQ_MAX_DEVS 16
560 +
561 +#define IMQ_F_IFMASK 0x7f
562 +#define IMQ_F_ENQUEUE 0x80
563 +
564 +#endif /* _IMQ_H */
565 diff -Nur linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.16-owrt/include/linux/netfilter_ipv4/ipt_IMQ.h
566 --- linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 01:00:00.000000000 +0100
567 +++ linux-2.6.16-owrt/include/linux/netfilter_ipv4/ipt_IMQ.h 2006-03-20 12:59:23.000000000 +0100
568 @@ -0,0 +1,8 @@
569 +#ifndef _IPT_IMQ_H
570 +#define _IPT_IMQ_H
571 +
572 +struct ipt_imq_info {
573 + unsigned int todev; /* target imq device */
574 +};
575 +
576 +#endif /* _IPT_IMQ_H */
577 diff -Nur linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.16-owrt/include/linux/netfilter_ipv6/ip6t_IMQ.h
578 --- linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 01:00:00.000000000 +0100
579 +++ linux-2.6.16-owrt/include/linux/netfilter_ipv6/ip6t_IMQ.h 2006-03-20 12:59:23.000000000 +0100
580 @@ -0,0 +1,8 @@
581 +#ifndef _IP6T_IMQ_H
582 +#define _IP6T_IMQ_H
583 +
584 +struct ip6t_imq_info {
585 + unsigned int todev; /* target imq device */
586 +};
587 +
588 +#endif /* _IP6T_IMQ_H */
589 diff -Nur linux-2.6.16/include/linux/skbuff.h linux-2.6.16-owrt/include/linux/skbuff.h
590 --- linux-2.6.16/include/linux/skbuff.h 2006-03-20 06:53:29.000000000 +0100
591 +++ linux-2.6.16-owrt/include/linux/skbuff.h 2006-03-20 12:59:23.000000000 +0100
592 @@ -275,6 +275,10 @@
593 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
594 struct sk_buff *nfct_reasm;
595 #endif
596 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
597 + unsigned char imq_flags;
598 + struct nf_info *nf_info;
599 +#endif
600 #ifdef CONFIG_BRIDGE_NETFILTER
601 struct nf_bridge_info *nf_bridge;
602 #endif
603 diff -Nur linux-2.6.16/net/core/skbuff.c linux-2.6.16-owrt/net/core/skbuff.c
604 --- linux-2.6.16/net/core/skbuff.c 2006-03-20 06:53:29.000000000 +0100
605 +++ linux-2.6.16-owrt/net/core/skbuff.c 2006-03-20 12:59:23.000000000 +0100
606 @@ -425,6 +425,10 @@
607 C(nfct_reasm);
608 nf_conntrack_get_reasm(skb->nfct_reasm);
609 #endif
610 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
611 + C(imq_flags);
612 + C(nf_info);
613 +#endif /*CONFIG_IMQ*/
614 #ifdef CONFIG_BRIDGE_NETFILTER
615 C(nf_bridge);
616 nf_bridge_get(skb->nf_bridge);
617 @@ -489,6 +493,10 @@
618 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
619 new->ipvs_property = old->ipvs_property;
620 #endif
621 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
622 + new->imq_flags = old->imq_flags;
623 + new->nf_info = old->nf_info;
624 +#endif /*CONFIG_IMQ*/
625 #ifdef CONFIG_BRIDGE_NETFILTER
626 new->nf_bridge = old->nf_bridge;
627 nf_bridge_get(old->nf_bridge);
628 diff -Nur linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.16-owrt/net/ipv4/netfilter/ipt_IMQ.c
629 --- linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 01:00:00.000000000 +0100
630 +++ linux-2.6.16-owrt/net/ipv4/netfilter/ipt_IMQ.c 2006-03-20 12:59:23.000000000 +0100
631 @@ -0,0 +1,80 @@
632 +/*
633 + * This target marks packets to be enqueued to an imq device
634 + */
635 +#include <linux/module.h>
636 +#include <linux/skbuff.h>
637 +#include <linux/netfilter_ipv4/ip_tables.h>
638 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
639 +#include <linux/imq.h>
640 +
641 +static unsigned int imq_target(struct sk_buff **pskb,
642 + const struct net_device *in,
643 + const struct net_device *out,
644 + unsigned int hooknum,
645 + const void *targinfo,
646 + void *userdata)
647 +{
648 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
649 +
650 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
651 +
652 + return IPT_CONTINUE;
653 +}
654 +
655 +static int imq_checkentry(const char *tablename,
656 + const struct ipt_entry *e,
657 + void *targinfo,
658 + unsigned int targinfosize,
659 + unsigned int hook_mask)
660 +{
661 + struct ipt_imq_info *mr;
662 +
663 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) {
664 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
665 + return 0;
666 + }
667 + mr = (struct ipt_imq_info*)targinfo;
668 +
669 + if (strcmp(tablename, "mangle") != 0) {
670 + printk(KERN_WARNING
671 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
672 + tablename);
673 + return 0;
674 + }
675 +
676 + if (mr->todev > IMQ_MAX_DEVS) {
677 + printk(KERN_WARNING
678 + "IMQ: invalid device specified, highest is %u\n",
679 + IMQ_MAX_DEVS);
680 + return 0;
681 + }
682 +
683 + return 1;
684 +}
685 +
686 +static struct ipt_target ipt_imq_reg = {
687 + .name = "IMQ",
688 + .target = imq_target,
689 + .checkentry = imq_checkentry,
690 + .me = THIS_MODULE
691 +};
692 +
693 +static int __init init(void)
694 +{
695 + if (ipt_register_target(&ipt_imq_reg))
696 + return -EINVAL;
697 +
698 + return 0;
699 +}
700 +
701 +static void __exit fini(void)
702 +{
703 + ipt_unregister_target(&ipt_imq_reg);
704 +}
705 +
706 +module_init(init);
707 +module_exit(fini);
708 +
709 +MODULE_AUTHOR("http://www.linuximq.net");
710 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
711 +MODULE_LICENSE("GPL");
712 diff -Nur linux-2.6.16/net/ipv4/netfilter/Kconfig linux-2.6.16-owrt/net/ipv4/netfilter/Kconfig
713 --- linux-2.6.16/net/ipv4/netfilter/Kconfig 2006-03-20 12:58:53.000000000 +0100
714 +++ linux-2.6.16-owrt/net/ipv4/netfilter/Kconfig 2006-03-20 12:59:23.000000000 +0100
715 @@ -351,6 +351,17 @@
716
717 To compile it as a module, choose M here. If unsure, say N.
718
719 +config IP_NF_TARGET_IMQ
720 + tristate "IMQ target support"
721 + depends on IP_NF_MANGLE
722 + help
723 + This option adds a `IMQ' target which is used to specify if and
724 + to which IMQ device packets should get enqueued/dequeued.
725 +
726 + For more information visit: http://www.linuximq.net/
727 +
728 + To compile it as a module, choose M here. If unsure, say N.
729 +
730 config IP_NF_TARGET_LOG
731 tristate "LOG target support"
732 depends on IP_NF_IPTABLES
733 diff -Nur linux-2.6.16/net/ipv4/netfilter/Makefile linux-2.6.16-owrt/net/ipv4/netfilter/Makefile
734 --- linux-2.6.16/net/ipv4/netfilter/Makefile 2006-03-20 12:58:53.000000000 +0100
735 +++ linux-2.6.16-owrt/net/ipv4/netfilter/Makefile 2006-03-20 13:01:12.000000000 +0100
736 @@ -67,6 +67,7 @@
737 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
738 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
739 obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
740 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
741 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
742 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
743 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
744 diff -Nur linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.16-owrt/net/ipv6/netfilter/ip6t_IMQ.c
745 --- linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 01:00:00.000000000 +0100
746 +++ linux-2.6.16-owrt/net/ipv6/netfilter/ip6t_IMQ.c 2006-03-20 12:59:23.000000000 +0100
747 @@ -0,0 +1,80 @@
748 +/*
749 + * This target marks packets to be enqueued to an imq device
750 + */
751 +#include <linux/module.h>
752 +#include <linux/skbuff.h>
753 +#include <linux/netfilter_ipv6/ip6_tables.h>
754 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
755 +#include <linux/imq.h>
756 +
757 +static unsigned int imq_target(struct sk_buff **pskb,
758 + unsigned int hooknum,
759 + const struct net_device *in,
760 + const struct net_device *out,
761 + const void *targinfo,
762 + void *userdata)
763 +{
764 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
765 +
766 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
767 +
768 + return IP6T_CONTINUE;
769 +}
770 +
771 +static int imq_checkentry(const char *tablename,
772 + const struct ip6t_entry *e,
773 + void *targinfo,
774 + unsigned int targinfosize,
775 + unsigned int hook_mask)
776 +{
777 + struct ip6t_imq_info *mr;
778 +
779 + if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) {
780 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
781 + return 0;
782 + }
783 + mr = (struct ip6t_imq_info*)targinfo;
784 +
785 + if (strcmp(tablename, "mangle") != 0) {
786 + printk(KERN_WARNING
787 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
788 + tablename);
789 + return 0;
790 + }
791 +
792 + if (mr->todev > IMQ_MAX_DEVS) {
793 + printk(KERN_WARNING
794 + "IMQ: invalid device specified, highest is %u\n",
795 + IMQ_MAX_DEVS);
796 + return 0;
797 + }
798 +
799 + return 1;
800 +}
801 +
802 +static struct ip6t_target ip6t_imq_reg = {
803 + .name = "IMQ",
804 + .target = imq_target,
805 + .checkentry = imq_checkentry,
806 + .me = THIS_MODULE
807 +};
808 +
809 +static int __init init(void)
810 +{
811 + if (ip6t_register_target(&ip6t_imq_reg))
812 + return -EINVAL;
813 +
814 + return 0;
815 +}
816 +
817 +static void __exit fini(void)
818 +{
819 + ip6t_unregister_target(&ip6t_imq_reg);
820 +}
821 +
822 +module_init(init);
823 +module_exit(fini);
824 +
825 +MODULE_AUTHOR("http://www.linuximq.net");
826 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
827 +MODULE_LICENSE("GPL");
828 diff -Nur linux-2.6.16/net/ipv6/netfilter/Kconfig linux-2.6.16-owrt/net/ipv6/netfilter/Kconfig
829 --- linux-2.6.16/net/ipv6/netfilter/Kconfig 2006-03-20 06:53:29.000000000 +0100
830 +++ linux-2.6.16-owrt/net/ipv6/netfilter/Kconfig 2006-03-20 12:59:23.000000000 +0100
831 @@ -154,6 +154,15 @@
832
833 To compile it as a module, choose M here. If unsure, say N.
834
835 +config IP6_NF_TARGET_IMQ
836 + tristate "IMQ target support"
837 + depends on IP6_NF_MANGLE
838 + help
839 + This option adds a `IMQ' target which is used to specify if and
840 + to which imq device packets should get enqueued/dequeued.
841 +
842 + To compile it as a module, choose M here. If unsure, say N.
843 +
844 config IP6_NF_TARGET_LOG
845 tristate "LOG target support"
846 depends on IP6_NF_FILTER
847 diff -Nur linux-2.6.16/net/ipv6/netfilter/Makefile linux-2.6.16-owrt/net/ipv6/netfilter/Makefile
848 --- linux-2.6.16/net/ipv6/netfilter/Makefile 2006-03-20 06:53:29.000000000 +0100
849 +++ linux-2.6.16-owrt/net/ipv6/netfilter/Makefile 2006-03-20 13:02:14.000000000 +0100
850 @@ -4,6 +4,7 @@
851
852 # Link order matters here.
853 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
854 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
855 obj-$(CONFIG_IP6_NF_MATCH_RT) += ip6t_rt.o
856 obj-$(CONFIG_IP6_NF_MATCH_OPTS) += ip6t_hbh.o ip6t_dst.o
857 obj-$(CONFIG_IP6_NF_MATCH_IPV6HEADER) += ip6t_ipv6header.o
858 diff -Nur linux-2.6.16/net/sched/sch_generic.c linux-2.6.16-owrt/net/sched/sch_generic.c
859 --- linux-2.6.16/net/sched/sch_generic.c 2006-03-20 06:53:29.000000000 +0100
860 +++ linux-2.6.16-owrt/net/sched/sch_generic.c 2006-03-20 12:59:23.000000000 +0100
861 @@ -29,6 +29,9 @@
862 #include <linux/netdevice.h>
863 #include <linux/skbuff.h>
864 #include <linux/rtnetlink.h>
865 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
866 +#include <linux/imq.h>
867 +#endif
868 #include <linux/init.h>
869 #include <linux/rcupdate.h>
870 #include <linux/list.h>
871 @@ -136,7 +139,13 @@
872
873 if (!netif_queue_stopped(dev)) {
874 int ret;
875 - if (netdev_nit)
876 +
877 + if (netdev_nit
878 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
879 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
880 +#endif
881 + )
882 +
883 dev_queue_xmit_nit(skb, dev);
884
885 ret = dev->hard_start_xmit(skb, dev);