1 Index: linux-2.6.23.17/drivers/net/imq.c
2 ===================================================================
4 +++ linux-2.6.23.17/drivers/net/imq.c
7 + * Pseudo-driver for the intermediate queue device.
9 + * This program is free software; you can redistribute it and/or
10 + * modify it under the terms of the GNU General Public License
11 + * as published by the Free Software Foundation; either version
12 + * 2 of the License, or (at your option) any later version.
14 + * Authors: Patrick McHardy, <kaber@trash.net>
16 + * The first version was written by Martin Devera, <devik@cdi.cz>
18 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
19 + * - Update patch to 2.4.21
20 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
21 + * - Fix "Dead-loop on netdevice imq"-issue
22 + * Marcel Sebek <sebek64@post.cz>
23 + * - Update to 2.6.2-rc1
25 + * After some time of inactivity there is a group taking care
26 + * of IMQ again: http://www.linuximq.net
29 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
30 + * the following changes:
32 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
33 + * - Correction of imq_init_devs() issue that resulted in
34 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
35 + * - Addition of functionality to choose number of IMQ devices
36 + * during kernel config (Andre Correa)
37 + * - Addition of functionality to choose how IMQ hooks on
38 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
39 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
42 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
43 + * released with almost no problems. 2.6.14-x was released
44 + * with some important changes: nfcache was removed; After
45 + * some weeks of trouble we figured out that some IMQ fields
46 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
47 + * These functions are correctly patched by this new patch version.
49 + * Thanks for all who helped to figure out all the problems with
50 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
51 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
52 + * I didn't forget anybody). I apologize again for my lack of time.
54 + * More info at: http://www.linuximq.net/ (Andre Correa)
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 +extern int qdisc_restart1(struct net_device *dev);
74 +static nf_hookfn imq_nf_hook;
76 +static struct nf_hook_ops imq_ingress_ipv4 = {
77 + .hook = imq_nf_hook,
78 + .owner = THIS_MODULE,
80 + .hooknum = NF_IP_PRE_ROUTING,
81 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
82 + .priority = NF_IP_PRI_MANGLE + 1
84 + .priority = NF_IP_PRI_NAT_DST + 1
88 +static struct nf_hook_ops imq_egress_ipv4 = {
89 + .hook = imq_nf_hook,
90 + .owner = THIS_MODULE,
92 + .hooknum = NF_IP_POST_ROUTING,
93 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
94 + .priority = NF_IP_PRI_LAST
96 + .priority = NF_IP_PRI_NAT_SRC - 1
100 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
101 +static struct nf_hook_ops imq_ingress_ipv6 = {
102 + .hook = imq_nf_hook,
103 + .owner = THIS_MODULE,
105 + .hooknum = NF_IP6_PRE_ROUTING,
106 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
107 + .priority = NF_IP6_PRI_MANGLE + 1
109 + .priority = NF_IP6_PRI_NAT_DST + 1
113 +static struct nf_hook_ops imq_egress_ipv6 = {
114 + .hook = imq_nf_hook,
115 + .owner = THIS_MODULE,
117 + .hooknum = NF_IP6_POST_ROUTING,
118 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
119 + .priority = NF_IP6_PRI_LAST
121 + .priority = NF_IP6_PRI_NAT_SRC - 1
126 +#if defined(CONFIG_IMQ_NUM_DEVS)
127 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
129 +static unsigned int numdevs = 16;
132 +static struct net_device *imq_devs;
134 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
136 + return (struct net_device_stats *)dev->priv;
139 +/* called for packets kfree'd in qdiscs at places other than enqueue */
140 +static void imq_skb_destructor(struct sk_buff *skb)
142 + struct nf_info *info = skb->nf_info;
146 + dev_put(info->indev);
148 + dev_put(info->outdev);
153 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
155 + struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
157 + stats->tx_bytes += skb->len;
158 + stats->tx_packets++;
160 + skb->imq_flags = 0;
161 + skb->destructor = NULL;
163 + dev->trans_start = jiffies;
164 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
168 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
170 + struct net_device *dev;
171 + struct net_device_stats *stats;
172 + struct sk_buff *skb2 = NULL;
174 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
177 + if (index > numdevs)
180 + dev = imq_devs + index;
181 + if (!(dev->flags & IFF_UP)) {
182 + skb->imq_flags = 0;
183 + nf_reinject(skb, info, NF_ACCEPT);
186 + dev->last_rx = jiffies;
188 + if (skb->destructor) {
190 + skb = skb_clone(skb, GFP_ATOMIC);
194 + skb->nf_info = info;
196 + stats = (struct net_device_stats *)dev->priv;
197 + stats->rx_bytes+= skb->len;
198 + stats->rx_packets++;
200 + spin_lock_bh(&dev->queue_lock);
203 + q->enqueue(skb_get(skb), q);
204 + if (skb_shared(skb)) {
205 + skb->destructor = imq_skb_destructor;
210 + if (spin_is_locked(&dev->_xmit_lock))
211 + netif_schedule(dev);
213 + while (!netif_queue_stopped(dev) && qdisc_restart1(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, &nfqh);
269 + nf_unregister_hook(&imq_egress_ipv4);
272 + nf_unregister_hook(&imq_ingress_ipv4);
274 + nf_unregister_queue_handler(PF_INET, &nfqh);
279 +static void __exit imq_unhook(void)
281 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
282 + nf_unregister_hook(&imq_ingress_ipv6);
283 + nf_unregister_hook(&imq_egress_ipv6);
284 + nf_unregister_queue_handler(PF_INET6, &nfqh);
286 + nf_unregister_hook(&imq_ingress_ipv4);
287 + nf_unregister_hook(&imq_egress_ipv4);
288 + nf_unregister_queue_handler(PF_INET, &nfqh);
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 = 11000;
297 + dev->flags = IFF_NOARP;
298 + dev->priv = kzalloc(sizeof(struct net_device_stats), GFP_KERNEL);
299 + if (dev->priv == NULL)
301 + dev->get_stats = imq_get_stats;
306 +static void imq_dev_uninit(struct net_device *dev)
311 +static int __init imq_init_devs(void)
313 + struct net_device *dev;
317 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
318 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
323 + imq_devs = kzalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
327 + /* we start counting at zero */
330 + for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
331 + SET_MODULE_OWNER(dev);
332 + strcpy(dev->name, "imq%d");
333 + dev->init = imq_dev_init;
334 + dev->uninit = imq_dev_uninit;
336 + if (register_netdev(dev) < 0)
339 + printk(KERN_INFO "IMQ starting with %u devices...\n", j);
344 + unregister_netdev(--dev);
349 +static void imq_cleanup_devs(void)
352 + struct net_device *dev = imq_devs;
354 + for (i = 0; i <= numdevs; i++)
355 + unregister_netdev(dev++);
360 +static int __init imq_init_module(void)
364 + if ((err = imq_init_devs())) {
365 + printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
368 + if ((err = imq_init_hooks())) {
369 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
370 + imq_cleanup_devs();
374 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
376 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
377 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
379 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
381 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
382 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
384 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
390 +static void __exit imq_cleanup_module(void)
393 + imq_cleanup_devs();
394 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
398 +module_init(imq_init_module);
399 +module_exit(imq_cleanup_module);
401 +module_param(numdevs, int, 16);
402 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
403 +MODULE_AUTHOR("http://www.linuximq.net");
404 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
405 +MODULE_LICENSE("GPL");
406 Index: linux-2.6.23.17/drivers/net/Kconfig
407 ===================================================================
408 --- linux-2.6.23.17.orig/drivers/net/Kconfig
409 +++ linux-2.6.23.17/drivers/net/Kconfig
410 @@ -112,6 +112,129 @@ config EQUALIZER
411 To compile this driver as a module, choose M here: the module
412 will be called eql. If unsure, say N.
415 + tristate "IMQ (intermediate queueing device) support"
416 + depends on NETDEVICES && NETFILTER
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.
425 + More information at: http://www.linuximq.net/
427 + To compile this driver as a module, choose M here: the module
428 + will be called imq. If unsure, say N.
431 + prompt "IMQ behavior (PRE/POSTROUTING)"
433 + default IMQ_BEHAVIOR_AB
436 + This settings defines how IMQ behaves in respect to its
437 + hooking in PREROUTING and POSTROUTING.
439 + IMQ can work in any of the following ways:
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
448 + The default behavior is to hook before NAT on PREROUTING
449 + and after NAT on POSTROUTING (#3).
451 + This settings are specially usefull when trying to use IMQ
452 + to shape NATed clients.
454 + More information can be found at: www.linuximq.net
456 + If not sure leave the default settings alone.
458 +config IMQ_BEHAVIOR_AA
461 + This settings defines how IMQ behaves in respect to its
462 + hooking in PREROUTING and POSTROUTING.
464 + Choosing this option will make IMQ hook like this:
466 + PREROUTING: After NAT
467 + POSTROUTING: After NAT
469 + More information can be found at: www.linuximq.net
471 + If not sure leave the default settings alone.
473 +config IMQ_BEHAVIOR_AB
476 + This settings defines how IMQ behaves in respect to its
477 + hooking in PREROUTING and POSTROUTING.
479 + Choosing this option will make IMQ hook like this:
481 + PREROUTING: After NAT
482 + POSTROUTING: Before NAT
484 + More information can be found at: www.linuximq.net
486 + If not sure leave the default settings alone.
488 +config IMQ_BEHAVIOR_BA
491 + This settings defines how IMQ behaves in respect to its
492 + hooking in PREROUTING and POSTROUTING.
494 + Choosing this option will make IMQ hook like this:
496 + PREROUTING: Before NAT
497 + POSTROUTING: After NAT
499 + More information can be found at: www.linuximq.net
501 + If not sure leave the default settings alone.
503 +config IMQ_BEHAVIOR_BB
506 + This settings defines how IMQ behaves in respect to its
507 + hooking in PREROUTING and POSTROUTING.
509 + Choosing this option will make IMQ hook like this:
511 + PREROUTING: Before NAT
512 + POSTROUTING: Before NAT
514 + More information can be found at: www.linuximq.net
516 + If not sure leave the default settings alone.
522 + int "Number of IMQ devices"
528 + This settings defines how many IMQ devices will be
531 + The default value is 16.
533 + More information can be found at: www.linuximq.net
535 + If not sure leave the default settings alone.
538 tristate "Universal TUN/TAP device driver support"
540 Index: linux-2.6.23.17/drivers/net/Makefile
541 ===================================================================
542 --- linux-2.6.23.17.orig/drivers/net/Makefile
543 +++ linux-2.6.23.17/drivers/net/Makefile
544 @@ -131,6 +131,7 @@ obj-$(CONFIG_SLHC) += slhc.o
545 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
547 obj-$(CONFIG_DUMMY) += dummy.o
548 +obj-$(CONFIG_IMQ) += imq.o
549 obj-$(CONFIG_IFB) += ifb.o
550 obj-$(CONFIG_MACVLAN) += macvlan.o
551 obj-$(CONFIG_DE600) += de600.o
552 Index: linux-2.6.23.17/include/linux/imq.h
553 ===================================================================
555 +++ linux-2.6.23.17/include/linux/imq.h
560 +#define IMQ_MAX_DEVS 16
562 +#define IMQ_F_IFMASK 0x7f
563 +#define IMQ_F_ENQUEUE 0x80
566 Index: linux-2.6.23.17/include/linux/netfilter_ipv4/ipt_IMQ.h
567 ===================================================================
569 +++ linux-2.6.23.17/include/linux/netfilter_ipv4/ipt_IMQ.h
574 +struct ipt_imq_info {
575 + unsigned int todev; /* target imq device */
578 +#endif /* _IPT_IMQ_H */
579 Index: linux-2.6.23.17/include/linux/netfilter_ipv6/ip6t_IMQ.h
580 ===================================================================
582 +++ linux-2.6.23.17/include/linux/netfilter_ipv6/ip6t_IMQ.h
587 +struct ip6t_imq_info {
588 + unsigned int todev; /* target imq device */
591 +#endif /* _IP6T_IMQ_H */
592 Index: linux-2.6.23.17/include/linux/skbuff.h
593 ===================================================================
594 --- linux-2.6.23.17.orig/include/linux/skbuff.h
595 +++ linux-2.6.23.17/include/linux/skbuff.h
596 @@ -295,6 +295,10 @@ struct sk_buff {
597 struct nf_conntrack *nfct;
598 struct sk_buff *nfct_reasm;
600 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
601 + unsigned char imq_flags;
602 + struct nf_info *nf_info;
604 #ifdef CONFIG_BRIDGE_NETFILTER
605 struct nf_bridge_info *nf_bridge;
607 @@ -1725,6 +1729,10 @@ static inline void __nf_copy(struct sk_b
608 dst->nfct_reasm = src->nfct_reasm;
609 nf_conntrack_get_reasm(src->nfct_reasm);
611 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
612 + dst->imq_flags = src->imq_flags;
613 + dst->nf_info = src->nf_info;
615 #ifdef CONFIG_BRIDGE_NETFILTER
616 dst->nf_bridge = src->nf_bridge;
617 nf_bridge_get(src->nf_bridge);
618 Index: linux-2.6.23.17/net/core/dev.c
619 ===================================================================
620 --- linux-2.6.23.17.orig/net/core/dev.c
621 +++ linux-2.6.23.17/net/core/dev.c
623 #include <linux/skbuff.h>
624 #include <net/sock.h>
625 #include <linux/rtnetlink.h>
626 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
627 +#include <linux/imq.h>
629 #include <linux/proc_fs.h>
630 #include <linux/seq_file.h>
631 #include <linux/stat.h>
632 @@ -1462,7 +1465,11 @@ static int dev_gso_segment(struct sk_buf
633 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
635 if (likely(!skb->next)) {
636 - if (!list_empty(&ptype_all))
637 + if (!list_empty(&ptype_all)
638 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
639 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
642 dev_queue_xmit_nit(skb, dev);
644 if (netif_needs_gso(dev, skb)) {
645 Index: linux-2.6.23.17/net/ipv4/netfilter/ipt_IMQ.c
646 ===================================================================
648 +++ linux-2.6.23.17/net/ipv4/netfilter/ipt_IMQ.c
651 + * This target marks packets to be enqueued to an imq device
653 +#include <linux/module.h>
654 +#include <linux/skbuff.h>
655 +#include <linux/netfilter_ipv4/ip_tables.h>
656 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
657 +#include <linux/imq.h>
659 +static unsigned int imq_target(struct sk_buff **pskb,
660 + const struct net_device *in,
661 + const struct net_device *out,
662 + unsigned int hooknum,
663 + const struct xt_target *target,
664 + const void *targinfo)
666 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
668 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
670 + return XT_CONTINUE;
673 +static bool imq_checkentry(const char *tablename,
675 + const struct xt_target *target,
677 + unsigned int hook_mask)
679 + struct ipt_imq_info *mr;
681 + mr = (struct ipt_imq_info*)targinfo;
683 + if (mr->todev > IMQ_MAX_DEVS) {
684 + printk(KERN_WARNING
685 + "IMQ: invalid device specified, highest is %u\n",
693 +static struct xt_target ipt_imq_reg = {
696 + .target = imq_target,
697 + .targetsize = sizeof(struct ipt_imq_info),
698 + .checkentry = imq_checkentry,
703 +static int __init init(void)
705 + return xt_register_target(&ipt_imq_reg);
708 +static void __exit fini(void)
710 + xt_unregister_target(&ipt_imq_reg);
716 +MODULE_AUTHOR("http://www.linuximq.net");
717 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
718 +MODULE_LICENSE("GPL");
719 Index: linux-2.6.23.17/net/ipv4/netfilter/Kconfig
720 ===================================================================
721 --- linux-2.6.23.17.orig/net/ipv4/netfilter/Kconfig
722 +++ linux-2.6.23.17/net/ipv4/netfilter/Kconfig
723 @@ -333,6 +333,17 @@ config IP_NF_MANGLE
725 To compile it as a module, choose M here. If unsure, say N.
727 +config IP_NF_TARGET_IMQ
728 + tristate "IMQ target support"
729 + depends on IP_NF_MANGLE
731 + This option adds a `IMQ' target which is used to specify if and
732 + to which IMQ device packets should get enqueued/dequeued.
734 + For more information visit: http://www.linuximq.net/
736 + To compile it as a module, choose M here. If unsure, say N.
738 config IP_NF_TARGET_TOS
739 tristate "TOS target support"
740 depends on IP_NF_MANGLE
741 Index: linux-2.6.23.17/net/ipv4/netfilter/Makefile
742 ===================================================================
743 --- linux-2.6.23.17.orig/net/ipv4/netfilter/Makefile
744 +++ linux-2.6.23.17/net/ipv4/netfilter/Makefile
745 @@ -58,6 +58,7 @@ obj-$(CONFIG_IP_NF_MATCH_IPP2P) += ipt_i
746 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
747 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
748 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
749 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
750 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
751 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
752 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
753 Index: linux-2.6.23.17/net/ipv6/netfilter/ip6t_IMQ.c
754 ===================================================================
756 +++ linux-2.6.23.17/net/ipv6/netfilter/ip6t_IMQ.c
759 + * This target marks packets to be enqueued to an imq device
761 +#include <linux/module.h>
762 +#include <linux/skbuff.h>
763 +#include <linux/netfilter_ipv6/ip6_tables.h>
764 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
765 +#include <linux/imq.h>
767 +static unsigned int imq_target(struct sk_buff **pskb,
768 + const struct net_device *in,
769 + const struct net_device *out,
770 + unsigned int hooknum,
771 + const struct xt_target *target,
772 + const void *targinfo)
774 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
776 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
778 + return XT_CONTINUE;
781 +static bool imq_checkentry(const char *tablename,
783 + const struct xt_target *target,
785 + unsigned int hook_mask)
787 + struct ip6t_imq_info *mr;
789 + mr = (struct ip6t_imq_info*)targinfo;
791 + if (mr->todev > IMQ_MAX_DEVS) {
792 + printk(KERN_WARNING
793 + "IMQ: invalid device specified, highest is %u\n",
801 +static struct xt_target ip6t_imq_reg = {
803 + .family = AF_INET6,
804 + .target = imq_target,
805 + .targetsize = sizeof(struct ip6t_imq_info),
807 + .checkentry = imq_checkentry,
811 +static int __init init(void)
813 + return xt_register_target(&ip6t_imq_reg);
816 +static void __exit fini(void)
818 + xt_unregister_target(&ip6t_imq_reg);
824 +MODULE_AUTHOR("http://www.linuximq.net");
825 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
826 +MODULE_LICENSE("GPL");
827 Index: linux-2.6.23.17/net/ipv6/netfilter/Kconfig
828 ===================================================================
829 --- linux-2.6.23.17.orig/net/ipv6/netfilter/Kconfig
830 +++ linux-2.6.23.17/net/ipv6/netfilter/Kconfig
831 @@ -173,6 +173,15 @@ config IP6_NF_MANGLE
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_HL
845 tristate 'HL (hoplimit) target support'
846 depends on IP6_NF_MANGLE
847 Index: linux-2.6.23.17/net/ipv6/netfilter/Makefile
848 ===================================================================
849 --- linux-2.6.23.17.orig/net/ipv6/netfilter/Makefile
850 +++ linux-2.6.23.17/net/ipv6/netfilter/Makefile
851 @@ -13,6 +13,7 @@ obj-$(CONFIG_IP6_NF_MATCH_EUI64) += ip6t
852 obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
853 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
854 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
855 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
856 obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
857 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
858 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
859 Index: linux-2.6.23.17/net/sched/sch_generic.c
860 ===================================================================
861 --- linux-2.6.23.17.orig/net/sched/sch_generic.c
862 +++ linux-2.6.23.17/net/sched/sch_generic.c
863 @@ -191,6 +191,11 @@ static inline int qdisc_restart(struct n
867 +int qdisc_restart1(struct net_device *dev)
869 + return qdisc_restart(dev);
872 void __qdisc_run(struct net_device *dev)
875 @@ -620,3 +625,4 @@ EXPORT_SYMBOL(qdisc_destroy);
876 EXPORT_SYMBOL(qdisc_reset);
877 EXPORT_SYMBOL(qdisc_lock_tree);
878 EXPORT_SYMBOL(qdisc_unlock_tree);
879 +EXPORT_SYMBOL(qdisc_restart1);