1 Index: linux-2.6.21.5/drivers/net/imq.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ linux-2.6.21.5/drivers/net/imq.c 2007-07-02 08:26:03.223788000 +0200
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 = 2;
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);
269 + nf_unregister_hook(&imq_egress_ipv4);
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 Index: linux-2.6.21.5/drivers/net/Kconfig
409 ===================================================================
410 --- linux-2.6.21.5.orig/drivers/net/Kconfig 2007-07-02 08:25:36.554121250 +0200
411 +++ linux-2.6.21.5/drivers/net/Kconfig 2007-07-02 08:26:03.719819000 +0200
413 To compile this driver as a module, choose M here: the module
414 will be called eql. If unsure, say N.
417 + tristate "IMQ (intermediate queueing device) support"
418 + depends on NETDEVICES && NETFILTER
420 + The IMQ device(s) is used as placeholder for QoS queueing
421 + disciplines. Every packet entering/leaving the IP stack can be
422 + directed through the IMQ device where it's enqueued/dequeued to the
423 + attached qdisc. This allows you to treat network devices as classes
424 + and distribute bandwidth among them. Iptables is used to specify
425 + through which IMQ device, if any, packets travel.
427 + More information at: http://www.linuximq.net/
429 + To compile this driver as a module, choose M here: the module
430 + will be called imq. If unsure, say N.
433 + prompt "IMQ behavior (PRE/POSTROUTING)"
435 + default IMQ_BEHAVIOR_BA
438 + This settings defines how IMQ behaves in respect to its
439 + hooking in PREROUTING and POSTROUTING.
441 + IMQ can work in any of the following ways:
443 + PREROUTING | POSTROUTING
444 + -----------------|-------------------
445 + #1 After NAT | After NAT
446 + #2 After NAT | Before NAT
447 + #3 Before NAT | After NAT
448 + #4 Before NAT | Before NAT
450 + The default behavior is to hook before NAT on PREROUTING
451 + and after NAT on POSTROUTING (#3).
453 + This settings are specially usefull when trying to use IMQ
454 + to shape NATed clients.
456 + More information can be found at: www.linuximq.net
458 + If not sure leave the default settings alone.
460 +config IMQ_BEHAVIOR_AA
463 + This settings defines how IMQ behaves in respect to its
464 + hooking in PREROUTING and POSTROUTING.
466 + Choosing this option will make IMQ hook like this:
468 + PREROUTING: After NAT
469 + POSTROUTING: After NAT
471 + More information can be found at: www.linuximq.net
473 + If not sure leave the default settings alone.
475 +config IMQ_BEHAVIOR_AB
478 + This settings defines how IMQ behaves in respect to its
479 + hooking in PREROUTING and POSTROUTING.
481 + Choosing this option will make IMQ hook like this:
483 + PREROUTING: After NAT
484 + POSTROUTING: Before NAT
486 + More information can be found at: www.linuximq.net
488 + If not sure leave the default settings alone.
490 +config IMQ_BEHAVIOR_BA
493 + This settings defines how IMQ behaves in respect to its
494 + hooking in PREROUTING and POSTROUTING.
496 + Choosing this option will make IMQ hook like this:
498 + PREROUTING: Before NAT
499 + POSTROUTING: After NAT
501 + More information can be found at: www.linuximq.net
503 + If not sure leave the default settings alone.
505 +config IMQ_BEHAVIOR_BB
508 + This settings defines how IMQ behaves in respect to its
509 + hooking in PREROUTING and POSTROUTING.
511 + Choosing this option will make IMQ hook like this:
513 + PREROUTING: Before NAT
514 + POSTROUTING: Before NAT
516 + More information can be found at: www.linuximq.net
518 + If not sure leave the default settings alone.
524 + int "Number of IMQ devices"
530 + This settings defines how many IMQ devices will be
533 + The default value is 2.
535 + More information can be found at: www.linuximq.net
537 + If not sure leave the default settings alone.
540 tristate "Universal TUN/TAP device driver support"
542 Index: linux-2.6.21.5/drivers/net/Makefile
543 ===================================================================
544 --- linux-2.6.21.5.orig/drivers/net/Makefile 2007-07-02 08:25:36.566122000 +0200
545 +++ linux-2.6.21.5/drivers/net/Makefile 2007-07-02 08:26:03.859827750 +0200
547 obj-$(CONFIG_SLHC) += slhc.o
549 obj-$(CONFIG_DUMMY) += dummy.o
550 +obj-$(CONFIG_IMQ) += imq.o
551 obj-$(CONFIG_IFB) += ifb.o
552 obj-$(CONFIG_DE600) += de600.o
553 obj-$(CONFIG_DE620) += de620.o
554 Index: linux-2.6.21.5/include/linux/imq.h
555 ===================================================================
556 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
557 +++ linux-2.6.21.5/include/linux/imq.h 2007-07-02 08:26:04.311856000 +0200
562 +#define IMQ_MAX_DEVS 16
564 +#define IMQ_F_IFMASK 0x7f
565 +#define IMQ_F_ENQUEUE 0x80
568 Index: linux-2.6.21.5/include/linux/netfilter_ipv4/ipt_IMQ.h
569 ===================================================================
570 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
571 +++ linux-2.6.21.5/include/linux/netfilter_ipv4/ipt_IMQ.h 2007-07-02 08:26:04.607874500 +0200
576 +struct ipt_imq_info {
577 + unsigned int todev; /* target imq device */
580 +#endif /* _IPT_IMQ_H */
581 Index: linux-2.6.21.5/include/linux/netfilter_ipv6/ip6t_IMQ.h
582 ===================================================================
583 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
584 +++ linux-2.6.21.5/include/linux/netfilter_ipv6/ip6t_IMQ.h 2007-07-02 08:26:04.927894500 +0200
589 +struct ip6t_imq_info {
590 + unsigned int todev; /* target imq device */
593 +#endif /* _IP6T_IMQ_H */
594 Index: linux-2.6.21.5/include/linux/skbuff.h
595 ===================================================================
596 --- linux-2.6.21.5.orig/include/linux/skbuff.h 2007-07-02 08:25:36.598124000 +0200
597 +++ linux-2.6.21.5/include/linux/skbuff.h 2007-07-02 08:26:04.983898000 +0200
599 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
600 struct sk_buff *nfct_reasm;
602 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
603 + unsigned char imq_flags;
604 + struct nf_info *nf_info;
606 #ifdef CONFIG_BRIDGE_NETFILTER
607 struct nf_bridge_info *nf_bridge;
609 Index: linux-2.6.21.5/net/core/dev.c
610 ===================================================================
611 --- linux-2.6.21.5.orig/net/core/dev.c 2007-07-02 08:25:36.606124500 +0200
612 +++ linux-2.6.21.5/net/core/dev.c 2007-07-02 08:26:04.983898000 +0200
614 #include <linux/skbuff.h>
615 #include <net/sock.h>
616 #include <linux/rtnetlink.h>
617 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
618 +#include <linux/imq.h>
620 #include <linux/proc_fs.h>
621 #include <linux/seq_file.h>
622 #include <linux/stat.h>
623 @@ -1340,7 +1343,11 @@
624 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
626 if (likely(!skb->next)) {
629 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
630 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
633 dev_queue_xmit_nit(skb, dev);
635 if (netif_needs_gso(dev, skb)) {
636 Index: linux-2.6.21.5/net/core/skbuff.c
637 ===================================================================
638 --- linux-2.6.21.5.orig/net/core/skbuff.c 2007-07-02 08:25:36.618125250 +0200
639 +++ linux-2.6.21.5/net/core/skbuff.c 2007-07-02 08:26:05.007899500 +0200
642 nf_conntrack_get_reasm(skb->nfct_reasm);
644 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
647 +#endif /*CONFIG_IMQ*/
648 #ifdef CONFIG_BRIDGE_NETFILTER
650 nf_bridge_get(skb->nf_bridge);
652 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
653 new->ipvs_property = old->ipvs_property;
655 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
656 + new->imq_flags = old->imq_flags;
657 + new->nf_info = old->nf_info;
658 +#endif /*CONFIG_IMQ*/
659 #ifdef CONFIG_BRIDGE_NETFILTER
660 new->nf_bridge = old->nf_bridge;
661 nf_bridge_get(old->nf_bridge);
662 Index: linux-2.6.21.5/net/ipv4/netfilter/ipt_IMQ.c
663 ===================================================================
664 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
665 +++ linux-2.6.21.5/net/ipv4/netfilter/ipt_IMQ.c 2007-07-02 08:26:05.055902500 +0200
668 + * This target marks packets to be enqueued to an imq device
670 +#include <linux/module.h>
671 +#include <linux/skbuff.h>
672 +#include <linux/netfilter_ipv4/ip_tables.h>
673 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
674 +#include <linux/imq.h>
676 +static unsigned int imq_target(struct sk_buff **pskb,
677 + const struct net_device *in,
678 + const struct net_device *out,
679 + unsigned int hooknum,
680 + const struct xt_target *target,
681 + const void *targinfo)
683 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
685 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
687 + return XT_CONTINUE;
690 +static int imq_checkentry(const char *tablename,
692 + const struct xt_target *target,
694 + unsigned int hook_mask)
696 + struct ipt_imq_info *mr;
698 + mr = (struct ipt_imq_info*)targinfo;
700 + if (mr->todev > IMQ_MAX_DEVS) {
701 + printk(KERN_WARNING
702 + "IMQ: invalid device specified, highest is %u\n",
710 +static struct xt_target ipt_imq_reg = {
713 + .target = imq_target,
714 + .targetsize = sizeof(struct ipt_imq_info),
715 + .checkentry = imq_checkentry,
720 +static int __init init(void)
722 + return xt_register_target(&ipt_imq_reg);
725 +static void __exit fini(void)
727 + xt_unregister_target(&ipt_imq_reg);
733 +MODULE_AUTHOR("http://www.linuximq.net");
734 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
735 +MODULE_LICENSE("GPL");
736 Index: linux-2.6.21.5/net/ipv4/netfilter/Kconfig
737 ===================================================================
738 --- linux-2.6.21.5.orig/net/ipv4/netfilter/Kconfig 2007-07-02 08:25:36.630126000 +0200
739 +++ linux-2.6.21.5/net/ipv4/netfilter/Kconfig 2007-07-02 08:26:05.115906250 +0200
742 To compile it as a module, choose M here. If unsure, say N.
744 +config IP_NF_TARGET_IMQ
745 + tristate "IMQ target support"
746 + depends on IP_NF_MANGLE
748 + This option adds a `IMQ' target which is used to specify if and
749 + to which IMQ device packets should get enqueued/dequeued.
751 + For more information visit: http://www.linuximq.net/
753 + To compile it as a module, choose M here. If unsure, say N.
755 config IP_NF_TARGET_TOS
756 tristate "TOS target support"
757 depends on IP_NF_MANGLE
758 Index: linux-2.6.21.5/net/ipv4/netfilter/Makefile
759 ===================================================================
760 --- linux-2.6.21.5.orig/net/ipv4/netfilter/Makefile 2007-07-02 08:25:36.714131250 +0200
761 +++ linux-2.6.21.5/net/ipv4/netfilter/Makefile 2007-07-02 08:26:05.175910000 +0200
763 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
764 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
765 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
766 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
767 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
768 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
769 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
770 Index: linux-2.6.21.5/net/ipv6/netfilter/ip6t_IMQ.c
771 ===================================================================
772 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
773 +++ linux-2.6.21.5/net/ipv6/netfilter/ip6t_IMQ.c 2007-07-02 08:26:05.231913500 +0200
776 + * This target marks packets to be enqueued to an imq device
778 +#include <linux/module.h>
779 +#include <linux/skbuff.h>
780 +#include <linux/netfilter_ipv6/ip6_tables.h>
781 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
782 +#include <linux/imq.h>
784 +static unsigned int imq_target(struct sk_buff **pskb,
785 + const struct net_device *in,
786 + const struct net_device *out,
787 + unsigned int hooknum,
788 + const struct xt_target *target,
789 + const void *targinfo)
791 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
793 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
795 + return XT_CONTINUE;
798 +static int imq_checkentry(const char *tablename,
800 + const struct xt_target *target,
802 + unsigned int hook_mask)
804 + struct ip6t_imq_info *mr;
806 + mr = (struct ip6t_imq_info*)targinfo;
808 + if (mr->todev > IMQ_MAX_DEVS) {
809 + printk(KERN_WARNING
810 + "IMQ: invalid device specified, highest is %u\n",
818 +static struct xt_target ip6t_imq_reg = {
820 + .family = AF_INET6,
821 + .target = imq_target,
822 + .targetsize = sizeof(struct ip6t_imq_info),
824 + .checkentry = imq_checkentry,
828 +static int __init init(void)
830 + return xt_register_target(&ip6t_imq_reg);
833 +static void __exit fini(void)
835 + xt_unregister_target(&ip6t_imq_reg);
841 +MODULE_AUTHOR("http://www.linuximq.net");
842 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
843 +MODULE_LICENSE("GPL");
844 Index: linux-2.6.21.5/net/ipv6/netfilter/Kconfig
845 ===================================================================
846 --- linux-2.6.21.5.orig/net/ipv6/netfilter/Kconfig 2007-07-02 08:25:36.726132000 +0200
847 +++ linux-2.6.21.5/net/ipv6/netfilter/Kconfig 2007-07-02 08:26:05.267915750 +0200
850 To compile it as a module, choose M here. If unsure, say N.
852 +config IP6_NF_TARGET_IMQ
853 + tristate "IMQ target support"
854 + depends on IP6_NF_MANGLE
856 + This option adds a `IMQ' target which is used to specify if and
857 + to which imq device packets should get enqueued/dequeued.
859 + To compile it as a module, choose M here. If unsure, say N.
861 config IP6_NF_TARGET_HL
862 tristate 'HL (hoplimit) target support'
863 depends on IP6_NF_MANGLE
864 Index: linux-2.6.21.5/net/ipv6/netfilter/Makefile
865 ===================================================================
866 --- linux-2.6.21.5.orig/net/ipv6/netfilter/Makefile 2007-07-02 08:25:36.738132750 +0200
867 +++ linux-2.6.21.5/net/ipv6/netfilter/Makefile 2007-07-02 08:26:05.319919000 +0200
869 obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
870 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
871 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
872 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
873 obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
874 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
875 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
876 Index: linux-2.6.21.5/net/sched/sch_generic.c
877 ===================================================================
878 --- linux-2.6.21.5.orig/net/sched/sch_generic.c 2007-07-02 08:25:36.750133500 +0200
879 +++ linux-2.6.21.5/net/sched/sch_generic.c 2007-07-02 08:26:05.343920500 +0200
882 NOTE: Called under dev->queue_lock with locally disabled BH.
885 static inline int qdisc_restart(struct net_device *dev)
887 struct Qdisc *q = dev->qdisc;
892 +int qdisc_restart1(struct net_device *dev)
894 + return qdisc_restart(dev);
897 void __qdisc_run(struct net_device *dev)
899 if (unlikely(dev->qdisc == &noop_qdisc))
901 EXPORT_SYMBOL(qdisc_reset);
902 EXPORT_SYMBOL(qdisc_lock_tree);
903 EXPORT_SYMBOL(qdisc_unlock_tree);
904 +EXPORT_SYMBOL(qdisc_restart1);