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
6 + * Pseudo-driver for the intermediate queue device.
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.
13 + * Authors: Patrick McHardy, <kaber@trash.net>
15 + * The first version was written by Martin Devera, <devik@cdi.cz>
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
24 + * After some time of inactivity there is a group taking care
25 + * of IMQ again: http://www.linuximq.net
28 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
29 + * the following changes:
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)
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.
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.
53 + * More info at: http://www.linuximq.net/ (Andre Correa)
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>
69 +#include <linux/imq.h>
70 +#include <net/pkt_sched.h>
72 +static nf_hookfn imq_nf_hook;
74 +static struct nf_hook_ops imq_ingress_ipv4 = {
75 + .hook = imq_nf_hook,
76 + .owner = THIS_MODULE,
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
82 + .priority = NF_IP_PRI_NAT_DST + 1
86 +static struct nf_hook_ops imq_egress_ipv4 = {
87 + .hook = imq_nf_hook,
88 + .owner = THIS_MODULE,
90 + .hooknum = NF_IP_POST_ROUTING,
91 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
92 + .priority = NF_IP_PRI_LAST
94 + .priority = NF_IP_PRI_NAT_SRC - 1
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,
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
107 + .priority = NF_IP6_PRI_NAT_DST + 1
111 +static struct nf_hook_ops imq_egress_ipv6 = {
112 + .hook = imq_nf_hook,
113 + .owner = THIS_MODULE,
115 + .hooknum = NF_IP6_POST_ROUTING,
116 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
117 + .priority = NF_IP6_PRI_LAST
119 + .priority = NF_IP6_PRI_NAT_SRC - 1
124 +#if defined(CONFIG_IMQ_NUM_DEVS)
125 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
127 +static unsigned int numdevs = 2;
130 +static struct net_device *imq_devs;
132 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
134 + return (struct net_device_stats *)dev->priv;
137 +/* called for packets kfree'd in qdiscs at places other than enqueue */
138 +static void imq_skb_destructor(struct sk_buff *skb)
140 + struct nf_info *info = skb->nf_info;
144 + dev_put(info->indev);
146 + dev_put(info->outdev);
151 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
153 + struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
155 + stats->tx_bytes += skb->len;
156 + stats->tx_packets++;
158 + skb->imq_flags = 0;
159 + skb->destructor = NULL;
161 + dev->trans_start = jiffies;
162 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
166 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
168 + struct net_device *dev;
169 + struct net_device_stats *stats;
170 + struct sk_buff *skb2 = NULL;
172 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
175 + if (index > numdevs)
178 + dev = imq_devs + index;
179 + if (!(dev->flags & IFF_UP)) {
180 + skb->imq_flags = 0;
181 + nf_reinject(skb, info, NF_ACCEPT);
184 + dev->last_rx = jiffies;
186 + if (skb->destructor) {
188 + skb = skb_clone(skb, GFP_ATOMIC);
192 + skb->nf_info = info;
194 + stats = (struct net_device_stats *)dev->priv;
195 + stats->rx_bytes+= skb->len;
196 + stats->rx_packets++;
198 + spin_lock_bh(&dev->queue_lock);
201 + q->enqueue(skb_get(skb), q);
202 + if (skb_shared(skb)) {
203 + skb->destructor = imq_skb_destructor;
208 + if (spin_is_locked(&dev->xmit_lock))
209 + netif_schedule(dev);
212 + while (!netif_queue_stopped(dev) &&
213 + qdisc_restart(dev)<0)
216 + spin_unlock_bh(&dev->queue_lock);
219 + kfree_skb(ret ? skb : skb2);
224 +static struct nf_queue_handler nfqh = {
226 + .outfn = imq_nf_queue,
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 *))
234 + if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
241 +static int __init imq_init_hooks(void)
245 + err = nf_register_queue_handler(PF_INET, &nfqh);
248 + if ((err = nf_register_hook(&imq_ingress_ipv4)))
250 + if ((err = nf_register_hook(&imq_egress_ipv4)))
252 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
253 + if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
255 + if ((err = nf_register_hook(&imq_ingress_ipv6)))
257 + if ((err = nf_register_hook(&imq_egress_ipv6)))
263 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
265 + nf_unregister_hook(&imq_ingress_ipv6);
267 + nf_unregister_queue_handler(PF_INET6);
269 + nf_unregister_hook(&imq_egress_ipv6);
272 + nf_unregister_hook(&imq_ingress_ipv4);
274 + nf_unregister_queue_handler(PF_INET);
279 +static void __exit imq_unhook(void)
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);
291 +static int __init imq_dev_init(struct net_device *dev)
293 + dev->hard_start_xmit = imq_dev_xmit;
294 + dev->type = ARPHRD_VOID;
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)
301 + memset(dev->priv, 0, sizeof(struct net_device_stats));
302 + dev->get_stats = imq_get_stats;
307 +static void imq_dev_uninit(struct net_device *dev)
312 +static int __init imq_init_devs(void)
314 + struct net_device *dev;
318 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
319 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
324 + imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
327 + memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
329 + /* we start counting at zero */
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;
338 + if (register_netdev(dev) < 0)
341 + printk(KERN_INFO "IMQ starting with %u devices...\n", j);
346 + unregister_netdev(--dev);
351 +static void imq_cleanup_devs(void)
354 + struct net_device *dev = imq_devs;
356 + for (i = 0; i <= numdevs; i++)
357 + unregister_netdev(dev++);
362 +static int __init imq_init_module(void)
366 + if ((err = imq_init_devs())) {
367 + printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
370 + if ((err = imq_init_hooks())) {
371 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
372 + imq_cleanup_devs();
376 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
378 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
379 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
381 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
383 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
384 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
386 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
392 +static void __exit imq_cleanup_module(void)
395 + imq_cleanup_devs();
396 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
400 +module_init(imq_init_module);
401 +module_exit(imq_cleanup_module);
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
412 To compile this driver as a module, choose M here: the module
413 will be called eql. If unsure, say N.
416 + tristate "IMQ (intermediate queueing device) support"
417 + depends on NETDEVICES && NETFILTER
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.
426 + More information at: http://www.linuximq.net/
428 + To compile this driver as a module, choose M here: the module
429 + will be called imq. If unsure, say N.
432 + prompt "IMQ behavior (PRE/POSTROUTING)"
434 + default IMQ_BEHAVIOR_BA
437 + This settings defines how IMQ behaves in respect to its
438 + hooking in PREROUTING and POSTROUTING.
440 + IMQ can work in any of the following ways:
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
449 + The default behavior is to hook before NAT on PREROUTING
450 + and after NAT on POSTROUTING (#3).
452 + This settings are specially usefull when trying to use IMQ
453 + to shape NATed clients.
455 + More information can be found at: www.linuximq.net
457 + If not sure leave the default settings alone.
459 +config IMQ_BEHAVIOR_AA
462 + This settings defines how IMQ behaves in respect to its
463 + hooking in PREROUTING and POSTROUTING.
465 + Choosing this option will make IMQ hook like this:
467 + PREROUTING: After NAT
468 + POSTROUTING: After NAT
470 + More information can be found at: www.linuximq.net
472 + If not sure leave the default settings alone.
474 +config IMQ_BEHAVIOR_AB
477 + This settings defines how IMQ behaves in respect to its
478 + hooking in PREROUTING and POSTROUTING.
480 + Choosing this option will make IMQ hook like this:
482 + PREROUTING: After NAT
483 + POSTROUTING: Before NAT
485 + More information can be found at: www.linuximq.net
487 + If not sure leave the default settings alone.
489 +config IMQ_BEHAVIOR_BA
492 + This settings defines how IMQ behaves in respect to its
493 + hooking in PREROUTING and POSTROUTING.
495 + Choosing this option will make IMQ hook like this:
497 + PREROUTING: Before NAT
498 + POSTROUTING: After NAT
500 + More information can be found at: www.linuximq.net
502 + If not sure leave the default settings alone.
504 +config IMQ_BEHAVIOR_BB
507 + This settings defines how IMQ behaves in respect to its
508 + hooking in PREROUTING and POSTROUTING.
510 + Choosing this option will make IMQ hook like this:
512 + PREROUTING: Before NAT
513 + POSTROUTING: Before NAT
515 + More information can be found at: www.linuximq.net
517 + If not sure leave the default settings alone.
523 + int "Number of IMQ devices"
529 + This settings defines how many IMQ devices will be
532 + The default value is 2.
534 + More information can be found at: www.linuximq.net
536 + If not sure leave the default settings alone.
539 tristate "Universal TUN/TAP device driver support"
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
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
559 +#define IMQ_MAX_DEVS 16
561 +#define IMQ_F_IFMASK 0x7f
562 +#define IMQ_F_ENQUEUE 0x80
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
572 +struct ipt_imq_info {
573 + unsigned int todev; /* target imq device */
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
584 +struct ip6t_imq_info {
585 + unsigned int todev; /* target imq device */
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
593 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
594 struct sk_buff *nfct_reasm;
596 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
597 + unsigned char imq_flags;
598 + struct nf_info *nf_info;
600 #ifdef CONFIG_BRIDGE_NETFILTER
601 struct nf_bridge_info *nf_bridge;
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
608 nf_conntrack_get_reasm(skb->nfct_reasm);
610 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
613 +#endif /*CONFIG_IMQ*/
614 #ifdef CONFIG_BRIDGE_NETFILTER
616 nf_bridge_get(skb->nf_bridge);
618 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
619 new->ipvs_property = old->ipvs_property;
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
633 + * This target marks packets to be enqueued to an imq device
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>
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,
648 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
650 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
652 + return IPT_CONTINUE;
655 +static int imq_checkentry(const char *tablename,
656 + const struct ipt_entry *e,
658 + unsigned int targinfosize,
659 + unsigned int hook_mask)
661 + struct ipt_imq_info *mr;
663 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) {
664 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
667 + mr = (struct ipt_imq_info*)targinfo;
669 + if (strcmp(tablename, "mangle") != 0) {
670 + printk(KERN_WARNING
671 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
676 + if (mr->todev > IMQ_MAX_DEVS) {
677 + printk(KERN_WARNING
678 + "IMQ: invalid device specified, highest is %u\n",
686 +static struct ipt_target ipt_imq_reg = {
688 + .target = imq_target,
689 + .checkentry = imq_checkentry,
693 +static int __init init(void)
695 + if (ipt_register_target(&ipt_imq_reg))
701 +static void __exit fini(void)
703 + ipt_unregister_target(&ipt_imq_reg);
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
717 To compile it as a module, choose M here. If unsure, say N.
719 +config IP_NF_TARGET_IMQ
720 + tristate "IMQ target support"
721 + depends on IP_NF_MANGLE
723 + This option adds a `IMQ' target which is used to specify if and
724 + to which IMQ device packets should get enqueued/dequeued.
726 + For more information visit: http://www.linuximq.net/
728 + To compile it as a module, choose M here. If unsure, say N.
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
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
749 + * This target marks packets to be enqueued to an imq device
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>
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,
764 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
766 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
768 + return IP6T_CONTINUE;
771 +static int imq_checkentry(const char *tablename,
772 + const struct ip6t_entry *e,
774 + unsigned int targinfosize,
775 + unsigned int hook_mask)
777 + struct ip6t_imq_info *mr;
779 + if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) {
780 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
783 + mr = (struct ip6t_imq_info*)targinfo;
785 + if (strcmp(tablename, "mangle") != 0) {
786 + printk(KERN_WARNING
787 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
792 + if (mr->todev > IMQ_MAX_DEVS) {
793 + printk(KERN_WARNING
794 + "IMQ: invalid device specified, highest is %u\n",
802 +static struct ip6t_target ip6t_imq_reg = {
804 + .target = imq_target,
805 + .checkentry = imq_checkentry,
809 +static int __init init(void)
811 + if (ip6t_register_target(&ip6t_imq_reg))
817 +static void __exit fini(void)
819 + ip6t_unregister_target(&ip6t_imq_reg);
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
833 To compile it as a module, choose M here. If unsure, say N.
835 +config IP6_NF_TARGET_IMQ
836 + tristate "IMQ target support"
837 + depends on IP6_NF_MANGLE
839 + This option adds a `IMQ' target which is used to specify if and
840 + to which imq device packets should get enqueued/dequeued.
842 + To compile it as a module, choose M here. If unsure, say N.
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
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
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>
868 #include <linux/init.h>
869 #include <linux/rcupdate.h>
870 #include <linux/list.h>
873 if (!netif_queue_stopped(dev)) {
878 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
879 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
883 dev_queue_xmit_nit(skb, dev);
885 ret = dev->hard_start_xmit(skb, dev);