1 diff -urN linux-2.6.27.org/drivers/net/imq.c linux-2.6.27/drivers/net/imq.c
2 --- linux-2.6.27.org/drivers/net/imq.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.27/drivers/net/imq.c 2009-01-11 17:16:26.608878570 +0100
6 + * Pseudo-driver for the intermediate queue device.
8 + * This program is free software; you can redistribute it and/or
9 + * modify it under the terms of the GNU General Public License
10 + * as published by the Free Software Foundation; either version
11 + * 2 of the License, or (at your option) any later version.
13 + * Authors: Patrick McHardy, <kaber@trash.net>
15 + * The first version was written by Martin Devera, <devik@cdi.cz>
17 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
18 + * - Update patch to 2.4.21
19 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
20 + * - Fix "Dead-loop on netdevice imq"-issue
21 + * Marcel Sebek <sebek64@post.cz>
22 + * - Update to 2.6.2-rc1
24 + * After some time of inactivity there is a group taking care
25 + * of IMQ again: http://www.linuximq.net
28 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7
29 + * including the following changes:
31 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
32 + * - Correction of imq_init_devs() issue that resulted in
33 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
34 + * - Addition of functionality to choose number of IMQ devices
35 + * during kernel config (Andre Correa)
36 + * - Addition of functionality to choose how IMQ hooks on
37 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
38 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
41 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
42 + * released with almost no problems. 2.6.14-x was released
43 + * with some important changes: nfcache was removed; After
44 + * some weeks of trouble we figured out that some IMQ fields
45 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
46 + * These functions are correctly patched by this new patch version.
48 + * Thanks for all who helped to figure out all the problems with
49 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
50 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
51 + * I didn't forget anybody). I apologize again for my lack of time.
54 + * 2008/06/17 - 2.6.25 - Changed imq.c to use qdisc_run() instead
55 + * of qdisc_restart() and moved qdisc_run() to tasklet to avoid
56 + * recursive locking. New initialization routines to fix 'rmmod' not
57 + * working anymore. Used code from ifb.c. (Jussi Kivilinna)
59 + * Also, many thanks to pablo Sebastian Greco for making the initial
60 + * patch and to those who helped the testing.
62 + * More info at: http://www.linuximq.net/ (Andre Correa)
65 +#include <linux/module.h>
66 +#include <linux/kernel.h>
67 +#include <linux/moduleparam.h>
68 +#include <linux/skbuff.h>
69 +#include <linux/netdevice.h>
70 +#include <linux/rtnetlink.h>
71 +#include <linux/if_arp.h>
72 +#include <linux/netfilter.h>
73 +#include <linux/netfilter_ipv4.h>
74 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
75 + #include <linux/netfilter_ipv6.h>
77 +#include <linux/imq.h>
78 +#include <net/pkt_sched.h>
79 +#include <net/netfilter/nf_queue.h>
82 + struct tasklet_struct tasklet;
83 + long tasklet_pending[1];
86 +static nf_hookfn imq_nf_hook;
88 +static struct nf_hook_ops imq_ingress_ipv4 = {
89 + .hook = imq_nf_hook,
90 + .owner = THIS_MODULE,
92 + .hooknum = NF_INET_PRE_ROUTING,
93 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
94 + .priority = NF_IP_PRI_MANGLE + 1
96 + .priority = NF_IP_PRI_NAT_DST + 1
100 +static struct nf_hook_ops imq_egress_ipv4 = {
101 + .hook = imq_nf_hook,
102 + .owner = THIS_MODULE,
104 + .hooknum = NF_INET_POST_ROUTING,
105 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
106 + .priority = NF_IP_PRI_LAST
108 + .priority = NF_IP_PRI_NAT_SRC - 1
112 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
113 +static struct nf_hook_ops imq_ingress_ipv6 = {
114 + .hook = imq_nf_hook,
115 + .owner = THIS_MODULE,
117 + .hooknum = NF_INET_PRE_ROUTING,
118 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
119 + .priority = NF_IP6_PRI_MANGLE + 1
121 + .priority = NF_IP6_PRI_NAT_DST + 1
125 +static struct nf_hook_ops imq_egress_ipv6 = {
126 + .hook = imq_nf_hook,
127 + .owner = THIS_MODULE,
129 + .hooknum = NF_INET_POST_ROUTING,
130 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
131 + .priority = NF_IP6_PRI_LAST
133 + .priority = NF_IP6_PRI_NAT_SRC - 1
138 +#if defined(CONFIG_IMQ_NUM_DEVS)
139 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
141 +static unsigned int numdevs = IMQ_MAX_DEVS;
144 +static struct net_device *imq_devs_cache[IMQ_MAX_DEVS];
145 +static struct lock_class_key imq_netdev_xmit_lock_key[IMQ_MAX_DEVS];
146 +static struct lock_class_key imq_netdev_addr_lock_key[IMQ_MAX_DEVS];
148 +static void imq_set_lockdep_class_one(struct net_device *dev,
149 + struct netdev_queue *txq,
152 + int *index=(int*)data;
153 + lockdep_set_class(&txq->_xmit_lock, &imq_netdev_xmit_lock_key[*index]);
156 +static void imq_set_lockdep_class(struct net_device *dev, int index)
158 + lockdep_set_class(&dev->addr_list_lock, &imq_netdev_addr_lock_key[index]);
159 + netdev_for_each_tx_queue(dev, imq_set_lockdep_class_one, &index);
162 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
164 + return &dev->stats;
167 +/* called for packets kfree'd in qdiscs at places other than enqueue */
168 +static void imq_skb_destructor(struct sk_buff *skb)
170 + struct nf_queue_entry *entry = skb->nf_queue_entry;
174 + dev_put(entry->indev);
176 + dev_put(entry->outdev);
181 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
183 + dev->stats.tx_bytes += skb->len;
184 + dev->stats.tx_packets++;
186 + skb->imq_flags = 0;
187 + skb->destructor = NULL;
189 + dev->trans_start = jiffies;
190 + nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
194 +static int imq_nf_queue(struct nf_queue_entry *entry, unsigned queue_num)
196 + struct net_device *dev;
197 + struct imq_private *priv;
198 + struct sk_buff *skb2 = NULL;
199 + struct netdev_queue *txq;
201 + spinlock_t *root_lock;
203 + unsigned int index = entry->skb->imq_flags & IMQ_F_IFMASK;
206 + if (index > numdevs)
209 + /* check for imq device by index from cache */
210 + dev = imq_devs_cache[index];
214 + /* get device by name and cache result */
215 + snprintf(buf, sizeof(buf), "imq%d", index);
216 + dev = dev_get_by_name(&init_net, buf);
223 + imq_devs_cache[index] = dev;
226 + priv = netdev_priv(dev);
227 + if (!(dev->flags & IFF_UP)) {
228 + entry->skb->imq_flags = 0;
229 + nf_reinject(entry, NF_ACCEPT);
232 + dev->last_rx = jiffies;
234 + if (entry->skb->destructor) {
236 + entry->skb = skb_clone(entry->skb, GFP_ATOMIC);
240 + entry->skb->nf_queue_entry = entry;
242 + dev->stats.rx_bytes += entry->skb->len;
243 + dev->stats.rx_packets++;
245 + txq = netdev_get_tx_queue(dev, queue_num);
247 + root_lock = qdisc_lock(q);
248 + spin_lock_bh(root_lock);
250 + q->enqueue(skb_get(entry->skb), q);
251 + if (skb_shared(entry->skb)) {
252 + entry->skb->destructor = imq_skb_destructor;
253 + kfree_skb(entry->skb);
257 + if (!test_and_set_bit(1, &priv->tasklet_pending[queue_num]))
258 + tasklet_schedule(&priv->tasklet);
259 + spin_unlock_bh(root_lock);
262 + kfree_skb(ret ? entry->skb : skb2);
267 +static struct nf_queue_handler nfqh = {
269 + .outfn = imq_nf_queue,
272 +static void qdisc_run_tasklet(unsigned long arg)
274 + struct net_device *dev = (struct net_device *)arg;
275 + struct imq_private *priv = netdev_priv(dev);
276 + struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
277 + struct Qdisc *q = txq->qdisc;
278 + spinlock_t *root_lock = qdisc_lock(q);
280 + spin_lock(root_lock);
282 + clear_bit(1, &priv->tasklet_pending[0]);
283 + spin_unlock(root_lock);
286 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
287 + const struct net_device *indev,
288 + const struct net_device *outdev,
289 + int (*okfn)(struct sk_buff *))
291 + if (pskb->imq_flags & IMQ_F_ENQUEUE)
297 +static int imq_close(struct net_device *dev)
299 + struct imq_private *priv = netdev_priv(dev);
301 + tasklet_kill(&priv->tasklet);
302 + netif_stop_queue(dev);
307 +static int imq_open(struct net_device *dev)
309 + struct imq_private *priv = netdev_priv(dev);
311 + tasklet_init(&priv->tasklet, qdisc_run_tasklet, (unsigned long)dev);
312 + netif_start_queue(dev);
317 +static void imq_setup(struct net_device *dev)
319 + dev->hard_start_xmit = imq_dev_xmit;
320 + dev->open = imq_open;
321 + dev->get_stats = imq_get_stats;
322 + dev->stop = imq_close;
323 + dev->type = ARPHRD_VOID;
325 + dev->tx_queue_len = 11000;
326 + dev->flags = IFF_NOARP;
329 +static struct rtnl_link_ops imq_link_ops __read_mostly = {
331 + .priv_size = sizeof(struct imq_private),
332 + .setup = imq_setup,
335 +static int __init imq_init_hooks(void)
339 + err = nf_register_queue_handler(PF_INET, &nfqh);
343 + err = nf_register_hook(&imq_ingress_ipv4);
347 + err = nf_register_hook(&imq_egress_ipv4);
351 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
352 + err = nf_register_queue_handler(PF_INET6, &nfqh);
356 + err = nf_register_hook(&imq_ingress_ipv6);
360 + err = nf_register_hook(&imq_egress_ipv6);
367 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
369 + nf_unregister_hook(&imq_ingress_ipv6);
371 + nf_unregister_queue_handler(PF_INET6, &nfqh);
373 + nf_unregister_hook(&imq_egress_ipv4);
376 + nf_unregister_hook(&imq_ingress_ipv4);
378 + nf_unregister_queue_handler(PF_INET, &nfqh);
383 +static int __init imq_init_one(int index)
385 + struct net_device *dev;
388 + dev = alloc_netdev(sizeof(struct imq_private), "imq%d", imq_setup);
392 + ret = dev_alloc_name(dev, dev->name);
393 + dev->num_tx_queues=1;
394 + imq_set_lockdep_class(dev, index);
398 + dev->rtnl_link_ops = &imq_link_ops;
399 + ret = register_netdevice(dev);
409 +static int __init imq_init_devs(void)
413 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
414 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
420 + err = __rtnl_link_register(&imq_link_ops);
422 + for (i = 0; i < numdevs && !err; i++)
423 + err = imq_init_one(i);
426 + __rtnl_link_unregister(&imq_link_ops);
427 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
434 +static int __init imq_init_module(void)
438 + err = imq_init_devs();
440 + printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
444 + err = imq_init_hooks();
446 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
447 + rtnl_link_unregister(&imq_link_ops);
448 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
452 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
454 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
455 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
457 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
459 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
460 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
462 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
468 +static void __exit imq_unhook(void)
470 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
471 + nf_unregister_hook(&imq_ingress_ipv6);
472 + nf_unregister_hook(&imq_egress_ipv6);
473 + nf_unregister_queue_handler(PF_INET6, &nfqh);
475 + nf_unregister_hook(&imq_ingress_ipv4);
476 + nf_unregister_hook(&imq_egress_ipv4);
477 + nf_unregister_queue_handler(PF_INET, &nfqh);
480 +static void __exit imq_cleanup_devs(void)
482 + rtnl_link_unregister(&imq_link_ops);
483 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
486 +static void __exit imq_exit_module(void)
489 + imq_cleanup_devs();
490 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
493 +module_init(imq_init_module);
494 +module_exit(imq_exit_module);
496 +module_param(numdevs, int, 0);
497 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will "
499 +MODULE_AUTHOR("http://www.linuximq.net");
500 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See "
501 + "http://www.linuximq.net/ for more information.");
502 +MODULE_LICENSE("GPL");
503 +MODULE_ALIAS_RTNL_LINK("imq");
505 diff -urN linux-2.6.27.org/drivers/net/Kconfig linux-2.6.27/drivers/net/Kconfig
506 --- linux-2.6.27.org/drivers/net/Kconfig 2009-01-11 17:08:24.201024820 +0100
507 +++ linux-2.6.27/drivers/net/Kconfig 2009-01-11 17:16:26.605321939 +0100
508 @@ -109,6 +109,129 @@
509 To compile this driver as a module, choose M here: the module
510 will be called eql. If unsure, say N.
513 + tristate "IMQ (intermediate queueing device) support"
514 + depends on NETDEVICES && NETFILTER
516 + The IMQ device(s) is used as placeholder for QoS queueing
517 + disciplines. Every packet entering/leaving the IP stack can be
518 + directed through the IMQ device where it's enqueued/dequeued to the
519 + attached qdisc. This allows you to treat network devices as classes
520 + and distribute bandwidth among them. Iptables is used to specify
521 + through which IMQ device, if any, packets travel.
523 + More information at: http://www.linuximq.net/
525 + To compile this driver as a module, choose M here: the module
526 + will be called imq. If unsure, say N.
529 + prompt "IMQ behavior (PRE/POSTROUTING)"
531 + default IMQ_BEHAVIOR_AB
534 + This settings defines how IMQ behaves in respect to its
535 + hooking in PREROUTING and POSTROUTING.
537 + IMQ can work in any of the following ways:
539 + PREROUTING | POSTROUTING
540 + -----------------|-------------------
541 + #1 After NAT | After NAT
542 + #2 After NAT | Before NAT
543 + #3 Before NAT | After NAT
544 + #4 Before NAT | Before NAT
546 + The default behavior is to hook before NAT on PREROUTING
547 + and after NAT on POSTROUTING (#3).
549 + This settings are specially usefull when trying to use IMQ
550 + to shape NATed clients.
552 + More information can be found at: www.linuximq.net
554 + If not sure leave the default settings alone.
556 +config IMQ_BEHAVIOR_AA
559 + This settings defines how IMQ behaves in respect to its
560 + hooking in PREROUTING and POSTROUTING.
562 + Choosing this option will make IMQ hook like this:
564 + PREROUTING: After NAT
565 + POSTROUTING: After NAT
567 + More information can be found at: www.linuximq.net
569 + If not sure leave the default settings alone.
571 +config IMQ_BEHAVIOR_AB
574 + This settings defines how IMQ behaves in respect to its
575 + hooking in PREROUTING and POSTROUTING.
577 + Choosing this option will make IMQ hook like this:
579 + PREROUTING: After NAT
580 + POSTROUTING: Before NAT
582 + More information can be found at: www.linuximq.net
584 + If not sure leave the default settings alone.
586 +config IMQ_BEHAVIOR_BA
589 + This settings defines how IMQ behaves in respect to its
590 + hooking in PREROUTING and POSTROUTING.
592 + Choosing this option will make IMQ hook like this:
594 + PREROUTING: Before NAT
595 + POSTROUTING: After NAT
597 + More information can be found at: www.linuximq.net
599 + If not sure leave the default settings alone.
601 +config IMQ_BEHAVIOR_BB
604 + This settings defines how IMQ behaves in respect to its
605 + hooking in PREROUTING and POSTROUTING.
607 + Choosing this option will make IMQ hook like this:
609 + PREROUTING: Before NAT
610 + POSTROUTING: Before NAT
612 + More information can be found at: www.linuximq.net
614 + If not sure leave the default settings alone.
620 + int "Number of IMQ devices"
626 + This settings defines how many IMQ devices will be
629 + The default value is 16.
631 + More information can be found at: www.linuximq.net
633 + If not sure leave the default settings alone.
636 tristate "Universal TUN/TAP device driver support"
638 diff -urN linux-2.6.27.org/drivers/net/Makefile linux-2.6.27/drivers/net/Makefile
639 --- linux-2.6.27.org/drivers/net/Makefile 2008-10-10 00:13:53.000000000 +0200
640 +++ linux-2.6.27/drivers/net/Makefile 2009-01-11 17:16:26.608878570 +0100
642 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
644 obj-$(CONFIG_DUMMY) += dummy.o
645 +obj-$(CONFIG_IMQ) += imq.o
646 obj-$(CONFIG_IFB) += ifb.o
647 obj-$(CONFIG_MACVLAN) += macvlan.o
648 obj-$(CONFIG_DE600) += de600.o
649 diff -urN linux-2.6.27.org/include/linux/imq.h linux-2.6.27/include/linux/imq.h
650 --- linux-2.6.27.org/include/linux/imq.h 1970-01-01 01:00:00.000000000 +0100
651 +++ linux-2.6.27/include/linux/imq.h 2009-01-11 17:16:26.624402721 +0100
656 +#define IMQ_MAX_DEVS 16
658 +#define IMQ_F_IFMASK 0x7f
659 +#define IMQ_F_ENQUEUE 0x80
662 diff -urN linux-2.6.27.org/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.27/include/linux/netfilter_ipv4/ipt_IMQ.h
663 --- linux-2.6.27.org/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 01:00:00.000000000 +0100
664 +++ linux-2.6.27/include/linux/netfilter_ipv4/ipt_IMQ.h 2009-01-11 17:16:26.624402721 +0100
669 +struct ipt_imq_info {
670 + unsigned int todev; /* target imq device */
673 +#endif /* _IPT_IMQ_H */
674 diff -urN linux-2.6.27.org/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.27/include/linux/netfilter_ipv6/ip6t_IMQ.h
675 --- linux-2.6.27.org/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 01:00:00.000000000 +0100
676 +++ linux-2.6.27/include/linux/netfilter_ipv6/ip6t_IMQ.h 2009-01-11 17:16:26.624402721 +0100
681 +struct ip6t_imq_info {
682 + unsigned int todev; /* target imq device */
685 +#endif /* _IP6T_IMQ_H */
686 diff -urN linux-2.6.27.org/include/linux/skbuff.h linux-2.6.27/include/linux/skbuff.h
687 --- linux-2.6.27.org/include/linux/skbuff.h 2008-10-10 00:13:53.000000000 +0200
688 +++ linux-2.6.27/include/linux/skbuff.h 2009-01-11 17:16:26.624402721 +0100
690 struct nf_conntrack *nfct;
691 struct sk_buff *nfct_reasm;
693 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
694 + unsigned char imq_flags;
695 + struct nf_queue_entry *nf_queue_entry;
697 #ifdef CONFIG_BRIDGE_NETFILTER
698 struct nf_bridge_info *nf_bridge;
700 @@ -1642,6 +1646,10 @@
701 dst->nfct_reasm = src->nfct_reasm;
702 nf_conntrack_get_reasm(src->nfct_reasm);
704 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
705 + dst->imq_flags = src->imq_flags;
706 + dst->nf_queue_entry = src->nf_queue_entry;
708 #ifdef CONFIG_BRIDGE_NETFILTER
709 dst->nf_bridge = src->nf_bridge;
710 nf_bridge_get(src->nf_bridge);
711 diff -urN linux-2.6.27.org/net/core/dev.c linux-2.6.27/net/core/dev.c
712 --- linux-2.6.27.org/net/core/dev.c 2009-01-11 17:08:24.484360310 +0100
713 +++ linux-2.6.27/net/core/dev.c 2009-01-11 17:16:26.628877583 +0100
715 #include <net/net_namespace.h>
716 #include <net/sock.h>
717 #include <linux/rtnetlink.h>
718 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
719 +#include <linux/imq.h>
721 #include <linux/proc_fs.h>
722 #include <linux/seq_file.h>
723 #include <linux/stat.h>
724 @@ -1624,7 +1627,11 @@
725 struct netdev_queue *txq)
727 if (likely(!skb->next)) {
728 - if (!list_empty(&ptype_all))
729 + if (!list_empty(&ptype_all)
730 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
731 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
734 dev_queue_xmit_nit(skb, dev);
736 if (netif_needs_gso(dev, skb)) {
737 diff -urN linux-2.6.27.org/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.27/net/ipv4/netfilter/ipt_IMQ.c
738 --- linux-2.6.27.org/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 01:00:00.000000000 +0100
739 +++ linux-2.6.27/net/ipv4/netfilter/ipt_IMQ.c 2009-01-11 17:16:26.631246773 +0100
742 + * This target marks packets to be enqueued to an imq device
744 +#include <linux/module.h>
745 +#include <linux/skbuff.h>
746 +#include <linux/netfilter_ipv4/ip_tables.h>
747 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
748 +#include <linux/imq.h>
750 +static unsigned int imq_target(struct sk_buff *pskb, const struct xt_target_param *target)
752 + struct ipt_imq_info *mr = (struct ipt_imq_info *)target->targinfo;
754 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
756 + return XT_CONTINUE;
759 +static bool imq_checkentry(const struct xt_tgchk_param *target)
761 + struct ipt_imq_info *mr = (struct ipt_imq_info *)target->targinfo;
763 + if (mr->todev > IMQ_MAX_DEVS) {
764 + printk(KERN_WARNING
765 + "IMQ: invalid device specified, highest is %u\n",
773 +static struct xt_target ipt_imq_reg = {
776 + .target = imq_target,
777 + .targetsize = sizeof(struct ipt_imq_info),
778 + .checkentry = imq_checkentry,
783 +static int __init init(void)
785 + return xt_register_target(&ipt_imq_reg);
788 +static void __exit fini(void)
790 + xt_unregister_target(&ipt_imq_reg);
796 +MODULE_AUTHOR("http://www.linuximq.net");
797 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
798 +MODULE_LICENSE("GPL");
799 diff -urN linux-2.6.27.org/net/ipv4/netfilter/Kconfig linux-2.6.27/net/ipv4/netfilter/Kconfig
800 --- linux-2.6.27.org/net/ipv4/netfilter/Kconfig 2009-01-11 17:08:24.774134145 +0100
801 +++ linux-2.6.27/net/ipv4/netfilter/Kconfig 2009-01-11 17:16:26.628877583 +0100
804 To compile it as a module, choose M here. If unsure, say N.
806 +config IP_NF_TARGET_IMQ
807 + tristate "IMQ target support"
808 + depends on IP_NF_MANGLE
810 + This option adds a `IMQ' target which is used to specify if and
811 + to which IMQ device packets should get enqueued/dequeued.
813 + For more information visit: http://www.linuximq.net/
815 + To compile it as a module, choose M here. If unsure, say N.
817 config IP_NF_TARGET_REJECT
818 tristate "REJECT target support"
819 depends on IP_NF_FILTER
820 diff -urN linux-2.6.27.org/net/ipv4/netfilter/Makefile linux-2.6.27/net/ipv4/netfilter/Makefile
821 --- linux-2.6.27.org/net/ipv4/netfilter/Makefile 2009-01-11 17:08:24.774134145 +0100
822 +++ linux-2.6.27/net/ipv4/netfilter/Makefile 2009-01-11 17:16:46.727417283 +0100
824 obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
825 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
826 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
827 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
828 obj-$(CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP) += ipt_IPV4OPTSSTRIP.o
829 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
830 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
831 diff -urN linux-2.6.27.org/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.27/net/ipv6/netfilter/ip6t_IMQ.c
832 --- linux-2.6.27.org/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 01:00:00.000000000 +0100
833 +++ linux-2.6.27/net/ipv6/netfilter/ip6t_IMQ.c 2009-01-11 17:16:26.631246773 +0100
836 + * This target marks packets to be enqueued to an imq device
838 +#include <linux/module.h>
839 +#include <linux/skbuff.h>
840 +#include <linux/netfilter_ipv6/ip6_tables.h>
841 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
842 +#include <linux/imq.h>
844 +static unsigned int imq_target(struct sk_buff *pskb, const struct xt_target_param *target)
846 + struct ip6t_imq_info *mr = (struct ip6t_imq_info *)target->targinfo;
848 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
850 + return XT_CONTINUE;
853 +static bool imq_checkentry(const struct xt_tgchk_param *target)
855 + struct ip6t_imq_info *mr = (struct ip6t_imq_info *)target->targinfo;
857 + if (mr->todev > IMQ_MAX_DEVS) {
858 + printk(KERN_WARNING
859 + "IMQ: invalid device specified, highest is %u\n",
867 +static struct xt_target ip6t_imq_reg = {
869 + .family = AF_INET6,
870 + .target = imq_target,
871 + .targetsize = sizeof(struct ip6t_imq_info),
873 + .checkentry = imq_checkentry,
877 +static int __init init(void)
879 + return xt_register_target(&ip6t_imq_reg);
882 +static void __exit fini(void)
884 + xt_unregister_target(&ip6t_imq_reg);
890 +MODULE_AUTHOR("http://www.linuximq.net");
891 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
892 +MODULE_LICENSE("GPL");
893 diff -urN linux-2.6.27.org/net/ipv6/netfilter/Kconfig linux-2.6.27/net/ipv6/netfilter/Kconfig
894 --- linux-2.6.27.org/net/ipv6/netfilter/Kconfig 2009-01-11 17:08:24.720800755 +0100
895 +++ linux-2.6.27/net/ipv6/netfilter/Kconfig 2009-01-11 17:16:26.631246773 +0100
898 To compile it as a module, choose M here. If unsure, say N.
900 +config IP6_NF_TARGET_IMQ
901 + tristate "IMQ target support"
902 + depends on IP6_NF_MANGLE
904 + This option adds a `IMQ' target which is used to specify if and
905 + to which imq device packets should get enqueued/dequeued.
907 + To compile it as a module, choose M here. If unsure, say N.
909 config IP6_NF_TARGET_HL
910 tristate 'HL (hoplimit) target support'
911 depends on IP6_NF_MANGLE
912 diff -urN linux-2.6.27.org/net/ipv6/netfilter/Makefile linux-2.6.27/net/ipv6/netfilter/Makefile
913 --- linux-2.6.27.org/net/ipv6/netfilter/Makefile 2009-01-11 17:08:24.720800755 +0100
914 +++ linux-2.6.27/net/ipv6/netfilter/Makefile 2009-01-11 17:16:26.631246773 +0100
916 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
917 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
918 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
919 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
920 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
921 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
922 obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
923 diff -urN linux-2.6.27.org/net/sched/sch_generic.c linux-2.6.27/net/sched/sch_generic.c
924 --- linux-2.6.27.org/net/sched/sch_generic.c 2009-01-11 17:08:24.498092451 +0100
925 +++ linux-2.6.27/net/sched/sch_generic.c 2009-01-11 17:16:26.631246773 +0100
928 clear_bit(__QDISC_STATE_RUNNING, &q->state);
930 +EXPORT_SYMBOL(__qdisc_run);
932 static void dev_watchdog(unsigned long arg)