]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/linux-2.6.21-img2.diff
...
[people/pmueller/ipfire-2.x.git] / src / patches / linux-2.6.21-img2.diff
CommitLineData
71430cf6
MT
1diff -Nru linux-2.6.21.1-orig/drivers/net/Kconfig linux-2.6.21.1/drivers/net/Kconfig
2--- linux-2.6.21.1-orig/drivers/net/Kconfig 2007-04-27 21:49:26.000000000 +0000
3+++ linux-2.6.21.1/drivers/net/Kconfig 2007-06-02 21:43:55.000000000 +0000
4@@ -96,6 +96,129 @@
5 To compile this driver as a module, choose M here: the module
6 will be called eql. If unsure, say N.
7
8+config IMQ
9+ tristate "IMQ (intermediate queueing device) support"
10+ depends on NETDEVICES && NETFILTER
11+ ---help---
12+ The IMQ device(s) is used as placeholder for QoS queueing
13+ disciplines. Every packet entering/leaving the IP stack can be
14+ directed through the IMQ device where it's enqueued/dequeued to the
15+ attached qdisc. This allows you to treat network devices as classes
16+ and distribute bandwidth among them. Iptables is used to specify
17+ through which IMQ device, if any, packets travel.
18+
19+ More information at: http://www.linuximq.net/
20+
21+ To compile this driver as a module, choose M here: the module
22+ will be called imq. If unsure, say N.
23+
24+choice
25+ prompt "IMQ behavior (PRE/POSTROUTING)"
26+ depends on IMQ
27+ default IMQ_BEHAVIOR_BA
28+ help
29+
30+ This settings defines how IMQ behaves in respect to its
31+ hooking in PREROUTING and POSTROUTING.
32+
33+ IMQ can work in any of the following ways:
34+
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
41+
42+ The default behavior is to hook before NAT on PREROUTING
43+ and after NAT on POSTROUTING (#3).
44+
45+ This settings are specially usefull when trying to use IMQ
46+ to shape NATed clients.
47+
48+ More information can be found at: www.linuximq.net
49+
50+ If not sure leave the default settings alone.
51+
52+config IMQ_BEHAVIOR_AA
53+ bool "IMQ AA"
54+ help
55+ This settings defines how IMQ behaves in respect to its
56+ hooking in PREROUTING and POSTROUTING.
57+
58+ Choosing this option will make IMQ hook like this:
59+
60+ PREROUTING: After NAT
61+ POSTROUTING: After NAT
62+
63+ More information can be found at: www.linuximq.net
64+
65+ If not sure leave the default settings alone.
66+
67+config IMQ_BEHAVIOR_AB
68+ bool "IMQ AB"
69+ help
70+ This settings defines how IMQ behaves in respect to its
71+ hooking in PREROUTING and POSTROUTING.
72+
73+ Choosing this option will make IMQ hook like this:
74+
75+ PREROUTING: After NAT
76+ POSTROUTING: Before NAT
77+
78+ More information can be found at: www.linuximq.net
79+
80+ If not sure leave the default settings alone.
81+
82+config IMQ_BEHAVIOR_BA
83+ bool "IMQ BA"
84+ help
85+ This settings defines how IMQ behaves in respect to its
86+ hooking in PREROUTING and POSTROUTING.
87+
88+ Choosing this option will make IMQ hook like this:
89+
90+ PREROUTING: Before NAT
91+ POSTROUTING: After NAT
92+
93+ More information can be found at: www.linuximq.net
94+
95+ If not sure leave the default settings alone.
96+
97+config IMQ_BEHAVIOR_BB
98+ bool "IMQ BB"
99+ help
100+ This settings defines how IMQ behaves in respect to its
101+ hooking in PREROUTING and POSTROUTING.
102+
103+ Choosing this option will make IMQ hook like this:
104+
105+ PREROUTING: Before NAT
106+ POSTROUTING: Before NAT
107+
108+ More information can be found at: www.linuximq.net
109+
110+ If not sure leave the default settings alone.
111+
112+endchoice
113+
114+config IMQ_NUM_DEVS
115+
116+ int "Number of IMQ devices"
117+ range 2 8
118+ depends on IMQ
119+ default "2"
120+ help
121+
122+ This settings defines how many IMQ devices will be
123+ created.
124+
125+ The default value is 2.
126+
127+ More information can be found at: www.linuximq.net
128+
129+ If not sure leave the default settings alone.
130+
131 config TUN
132 tristate "Universal TUN/TAP device driver support"
133 select CRC32
134diff -Nru linux-2.6.21.1-orig/drivers/net/Makefile linux-2.6.21.1/drivers/net/Makefile
135--- linux-2.6.21.1-orig/drivers/net/Makefile 2007-04-27 21:49:26.000000000 +0000
136+++ linux-2.6.21.1/drivers/net/Makefile 2007-06-02 21:43:55.000000000 +0000
137@@ -124,6 +124,7 @@
138 obj-$(CONFIG_SLHC) += slhc.o
139
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
145diff -Nru linux-2.6.21.1-orig/drivers/net/imq.c linux-2.6.21.1/drivers/net/imq.c
146--- linux-2.6.21.1-orig/drivers/net/imq.c 1970-01-01 00:00:00.000000000 +0000
147+++ linux-2.6.21.1/drivers/net/imq.c 2007-06-02 21:43:55.000000000 +0000
148@@ -0,0 +1,402 @@
149+/*
150+ * Pseudo-driver for the intermediate queue device.
151+ *
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.
156+ *
157+ * Authors: Patrick McHardy, <kaber@trash.net>
158+ *
159+ * The first version was written by Martin Devera, <devik@cdi.cz>
160+ *
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
167+ *
168+ * After some time of inactivity there is a group taking care
169+ * of IMQ again: http://www.linuximq.net
170+ *
171+ *
172+ * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
173+ * the following changes:
174+ *
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)
183+ *
184+ *
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.
191+ *
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.
196+ *
197+ * More info at: http://www.linuximq.net/ (Andre Correa)
198+ */
199+
200+#include <linux/module.h>
201+#include <linux/kernel.h>
202+#include <linux/moduleparam.h>
203+#include <linux/skbuff.h>
204+#include <linux/netdevice.h>
205+#include <linux/rtnetlink.h>
206+#include <linux/if_arp.h>
207+#include <linux/netfilter.h>
208+#include <linux/netfilter_ipv4.h>
209+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
210+ #include <linux/netfilter_ipv6.h>
211+#endif
212+#include <linux/imq.h>
213+#include <net/pkt_sched.h>
214+
215+extern int qdisc_restart1(struct net_device *dev);
216+
217+static nf_hookfn imq_nf_hook;
218+
219+static struct nf_hook_ops imq_ingress_ipv4 = {
220+ .hook = imq_nf_hook,
221+ .owner = THIS_MODULE,
222+ .pf = PF_INET,
223+ .hooknum = NF_IP_PRE_ROUTING,
224+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
225+ .priority = NF_IP_PRI_MANGLE + 1
226+#else
227+ .priority = NF_IP_PRI_NAT_DST + 1
228+#endif
229+};
230+
231+static struct nf_hook_ops imq_egress_ipv4 = {
232+ .hook = imq_nf_hook,
233+ .owner = THIS_MODULE,
234+ .pf = PF_INET,
235+ .hooknum = NF_IP_POST_ROUTING,
236+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
237+ .priority = NF_IP_PRI_LAST
238+#else
239+ .priority = NF_IP_PRI_NAT_SRC - 1
240+#endif
241+};
242+
243+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
244+static struct nf_hook_ops imq_ingress_ipv6 = {
245+ .hook = imq_nf_hook,
246+ .owner = THIS_MODULE,
247+ .pf = PF_INET6,
248+ .hooknum = NF_IP6_PRE_ROUTING,
249+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
250+ .priority = NF_IP6_PRI_MANGLE + 1
251+#else
252+ .priority = NF_IP6_PRI_NAT_DST + 1
253+#endif
254+};
255+
256+static struct nf_hook_ops imq_egress_ipv6 = {
257+ .hook = imq_nf_hook,
258+ .owner = THIS_MODULE,
259+ .pf = PF_INET6,
260+ .hooknum = NF_IP6_POST_ROUTING,
261+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
262+ .priority = NF_IP6_PRI_LAST
263+#else
264+ .priority = NF_IP6_PRI_NAT_SRC - 1
265+#endif
266+};
267+#endif
268+
269+#if defined(CONFIG_IMQ_NUM_DEVS)
270+static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
271+#else
272+static unsigned int numdevs = 2;
273+#endif
274+
275+static struct net_device *imq_devs;
276+
277+static struct net_device_stats *imq_get_stats(struct net_device *dev)
278+{
279+ return (struct net_device_stats *)dev->priv;
280+}
281+
282+/* called for packets kfree'd in qdiscs at places other than enqueue */
283+static void imq_skb_destructor(struct sk_buff *skb)
284+{
285+ struct nf_info *info = skb->nf_info;
286+
287+ if (info) {
288+ if (info->indev)
289+ dev_put(info->indev);
290+ if (info->outdev)
291+ dev_put(info->outdev);
292+ kfree(info);
293+ }
294+}
295+
296+static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
297+{
298+ struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
299+
300+ stats->tx_bytes += skb->len;
301+ stats->tx_packets++;
302+
303+ skb->imq_flags = 0;
304+ skb->destructor = NULL;
305+
306+ dev->trans_start = jiffies;
307+ nf_reinject(skb, skb->nf_info, NF_ACCEPT);
308+ return 0;
309+}
310+
311+static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
312+{
313+ struct net_device *dev;
314+ struct net_device_stats *stats;
315+ struct sk_buff *skb2 = NULL;
316+ struct Qdisc *q;
317+ unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
318+ int ret = -1;
319+
320+ if (index > numdevs)
321+ return -1;
322+
323+ dev = imq_devs + index;
324+ if (!(dev->flags & IFF_UP)) {
325+ skb->imq_flags = 0;
326+ nf_reinject(skb, info, NF_ACCEPT);
327+ return 0;
328+ }
329+ dev->last_rx = jiffies;
330+
331+ if (skb->destructor) {
332+ skb2 = skb;
333+ skb = skb_clone(skb, GFP_ATOMIC);
334+ if (!skb)
335+ return -1;
336+ }
337+ skb->nf_info = info;
338+
339+ stats = (struct net_device_stats *)dev->priv;
340+ stats->rx_bytes+= skb->len;
341+ stats->rx_packets++;
342+
343+ spin_lock_bh(&dev->queue_lock);
344+ q = dev->qdisc;
345+ if (q->enqueue) {
346+ q->enqueue(skb_get(skb), q);
347+ if (skb_shared(skb)) {
348+ skb->destructor = imq_skb_destructor;
349+ kfree_skb(skb);
350+ ret = 0;
351+ }
352+ }
353+ if (spin_is_locked(&dev->_xmit_lock))
354+ netif_schedule(dev);
355+ else
356+ while (!netif_queue_stopped(dev) && qdisc_restart1(dev) < 0)
357+ /* NOTHING */;
358+
359+ spin_unlock_bh(&dev->queue_lock);
360+
361+ if (skb2)
362+ kfree_skb(ret ? skb : skb2);
363+
364+ return ret;
365+}
366+
367+static struct nf_queue_handler nfqh = {
368+ .name = "imq",
369+ .outfn = imq_nf_queue,
370+};
371+
372+static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
373+ const struct net_device *indev,
374+ const struct net_device *outdev,
375+ int (*okfn)(struct sk_buff *))
376+{
377+ if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
378+ return NF_QUEUE;
379+
380+ return NF_ACCEPT;
381+}
382+
383+
384+static int __init imq_init_hooks(void)
385+{
386+ int err;
387+
388+ err = nf_register_queue_handler(PF_INET, &nfqh);
389+ if (err > 0)
390+ goto err1;
391+ if ((err = nf_register_hook(&imq_ingress_ipv4)))
392+ goto err2;
393+ if ((err = nf_register_hook(&imq_egress_ipv4)))
394+ goto err3;
395+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
396+ if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
397+ goto err4;
398+ if ((err = nf_register_hook(&imq_ingress_ipv6)))
399+ goto err5;
400+ if ((err = nf_register_hook(&imq_egress_ipv6)))
401+ goto err6;
402+#endif
403+
404+ return 0;
405+
406+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
407+err6:
408+ nf_unregister_hook(&imq_ingress_ipv6);
409+err5:
410+ nf_unregister_queue_handler(PF_INET6);
411+err4:
412+ nf_unregister_hook(&imq_egress_ipv6);
413+#endif
414+err3:
415+ nf_unregister_hook(&imq_ingress_ipv4);
416+err2:
417+ nf_unregister_queue_handler(PF_INET);
418+err1:
419+ return err;
420+}
421+
422+static void __exit imq_unhook(void)
423+{
424+ nf_unregister_hook(&imq_ingress_ipv4);
425+ nf_unregister_hook(&imq_egress_ipv4);
426+ nf_unregister_queue_handler(PF_INET);
427+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
428+ nf_unregister_hook(&imq_ingress_ipv6);
429+ nf_unregister_hook(&imq_egress_ipv6);
430+ nf_unregister_queue_handler(PF_INET6);
431+#endif
432+}
433+
434+static int __init imq_dev_init(struct net_device *dev)
435+{
436+ dev->hard_start_xmit = imq_dev_xmit;
437+ dev->type = ARPHRD_VOID;
438+ dev->mtu = 1500;
439+ dev->tx_queue_len = 30;
440+ dev->flags = IFF_NOARP;
441+ dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
442+ if (dev->priv == NULL)
443+ return -ENOMEM;
444+ memset(dev->priv, 0, sizeof(struct net_device_stats));
445+ dev->get_stats = imq_get_stats;
446+
447+ return 0;
448+}
449+
450+static void imq_dev_uninit(struct net_device *dev)
451+{
452+ kfree(dev->priv);
453+}
454+
455+static int __init imq_init_devs(void)
456+{
457+ struct net_device *dev;
458+ int i,j;
459+ j = numdevs;
460+
461+ if (!numdevs || numdevs > IMQ_MAX_DEVS) {
462+ printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
463+ IMQ_MAX_DEVS);
464+ return -EINVAL;
465+ }
466+
467+ imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
468+ if (!imq_devs)
469+ return -ENOMEM;
470+ memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
471+
472+ /* we start counting at zero */
473+ numdevs--;
474+
475+ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
476+ SET_MODULE_OWNER(dev);
477+ strcpy(dev->name, "imq%d");
478+ dev->init = imq_dev_init;
479+ dev->uninit = imq_dev_uninit;
480+
481+ if (register_netdev(dev) < 0)
482+ goto err_register;
483+ }
484+ printk(KERN_INFO "IMQ starting with %u devices...\n", j);
485+ return 0;
486+
487+err_register:
488+ for (; i; i--)
489+ unregister_netdev(--dev);
490+ kfree(imq_devs);
491+ return -EIO;
492+}
493+
494+static void imq_cleanup_devs(void)
495+{
496+ int i;
497+ struct net_device *dev = imq_devs;
498+
499+ for (i = 0; i <= numdevs; i++)
500+ unregister_netdev(dev++);
501+
502+ kfree(imq_devs);
503+}
504+
505+static int __init imq_init_module(void)
506+{
507+ int err;
508+
509+ if ((err = imq_init_devs())) {
510+ printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
511+ return err;
512+ }
513+ if ((err = imq_init_hooks())) {
514+ printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
515+ imq_cleanup_devs();
516+ return err;
517+ }
518+
519+ printk(KERN_INFO "IMQ driver loaded successfully.\n");
520+
521+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
522+ printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
523+#else
524+ printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
525+#endif
526+#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
527+ printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
528+#else
529+ printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
530+#endif
531+
532+ return 0;
533+}
534+
535+static void __exit imq_cleanup_module(void)
536+{
537+ imq_unhook();
538+ imq_cleanup_devs();
539+ printk(KERN_INFO "IMQ driver unloaded successfully.\n");
540+}
541+
542+
543+module_init(imq_init_module);
544+module_exit(imq_cleanup_module);
545+
546+module_param(numdevs, int, 0);
547+MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
548+MODULE_AUTHOR("http://www.linuximq.net");
549+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
550+MODULE_LICENSE("GPL");
551diff -Nru linux-2.6.21.1-orig/include/linux/imq.h linux-2.6.21.1/include/linux/imq.h
552--- linux-2.6.21.1-orig/include/linux/imq.h 1970-01-01 00:00:00.000000000 +0000
553+++ linux-2.6.21.1/include/linux/imq.h 2007-06-02 21:43:55.000000000 +0000
554@@ -0,0 +1,9 @@
555+#ifndef _IMQ_H
556+#define _IMQ_H
557+
558+#define IMQ_MAX_DEVS 16
559+
560+#define IMQ_F_IFMASK 0x7f
561+#define IMQ_F_ENQUEUE 0x80
562+
563+#endif /* _IMQ_H */
564diff -Nru linux-2.6.21.1-orig/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.21.1/include/linux/netfilter_ipv4/ipt_IMQ.h
565--- linux-2.6.21.1-orig/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 00:00:00.000000000 +0000
566+++ linux-2.6.21.1/include/linux/netfilter_ipv4/ipt_IMQ.h 2007-06-02 21:43:55.000000000 +0000
567@@ -0,0 +1,8 @@
568+#ifndef _IPT_IMQ_H
569+#define _IPT_IMQ_H
570+
571+struct ipt_imq_info {
572+ unsigned int todev; /* target imq device */
573+};
574+
575+#endif /* _IPT_IMQ_H */
576diff -Nru linux-2.6.21.1-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.21.1/include/linux/netfilter_ipv6/ip6t_IMQ.h
577--- linux-2.6.21.1-orig/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 00:00:00.000000000 +0000
578+++ linux-2.6.21.1/include/linux/netfilter_ipv6/ip6t_IMQ.h 2007-06-02 21:43:55.000000000 +0000
579@@ -0,0 +1,8 @@
580+#ifndef _IP6T_IMQ_H
581+#define _IP6T_IMQ_H
582+
583+struct ip6t_imq_info {
584+ unsigned int todev; /* target imq device */
585+};
586+
587+#endif /* _IP6T_IMQ_H */
588diff -Nru linux-2.6.21.1-orig/include/linux/skbuff.h linux-2.6.21.1/include/linux/skbuff.h
589--- linux-2.6.21.1-orig/include/linux/skbuff.h 2007-04-27 21:49:26.000000000 +0000
590+++ linux-2.6.21.1/include/linux/skbuff.h 2007-06-02 21:43:55.000000000 +0000
591@@ -294,6 +294,10 @@
592 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
593 struct sk_buff *nfct_reasm;
594 #endif
595+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
596+ unsigned char imq_flags;
597+ struct nf_info *nf_info;
598+#endif
599 #ifdef CONFIG_BRIDGE_NETFILTER
600 struct nf_bridge_info *nf_bridge;
601 #endif
602diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/Kconfig linux-2.6.21.1/net/ipv4/netfilter/Kconfig
603--- linux-2.6.21.1-orig/net/ipv4/netfilter/Kconfig 2007-04-27 21:49:26.000000000 +0000
604+++ linux-2.6.21.1/net/ipv4/netfilter/Kconfig 2007-06-02 21:43:55.000000000 +0000
605@@ -565,6 +565,17 @@
606
607 To compile it as a module, choose M here. If unsure, say N.
608
609+config IP_NF_TARGET_IMQ
610+ tristate "IMQ target support"
611+ depends on IP_NF_MANGLE
612+ help
613+ This option adds a `IMQ' target which is used to specify if and
614+ to which IMQ device packets should get enqueued/dequeued.
615+
616+ For more information visit: http://www.linuximq.net/
617+
618+ To compile it as a module, choose M here. If unsure, say N.
619+
620 config IP_NF_TARGET_TOS
621 tristate "TOS target support"
622 depends on IP_NF_MANGLE
623diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/Makefile linux-2.6.21.1/net/ipv4/netfilter/Makefile
624--- linux-2.6.21.1-orig/net/ipv4/netfilter/Makefile 2007-04-27 21:49:26.000000000 +0000
625+++ linux-2.6.21.1/net/ipv4/netfilter/Makefile 2007-06-02 21:43:55.000000000 +0000
626@@ -96,6 +96,7 @@
627 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
628 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
629 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
630+obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
631 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
632 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
633 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
634diff -Nru linux-2.6.21.1-orig/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.21.1/net/ipv4/netfilter/ipt_IMQ.c
635--- linux-2.6.21.1-orig/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 00:00:00.000000000 +0000
636+++ linux-2.6.21.1/net/ipv4/netfilter/ipt_IMQ.c 2007-06-02 21:44:24.000000000 +0000
637@@ -0,0 +1,70 @@
638+/*
639+ * This target marks packets to be enqueued to an imq device
640+ */
641+#include <linux/module.h>
642+#include <linux/skbuff.h>
643+#include <linux/netfilter_ipv4/ip_tables.h>
644+#include <linux/netfilter_ipv4/ipt_IMQ.h>
645+#include <linux/imq.h>
646+
647+static unsigned int imq_target(struct sk_buff **pskb,
648+ const struct net_device *in,
649+ const struct net_device *out,
650+ unsigned int hooknum,
651+ const struct xt_target *target,
652+ const void *targinfo)
653+{
654+ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
655+
656+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
657+
658+ return XT_CONTINUE;
659+}
660+
661+static int imq_checkentry(const char *tablename,
662+ const void *e,
663+ const struct xt_target *target,
664+ void *targinfo,
665+ unsigned int hook_mask)
666+{
667+ struct ipt_imq_info *mr;
668+
669+ mr = (struct ipt_imq_info*)targinfo;
670+
671+ if (mr->todev > IMQ_MAX_DEVS) {
672+ printk(KERN_WARNING
673+ "IMQ: invalid device specified, highest is %u\n",
674+ IMQ_MAX_DEVS);
675+ return 0;
676+ }
677+
678+ return 1;
679+}
680+
681+static struct xt_target ipt_imq_reg = {
682+ .name = "IMQ",
683+ .family = AF_INET,
684+ .target = imq_target,
685+ .targetsize = sizeof(struct ipt_imq_info),
686+ .checkentry = imq_checkentry,
687+ .me = THIS_MODULE,
688+ .table = "mangle"
689+};
690+
691+static int __init init(void)
692+{
693+ return xt_register_target(&ipt_imq_reg);
694+}
695+
696+static void __exit fini(void)
697+{
698+ xt_unregister_target(&ipt_imq_reg);
699+}
700+
701+module_init(init);
702+module_exit(fini);
703+
704+MODULE_AUTHOR("http://www.linuximq.net");
705+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
706+MODULE_LICENSE("GPL");
707+
708Binary files linux-2.6.21.1-orig/net/ipv6/netfilter/.ip6t_IMQ.swp and linux-2.6.21.1/net/ipv6/netfilter/.ip6t_IMQ.swp differ
709diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/Kconfig linux-2.6.21.1/net/ipv6/netfilter/Kconfig
710--- linux-2.6.21.1-orig/net/ipv6/netfilter/Kconfig 2007-04-27 21:49:26.000000000 +0000
711+++ linux-2.6.21.1/net/ipv6/netfilter/Kconfig 2007-06-02 21:43:55.000000000 +0000
712@@ -173,6 +173,15 @@
713
714 To compile it as a module, choose M here. If unsure, say N.
715
716+config IP6_NF_TARGET_IMQ
717+ tristate "IMQ target support"
718+ depends on IP6_NF_MANGLE
719+ help
720+ This option adds a `IMQ' target which is used to specify if and
721+ to which imq device packets should get enqueued/dequeued.
722+
723+ To compile it as a module, choose M here. If unsure, say N.
724+
725 config IP6_NF_TARGET_HL
726 tristate 'HL (hoplimit) target support'
727 depends on IP6_NF_MANGLE
728diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/Makefile linux-2.6.21.1/net/ipv6/netfilter/Makefile
729--- linux-2.6.21.1-orig/net/ipv6/netfilter/Makefile 2007-04-27 21:49:26.000000000 +0000
730+++ linux-2.6.21.1/net/ipv6/netfilter/Makefile 2007-06-02 21:43:55.000000000 +0000
731@@ -13,6 +13,7 @@
732 obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
733 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
734 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
735+obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
736 obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
737 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
738 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
739diff -Nru linux-2.6.21.1-orig/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.21.1/net/ipv6/netfilter/ip6t_IMQ.c
740--- linux-2.6.21.1-orig/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 00:00:00.000000000 +0000
741+++ linux-2.6.21.1/net/ipv6/netfilter/ip6t_IMQ.c 2007-06-02 21:45:36.000000000 +0000
742@@ -0,0 +1,70 @@
743+/*
744+ * This target marks packets to be enqueued to an imq device
745+ */
746+#include <linux/module.h>
747+#include <linux/skbuff.h>
748+#include <linux/netfilter_ipv6/ip6_tables.h>
749+#include <linux/netfilter_ipv6/ip6t_IMQ.h>
750+#include <linux/imq.h>
751+
752+static unsigned int imq_target(struct sk_buff **pskb,
753+ const struct net_device *in,
754+ const struct net_device *out,
755+ unsigned int hooknum,
756+ const struct xt_target *target,
757+ const void *targinfo)
758+{
759+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
760+
761+ (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
762+
763+ return XT_CONTINUE;
764+}
765+
766+static int imq_checkentry(const char *tablename,
767+ const void *entry,
768+ const struct xt_target *target,
769+ void *targinfo,
770+ unsigned int hook_mask)
771+{
772+ struct ip6t_imq_info *mr;
773+
774+ mr = (struct ip6t_imq_info*)targinfo;
775+
776+ if (mr->todev > IMQ_MAX_DEVS) {
777+ printk(KERN_WARNING
778+ "IMQ: invalid device specified, highest is %u\n",
779+ IMQ_MAX_DEVS);
780+ return 0;
781+ }
782+
783+ return 1;
784+}
785+
786+static struct xt_target ip6t_imq_reg = {
787+ .name = "IMQ",
788+ .family = AF_INET6,
789+ .target = imq_target,
790+ .targetsize = sizeof(struct ip6t_imq_info),
791+ .table = "mangle",
792+ .checkentry = imq_checkentry,
793+ .me = THIS_MODULE
794+};
795+
796+static int __init init(void)
797+{
798+ return xt_register_target(&ip6t_imq_reg);
799+}
800+
801+static void __exit fini(void)
802+{
803+ xt_unregister_target(&ip6t_imq_reg);
804+}
805+
806+module_init(init);
807+module_exit(fini);
808+
809+MODULE_AUTHOR("http://www.linuximq.net");
810+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
811+MODULE_LICENSE("GPL");
812+
813diff -Nru linux-2.6.21.1-orig/net/sched/sch_generic.c linux-2.6.21.1/net/sched/sch_generic.c
814--- linux-2.6.21.1-orig/net/sched/sch_generic.c 2007-04-27 21:49:26.000000000 +0000
815+++ linux-2.6.21.1/net/sched/sch_generic.c 2007-06-02 21:43:55.000000000 +0000
816@@ -87,7 +87,6 @@
817
818 NOTE: Called under dev->queue_lock with locally disabled BH.
819 */
820-
821 static inline int qdisc_restart(struct net_device *dev)
822 {
823 struct Qdisc *q = dev->qdisc;
824@@ -181,6 +180,11 @@
825 return q->q.qlen;
826 }
827
828+int qdisc_restart1(struct net_device *dev)
829+{
830+ return qdisc_restart(dev);
831+}
832+
833 void __qdisc_run(struct net_device *dev)
834 {
835 if (unlikely(dev->qdisc == &noop_qdisc))
836@@ -617,3 +621,4 @@
837 EXPORT_SYMBOL(qdisc_reset);
838 EXPORT_SYMBOL(qdisc_lock_tree);
839 EXPORT_SYMBOL(qdisc_unlock_tree);
840+EXPORT_SYMBOL(qdisc_restart1);