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 diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
30 index 3a0b20a..05c51e7 100644
31 --- a/drivers/net/Kconfig
32 +++ b/drivers/net/Kconfig
33 @@ -117,6 +117,129 @@ config EQUALIZER
34 To compile this driver as a module, choose M here: the module
35 will be called eql. If unsure, say N.
38 + tristate "IMQ (intermediate queueing device) support"
39 + depends on NETDEVICES && NETFILTER
41 + The IMQ device(s) is used as placeholder for QoS queueing
42 + disciplines. Every packet entering/leaving the IP stack can be
43 + directed through the IMQ device where it's enqueued/dequeued to the
44 + attached qdisc. This allows you to treat network devices as classes
45 + and distribute bandwidth among them. Iptables is used to specify
46 + through which IMQ device, if any, packets travel.
48 + More information at: http://www.linuximq.net/
50 + To compile this driver as a module, choose M here: the module
51 + will be called imq. If unsure, say N.
54 + prompt "IMQ behavior (PRE/POSTROUTING)"
56 + default IMQ_BEHAVIOR_BB
59 + This settings defines how IMQ behaves in respect to its
60 + hooking in PREROUTING and POSTROUTING.
62 + IMQ can work in any of the following ways:
64 + PREROUTING | POSTROUTING
65 + -----------------|-------------------
66 + #1 After NAT | After NAT
67 + #2 After NAT | Before NAT
68 + #3 Before NAT | After NAT
69 + #4 Before NAT | Before NAT
71 + The default behavior is to hook before NAT on PREROUTING
72 + and after NAT on POSTROUTING (#3).
74 + This settings are specially usefull when trying to use IMQ
75 + to shape NATed clients.
77 + More information can be found at: www.linuximq.net
79 + If not sure leave the default settings alone.
81 +config IMQ_BEHAVIOR_AA
84 + This settings defines how IMQ behaves in respect to its
85 + hooking in PREROUTING and POSTROUTING.
87 + Choosing this option will make IMQ hook like this:
89 + PREROUTING: After NAT
90 + POSTROUTING: After NAT
92 + More information can be found at: www.linuximq.net
94 + If not sure leave the default settings alone.
96 +config IMQ_BEHAVIOR_AB
99 + This settings defines how IMQ behaves in respect to its
100 + hooking in PREROUTING and POSTROUTING.
102 + Choosing this option will make IMQ hook like this:
104 + PREROUTING: After NAT
105 + POSTROUTING: Before NAT
107 + More information can be found at: www.linuximq.net
109 + If not sure leave the default settings alone.
111 +config IMQ_BEHAVIOR_BA
114 + This settings defines how IMQ behaves in respect to its
115 + hooking in PREROUTING and POSTROUTING.
117 + Choosing this option will make IMQ hook like this:
119 + PREROUTING: Before NAT
120 + POSTROUTING: After NAT
122 + More information can be found at: www.linuximq.net
124 + If not sure leave the default settings alone.
126 +config IMQ_BEHAVIOR_BB
129 + This settings defines how IMQ behaves in respect to its
130 + hooking in PREROUTING and POSTROUTING.
132 + Choosing this option will make IMQ hook like this:
134 + PREROUTING: Before NAT
135 + POSTROUTING: Before NAT
137 + More information can be found at: www.linuximq.net
139 + If not sure leave the default settings alone.
145 + int "Number of IMQ devices"
151 + This settings defines how many IMQ devices will be
154 + The default value is 16.
156 + More information can be found at: www.linuximq.net
158 + If not sure leave the default settings alone.
161 tristate "Universal TUN/TAP device driver support"
163 diff --git a/drivers/net/Makefile b/drivers/net/Makefile
164 index 3b1ea32..17d0575 100644
165 --- a/drivers/net/Makefile
166 +++ b/drivers/net/Makefile
167 @@ -143,6 +143,7 @@ obj-$(CONFIG_SLHC) += slhc.o
168 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
170 obj-$(CONFIG_DUMMY) += dummy.o
171 +obj-$(CONFIG_IMQ) += imq.o
172 obj-$(CONFIG_IFB) += ifb.o
173 obj-$(CONFIG_MACVLAN) += macvlan.o
174 obj-$(CONFIG_DE600) += de600.o
175 diff --git a/drivers/net/imq.c b/drivers/net/imq.c
177 index 0000000..47c31b4
179 +++ b/drivers/net/imq.c
182 + * Pseudo-driver for the intermediate queue device.
184 + * This program is free software; you can redistribute it and/or
185 + * modify it under the terms of the GNU General Public License
186 + * as published by the Free Software Foundation; either version
187 + * 2 of the License, or (at your option) any later version.
189 + * Authors: Patrick McHardy, <kaber@trash.net>
191 + * The first version was written by Martin Devera, <devik@cdi.cz>
193 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
194 + * - Update patch to 2.4.21
195 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
196 + * - Fix "Dead-loop on netdevice imq"-issue
197 + * Marcel Sebek <sebek64@post.cz>
198 + * - Update to 2.6.2-rc1
200 + * After some time of inactivity there is a group taking care
201 + * of IMQ again: http://www.linuximq.net
204 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7
205 + * including the following changes:
207 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
208 + * - Correction of imq_init_devs() issue that resulted in
209 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
210 + * - Addition of functionality to choose number of IMQ devices
211 + * during kernel config (Andre Correa)
212 + * - Addition of functionality to choose how IMQ hooks on
213 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
214 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
217 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
218 + * released with almost no problems. 2.6.14-x was released
219 + * with some important changes: nfcache was removed; After
220 + * some weeks of trouble we figured out that some IMQ fields
221 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
222 + * These functions are correctly patched by this new patch version.
224 + * Thanks for all who helped to figure out all the problems with
225 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
226 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
227 + * I didn't forget anybody). I apologize again for my lack of time.
230 + * 2008/06/07 - Changed imq.c to use qdisc_run() instead of
231 + * qdisc_restart() and moved qdisc_run() to tasklet to avoid
232 + * recursive locking. (Jussi Kivilinna)
234 + * 2008/06/14 - New initialization routines to fix 'rmmod' not
235 + * working anymore. Used code from ifb.c (Jussi Kivilinna)
238 + * More info at: http://www.linuximq.net/ (Andre Correa)
241 +#include <linux/module.h>
242 +#include <linux/kernel.h>
243 +#include <linux/moduleparam.h>
244 +#include <linux/skbuff.h>
245 +#include <linux/netdevice.h>
246 +#include <linux/rtnetlink.h>
247 +#include <linux/if_arp.h>
248 +#include <linux/netfilter.h>
249 +#include <linux/netfilter_ipv4.h>
250 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
251 + #include <linux/netfilter_ipv6.h>
253 +#include <linux/imq.h>
254 +#include <net/pkt_sched.h>
255 +#include <net/netfilter/nf_queue.h>
257 +struct imq_private {
258 + struct tasklet_struct tasklet;
259 + int tasklet_pending;
262 +static nf_hookfn imq_nf_hook;
264 +static struct nf_hook_ops imq_ingress_ipv4 = {
265 + .hook = imq_nf_hook,
266 + .owner = THIS_MODULE,
268 + .hooknum = NF_INET_PRE_ROUTING,
269 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
270 + .priority = NF_IP_PRI_MANGLE + 1
272 + .priority = NF_IP_PRI_NAT_DST + 1
276 +static struct nf_hook_ops imq_egress_ipv4 = {
277 + .hook = imq_nf_hook,
278 + .owner = THIS_MODULE,
280 + .hooknum = NF_INET_POST_ROUTING,
281 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
282 + .priority = NF_IP_PRI_LAST
284 + .priority = NF_IP_PRI_NAT_SRC - 1
288 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
289 +static struct nf_hook_ops imq_ingress_ipv6 = {
290 + .hook = imq_nf_hook,
291 + .owner = THIS_MODULE,
293 + .hooknum = NF_INET_PRE_ROUTING,
294 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
295 + .priority = NF_IP6_PRI_MANGLE + 1
297 + .priority = NF_IP6_PRI_NAT_DST + 1
301 +static struct nf_hook_ops imq_egress_ipv6 = {
302 + .hook = imq_nf_hook,
303 + .owner = THIS_MODULE,
305 + .hooknum = NF_INET_POST_ROUTING,
306 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
307 + .priority = NF_IP6_PRI_LAST
309 + .priority = NF_IP6_PRI_NAT_SRC - 1
314 +#if defined(CONFIG_IMQ_NUM_DEVS)
315 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
317 +static unsigned int numdevs = IMQ_MAX_DEVS;
320 +static struct net_device *imq_devs_cache[IMQ_MAX_DEVS];
322 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
324 + return &dev->stats;
327 +/* called for packets kfree'd in qdiscs at places other than enqueue */
328 +static void imq_skb_destructor(struct sk_buff *skb)
330 + struct nf_queue_entry *entry = skb->nf_queue_entry;
334 + dev_put(entry->indev);
336 + dev_put(entry->outdev);
341 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
343 + dev->stats.tx_bytes += skb->len;
344 + dev->stats.tx_packets++;
346 + skb->imq_flags = 0;
347 + skb->destructor = NULL;
349 + dev->trans_start = jiffies;
350 + nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
354 +static int imq_nf_queue(struct nf_queue_entry *entry, unsigned queue_num)
356 + struct net_device *dev;
357 + struct imq_private *priv;
358 + struct sk_buff *skb2 = NULL;
360 + unsigned int index = entry->skb->imq_flags & IMQ_F_IFMASK;
363 + if (index > numdevs)
366 + /* check for imq device by index from cache */
367 + dev = imq_devs_cache[index];
371 + /* get device by name and cache result */
372 + snprintf(buf, sizeof(buf), "imq%d", index);
373 + dev = dev_get_by_name(&init_net, buf);
380 + imq_devs_cache[index] = dev;
383 + priv = netdev_priv(dev);
384 + if (!(dev->flags & IFF_UP)) {
385 + entry->skb->imq_flags = 0;
386 + nf_reinject(entry, NF_ACCEPT);
389 + dev->last_rx = jiffies;
391 + if (entry->skb->destructor) {
393 + entry->skb = skb_clone(entry->skb, GFP_ATOMIC);
397 + entry->skb->nf_queue_entry = entry;
399 + dev->stats.rx_bytes += entry->skb->len;
400 + dev->stats.rx_packets++;
402 + spin_lock_bh(&dev->queue_lock);
405 + q->enqueue(skb_get(entry->skb), q);
406 + if (skb_shared(entry->skb)) {
407 + entry->skb->destructor = imq_skb_destructor;
408 + kfree_skb(entry->skb);
412 + if (!test_and_set_bit(1, &priv->tasklet_pending))
413 + tasklet_schedule(&priv->tasklet);
414 + spin_unlock_bh(&dev->queue_lock);
417 + kfree_skb(ret ? entry->skb : skb2);
422 +static struct nf_queue_handler nfqh = {
424 + .outfn = imq_nf_queue,
427 +static void qdisc_run_tasklet(unsigned long arg)
429 + struct net_device *dev = (struct net_device *)arg;
430 + struct imq_private *priv = netdev_priv(dev);
432 + spin_lock(&dev->queue_lock);
434 + clear_bit(1, &priv->tasklet_pending);
435 + spin_unlock(&dev->queue_lock);
438 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
439 + const struct net_device *indev,
440 + const struct net_device *outdev,
441 + int (*okfn)(struct sk_buff *))
443 + if (pskb->imq_flags & IMQ_F_ENQUEUE)
449 +static int imq_close(struct net_device *dev)
451 + struct imq_private *priv = netdev_priv(dev);
453 + tasklet_kill(&priv->tasklet);
454 + netif_stop_queue(dev);
459 +static int imq_open(struct net_device *dev)
461 + struct imq_private *priv = netdev_priv(dev);
463 + tasklet_init(&priv->tasklet, qdisc_run_tasklet, (unsigned long)dev);
464 + netif_start_queue(dev);
469 +static void imq_setup(struct net_device *dev)
471 + dev->hard_start_xmit = imq_dev_xmit;
472 + dev->open = imq_open;
473 + dev->get_stats = imq_get_stats;
474 + dev->stop = imq_close;
475 + dev->type = ARPHRD_VOID;
477 + dev->tx_queue_len = 11000;
478 + dev->flags = IFF_NOARP;
481 +static struct rtnl_link_ops imq_link_ops __read_mostly = {
483 + .priv_size = sizeof(struct imq_private),
484 + .setup = imq_setup,
487 +static int __init imq_init_hooks(void)
491 + err = nf_register_queue_handler(PF_INET, &nfqh);
495 + err = nf_register_hook(&imq_ingress_ipv4);
499 + err = nf_register_hook(&imq_egress_ipv4);
503 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
504 + err = nf_register_queue_handler(PF_INET6, &nfqh);
508 + err = nf_register_hook(&imq_ingress_ipv6);
512 + err = nf_register_hook(&imq_egress_ipv6);
519 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
521 + nf_unregister_hook(&imq_ingress_ipv6);
523 + nf_unregister_queue_handler(PF_INET6, &nfqh);
525 + nf_unregister_hook(&imq_egress_ipv4);
528 + nf_unregister_hook(&imq_ingress_ipv4);
530 + nf_unregister_queue_handler(PF_INET, &nfqh);
535 +static int __init imq_init_one(int index)
537 + struct net_device *dev;
540 + dev = alloc_netdev(sizeof(struct imq_private), "imq%d", imq_setup);
544 + ret = dev_alloc_name(dev, dev->name);
548 + dev->rtnl_link_ops = &imq_link_ops;
549 + ret = register_netdevice(dev);
559 +static int __init imq_init_devs(void)
563 + if (!numdevs || numdevs > IMQ_MAX_DEVS) {
564 + printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
570 + err = __rtnl_link_register(&imq_link_ops);
572 + for (i = 0; i < numdevs && !err; i++)
573 + err = imq_init_one(i);
576 + __rtnl_link_unregister(&imq_link_ops);
577 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
584 +static int __init imq_init_module(void)
588 + err = imq_init_devs();
590 + printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
594 + err = imq_init_hooks();
596 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
597 + rtnl_link_unregister(&imq_link_ops);
598 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
602 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
604 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
605 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
607 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
609 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
610 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
612 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
618 +static void __exit imq_unhook(void)
620 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
621 + nf_unregister_hook(&imq_ingress_ipv6);
622 + nf_unregister_hook(&imq_egress_ipv6);
623 + nf_unregister_queue_handler(PF_INET6, &nfqh);
625 + nf_unregister_hook(&imq_ingress_ipv4);
626 + nf_unregister_hook(&imq_egress_ipv4);
627 + nf_unregister_queue_handler(PF_INET, &nfqh);
630 +static void __exit imq_cleanup_devs(void)
632 + rtnl_link_unregister(&imq_link_ops);
633 + memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
636 +static void __exit imq_exit_module(void)
639 + imq_cleanup_devs();
640 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
643 +module_init(imq_init_module);
644 +module_exit(imq_exit_module);
646 +module_param(numdevs, int, 0);
647 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will "
649 +MODULE_AUTHOR("http://www.linuximq.net");
650 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See "
651 + "http://www.linuximq.net/ for more information.");
652 +MODULE_LICENSE("GPL");
653 +MODULE_ALIAS_RTNL_LINK("imq");
655 diff --git a/include/linux/imq.h b/include/linux/imq.h
657 index 0000000..1447c4e
659 +++ b/include/linux/imq.h
664 +#define IMQ_MAX_DEVS 16
666 +#define IMQ_F_IFMASK 0x7f
667 +#define IMQ_F_ENQUEUE 0x80
670 diff --git a/include/linux/netfilter_ipv4/ipt_IMQ.h b/include/linux/netfilter_ipv4/ipt_IMQ.h
672 index 0000000..a304991
674 +++ b/include/linux/netfilter_ipv4/ipt_IMQ.h
679 +struct ipt_imq_info {
680 + unsigned int todev; /* target imq device */
683 +#endif /* _IPT_IMQ_H */
684 diff --git a/include/linux/netfilter_ipv6/ip6t_IMQ.h b/include/linux/netfilter_ipv6/ip6t_IMQ.h
686 index 0000000..605f549
688 +++ b/include/linux/netfilter_ipv6/ip6t_IMQ.h
693 +struct ip6t_imq_info {
694 + unsigned int todev; /* target imq device */
697 +#endif /* _IP6T_IMQ_H */
698 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
699 index bbd8d00..f7d6f7e 100644
700 --- a/include/linux/skbuff.h
701 +++ b/include/linux/skbuff.h
702 @@ -296,6 +296,10 @@ struct sk_buff {
703 struct nf_conntrack *nfct;
704 struct sk_buff *nfct_reasm;
706 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
707 + unsigned char imq_flags;
708 + struct nf_queue_entry *nf_queue_entry;
710 #ifdef CONFIG_BRIDGE_NETFILTER
711 struct nf_bridge_info *nf_bridge;
713 @@ -1736,6 +1740,10 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
714 dst->nfct_reasm = src->nfct_reasm;
715 nf_conntrack_get_reasm(src->nfct_reasm);
717 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
718 + dst->imq_flags = src->imq_flags;
719 + dst->nf_queue_entry = src->nf_queue_entry;
721 #ifdef CONFIG_BRIDGE_NETFILTER
722 dst->nf_bridge = src->nf_bridge;
723 nf_bridge_get(src->nf_bridge);
724 diff --git a/net/core/dev.c b/net/core/dev.c
725 index 460e7f9..094838b 100644
729 #include <net/net_namespace.h>
730 #include <net/sock.h>
731 #include <linux/rtnetlink.h>
732 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
733 +#include <linux/imq.h>
735 #include <linux/proc_fs.h>
736 #include <linux/seq_file.h>
737 #include <linux/stat.h>
738 @@ -1537,7 +1540,11 @@ static int dev_gso_segment(struct sk_buff *skb)
739 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
741 if (likely(!skb->next)) {
742 - if (!list_empty(&ptype_all))
743 + if (!list_empty(&ptype_all)
744 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
745 + && !(skb->imq_flags & IMQ_F_ENQUEUE)
748 dev_queue_xmit_nit(skb, dev);
750 if (netif_needs_gso(dev, skb)) {
751 diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
752 index 9a077cb..3bde19b 100644
753 --- a/net/ipv4/netfilter/Kconfig
754 +++ b/net/ipv4/netfilter/Kconfig
755 @@ -123,6 +123,17 @@ config IP_NF_FILTER
757 To compile it as a module, choose M here. If unsure, say N.
759 +config IP_NF_TARGET_IMQ
760 + tristate "IMQ target support"
761 + depends on IP_NF_MANGLE
763 + This option adds a `IMQ' target which is used to specify if and
764 + to which IMQ device packets should get enqueued/dequeued.
766 + For more information visit: http://www.linuximq.net/
768 + To compile it as a module, choose M here. If unsure, say N.
770 config IP_NF_TARGET_REJECT
771 tristate "REJECT target support"
772 depends on IP_NF_FILTER
773 diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
774 index 0c7dc78..7617528 100644
775 --- a/net/ipv4/netfilter/Makefile
776 +++ b/net/ipv4/netfilter/Makefile
777 @@ -51,6 +51,7 @@ obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o
778 obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
779 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
780 obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
781 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
782 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
783 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
784 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
785 diff --git a/net/ipv4/netfilter/ipt_IMQ.c b/net/ipv4/netfilter/ipt_IMQ.c
787 index 0000000..cda69a4
789 +++ b/net/ipv4/netfilter/ipt_IMQ.c
792 + * This target marks packets to be enqueued to an imq device
794 +#include <linux/module.h>
795 +#include <linux/skbuff.h>
796 +#include <linux/netfilter_ipv4/ip_tables.h>
797 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
798 +#include <linux/imq.h>
800 +static unsigned int imq_target(struct sk_buff *pskb,
801 + const struct net_device *in,
802 + const struct net_device *out,
803 + unsigned int hooknum,
804 + const struct xt_target *target,
805 + const void *targinfo)
807 + struct ipt_imq_info *mr = (struct ipt_imq_info *)targinfo;
809 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
811 + return XT_CONTINUE;
814 +static bool imq_checkentry(const char *tablename,
816 + const struct xt_target *target,
818 + unsigned int hook_mask)
820 + struct ipt_imq_info *mr;
822 + mr = (struct ipt_imq_info *)targinfo;
824 + if (mr->todev > IMQ_MAX_DEVS) {
825 + printk(KERN_WARNING
826 + "IMQ: invalid device specified, highest is %u\n",
834 +static struct xt_target ipt_imq_reg = {
837 + .target = imq_target,
838 + .targetsize = sizeof(struct ipt_imq_info),
839 + .checkentry = imq_checkentry,
844 +static int __init init(void)
846 + return xt_register_target(&ipt_imq_reg);
849 +static void __exit fini(void)
851 + xt_unregister_target(&ipt_imq_reg);
857 +MODULE_AUTHOR("http://www.linuximq.net");
858 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
859 +MODULE_LICENSE("GPL");
860 diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
861 index 6cae547..3b3b610 100644
862 --- a/net/ipv6/netfilter/Kconfig
863 +++ b/net/ipv6/netfilter/Kconfig
864 @@ -179,6 +179,15 @@ config IP6_NF_MANGLE
866 To compile it as a module, choose M here. If unsure, say N.
868 +config IP6_NF_TARGET_IMQ
869 + tristate "IMQ target support"
870 + depends on IP6_NF_MANGLE
872 + This option adds a `IMQ' target which is used to specify if and
873 + to which imq device packets should get enqueued/dequeued.
875 + To compile it as a module, choose M here. If unsure, say N.
877 config IP6_NF_TARGET_HL
878 tristate 'HL (hoplimit) target support'
879 depends on IP6_NF_MANGLE
880 diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile
881 index fbf2c14..dcfe80b 100644
882 --- a/net/ipv6/netfilter/Makefile
883 +++ b/net/ipv6/netfilter/Makefile
885 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
886 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
887 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
888 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
889 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
890 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
892 diff --git a/net/ipv6/netfilter/ip6t_IMQ.c b/net/ipv6/netfilter/ip6t_IMQ.c
894 index 0000000..5cf7b72
896 +++ b/net/ipv6/netfilter/ip6t_IMQ.c
899 + * This target marks packets to be enqueued to an imq device
901 +#include <linux/module.h>
902 +#include <linux/skbuff.h>
903 +#include <linux/netfilter_ipv6/ip6_tables.h>
904 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
905 +#include <linux/imq.h>
907 +static unsigned int imq_target(struct sk_buff *pskb,
908 + const struct net_device *in,
909 + const struct net_device *out,
910 + unsigned int hooknum,
911 + const struct xt_target *target,
912 + const void *targinfo)
914 + struct ip6t_imq_info *mr = (struct ip6t_imq_info *)targinfo;
916 + pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
918 + return XT_CONTINUE;
921 +static bool imq_checkentry(const char *tablename,
923 + const struct xt_target *target,
925 + unsigned int hook_mask)
927 + struct ip6t_imq_info *mr;
929 + mr = (struct ip6t_imq_info *)targinfo;
931 + if (mr->todev > IMQ_MAX_DEVS) {
932 + printk(KERN_WARNING
933 + "IMQ: invalid device specified, highest is %u\n",
941 +static struct xt_target ip6t_imq_reg = {
943 + .family = AF_INET6,
944 + .target = imq_target,
945 + .targetsize = sizeof(struct ip6t_imq_info),
947 + .checkentry = imq_checkentry,
951 +static int __init init(void)
953 + return xt_register_target(&ip6t_imq_reg);
956 +static void __exit fini(void)
958 + xt_unregister_target(&ip6t_imq_reg);
964 +MODULE_AUTHOR("http://www.linuximq.net");
965 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
966 +MODULE_LICENSE("GPL");
967 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
968 index b741618..dcb916e 100644
969 --- a/net/sched/sch_generic.c
970 +++ b/net/sched/sch_generic.c
971 @@ -203,6 +203,7 @@ void __qdisc_run(struct net_device *dev)
973 clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
975 +EXPORT_SYMBOL(__qdisc_run);
977 static void dev_watchdog(unsigned long arg)