5 drivers/net/Kconfig | 123 ++++++++
6 drivers/net/Makefile | 1
7 drivers/net/imq.c | 474 +++++++++++++++++++++++++++++++
8 include/linux/imq.h | 9 +
9 include/linux/netfilter_ipv4/ipt_IMQ.h | 8 +
10 include/linux/netfilter_ipv6/ip6t_IMQ.h | 8 +
11 include/linux/skbuff.h | 8 +
13 net/ipv4/netfilter/Kconfig | 11 +
14 net/ipv4/netfilter/Makefile | 1
15 net/ipv4/netfilter/ipt_IMQ.c | 69 +++++
16 net/ipv6/netfilter/Kconfig | 9 +
17 net/ipv6/netfilter/Makefile | 1
18 net/ipv6/netfilter/ip6t_IMQ.c | 69 +++++
19 net/sched/sch_generic.c | 1
20 15 files changed, 800 insertions(+), 1 deletions(-)
21 create mode 100644 drivers/net/imq.c
22 create mode 100644 include/linux/imq.h
23 create mode 100644 include/linux/netfilter_ipv4/ipt_IMQ.h
24 create mode 100644 include/linux/netfilter_ipv6/ip6t_IMQ.h
25 create mode 100644 net/ipv4/netfilter/ipt_IMQ.c
26 create mode 100644 net/ipv6/netfilter/ip6t_IMQ.c
29 --- a/drivers/net/Kconfig
30 +++ b/drivers/net/Kconfig
32 To compile this driver as a module, choose M here: the module
33 will be called eql. If unsure, say N.
36 + tristate "IMQ (intermediate queueing device) support"
37 + depends on NETDEVICES && NETFILTER
39 + The IMQ device(s) is used as placeholder for QoS queueing
40 + disciplines. Every packet entering/leaving the IP stack can be
41 + directed through the IMQ device where it's enqueued/dequeued to the
42 + attached qdisc. This allows you to treat network devices as classes
43 + and distribute bandwidth among them. Iptables is used to specify
44 + through which IMQ device, if any, packets travel.
46 + More information at: http://www.linuximq.net/
48 + To compile this driver as a module, choose M here: the module
49 + will be called imq. If unsure, say N.
52 + prompt "IMQ behavior (PRE/POSTROUTING)"
54 + default IMQ_BEHAVIOR_BB
57 + This settings defines how IMQ behaves in respect to its
58 + hooking in PREROUTING and POSTROUTING.
60 + IMQ can work in any of the following ways:
62 + PREROUTING | POSTROUTING
63 + -----------------|-------------------
64 + #1 After NAT | After NAT
65 + #2 After NAT | Before NAT
66 + #3 Before NAT | After NAT
67 + #4 Before NAT | Before NAT
69 + The default behavior is to hook before NAT on PREROUTING
70 + and after NAT on POSTROUTING (#3).
72 + This settings are specially usefull when trying to use IMQ
73 + to shape NATed clients.
75 + More information can be found at: www.linuximq.net
77 + If not sure leave the default settings alone.
79 +config IMQ_BEHAVIOR_AA
82 + This settings defines how IMQ behaves in respect to its
83 + hooking in PREROUTING and POSTROUTING.
85 + Choosing this option will make IMQ hook like this:
87 + PREROUTING: After NAT
88 + POSTROUTING: After NAT
90 + More information can be found at: www.linuximq.net
92 + If not sure leave the default settings alone.
94 +config IMQ_BEHAVIOR_AB
97 + This settings defines how IMQ behaves in respect to its
98 + hooking in PREROUTING and POSTROUTING.
100 + Choosing this option will make IMQ hook like this:
102 + PREROUTING: After NAT
103 + POSTROUTING: Before NAT
105 + More information can be found at: www.linuximq.net
107 + If not sure leave the default settings alone.
109 +config IMQ_BEHAVIOR_BA
112 + This settings defines how IMQ behaves in respect to its
113 + hooking in PREROUTING and POSTROUTING.
115 + Choosing this option will make IMQ hook like this:
117 + PREROUTING: Before NAT
118 + POSTROUTING: After NAT
120 + More information can be found at: www.linuximq.net
122 + If not sure leave the default settings alone.
124 +config IMQ_BEHAVIOR_BB
127 + This settings defines how IMQ behaves in respect to its
128 + hooking in PREROUTING and POSTROUTING.
130 + Choosing this option will make IMQ hook like this:
132 + PREROUTING: Before NAT
133 + POSTROUTING: Before NAT
135 + More information can be found at: www.linuximq.net
137 + If not sure leave the default settings alone.
143 + int "Number of IMQ devices"
149 + This settings defines how many IMQ devices will be
152 + The default value is 16.
154 + More information can be found at: www.linuximq.net
156 + If not sure leave the default settings alone.
159 tristate "Universal TUN/TAP device driver support"
161 --- a/drivers/net/Makefile
162 +++ b/drivers/net/Makefile
164 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
166 obj-$(CONFIG_DUMMY) += dummy.o
167 +obj-$(CONFIG_IMQ) += imq.o
168 obj-$(CONFIG_IFB) += ifb.o
169 obj-$(CONFIG_MACVLAN) += macvlan.o
170 obj-$(CONFIG_DE600) += de600.o
172 +++ b/drivers/net/imq.c
175 + * Pseudo-driver for the intermediate queue device.
177 + * This program is free software; you can redistribute it and/or
178 + * modify it under the terms of the GNU General Public License
179 + * as published by the Free Software Foundation; either version
180 + * 2 of the License, or (at your option) any later version.
182 + * Authors: Patrick McHardy, <kaber@trash.net>
184 + * The first version was written by Martin Devera, <devik@cdi.cz>
186 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
187 + * - Update patch to 2.4.21
188 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
189 + * - Fix "Dead-loop on netdevice imq"-issue
190 + * Marcel Sebek <sebek64@post.cz>
191 + * - Update to 2.6.2-rc1
193 + * After some time of inactivity there is a group taking care
194 + * of IMQ again: http://www.linuximq.net
197 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7
198 + * including the following changes:
200 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
201 + * - Correction of imq_init_devs() issue that resulted in
202 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
203 + * - Addition of functionality to choose number of IMQ devices
204 + * during kernel config (Andre Correa)
205 + * - Addition of functionality to choose how IMQ hooks on
206 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
207 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
210 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
211 + * released with almost no problems. 2.6.14-x was released
212 + * with some important changes: nfcache was removed; After
213 + * some weeks of trouble we figured out that some IMQ fields
214 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
215 + * These functions are correctly patched by this new patch version.
217 + * Thanks for all who helped to figure out all the problems with
218 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
219 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
220 + * I didn't forget anybody). I apologize again for my lack of time.
223 + * 2008/06/07 - Changed imq.c to use qdisc_run() instead of
224 + * qdisc_restart() and moved qdisc_run() to tasklet to avoid
225 + * recursive locking. (Jussi Kivilinna)
227 + * 2008/06/14 - New initialization routines to fix 'rmmod' not
228 + * working anymore. Used code from ifb.c (Jussi Kivilinna)
231 + * More info at: http://www.linuximq.net/ (Andre Correa)
234 +#include <linux/module.h>
235 +#include <linux/kernel.h>
236 +#include <linux/moduleparam.h>
237 +#include <linux/skbuff.h>
238 +#include <linux/netdevice.h>
239 +#include <linux/rtnetlink.h>
240 +#include <linux/if_arp.h>
241 +#include <linux/netfilter.h>
242 +#include <linux/netfilter_ipv4.h>
243 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
244 + #include <linux/netfilter_ipv6.h>
246 +#include <linux/imq.h>
247 +#include <net/pkt_sched.h>
248 +#include <net/netfilter/nf_queue.h>
250 +struct imq_private {
251 + struct tasklet_struct tasklet;
252 + int tasklet_pending;
255 +static nf_hookfn imq_nf_hook;
257 +static struct nf_hook_ops imq_ingress_ipv4 = {
258 + .hook = imq_nf_hook,
259 + .owner = THIS_MODULE,
261 + .hooknum = NF_INET_PRE_ROUTING,
262 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
263 + .priority = NF_IP_PRI_MANGLE + 1
265 + .priority = NF_IP_PRI_NAT_DST + 1
269 +static struct nf_hook_ops imq_egress_ipv4 = {
270 + .hook = imq_nf_hook,
271 + .owner = THIS_MODULE,
273 + .hooknum = NF_INET_POST_ROUTING,
274 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
275 + .priority = NF_IP_PRI_LAST
277 + .priority = NF_IP_PRI_NAT_SRC - 1
281 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
282 +static struct nf_hook_ops imq_ingress_ipv6 = {
283 + .hook = imq_nf_hook,
284 + .owner = THIS_MODULE,
286 + .hooknum = NF_INET_PRE_ROUTING,
287 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
288 + .priority = NF_IP6_PRI_MANGLE + 1
290 + .priority = NF_IP6_PRI_NAT_DST + 1
294 +static struct nf_hook_ops imq_egress_ipv6 = {
295 + .hook = imq_nf_hook,
296 + .owner = THIS_MODULE,
298 + .hooknum = NF_INET_POST_ROUTING,
299 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
300 + .priority = NF_IP6_PRI_LAST
302 + .priority = NF_IP6_PRI_NAT_SRC - 1
307 +#if defined(CONFIG_IMQ_NUM_DEVS)
308 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
310 +static unsigned int numdevs = IMQ_MAX_DEVS;
313 +static struct net_device *imq_devs_cache[IMQ_MAX_DEVS];
315 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
317 + return &dev->stats;
320 +/* called for packets kfree'd in qdiscs at places other than enqueue */
321 +static void imq_skb_destructor(struct sk_buff *skb)
323 + struct nf_queue_entry *entry = skb->nf_queue_entry;
327 + dev_put(entry->indev);
329 + dev_put(entry->outdev);
334 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
336 + dev->stats.tx_bytes += skb->len;
337 + dev->stats.tx_packets++;
339 + skb->imq_flags = 0;
340 + skb->destructor = NULL;
342 + dev->trans_start = jiffies;
343 + nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
347 +static int imq_nf_queue(struct nf_queue_entry *entry, unsigned queue_num)
349 + struct net_device *dev;
350 + struct imq_private *priv;
351 + struct sk_buff *skb2 = NULL;
353 + unsigned int index = entry->skb->imq_flags & IMQ_F_IFMASK;
356 + if (index > numdevs)
359 + /* check for imq device by index from cache */
360 + dev = imq_devs_cache[index];
364 + /* get device by name and cache result */
365 + snprintf(buf, sizeof(buf), "imq%d", index);
366 + dev = dev_get_by_name(&init_net, buf);
373 + imq_devs_cache[index] = dev;
376 + priv = netdev_priv(dev);
377 + if (!(dev->flags & IFF_UP)) {
378 + entry->skb->imq_flags = 0;
379 + nf_reinject(entry, NF_ACCEPT);
382 + dev->last_rx = jiffies;
384 + if (entry->skb->destructor) {
386 + entry->skb = skb_clone(entry->skb, GFP_ATOMIC);
390 + entry->skb->nf_queue_entry = entry;
392 + dev->stats.rx_bytes += entry->skb->len;
393 + dev->stats.rx_packets++;
395 + spin_lock_bh(&dev->queue_lock);
398 + q->enqueue(skb_get(entry->skb), q);
399 + if (skb_shared(entry->skb)) {
400 + entry->skb->destructor = imq_skb_destructor;
401 + kfree_skb(entry->skb);
405 + if (!test_and_set_bit(1, &priv->tasklet_pending))
406 + tasklet_schedule(&priv->tasklet);
407 + spin_unlock_bh(&dev->queue_lock);
410 + kfree_skb(ret ? entry->skb : skb2);
415 +static struct nf_queue_handler nfqh = {
417 + .outfn = imq_nf_queue,
420 +static void qdisc_run_tasklet(unsigned long arg)
422 + struct net_device *dev = (struct net_device *)arg;
423 + struct imq_private *priv = netdev_priv(dev);
425 + spin_lock(&dev->queue_lock);
427 + clear_bit(1, &priv->tasklet_pending);
428 + spin_unlock(&dev->queue_lock);
431 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
432 + const struct net_device *indev,
433 + const struct net_device *outdev,
434 + int (*okfn)(struct sk_buff *))
436 + if (pskb->imq_flags & IMQ_F_ENQUEUE)
442 +static int imq_close(struct net_device *dev)
444 + struct imq_private *priv = netdev_priv(dev);
446 + tasklet_kill(&priv->tasklet);
447 + netif_stop_queue(dev);
452 +static int imq_open(struct net_device *dev)
454 + struct imq_private *priv = netdev_priv(dev);
456 + tasklet_init(&priv->tasklet, qdisc_run_tasklet, (unsigned long)dev);
457 + netif_start_queue(dev);
462 +static void imq_setup(struct net_device *dev)
464 + dev->hard_start_xmit = imq_dev_xmit;
465 + dev->open = imq_open;
466 + dev->get_stats = imq_get_stats;
467 + dev->stop = imq_close;
468 + dev->type = ARPHRD_VOID;
470 + dev->tx_queue_len = 11000;
471 + dev->flags = IFF_NOARP;
474 +static struct rtnl_link_ops imq_link_ops __read_mostly = {
476 + .priv_size = sizeof(struct imq_private),
477 + .setup = imq_setup,
480 +static int __init imq_init_hooks(void)
484 + err = nf_register_queue_handler(PF_INET, &nfqh);
488 + err = nf_register_hook(&imq_ingress_ipv4);
492 + err = nf_register_hook(&imq_egress_ipv4);
496 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
497 + err = nf_register_queue_handler(PF_INET6, &nfqh);
501 + err = nf_register_hook(&imq_ingress_ipv6);
505 + err = nf_register_hook(&imq_egress_ipv6);
512 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
514 + nf_unregister_hook(&imq_ingress_ipv6);
516 + nf_unregister_queue_handler(PF_INET6, &nfqh);
518 + nf_unregister_hook(&imq_egress_ipv4);
521 + nf_unregister_hook(&imq_ingress_ipv4);
523 + nf_unregister_queue_handler(PF_INET, &nfqh);
528 +static int __init imq_init_one(int index)
530 + struct net_device *dev;
533 + dev = alloc_netdev(sizeof(struct imq_private), "imq%d", imq_setup);
537 + ret = dev_alloc_name(dev, dev->name);
541 + dev->rtnl_link_ops = &imq_link_ops;
542 + ret = register_netdevice(dev);
552 +static int __init imq_init_devs(void)
556 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
557 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
563 + err = __rtnl_link_register(&imq_link_ops);
565 + for (i = 0; i < numdevs && !err; i++)
566 + err = imq_init_one(i);
569 + __rtnl_link_unregister(&imq_link_ops);
570 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
577 +static int __init imq_init_module(void)
581 + err = imq_init_devs();
583 + printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
587 + err = imq_init_hooks();
589 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
590 + rtnl_link_unregister(&imq_link_ops);
591 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
595 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
597 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
598 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
600 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
602 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
603 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
605 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
611 +static void __exit imq_unhook(void)
613 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
614 + nf_unregister_hook(&imq_ingress_ipv6);
615 + nf_unregister_hook(&imq_egress_ipv6);
616 + nf_unregister_queue_handler(PF_INET6, &nfqh);
618 + nf_unregister_hook(&imq_ingress_ipv4);
619 + nf_unregister_hook(&imq_egress_ipv4);
620 + nf_unregister_queue_handler(PF_INET, &nfqh);
623 +static void __exit imq_cleanup_devs(void)
625 + rtnl_link_unregister(&imq_link_ops);
626 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
629 +static void __exit imq_exit_module(void)
632 + imq_cleanup_devs();
633 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
636 +module_init(imq_init_module);
637 +module_exit(imq_exit_module);
639 +module_param(numdevs, int, 0);
640 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will "
642 +MODULE_AUTHOR("http://www.linuximq.net");
643 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See "
644 + "http://www.linuximq.net/ for more information.");
645 +MODULE_LICENSE("GPL");
646 +MODULE_ALIAS_RTNL_LINK("imq");
649 +++ b/include/linux/imq.h
654 +#define IMQ_MAX_DEVS 16
656 +#define IMQ_F_IFMASK 0x7f
657 +#define IMQ_F_ENQUEUE 0x80
661 +++ b/include/linux/netfilter_ipv4/ipt_IMQ.h
666 +struct ipt_imq_info {
667 + unsigned int todev; /* target imq device */
670 +#endif /* _IPT_IMQ_H */
672 +++ b/include/linux/netfilter_ipv6/ip6t_IMQ.h
677 +struct ip6t_imq_info {
678 + unsigned int todev; /* target imq device */
681 +#endif /* _IP6T_IMQ_H */
682 --- a/include/linux/skbuff.h
683 +++ b/include/linux/skbuff.h
685 struct nf_conntrack *nfct;
686 struct sk_buff *nfct_reasm;
688 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
689 + unsigned char imq_flags;
690 + struct nf_queue_entry *nf_queue_entry;
692 #ifdef CONFIG_BRIDGE_NETFILTER
693 struct nf_bridge_info *nf_bridge;
695 @@ -1633,6 +1637,10 @@
696 dst->nfct_reasm = src->nfct_reasm;
697 nf_conntrack_get_reasm(src->nfct_reasm);
699 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
700 + dst->imq_flags = src->imq_flags;
701 + dst->nf_queue_entry = src->nf_queue_entry;
703 #ifdef CONFIG_BRIDGE_NETFILTER
704 dst->nf_bridge = src->nf_bridge;
705 nf_bridge_get(src->nf_bridge);
709 #include <net/net_namespace.h>
710 #include <net/sock.h>
711 #include <linux/rtnetlink.h>
712 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
713 +#include <linux/imq.h>
715 #include <linux/proc_fs.h>
716 #include <linux/seq_file.h>
717 #include <linux/stat.h>
718 @@ -1545,7 +1548,11 @@
719 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
721 if (likely(!skb->next)) {
722 - if (!list_empty(&ptype_all))
723 + if (!list_empty(&ptype_all)
724 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
725 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
728 dev_queue_xmit_nit(skb, dev);
730 if (netif_needs_gso(dev, skb)) {
731 --- a/net/ipv4/netfilter/Kconfig
732 +++ b/net/ipv4/netfilter/Kconfig
735 To compile it as a module, choose M here. If unsure, say N.
737 +config IP_NF_TARGET_IMQ
738 + tristate "IMQ target support"
739 + depends on IP_NF_MANGLE
741 + This option adds a `IMQ' target which is used to specify if and
742 + to which IMQ device packets should get enqueued/dequeued.
744 + For more information visit: http://www.linuximq.net/
746 + To compile it as a module, choose M here. If unsure, say N.
748 config IP_NF_TARGET_REJECT
749 tristate "REJECT target support"
750 depends on IP_NF_FILTER
751 --- a/net/ipv4/netfilter/Makefile
752 +++ b/net/ipv4/netfilter/Makefile
754 obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
755 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
756 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
757 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
758 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
759 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
760 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
762 +++ b/net/ipv4/netfilter/ipt_IMQ.c
765 + * This target marks packets to be enqueued to an imq device
767 +#include <linux/module.h>
768 +#include <linux/skbuff.h>
769 +#include <linux/netfilter_ipv4/ip_tables.h>
770 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
771 +#include <linux/imq.h>
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)
780 + struct ipt_imq_info *mr = (struct ipt_imq_info *)targinfo;
782 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
784 + return XT_CONTINUE;
787 +static bool imq_checkentry(const char *tablename,
789 + const struct xt_target *target,
791 + unsigned int hook_mask)
793 + struct ipt_imq_info *mr;
795 + mr = (struct ipt_imq_info *)targinfo;
797 + if (mr->todev > IMQ_MAX_DEVS) {
798 + printk(KERN_WARNING
799 + "IMQ: invalid device specified, highest is %u\n",
807 +static struct xt_target ipt_imq_reg = {
810 + .target = imq_target,
811 + .targetsize = sizeof(struct ipt_imq_info),
812 + .checkentry = imq_checkentry,
817 +static int __init init(void)
819 + return xt_register_target(&ipt_imq_reg);
822 +static void __exit fini(void)
824 + xt_unregister_target(&ipt_imq_reg);
830 +MODULE_AUTHOR("http://www.linuximq.net");
831 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
832 +MODULE_LICENSE("GPL");
833 --- a/net/ipv6/netfilter/Kconfig
834 +++ b/net/ipv6/netfilter/Kconfig
837 To compile it as a module, choose M here. If unsure, say N.
839 +config IP6_NF_TARGET_IMQ
840 + tristate "IMQ target support"
841 + depends on IP6_NF_MANGLE
843 + This option adds a `IMQ' target which is used to specify if and
844 + to which imq device packets should get enqueued/dequeued.
846 + To compile it as a module, choose M here. If unsure, say N.
848 config IP6_NF_TARGET_HL
849 tristate 'HL (hoplimit) target support'
850 depends on IP6_NF_MANGLE
851 --- a/net/ipv6/netfilter/Makefile
852 +++ b/net/ipv6/netfilter/Makefile
854 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
855 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
856 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
857 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
858 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
859 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
862 +++ b/net/ipv6/netfilter/ip6t_IMQ.c
865 + * This target marks packets to be enqueued to an imq device
867 +#include <linux/module.h>
868 +#include <linux/skbuff.h>
869 +#include <linux/netfilter_ipv6/ip6_tables.h>
870 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
871 +#include <linux/imq.h>
873 +static unsigned int imq_target(struct sk_buff *pskb,
874 + const struct net_device *in,
875 + const struct net_device *out,
876 + unsigned int hooknum,
877 + const struct xt_target *target,
878 + const void *targinfo)
880 + struct ip6t_imq_info *mr = (struct ip6t_imq_info *)targinfo;
882 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
884 + return XT_CONTINUE;
887 +static bool imq_checkentry(const char *tablename,
889 + const struct xt_target *target,
891 + unsigned int hook_mask)
893 + struct ip6t_imq_info *mr;
895 + mr = (struct ip6t_imq_info *)targinfo;
897 + if (mr->todev > IMQ_MAX_DEVS) {
898 + printk(KERN_WARNING
899 + "IMQ: invalid device specified, highest is %u\n",
907 +static struct xt_target ip6t_imq_reg = {
909 + .family = AF_INET6,
910 + .target = imq_target,
911 + .targetsize = sizeof(struct ip6t_imq_info),
913 + .checkentry = imq_checkentry,
917 +static int __init init(void)
919 + return xt_register_target(&ip6t_imq_reg);
922 +static void __exit fini(void)
924 + xt_unregister_target(&ip6t_imq_reg);
930 +MODULE_AUTHOR("http://www.linuximq.net");
931 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
932 +MODULE_LICENSE("GPL");
933 --- a/net/sched/sch_generic.c
934 +++ b/net/sched/sch_generic.c
937 clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
939 +EXPORT_SYMBOL(__qdisc_run);
941 static void dev_watchdog(unsigned long arg)