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