2 +++ b/drivers/net/imq.c
5 + * Pseudo-driver for the intermediate queue device.
7 + * This program is free software; you can redistribute it and/or
8 + * modify it under the terms of the GNU General Public License
9 + * as published by the Free Software Foundation; either version
10 + * 2 of the License, or (at your option) any later version.
12 + * Authors: Patrick McHardy, <kaber@trash.net>
14 + * The first version was written by Martin Devera, <devik@cdi.cz>
16 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
17 + * - Update patch to 2.4.21
18 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
19 + * - Fix "Dead-loop on netdevice imq"-issue
20 + * Marcel Sebek <sebek64@post.cz>
21 + * - Update to 2.6.2-rc1
23 + * After some time of inactivity there is a group taking care
24 + * of IMQ again: http://www.linuximq.net
27 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7
28 + * including the following changes:
30 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
31 + * - Correction of imq_init_devs() issue that resulted in
32 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
33 + * - Addition of functionality to choose number of IMQ devices
34 + * during kernel config (Andre Correa)
35 + * - Addition of functionality to choose how IMQ hooks on
36 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
37 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
40 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
41 + * released with almost no problems. 2.6.14-x was released
42 + * with some important changes: nfcache was removed; After
43 + * some weeks of trouble we figured out that some IMQ fields
44 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
45 + * These functions are correctly patched by this new patch version.
47 + * Thanks for all who helped to figure out all the problems with
48 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
49 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
50 + * I didn't forget anybody). I apologize again for my lack of time.
53 + * 2008/06/17 - 2.6.25 - Changed imq.c to use qdisc_run() instead
54 + * of qdisc_restart() and moved qdisc_run() to tasklet to avoid
55 + * recursive locking. New initialization routines to fix 'rmmod' not
56 + * working anymore. Used code from ifb.c. (Jussi Kivilinna)
58 + * Also, many thanks to pablo Sebastian Greco for making the initial
59 + * patch and to those who helped the testing.
61 + * More info at: http://www.linuximq.net/ (Andre Correa)
64 +#include <linux/module.h>
65 +#include <linux/kernel.h>
66 +#include <linux/moduleparam.h>
67 +#include <linux/skbuff.h>
68 +#include <linux/netdevice.h>
69 +#include <linux/rtnetlink.h>
70 +#include <linux/if_arp.h>
71 +#include <linux/netfilter.h>
72 +#include <linux/netfilter_ipv4.h>
73 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
74 + #include <linux/netfilter_ipv6.h>
76 +#include <linux/imq.h>
77 +#include <net/pkt_sched.h>
78 +#include <net/netfilter/nf_queue.h>
81 + struct tasklet_struct tasklet;
82 + unsigned long tasklet_pending;
85 +static nf_hookfn imq_nf_hook;
87 +static struct nf_hook_ops imq_ingress_ipv4 = {
88 + .hook = imq_nf_hook,
89 + .owner = THIS_MODULE,
91 + .hooknum = NF_INET_PRE_ROUTING,
92 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
93 + .priority = NF_IP_PRI_MANGLE + 1
95 + .priority = NF_IP_PRI_NAT_DST + 1
99 +static struct nf_hook_ops imq_egress_ipv4 = {
100 + .hook = imq_nf_hook,
101 + .owner = THIS_MODULE,
103 + .hooknum = NF_INET_POST_ROUTING,
104 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
105 + .priority = NF_IP_PRI_LAST
107 + .priority = NF_IP_PRI_NAT_SRC - 1
111 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
112 +static struct nf_hook_ops imq_ingress_ipv6 = {
113 + .hook = imq_nf_hook,
114 + .owner = THIS_MODULE,
116 + .hooknum = NF_INET_PRE_ROUTING,
117 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
118 + .priority = NF_IP6_PRI_MANGLE + 1
120 + .priority = NF_IP6_PRI_NAT_DST + 1
124 +static struct nf_hook_ops imq_egress_ipv6 = {
125 + .hook = imq_nf_hook,
126 + .owner = THIS_MODULE,
128 + .hooknum = NF_INET_POST_ROUTING,
129 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
130 + .priority = NF_IP6_PRI_LAST
132 + .priority = NF_IP6_PRI_NAT_SRC - 1
137 +#if defined(CONFIG_IMQ_NUM_DEVS)
138 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
140 +static unsigned int numdevs = IMQ_MAX_DEVS;
143 +static struct net_device *imq_devs_cache[IMQ_MAX_DEVS];
145 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
147 + return &dev->stats;
150 +/* called for packets kfree'd in qdiscs at places other than enqueue */
151 +static void imq_skb_destructor(struct sk_buff *skb)
153 + struct nf_queue_entry *entry = skb->nf_queue_entry;
157 + dev_put(entry->indev);
159 + dev_put(entry->outdev);
164 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
166 + dev->stats.tx_bytes += skb->len;
167 + dev->stats.tx_packets++;
169 + skb->imq_flags = 0;
170 + skb->destructor = NULL;
172 + dev->trans_start = jiffies;
173 + nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
177 +static int imq_nf_queue(struct nf_queue_entry *entry, unsigned queue_num)
179 + struct net_device *dev;
180 + struct imq_private *priv;
181 + struct sk_buff *skb2 = NULL;
183 + unsigned int index = entry->skb->imq_flags & IMQ_F_IFMASK;
186 + if (index > numdevs)
189 + /* check for imq device by index from cache */
190 + dev = imq_devs_cache[index];
194 + /* get device by name and cache result */
195 + snprintf(buf, sizeof(buf), "imq%d", index);
196 + dev = dev_get_by_name(&init_net, buf);
203 + imq_devs_cache[index] = dev;
206 + priv = netdev_priv(dev);
207 + if (!(dev->flags & IFF_UP)) {
208 + entry->skb->imq_flags = 0;
209 + nf_reinject(entry, NF_ACCEPT);
212 + dev->last_rx = jiffies;
214 + if (entry->skb->destructor) {
216 + entry->skb = skb_clone(entry->skb, GFP_ATOMIC);
220 + entry->skb->nf_queue_entry = entry;
222 + dev->stats.rx_bytes += entry->skb->len;
223 + dev->stats.rx_packets++;
225 + spin_lock_bh(&dev->queue_lock);
228 + q->enqueue(skb_get(entry->skb), q);
229 + if (skb_shared(entry->skb)) {
230 + entry->skb->destructor = imq_skb_destructor;
231 + kfree_skb(entry->skb);
235 + if (!test_and_set_bit(1, &priv->tasklet_pending))
236 + tasklet_schedule(&priv->tasklet);
237 + spin_unlock_bh(&dev->queue_lock);
240 + kfree_skb(ret ? entry->skb : skb2);
245 +static struct nf_queue_handler nfqh = {
247 + .outfn = imq_nf_queue,
250 +static void qdisc_run_tasklet(unsigned long arg)
252 + struct net_device *dev = (struct net_device *)arg;
253 + struct imq_private *priv = netdev_priv(dev);
255 + spin_lock(&dev->queue_lock);
257 + clear_bit(1, &priv->tasklet_pending);
258 + spin_unlock(&dev->queue_lock);
261 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
262 + const struct net_device *indev,
263 + const struct net_device *outdev,
264 + int (*okfn)(struct sk_buff *))
266 + if (pskb->imq_flags & IMQ_F_ENQUEUE)
272 +static int imq_close(struct net_device *dev)
274 + struct imq_private *priv = netdev_priv(dev);
276 + tasklet_kill(&priv->tasklet);
277 + netif_stop_queue(dev);
282 +static int imq_open(struct net_device *dev)
284 + struct imq_private *priv = netdev_priv(dev);
286 + tasklet_init(&priv->tasklet, qdisc_run_tasklet, (unsigned long)dev);
287 + netif_start_queue(dev);
292 +static void imq_setup(struct net_device *dev)
294 + dev->hard_start_xmit = imq_dev_xmit;
295 + dev->open = imq_open;
296 + dev->get_stats = imq_get_stats;
297 + dev->stop = imq_close;
298 + dev->type = ARPHRD_VOID;
300 + dev->tx_queue_len = 11000;
301 + dev->flags = IFF_NOARP;
304 +static struct rtnl_link_ops imq_link_ops __read_mostly = {
306 + .priv_size = sizeof(struct imq_private),
307 + .setup = imq_setup,
310 +static int __init imq_init_hooks(void)
314 + err = nf_register_queue_handler(PF_INET, &nfqh);
318 + err = nf_register_hook(&imq_ingress_ipv4);
322 + err = nf_register_hook(&imq_egress_ipv4);
326 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
327 + err = nf_register_queue_handler(PF_INET6, &nfqh);
331 + err = nf_register_hook(&imq_ingress_ipv6);
335 + err = nf_register_hook(&imq_egress_ipv6);
342 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
344 + nf_unregister_hook(&imq_ingress_ipv6);
346 + nf_unregister_queue_handler(PF_INET6, &nfqh);
348 + nf_unregister_hook(&imq_egress_ipv4);
351 + nf_unregister_hook(&imq_ingress_ipv4);
353 + nf_unregister_queue_handler(PF_INET, &nfqh);
358 +static int __init imq_init_one(int index)
360 + struct net_device *dev;
363 + dev = alloc_netdev(sizeof(struct imq_private), "imq%d", imq_setup);
367 + ret = dev_alloc_name(dev, dev->name);
371 + dev->rtnl_link_ops = &imq_link_ops;
372 + ret = register_netdevice(dev);
382 +static int __init imq_init_devs(void)
386 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
387 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
393 + err = __rtnl_link_register(&imq_link_ops);
395 + for (i = 0; i < numdevs && !err; i++)
396 + err = imq_init_one(i);
399 + __rtnl_link_unregister(&imq_link_ops);
400 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
407 +static int __init imq_init_module(void)
411 + err = imq_init_devs();
413 + printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
417 + err = imq_init_hooks();
419 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
420 + rtnl_link_unregister(&imq_link_ops);
421 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
425 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
427 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
428 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
430 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
432 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
433 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
435 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
441 +static void __exit imq_unhook(void)
443 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
444 + nf_unregister_hook(&imq_ingress_ipv6);
445 + nf_unregister_hook(&imq_egress_ipv6);
446 + nf_unregister_queue_handler(PF_INET6, &nfqh);
448 + nf_unregister_hook(&imq_ingress_ipv4);
449 + nf_unregister_hook(&imq_egress_ipv4);
450 + nf_unregister_queue_handler(PF_INET, &nfqh);
453 +static void __exit imq_cleanup_devs(void)
455 + rtnl_link_unregister(&imq_link_ops);
456 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
459 +static void __exit imq_exit_module(void)
462 + imq_cleanup_devs();
463 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
466 +module_init(imq_init_module);
467 +module_exit(imq_exit_module);
469 +module_param(numdevs, int, 0);
470 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will "
472 +MODULE_AUTHOR("http://www.linuximq.net");
473 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See "
474 + "http://www.linuximq.net/ for more information.");
475 +MODULE_LICENSE("GPL");
476 +MODULE_ALIAS_RTNL_LINK("imq");
478 --- a/drivers/net/Kconfig
479 +++ b/drivers/net/Kconfig
480 @@ -109,6 +109,129 @@
481 To compile this driver as a module, choose M here: the module
482 will be called eql. If unsure, say N.
485 + tristate "IMQ (intermediate queueing device) support"
486 + depends on NETDEVICES && NETFILTER
488 + The IMQ device(s) is used as placeholder for QoS queueing
489 + disciplines. Every packet entering/leaving the IP stack can be
490 + directed through the IMQ device where it's enqueued/dequeued to the
491 + attached qdisc. This allows you to treat network devices as classes
492 + and distribute bandwidth among them. Iptables is used to specify
493 + through which IMQ device, if any, packets travel.
495 + More information at: http://www.linuximq.net/
497 + To compile this driver as a module, choose M here: the module
498 + will be called imq. If unsure, say N.
501 + prompt "IMQ behavior (PRE/POSTROUTING)"
503 + default IMQ_BEHAVIOR_AB
506 + This settings defines how IMQ behaves in respect to its
507 + hooking in PREROUTING and POSTROUTING.
509 + IMQ can work in any of the following ways:
511 + PREROUTING | POSTROUTING
512 + -----------------|-------------------
513 + #1 After NAT | After NAT
514 + #2 After NAT | Before NAT
515 + #3 Before NAT | After NAT
516 + #4 Before NAT | Before NAT
518 + The default behavior is to hook before NAT on PREROUTING
519 + and after NAT on POSTROUTING (#3).
521 + This settings are specially usefull when trying to use IMQ
522 + to shape NATed clients.
524 + More information can be found at: www.linuximq.net
526 + If not sure leave the default settings alone.
528 +config IMQ_BEHAVIOR_AA
531 + This settings defines how IMQ behaves in respect to its
532 + hooking in PREROUTING and POSTROUTING.
534 + Choosing this option will make IMQ hook like this:
536 + PREROUTING: After NAT
537 + POSTROUTING: After NAT
539 + More information can be found at: www.linuximq.net
541 + If not sure leave the default settings alone.
543 +config IMQ_BEHAVIOR_AB
546 + This settings defines how IMQ behaves in respect to its
547 + hooking in PREROUTING and POSTROUTING.
549 + Choosing this option will make IMQ hook like this:
551 + PREROUTING: After NAT
552 + POSTROUTING: Before NAT
554 + More information can be found at: www.linuximq.net
556 + If not sure leave the default settings alone.
558 +config IMQ_BEHAVIOR_BA
561 + This settings defines how IMQ behaves in respect to its
562 + hooking in PREROUTING and POSTROUTING.
564 + Choosing this option will make IMQ hook like this:
566 + PREROUTING: Before NAT
567 + POSTROUTING: After NAT
569 + More information can be found at: www.linuximq.net
571 + If not sure leave the default settings alone.
573 +config IMQ_BEHAVIOR_BB
576 + This settings defines how IMQ behaves in respect to its
577 + hooking in PREROUTING and POSTROUTING.
579 + Choosing this option will make IMQ hook like this:
581 + PREROUTING: Before NAT
582 + POSTROUTING: Before NAT
584 + More information can be found at: www.linuximq.net
586 + If not sure leave the default settings alone.
592 + int "Number of IMQ devices"
598 + This settings defines how many IMQ devices will be
601 + The default value is 16.
603 + More information can be found at: www.linuximq.net
605 + If not sure leave the default settings alone.
608 tristate "Universal TUN/TAP device driver support"
610 --- a/drivers/net/Makefile
611 +++ b/drivers/net/Makefile
613 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
615 obj-$(CONFIG_DUMMY) += dummy.o
616 +obj-$(CONFIG_IMQ) += imq.o
617 obj-$(CONFIG_IFB) += ifb.o
618 obj-$(CONFIG_MACVLAN) += macvlan.o
619 obj-$(CONFIG_DE600) += de600.o
621 +++ b/include/linux/imq.h
626 +#define IMQ_MAX_DEVS 16
628 +#define IMQ_F_IFMASK 0x7f
629 +#define IMQ_F_ENQUEUE 0x80
633 +++ b/include/linux/netfilter_ipv4/ipt_IMQ.h
638 +struct ipt_imq_info {
639 + unsigned int todev; /* target imq device */
642 +#endif /* _IPT_IMQ_H */
644 +++ b/include/linux/netfilter_ipv6/ip6t_IMQ.h
649 +struct ip6t_imq_info {
650 + unsigned int todev; /* target imq device */
653 +#endif /* _IP6T_IMQ_H */
654 --- a/include/linux/skbuff.h
655 +++ b/include/linux/skbuff.h
657 struct nf_conntrack *nfct;
658 struct sk_buff *nfct_reasm;
660 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
661 + unsigned char imq_flags;
662 + struct nf_queue_entry *nf_queue_entry;
664 #ifdef CONFIG_BRIDGE_NETFILTER
665 struct nf_bridge_info *nf_bridge;
667 @@ -1642,6 +1646,10 @@
668 dst->nfct_reasm = src->nfct_reasm;
669 nf_conntrack_get_reasm(src->nfct_reasm);
671 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
672 + dst->imq_flags = src->imq_flags;
673 + dst->nf_queue_entry = src->nf_queue_entry;
675 #ifdef CONFIG_BRIDGE_NETFILTER
676 dst->nf_bridge = src->nf_bridge;
677 nf_bridge_get(src->nf_bridge);
681 #include <net/net_namespace.h>
682 #include <net/sock.h>
683 #include <linux/rtnetlink.h>
684 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
685 +#include <linux/imq.h>
687 #include <linux/proc_fs.h>
688 #include <linux/seq_file.h>
689 #include <linux/stat.h>
690 @@ -1623,7 +1626,11 @@
691 struct netdev_queue *txq)
693 if (likely(!skb->next)) {
694 - if (!list_empty(&ptype_all))
695 + if (!list_empty(&ptype_all)
696 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
697 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
700 dev_queue_xmit_nit(skb, dev);
702 if (netif_needs_gso(dev, skb)) {
704 +++ b/net/ipv4/netfilter/ipt_IMQ.c
707 + * This target marks packets to be enqueued to an imq device
709 +#include <linux/module.h>
710 +#include <linux/skbuff.h>
711 +#include <linux/netfilter_ipv4/ip_tables.h>
712 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
713 +#include <linux/imq.h>
715 +static unsigned int imq_target(struct sk_buff *pskb,
716 + const struct net_device *in,
717 + const struct net_device *out,
718 + unsigned int hooknum,
719 + const struct xt_target *target,
720 + const void *targinfo)
722 + struct ipt_imq_info *mr = (struct ipt_imq_info *)targinfo;
724 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
726 + return XT_CONTINUE;
729 +static bool imq_checkentry(const char *tablename,
731 + const struct xt_target *target,
733 + unsigned int hook_mask)
735 + struct ipt_imq_info *mr;
737 + mr = (struct ipt_imq_info *)targinfo;
739 + if (mr->todev > IMQ_MAX_DEVS) {
740 + printk(KERN_WARNING
741 + "IMQ: invalid device specified, highest is %u\n",
749 +static struct xt_target ipt_imq_reg = {
752 + .target = imq_target,
753 + .targetsize = sizeof(struct ipt_imq_info),
754 + .checkentry = imq_checkentry,
759 +static int __init init(void)
761 + return xt_register_target(&ipt_imq_reg);
764 +static void __exit fini(void)
766 + xt_unregister_target(&ipt_imq_reg);
772 +MODULE_AUTHOR("http://www.linuximq.net");
773 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
774 +MODULE_LICENSE("GPL");
775 --- a/net/ipv4/netfilter/Kconfig
776 +++ b/net/ipv4/netfilter/Kconfig
779 To compile it as a module, choose M here. If unsure, say N.
781 +config IP_NF_TARGET_IMQ
782 + tristate "IMQ target support"
783 + depends on IP_NF_MANGLE && IMQ
785 + This option adds a `IMQ' target which is used to specify if and
786 + to which IMQ device packets should get enqueued/dequeued.
788 + For more information visit: http://www.linuximq.net/
790 + To compile it as a module, choose M here. If unsure, say N.
792 config IP_NF_TARGET_REJECT
793 tristate "REJECT target support"
794 depends on IP_NF_FILTER
795 --- a/net/ipv4/netfilter/Makefile
796 +++ b/net/ipv4/netfilter/Makefile
798 obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
799 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
800 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
801 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
802 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
803 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
804 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
806 +++ b/net/ipv6/netfilter/ip6t_IMQ.c
809 + * This target marks packets to be enqueued to an imq device
811 +#include <linux/module.h>
812 +#include <linux/skbuff.h>
813 +#include <linux/netfilter_ipv6/ip6_tables.h>
814 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
815 +#include <linux/imq.h>
817 +static unsigned int imq_target(struct sk_buff *pskb,
818 + const struct net_device *in,
819 + const struct net_device *out,
820 + unsigned int hooknum,
821 + const struct xt_target *target,
822 + const void *targinfo)
824 + struct ip6t_imq_info *mr = (struct ip6t_imq_info *)targinfo;
826 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
828 + return XT_CONTINUE;
831 +static bool imq_checkentry(const char *tablename,
833 + const struct xt_target *target,
835 + unsigned int hook_mask)
837 + struct ip6t_imq_info *mr;
839 + mr = (struct ip6t_imq_info *)targinfo;
841 + if (mr->todev > IMQ_MAX_DEVS) {
842 + printk(KERN_WARNING
843 + "IMQ: invalid device specified, highest is %u\n",
851 +static struct xt_target ip6t_imq_reg = {
853 + .family = AF_INET6,
854 + .target = imq_target,
855 + .targetsize = sizeof(struct ip6t_imq_info),
857 + .checkentry = imq_checkentry,
861 +static int __init init(void)
863 + return xt_register_target(&ip6t_imq_reg);
866 +static void __exit fini(void)
868 + xt_unregister_target(&ip6t_imq_reg);
874 +MODULE_AUTHOR("http://www.linuximq.net");
875 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
876 +MODULE_LICENSE("GPL");
877 --- a/net/ipv6/netfilter/Kconfig
878 +++ b/net/ipv6/netfilter/Kconfig
881 To compile it as a module, choose M here. If unsure, say N.
883 +config IP6_NF_TARGET_IMQ
884 + tristate "IMQ target support"
885 + depends on IP6_NF_MANGLE && IMQ
887 + This option adds a `IMQ' target which is used to specify if and
888 + to which imq device packets should get enqueued/dequeued.
890 + To compile it as a module, choose M here. If unsure, say N.
892 config IP6_NF_TARGET_HL
893 tristate 'HL (hoplimit) target support'
894 depends on IP6_NF_MANGLE
895 --- a/net/ipv6/netfilter/Makefile
896 +++ b/net/ipv6/netfilter/Makefile
898 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
899 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
900 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
901 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
902 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
903 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
904 obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
905 --- a/net/sched/sch_generic.c
906 +++ b/net/sched/sch_generic.c
909 clear_bit(__QDISC_STATE_RUNNING, &q->state);
911 +EXPORT_SYMBOL(__qdisc_run);
913 static void dev_watchdog(unsigned long arg)