1 diff -Nru linux-2.6.16/drivers/net/Kconfig linux-2.6.16-imq/drivers/net/Kconfig
2 --- linux-2.6.16/drivers/net/Kconfig 2006-03-20 05:53:29.000000000 +0000
3 +++ linux-2.6.16-imq/drivers/net/Kconfig 2006-03-25 20:57:14.000000000 +0000
5 To compile this driver as a module, choose M here: the module
6 will be called eql. If unsure, say N.
9 + tristate "IMQ (intermediate queueing device) support"
10 + depends on NETDEVICES && NETFILTER
12 + The IMQ device(s) is used as placeholder for QoS queueing disciplines.
13 + Every packet entering/leaving the IP stack can be directed through
14 + the IMQ device where it's enqueued/dequeued to the attached qdisc.
15 + This allows you to treat network devices as classes and distribute
16 + bandwidth among them. Iptables is used to specify through which IMQ
17 + device, if any, packets travel.
19 + More information at: http://www.linuximq.net/
21 + To compile this driver as a module, choose M here: the module
22 + will be called imq. If unsure, say N.
25 + prompt "IMQ behavior (PRE/POSTROUTING)"
27 + default IMQ_BEHAVIOR_BA
30 + This settings defines how IMQ behaves in respect to its
31 + hooking in PREROUTING and POSTROUTING.
33 + IMQ can work in any of the following ways:
35 + PREROUTING | POSTROUTING
36 + -----------------|-------------------
37 + #1 After NAT | After NAT
38 + #2 After NAT | Before NAT
39 + #3 Before NAT | After NAT
40 + #4 Before NAT | Before NAT
42 + The default behavior is to hook before NAT on PREROUTING
43 + and after NAT on POSTROUTING (#3).
45 + This settings are specially usefull when trying to use IMQ
46 + to shape NATed clients.
48 + More information can be found at: www.linuximq.net
50 + If not sure leave the default settings alone.
52 +config IMQ_BEHAVIOR_AA
55 + This settings defines how IMQ behaves in respect to its
56 + hooking in PREROUTING and POSTROUTING.
58 + Choosing this option will make IMQ hook like this:
60 + PREROUTING: After NAT
61 + POSTROUTING: After NAT
63 + More information can be found at: www.linuximq.net
65 + If not sure leave the default settings alone.
67 +config IMQ_BEHAVIOR_AB
70 + This settings defines how IMQ behaves in respect to its
71 + hooking in PREROUTING and POSTROUTING.
73 + Choosing this option will make IMQ hook like this:
75 + PREROUTING: After NAT
76 + POSTROUTING: Before NAT
78 + More information can be found at: www.linuximq.net
80 + If not sure leave the default settings alone.
82 +config IMQ_BEHAVIOR_BA
85 + This settings defines how IMQ behaves in respect to its
86 + hooking in PREROUTING and POSTROUTING.
88 + Choosing this option will make IMQ hook like this:
90 + PREROUTING: Before NAT
91 + POSTROUTING: After NAT
93 + More information can be found at: www.linuximq.net
95 + If not sure leave the default settings alone.
97 +config IMQ_BEHAVIOR_BB
100 + This settings defines how IMQ behaves in respect to its
101 + hooking in PREROUTING and POSTROUTING.
103 + Choosing this option will make IMQ hook like this:
105 + PREROUTING: Before NAT
106 + POSTROUTING: Before NAT
108 + More information can be found at: www.linuximq.net
110 + If not sure leave the default settings alone.
116 + int "Number of IMQ devices"
122 + This settings defines how many IMQ devices will be
125 + The default value is 2.
127 + More information can be found at: www.linuximq.net
129 + If not sure leave the default settings alone.
132 tristate "Universal TUN/TAP device driver support"
134 diff -Nru linux-2.6.16/drivers/net/Makefile linux-2.6.16-imq/drivers/net/Makefile
135 --- linux-2.6.16/drivers/net/Makefile 2006-03-20 05:53:29.000000000 +0000
136 +++ linux-2.6.16-imq/drivers/net/Makefile 2006-03-25 21:04:53.000000000 +0000
140 obj-$(CONFIG_DUMMY) += dummy.o
141 +obj-$(CONFIG_IMQ) += imq.o
142 obj-$(CONFIG_IFB) += ifb.o
143 obj-$(CONFIG_DE600) += de600.o
144 obj-$(CONFIG_DE620) += de620.o
145 diff -Nru linux-2.6.16/drivers/net/imq.c linux-2.6.16-imq/drivers/net/imq.c
146 --- linux-2.6.16/drivers/net/imq.c 1970-01-01 00:00:00.000000000 +0000
147 +++ linux-2.6.16-imq/drivers/net/imq.c 2006-03-25 20:57:14.000000000 +0000
150 + * Pseudo-driver for the intermediate queue device.
152 + * This program is free software; you can redistribute it and/or
153 + * modify it under the terms of the GNU General Public License
154 + * as published by the Free Software Foundation; either version
155 + * 2 of the License, or (at your option) any later version.
157 + * Authors: Patrick McHardy, <kaber@trash.net>
159 + * The first version was written by Martin Devera, <devik@cdi.cz>
161 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
162 + * - Update patch to 2.4.21
163 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
164 + * - Fix "Dead-loop on netdevice imq"-issue
165 + * Marcel Sebek <sebek64@post.cz>
166 + * - Update to 2.6.2-rc1
168 + * After some time of inactivity there is a group taking care
169 + * of IMQ again: http://www.linuximq.net
172 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
173 + * the following changes:
175 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
176 + * - Correction of imq_init_devs() issue that resulted in
177 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
178 + * - Addition of functionality to choose number of IMQ devices
179 + * during kernel config (Andre Correa)
180 + * - Addition of functionality to choose how IMQ hooks on
181 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
182 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
185 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
186 + * released with almost no problems. 2.6.14-x was released
187 + * with some important changes: nfcache was removed; After
188 + * some weeks of trouble we figured out that some IMQ fields
189 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
190 + * These functions are correctly patched by this new patch version.
192 + * Thanks for all who helped to figure out all the problems with
193 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
194 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
195 + * I didn't forget anybody). I apologize again for my lack of time.
197 + * More info at: http://www.linuximq.net/ (Andre Correa)
200 +#include <linux/config.h>
201 +#include <linux/module.h>
202 +#include <linux/kernel.h>
203 +#include <linux/moduleparam.h>
204 +#include <linux/skbuff.h>
205 +#include <linux/netdevice.h>
206 +#include <linux/rtnetlink.h>
207 +#include <linux/if_arp.h>
208 +#include <linux/netfilter.h>
209 +#include <linux/netfilter_ipv4.h>
210 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
211 + #include <linux/netfilter_ipv6.h>
213 +#include <linux/imq.h>
214 +#include <net/pkt_sched.h>
216 +static nf_hookfn imq_nf_hook;
218 +static struct nf_hook_ops imq_ingress_ipv4 = {
219 + .hook = imq_nf_hook,
220 + .owner = THIS_MODULE,
222 + .hooknum = NF_IP_PRE_ROUTING,
223 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
224 + .priority = NF_IP_PRI_MANGLE + 1
226 + .priority = NF_IP_PRI_NAT_DST + 1
230 +static struct nf_hook_ops imq_egress_ipv4 = {
231 + .hook = imq_nf_hook,
232 + .owner = THIS_MODULE,
234 + .hooknum = NF_IP_POST_ROUTING,
235 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
236 + .priority = NF_IP_PRI_LAST
238 + .priority = NF_IP_PRI_NAT_SRC - 1
242 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
243 +static struct nf_hook_ops imq_ingress_ipv6 = {
244 + .hook = imq_nf_hook,
245 + .owner = THIS_MODULE,
247 + .hooknum = NF_IP6_PRE_ROUTING,
248 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
249 + .priority = NF_IP6_PRI_MANGLE + 1
251 + .priority = NF_IP6_PRI_NAT_DST + 1
255 +static struct nf_hook_ops imq_egress_ipv6 = {
256 + .hook = imq_nf_hook,
257 + .owner = THIS_MODULE,
259 + .hooknum = NF_IP6_POST_ROUTING,
260 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
261 + .priority = NF_IP6_PRI_LAST
263 + .priority = NF_IP6_PRI_NAT_SRC - 1
268 +#if defined(CONFIG_IMQ_NUM_DEVS)
269 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
271 +static unsigned int numdevs = 2;
274 +static struct net_device *imq_devs;
276 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
278 + return (struct net_device_stats *)dev->priv;
281 +/* called for packets kfree'd in qdiscs at places other than enqueue */
282 +static void imq_skb_destructor(struct sk_buff *skb)
284 + struct nf_info *info = skb->nf_info;
288 + dev_put(info->indev);
290 + dev_put(info->outdev);
295 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
297 + struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
299 + stats->tx_bytes += skb->len;
300 + stats->tx_packets++;
302 + skb->imq_flags = 0;
303 + skb->destructor = NULL;
305 + dev->trans_start = jiffies;
306 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
310 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
312 + struct net_device *dev;
313 + struct net_device_stats *stats;
314 + struct sk_buff *skb2 = NULL;
316 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
319 + if (index > numdevs)
322 + dev = imq_devs + index;
323 + if (!(dev->flags & IFF_UP)) {
324 + skb->imq_flags = 0;
325 + nf_reinject(skb, info, NF_ACCEPT);
328 + dev->last_rx = jiffies;
330 + if (skb->destructor) {
332 + skb = skb_clone(skb, GFP_ATOMIC);
336 + skb->nf_info = info;
338 + stats = (struct net_device_stats *)dev->priv;
339 + stats->rx_bytes+= skb->len;
340 + stats->rx_packets++;
342 + spin_lock_bh(&dev->queue_lock);
345 + q->enqueue(skb_get(skb), q);
346 + if (skb_shared(skb)) {
347 + skb->destructor = imq_skb_destructor;
352 + if (spin_is_locked(&dev->xmit_lock))
353 + netif_schedule(dev);
356 + while (!netif_queue_stopped(dev) &&
357 + qdisc_restart(dev)<0)
360 + spin_unlock_bh(&dev->queue_lock);
363 + kfree_skb(ret ? skb : skb2);
368 +static struct nf_queue_handler nfqh = {
370 + .outfn = imq_nf_queue,
373 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
374 + const struct net_device *indev,
375 + const struct net_device *outdev,
376 + int (*okfn)(struct sk_buff *))
378 + if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
385 +static int __init imq_init_hooks(void)
389 + err = nf_register_queue_handler(PF_INET, &nfqh);
392 + if ((err = nf_register_hook(&imq_ingress_ipv4)))
394 + if ((err = nf_register_hook(&imq_egress_ipv4)))
396 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
397 + if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
399 + if ((err = nf_register_hook(&imq_ingress_ipv6)))
401 + if ((err = nf_register_hook(&imq_egress_ipv6)))
407 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
409 + nf_unregister_hook(&imq_ingress_ipv6);
411 + nf_unregister_queue_handler(PF_INET6);
413 + nf_unregister_hook(&imq_egress_ipv6);
416 + nf_unregister_hook(&imq_ingress_ipv4);
418 + nf_unregister_queue_handler(PF_INET);
423 +static void __exit imq_unhook(void)
425 + nf_unregister_hook(&imq_ingress_ipv4);
426 + nf_unregister_hook(&imq_egress_ipv4);
427 + nf_unregister_queue_handler(PF_INET);
428 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
429 + nf_unregister_hook(&imq_ingress_ipv6);
430 + nf_unregister_hook(&imq_egress_ipv6);
431 + nf_unregister_queue_handler(PF_INET6);
435 +static int __init imq_dev_init(struct net_device *dev)
437 + dev->hard_start_xmit = imq_dev_xmit;
438 + dev->type = ARPHRD_VOID;
440 + dev->tx_queue_len = 30;
441 + dev->flags = IFF_NOARP;
442 + dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
443 + if (dev->priv == NULL)
445 + memset(dev->priv, 0, sizeof(struct net_device_stats));
446 + dev->get_stats = imq_get_stats;
451 +static void imq_dev_uninit(struct net_device *dev)
456 +static int __init imq_init_devs(void)
458 + struct net_device *dev;
462 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
463 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
468 + imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
471 + memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
473 + /* we start counting at zero */
476 + for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
477 + SET_MODULE_OWNER(dev);
478 + strcpy(dev->name, "imq%d");
479 + dev->init = imq_dev_init;
480 + dev->uninit = imq_dev_uninit;
482 + if (register_netdev(dev) < 0)
485 + printk(KERN_INFO "IMQ starting with %u devices...\n", j);
490 + unregister_netdev(--dev);
495 +static void imq_cleanup_devs(void)
498 + struct net_device *dev = imq_devs;
500 + for (i = 0; i <= numdevs; i++)
501 + unregister_netdev(dev++);
506 +static int __init imq_init_module(void)
510 + if ((err = imq_init_devs())) {
511 + printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
514 + if ((err = imq_init_hooks())) {
515 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
516 + imq_cleanup_devs();
520 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
522 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
523 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
525 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
527 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
528 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
530 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
536 +static void __exit imq_cleanup_module(void)
539 + imq_cleanup_devs();
540 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
544 +module_init(imq_init_module);
545 +module_exit(imq_cleanup_module);
547 +module_param(numdevs, int, 0);
548 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
549 +MODULE_AUTHOR("http://www.linuximq.net");
550 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
551 +MODULE_LICENSE("GPL");
552 diff -Nru linux-2.6.16/include/linux/imq.h linux-2.6.16-imq/include/linux/imq.h
553 --- linux-2.6.16/include/linux/imq.h 1970-01-01 00:00:00.000000000 +0000
554 +++ linux-2.6.16-imq/include/linux/imq.h 2006-03-25 20:57:14.000000000 +0000
559 +#define IMQ_MAX_DEVS 16
561 +#define IMQ_F_IFMASK 0x7f
562 +#define IMQ_F_ENQUEUE 0x80
565 diff -Nru linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.16-imq/include/linux/netfilter_ipv4/ipt_IMQ.h
566 --- linux-2.6.16/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 00:00:00.000000000 +0000
567 +++ linux-2.6.16-imq/include/linux/netfilter_ipv4/ipt_IMQ.h 2006-03-25 20:57:14.000000000 +0000
572 +struct ipt_imq_info {
573 + unsigned int todev; /* target imq device */
576 +#endif /* _IPT_IMQ_H */
577 diff -Nru linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.16-imq/include/linux/netfilter_ipv6/ip6t_IMQ.h
578 --- linux-2.6.16/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 00:00:00.000000000 +0000
579 +++ linux-2.6.16-imq/include/linux/netfilter_ipv6/ip6t_IMQ.h 2006-03-25 20:57:14.000000000 +0000
584 +struct ip6t_imq_info {
585 + unsigned int todev; /* target imq device */
588 +#endif /* _IP6T_IMQ_H */
589 diff -Nru linux-2.6.16/include/linux/skbuff.h linux-2.6.16-imq/include/linux/skbuff.h
590 --- linux-2.6.16/include/linux/skbuff.h 2006-03-20 05:53:29.000000000 +0000
591 +++ linux-2.6.16-imq/include/linux/skbuff.h 2006-03-25 20:57:14.000000000 +0000
593 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
594 struct sk_buff *nfct_reasm;
596 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
597 + unsigned char imq_flags;
598 + struct nf_info *nf_info;
600 #ifdef CONFIG_BRIDGE_NETFILTER
601 struct nf_bridge_info *nf_bridge;
603 diff -Nru linux-2.6.16/net/core/skbuff.c linux-2.6.16-imq/net/core/skbuff.c
604 --- linux-2.6.16/net/core/skbuff.c 2006-03-20 05:53:29.000000000 +0000
605 +++ linux-2.6.16-imq/net/core/skbuff.c 2006-03-25 20:57:14.000000000 +0000
608 nf_conntrack_get_reasm(skb->nfct_reasm);
610 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
613 +#endif /*CONFIG_IMQ*/
614 #ifdef CONFIG_BRIDGE_NETFILTER
616 nf_bridge_get(skb->nf_bridge);
618 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
619 new->ipvs_property = old->ipvs_property;
621 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
622 + new->imq_flags = old->imq_flags;
623 + new->nf_info = old->nf_info;
624 +#endif /*CONFIG_IMQ*/
625 #ifdef CONFIG_BRIDGE_NETFILTER
626 new->nf_bridge = old->nf_bridge;
627 nf_bridge_get(old->nf_bridge);
628 diff -Nru linux-2.6.16/net/ipv4/netfilter/Kconfig linux-2.6.16-imq/net/ipv4/netfilter/Kconfig
629 --- linux-2.6.16/net/ipv4/netfilter/Kconfig 2006-03-20 05:53:29.000000000 +0000
630 +++ linux-2.6.16-imq/net/ipv4/netfilter/Kconfig 2006-03-25 21:54:10.000000000 +0000
633 To compile it as a module, choose M here. If unsure, say N.
635 +config IP_NF_TARGET_IMQ
636 + tristate "IMQ target support"
637 + depends on IP_NF_MANGLE
639 + This option adds a `IMQ' target which is used to specify if and
640 + to which IMQ device packets should get enqueued/dequeued.
642 + For more information visit: http://www.linuximq.net/
644 + To compile it as a module, choose M here. If unsure, say N.
646 config IP_NF_TARGET_TOS
647 tristate "TOS target support"
648 depends on IP_NF_MANGLE
649 diff -Nru linux-2.6.16/net/ipv4/netfilter/Makefile linux-2.6.16-imq/net/ipv4/netfilter/Makefile
650 --- linux-2.6.16/net/ipv4/netfilter/Makefile 2006-03-20 05:53:29.000000000 +0000
651 +++ linux-2.6.16-imq/net/ipv4/netfilter/Makefile 2006-03-25 21:06:00.000000000 +0000
653 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
654 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
655 obj-$(CONFIG_IP_NF_TARGET_DSCP) += ipt_DSCP.o
656 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
657 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
658 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
659 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
660 diff -Nru linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.16-imq/net/ipv4/netfilter/ipt_IMQ.c
661 --- linux-2.6.16/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 00:00:00.000000000 +0000
662 +++ linux-2.6.16-imq/net/ipv4/netfilter/ipt_IMQ.c 2006-03-25 20:57:14.000000000 +0000
665 + * This target marks packets to be enqueued to an imq device
667 +#include <linux/module.h>
668 +#include <linux/skbuff.h>
669 +#include <linux/netfilter_ipv4/ip_tables.h>
670 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
671 +#include <linux/imq.h>
673 +static unsigned int imq_target(struct sk_buff **pskb,
674 + const struct net_device *in,
675 + const struct net_device *out,
676 + unsigned int hooknum,
677 + const void *targinfo,
680 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
682 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
684 + return IPT_CONTINUE;
687 +static int imq_checkentry(const char *tablename,
688 + const struct ipt_entry *e,
690 + unsigned int targinfosize,
691 + unsigned int hook_mask)
693 + struct ipt_imq_info *mr;
695 + if (targinfosize != IPT_ALIGN(sizeof(struct ipt_imq_info))) {
696 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
699 + mr = (struct ipt_imq_info*)targinfo;
701 + if (strcmp(tablename, "mangle") != 0) {
702 + printk(KERN_WARNING
703 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
708 + if (mr->todev > IMQ_MAX_DEVS) {
709 + printk(KERN_WARNING
710 + "IMQ: invalid device specified, highest is %u\n",
718 +static struct ipt_target ipt_imq_reg = {
720 + .target = imq_target,
721 + .checkentry = imq_checkentry,
725 +static int __init init(void)
727 + if (ipt_register_target(&ipt_imq_reg))
733 +static void __exit fini(void)
735 + ipt_unregister_target(&ipt_imq_reg);
741 +MODULE_AUTHOR("http://www.linuximq.net");
742 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
743 +MODULE_LICENSE("GPL");
744 diff -Nru linux-2.6.16/net/ipv6/netfilter/Kconfig linux-2.6.16-imq/net/ipv6/netfilter/Kconfig
745 --- linux-2.6.16/net/ipv6/netfilter/Kconfig 2006-03-20 05:53:29.000000000 +0000
746 +++ linux-2.6.16-imq/net/ipv6/netfilter/Kconfig 2006-03-25 21:54:48.000000000 +0000
749 To compile it as a module, choose M here. If unsure, say N.
751 +config IP6_NF_TARGET_IMQ
752 + tristate "IMQ target support"
753 + depends on IP6_NF_MANGLE
755 + This option adds a `IMQ' target which is used to specify if and
756 + to which imq device packets should get enqueued/dequeued.
758 + To compile it as a module, choose M here. If unsure, say N.
760 config IP6_NF_TARGET_HL
761 tristate 'HL (hoplimit) target support'
762 depends on IP6_NF_MANGLE
763 diff -Nru linux-2.6.16/net/ipv6/netfilter/Makefile linux-2.6.16-imq/net/ipv6/netfilter/Makefile
764 --- linux-2.6.16/net/ipv6/netfilter/Makefile 2006-03-20 05:53:29.000000000 +0000
765 +++ linux-2.6.16-imq/net/ipv6/netfilter/Makefile 2006-03-25 21:07:08.000000000 +0000
767 obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
768 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
769 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
770 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
771 obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
772 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
773 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
774 diff -Nru linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.16-imq/net/ipv6/netfilter/ip6t_IMQ.c
775 --- linux-2.6.16/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 00:00:00.000000000 +0000
776 +++ linux-2.6.16-imq/net/ipv6/netfilter/ip6t_IMQ.c 2006-03-25 20:57:14.000000000 +0000
779 + * This target marks packets to be enqueued to an imq device
781 +#include <linux/module.h>
782 +#include <linux/skbuff.h>
783 +#include <linux/netfilter_ipv6/ip6_tables.h>
784 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
785 +#include <linux/imq.h>
787 +static unsigned int imq_target(struct sk_buff **pskb,
788 + unsigned int hooknum,
789 + const struct net_device *in,
790 + const struct net_device *out,
791 + const void *targinfo,
794 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
796 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
798 + return IP6T_CONTINUE;
801 +static int imq_checkentry(const char *tablename,
802 + const struct ip6t_entry *e,
804 + unsigned int targinfosize,
805 + unsigned int hook_mask)
807 + struct ip6t_imq_info *mr;
809 + if (targinfosize != IP6T_ALIGN(sizeof(struct ip6t_imq_info))) {
810 + printk(KERN_WARNING "IMQ: invalid targinfosize\n");
813 + mr = (struct ip6t_imq_info*)targinfo;
815 + if (strcmp(tablename, "mangle") != 0) {
816 + printk(KERN_WARNING
817 + "IMQ: IMQ can only be called from \"mangle\" table, not \"%s\"\n",
822 + if (mr->todev > IMQ_MAX_DEVS) {
823 + printk(KERN_WARNING
824 + "IMQ: invalid device specified, highest is %u\n",
832 +static struct ip6t_target ip6t_imq_reg = {
834 + .target = imq_target,
835 + .checkentry = imq_checkentry,
839 +static int __init init(void)
841 + if (ip6t_register_target(&ip6t_imq_reg))
847 +static void __exit fini(void)
849 + ip6t_unregister_target(&ip6t_imq_reg);
855 +MODULE_AUTHOR("http://www.linuximq.net");
856 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
857 +MODULE_LICENSE("GPL");
858 diff -Nru linux-2.6.16/net/sched/sch_generic.c linux-2.6.16-imq/net/sched/sch_generic.c
859 --- linux-2.6.16/net/sched/sch_generic.c 2006-03-20 05:53:29.000000000 +0000
860 +++ linux-2.6.16-imq/net/sched/sch_generic.c 2006-03-25 20:57:14.000000000 +0000
862 #include <linux/netdevice.h>
863 #include <linux/skbuff.h>
864 #include <linux/rtnetlink.h>
865 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
866 +#include <linux/imq.h>
868 #include <linux/init.h>
869 #include <linux/rcupdate.h>
870 #include <linux/list.h>
873 if (!netif_queue_stopped(dev)) {
878 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
879 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
883 dev_queue_xmit_nit(skb, dev);
885 ret = dev->hard_start_xmit(skb, dev);