]> git.pld-linux.org Git - packages/kernel.git/blame - kernel-imq.patch
- let's try unofficial patch http://kapturkiewicz.name/linux-2.6.25-imq1.diff
[packages/kernel.git] / kernel-imq.patch
CommitLineData
d6ad3303 1diff -U 6 -Nr linux-2.6.25/drivers/net/imq.c linux-2.6.25+imq/drivers/net/imq.c
2--- linux-2.6.25/drivers/net/imq.c 1970-01-01 02:00:00.000000000 +0200
3+++ linux-2.6.25+imq/drivers/net/imq.c 2008-04-18 18:59:11.759564156 +0300
4@@ -0,0 +1,411 @@
f4f8379a 5+/*
6+ * Pseudo-driver for the intermediate queue device.
7+ *
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.
12+ *
13+ * Authors: Patrick McHardy, <kaber@trash.net>
14+ *
15+ * The first version was written by Martin Devera, <devik@cdi.cz>
16+ *
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
23+ *
24+ * After some time of inactivity there is a group taking care
25+ * of IMQ again: http://www.linuximq.net
26+ *
27+ *
28+ * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
29+ * the following changes:
30+ *
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)
39+ *
40+ *
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.
47+ *
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.
52+ *
53+ * More info at: http://www.linuximq.net/ (Andre Correa)
54+ */
55+
56+#include <linux/module.h>
57+#include <linux/kernel.h>
58+#include <linux/moduleparam.h>
59+#include <linux/skbuff.h>
60+#include <linux/netdevice.h>
61+#include <linux/rtnetlink.h>
62+#include <linux/if_arp.h>
63+#include <linux/netfilter.h>
64+#include <linux/netfilter_ipv4.h>
65+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
66+ #include <linux/netfilter_ipv6.h>
67+#endif
68+#include <linux/imq.h>
69+#include <net/pkt_sched.h>
d6ad3303 70+#include <net/netfilter/nf_queue.h>
f4f8379a 71+
72+extern int qdisc_restart1(struct net_device *dev);
73+
2437dee6 74+static nf_hookfn imq_nf_hook;
f4f8379a 75+
76+static struct nf_hook_ops imq_ingress_ipv4 = {
77+ .hook = imq_nf_hook,
78+ .owner = THIS_MODULE,
79+ .pf = PF_INET,
d6ad3303 80+ .hooknum = NF_INET_PRE_ROUTING,
f4f8379a 81+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
82+ .priority = NF_IP_PRI_MANGLE + 1
83+#else
84+ .priority = NF_IP_PRI_NAT_DST + 1
85+#endif
86+};
87+
88+static struct nf_hook_ops imq_egress_ipv4 = {
89+ .hook = imq_nf_hook,
90+ .owner = THIS_MODULE,
91+ .pf = PF_INET,
d6ad3303 92+ .hooknum = NF_INET_POST_ROUTING,
f4f8379a 93+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
94+ .priority = NF_IP_PRI_LAST
95+#else
96+ .priority = NF_IP_PRI_NAT_SRC - 1
97+#endif
98+};
99+
100+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
101+static struct nf_hook_ops imq_ingress_ipv6 = {
102+ .hook = imq_nf_hook,
103+ .owner = THIS_MODULE,
104+ .pf = PF_INET6,
d6ad3303 105+ .hooknum = NF_INET_PRE_ROUTING,
f4f8379a 106+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
107+ .priority = NF_IP6_PRI_MANGLE + 1
108+#else
109+ .priority = NF_IP6_PRI_NAT_DST + 1
110+#endif
111+};
112+
113+static struct nf_hook_ops imq_egress_ipv6 = {
114+ .hook = imq_nf_hook,
115+ .owner = THIS_MODULE,
116+ .pf = PF_INET6,
d6ad3303 117+ .hooknum = NF_INET_POST_ROUTING,
f4f8379a 118+#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
119+ .priority = NF_IP6_PRI_LAST
120+#else
121+ .priority = NF_IP6_PRI_NAT_SRC - 1
122+#endif
123+};
124+#endif
125+
126+#if defined(CONFIG_IMQ_NUM_DEVS)
127+static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
128+#else
2437dee6 129+static unsigned int numdevs = 16;
f4f8379a 130+#endif
131+
132+static struct net_device *imq_devs;
133+
134+static struct net_device_stats *imq_get_stats(struct net_device *dev)
135+{
136+ return (struct net_device_stats *)dev->priv;
137+}
138+
139+/* called for packets kfree'd in qdiscs at places other than enqueue */
140+static void imq_skb_destructor(struct sk_buff *skb)
141+{
d6ad3303 142+ struct nf_queue_entry *entry = skb->nf_queue_entry;
143+
144+ if (entry) {
145+ if (entry->indev)
146+ dev_put(entry->indev);
147+ if (entry->outdev)
148+ dev_put(entry->outdev);
149+ kfree(entry);
f4f8379a 150+ }
151+}
152+
153+static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
154+{
155+ struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
156+
157+ stats->tx_bytes += skb->len;
158+ stats->tx_packets++;
159+
160+ skb->imq_flags = 0;
161+ skb->destructor = NULL;
162+
163+ dev->trans_start = jiffies;
d6ad3303 164+ nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
f4f8379a 165+ return 0;
166+}
167+
d6ad3303 168+static int imq_nf_queue(struct nf_queue_entry *entry, unsigned int queuenum)
f4f8379a 169+{
170+ struct net_device *dev;
171+ struct net_device_stats *stats;
d6ad3303 172+ struct sk_buff *skb = entry->skb;
f4f8379a 173+ struct sk_buff *skb2 = NULL;
174+ struct Qdisc *q;
175+ unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
176+ int ret = -1;
177+
178+ if (index > numdevs)
179+ return -1;
180+
181+ dev = imq_devs + index;
182+ if (!(dev->flags & IFF_UP)) {
183+ skb->imq_flags = 0;
d6ad3303 184+ nf_reinject(entry, NF_ACCEPT);
f4f8379a 185+ return 0;
186+ }
187+ dev->last_rx = jiffies;
188+
189+ if (skb->destructor) {
190+ skb2 = skb;
191+ skb = skb_clone(skb, GFP_ATOMIC);
192+ if (!skb)
193+ return -1;
194+ }
d6ad3303 195+ skb->nf_queue_entry = entry;
f4f8379a 196+
197+ stats = (struct net_device_stats *)dev->priv;
198+ stats->rx_bytes+= skb->len;
199+ stats->rx_packets++;
200+
201+ spin_lock_bh(&dev->queue_lock);
202+ q = dev->qdisc;
203+ if (q->enqueue) {
204+ q->enqueue(skb_get(skb), q);
205+ if (skb_shared(skb)) {
206+ skb->destructor = imq_skb_destructor;
207+ kfree_skb(skb);
208+ ret = 0;
209+ }
210+ }
211+ if (spin_is_locked(&dev->_xmit_lock))
212+ netif_schedule(dev);
213+ else
214+ while (!netif_queue_stopped(dev) && qdisc_restart1(dev) < 0)
215+ /* NOTHING */;
216+
217+ spin_unlock_bh(&dev->queue_lock);
218+
219+ if (skb2)
220+ kfree_skb(ret ? skb : skb2);
221+
222+ return ret;
223+}
224+
225+static struct nf_queue_handler nfqh = {
226+ .name = "imq",
227+ .outfn = imq_nf_queue,
228+};
229+
2437dee6 230+static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
f4f8379a 231+ const struct net_device *indev,
232+ const struct net_device *outdev,
233+ int (*okfn)(struct sk_buff *))
234+{
2437dee6 235+ if (pskb->imq_flags & IMQ_F_ENQUEUE)
f4f8379a 236+ return NF_QUEUE;
237+
238+ return NF_ACCEPT;
239+}
240+
241+
242+static int __init imq_init_hooks(void)
243+{
244+ int err;
245+
246+ err = nf_register_queue_handler(PF_INET, &nfqh);
247+ if (err > 0)
248+ goto err1;
249+ if ((err = nf_register_hook(&imq_ingress_ipv4)))
250+ goto err2;
251+ if ((err = nf_register_hook(&imq_egress_ipv4)))
252+ goto err3;
253+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
254+ if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
255+ goto err4;
256+ if ((err = nf_register_hook(&imq_ingress_ipv6)))
257+ goto err5;
258+ if ((err = nf_register_hook(&imq_egress_ipv6)))
259+ goto err6;
260+#endif
261+
262+ return 0;
263+
264+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
265+err6:
266+ nf_unregister_hook(&imq_ingress_ipv6);
267+err5:
3b8cc16d 268+ nf_unregister_queue_handler(PF_INET6, &nfqh);
f4f8379a 269+err4:
2437dee6 270+ nf_unregister_hook(&imq_egress_ipv4);
f4f8379a 271+#endif
272+err3:
273+ nf_unregister_hook(&imq_ingress_ipv4);
274+err2:
3b8cc16d 275+ nf_unregister_queue_handler(PF_INET, &nfqh);
f4f8379a 276+err1:
277+ return err;
278+}
279+
280+static void __exit imq_unhook(void)
281+{
f4f8379a 282+#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
283+ nf_unregister_hook(&imq_ingress_ipv6);
284+ nf_unregister_hook(&imq_egress_ipv6);
3b8cc16d 285+ nf_unregister_queue_handler(PF_INET6, &nfqh);
f4f8379a 286+#endif
2437dee6 287+ nf_unregister_hook(&imq_ingress_ipv4);
288+ nf_unregister_hook(&imq_egress_ipv4);
289+ nf_unregister_queue_handler(PF_INET, &nfqh);
f4f8379a 290+}
291+
292+static int __init imq_dev_init(struct net_device *dev)
293+{
294+ dev->hard_start_xmit = imq_dev_xmit;
295+ dev->type = ARPHRD_VOID;
2437dee6 296+ dev->mtu = 16000;
297+ dev->tx_queue_len = 11000;
f4f8379a 298+ dev->flags = IFF_NOARP;
2437dee6 299+ dev->priv = kzalloc(sizeof(struct net_device_stats), GFP_KERNEL);
f4f8379a 300+ if (dev->priv == NULL)
301+ return -ENOMEM;
f4f8379a 302+ dev->get_stats = imq_get_stats;
303+
304+ return 0;
305+}
306+
307+static void imq_dev_uninit(struct net_device *dev)
308+{
309+ kfree(dev->priv);
310+}
311+
2437dee6 312+static int __init imq_init_devs(struct net *net)
f4f8379a 313+{
314+ struct net_device *dev;
315+ int i,j;
316+ j = numdevs;
317+
318+ if (!numdevs || numdevs > IMQ_MAX_DEVS) {
319+ printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
320+ IMQ_MAX_DEVS);
321+ return -EINVAL;
322+ }
323+
2437dee6 324+ imq_devs = kzalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
f4f8379a 325+ if (!imq_devs)
326+ return -ENOMEM;
f4f8379a 327+
328+ /* we start counting at zero */
329+ numdevs--;
330+
331+ for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
f4f8379a 332+ strcpy(dev->name, "imq%d");
333+ dev->init = imq_dev_init;
334+ dev->uninit = imq_dev_uninit;
2437dee6 335+ dev->nd_net = net;
f4f8379a 336+
337+ if (register_netdev(dev) < 0)
338+ goto err_register;
339+ }
340+ printk(KERN_INFO "IMQ starting with %u devices...\n", j);
341+ return 0;
342+
343+err_register:
344+ for (; i; i--)
345+ unregister_netdev(--dev);
346+ kfree(imq_devs);
347+ return -EIO;
348+}
349+
350+static void imq_cleanup_devs(void)
351+{
352+ int i;
353+ struct net_device *dev = imq_devs;
354+
355+ for (i = 0; i <= numdevs; i++)
356+ unregister_netdev(dev++);
357+
358+ kfree(imq_devs);
359+}
360+
2437dee6 361+static __net_init int imq_init_module(struct net *net)
f4f8379a 362+{
363+ int err;
364+
2437dee6 365+ if ((err = imq_init_devs(net))) {
366+ printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
f4f8379a 367+ return err;
368+ }
369+ if ((err = imq_init_hooks())) {
370+ printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
371+ imq_cleanup_devs();
372+ return err;
373+ }
374+
375+ printk(KERN_INFO "IMQ driver loaded successfully.\n");
376+
377+#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
378+ printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
379+#else
380+ printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
381+#endif
382+#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
383+ printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
384+#else
385+ printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
386+#endif
387+
388+ return 0;
389+}
390+
2437dee6 391+static __net_exit void imq_exit_module(struct net *net)
f4f8379a 392+{
393+ imq_unhook();
394+ imq_cleanup_devs();
395+ printk(KERN_INFO "IMQ driver unloaded successfully.\n");
396+}
397+
2437dee6 398+static struct pernet_operations __net_initdata imq_net_ops = {
399+ .init = imq_init_module,
400+ .exit = imq_exit_module,
401+};
402+
403+static int __init imq_init(void)
404+{
405+ return register_pernet_device(&imq_net_ops);
406+}
f4f8379a 407+
2437dee6 408+module_init(imq_init);
409+//module_exit(imq_cleanup_module);
f4f8379a 410+
411+module_param(numdevs, int, 0);
412+MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
413+MODULE_AUTHOR("http://www.linuximq.net");
414+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
415+MODULE_LICENSE("GPL");
d6ad3303 416diff -U 6 -Nr linux-2.6.25/drivers/net/Kconfig linux-2.6.25+imq/drivers/net/Kconfig
417--- linux-2.6.25/drivers/net/Kconfig 2008-04-17 05:49:44.000000000 +0300
418+++ linux-2.6.25+imq/drivers/net/Kconfig 2008-04-18 14:54:49.587699858 +0300
419@@ -114,12 +114,135 @@
420 section 6.2 of the NET-3-HOWTO, available from
421 <http://www.tldp.org/docs.html#howto>.
422
2437dee6 423 To compile this driver as a module, choose M here: the module
424 will be called eql. If unsure, say N.
425
426+config IMQ
427+ tristate "IMQ (intermediate queueing device) support"
428+ depends on NETDEVICES && NETFILTER
429+ ---help---
430+ The IMQ device(s) is used as placeholder for QoS queueing
431+ disciplines. Every packet entering/leaving the IP stack can be
432+ directed through the IMQ device where it's enqueued/dequeued to the
433+ attached qdisc. This allows you to treat network devices as classes
434+ and distribute bandwidth among them. Iptables is used to specify
435+ through which IMQ device, if any, packets travel.
436+
437+ More information at: http://www.linuximq.net/
438+
439+ To compile this driver as a module, choose M here: the module
440+ will be called imq. If unsure, say N.
441+
442+choice
443+ prompt "IMQ behavior (PRE/POSTROUTING)"
444+ depends on IMQ
445+ default IMQ_BEHAVIOR_BB
446+ help
447+
448+ This settings defines how IMQ behaves in respect to its
449+ hooking in PREROUTING and POSTROUTING.
450+
451+ IMQ can work in any of the following ways:
452+
453+ PREROUTING | POSTROUTING
454+ -----------------|-------------------
455+ #1 After NAT | After NAT
456+ #2 After NAT | Before NAT
457+ #3 Before NAT | After NAT
458+ #4 Before NAT | Before NAT
459+
460+ The default behavior is to hook before NAT on PREROUTING
461+ and after NAT on POSTROUTING (#3).
462+
463+ This settings are specially usefull when trying to use IMQ
464+ to shape NATed clients.
465+
466+ More information can be found at: www.linuximq.net
467+
468+ If not sure leave the default settings alone.
469+
470+config IMQ_BEHAVIOR_AA
471+ bool "IMQ AA"
472+ help
473+ This settings defines how IMQ behaves in respect to its
474+ hooking in PREROUTING and POSTROUTING.
475+
476+ Choosing this option will make IMQ hook like this:
477+
478+ PREROUTING: After NAT
479+ POSTROUTING: After NAT
480+
481+ More information can be found at: www.linuximq.net
482+
483+ If not sure leave the default settings alone.
484+
485+config IMQ_BEHAVIOR_AB
486+ bool "IMQ AB"
487+ help
488+ This settings defines how IMQ behaves in respect to its
489+ hooking in PREROUTING and POSTROUTING.
490+
491+ Choosing this option will make IMQ hook like this:
492+
493+ PREROUTING: After NAT
494+ POSTROUTING: Before NAT
495+
496+ More information can be found at: www.linuximq.net
497+
498+ If not sure leave the default settings alone.
499+
500+config IMQ_BEHAVIOR_BA
501+ bool "IMQ BA"
502+ help
503+ This settings defines how IMQ behaves in respect to its
504+ hooking in PREROUTING and POSTROUTING.
505+
506+ Choosing this option will make IMQ hook like this:
507+
508+ PREROUTING: Before NAT
509+ POSTROUTING: After NAT
510+
511+ More information can be found at: www.linuximq.net
512+
513+ If not sure leave the default settings alone.
514+
515+config IMQ_BEHAVIOR_BB
516+ bool "IMQ BB"
517+ help
518+ This settings defines how IMQ behaves in respect to its
519+ hooking in PREROUTING and POSTROUTING.
520+
521+ Choosing this option will make IMQ hook like this:
522+
523+ PREROUTING: Before NAT
524+ POSTROUTING: Before NAT
525+
526+ More information can be found at: www.linuximq.net
527+
528+ If not sure leave the default settings alone.
529+
530+endchoice
531+
532+config IMQ_NUM_DEVS
533+
534+ int "Number of IMQ devices"
535+ range 2 16
536+ depends on IMQ
537+ default "16"
538+ help
539+
540+ This settings defines how many IMQ devices will be
541+ created.
542+
543+ The default value is 16.
544+
545+ More information can be found at: www.linuximq.net
546+
547+ If not sure leave the default settings alone.
548+
549 config TUN
550 tristate "Universal TUN/TAP device driver support"
551 select CRC32
d6ad3303 552 ---help---
553 TUN/TAP provides packet reception and transmission for user space
554 programs. It can be viewed as a simple Point-to-Point or Ethernet
555diff -U 6 -Nr linux-2.6.25/drivers/net/Makefile linux-2.6.25+imq/drivers/net/Makefile
556--- linux-2.6.25/drivers/net/Makefile 2008-04-17 05:49:44.000000000 +0300
557+++ linux-2.6.25+imq/drivers/net/Makefile 2008-04-18 14:54:49.591038604 +0300
558@@ -140,12 +140,13 @@
559 obj-$(CONFIG_SLIP) += slip.o
560 obj-$(CONFIG_SLHC) += slhc.o
561
2437dee6 562 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
563
564 obj-$(CONFIG_DUMMY) += dummy.o
565+obj-$(CONFIG_IMQ) += imq.o
566 obj-$(CONFIG_IFB) += ifb.o
567 obj-$(CONFIG_MACVLAN) += macvlan.o
568 obj-$(CONFIG_DE600) += de600.o
d6ad3303 569 obj-$(CONFIG_DE620) += de620.o
570 obj-$(CONFIG_LANCE) += lance.o
571 obj-$(CONFIG_SUN3_82586) += sun3_82586.o
572diff -U 6 -Nr linux-2.6.25/include/linux/imq.h linux-2.6.25+imq/include/linux/imq.h
573--- linux-2.6.25/include/linux/imq.h 1970-01-01 02:00:00.000000000 +0200
574+++ linux-2.6.25+imq/include/linux/imq.h 2008-04-18 14:54:49.594372600 +0300
f4f8379a 575@@ -0,0 +1,9 @@
576+#ifndef _IMQ_H
577+#define _IMQ_H
578+
579+#define IMQ_MAX_DEVS 16
580+
581+#define IMQ_F_IFMASK 0x7f
582+#define IMQ_F_ENQUEUE 0x80
583+
584+#endif /* _IMQ_H */
d6ad3303 585diff -U 6 -Nr linux-2.6.25/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.25+imq/include/linux/netfilter_ipv4/ipt_IMQ.h
586--- linux-2.6.25/include/linux/netfilter_ipv4/ipt_IMQ.h 1970-01-01 02:00:00.000000000 +0200
587+++ linux-2.6.25+imq/include/linux/netfilter_ipv4/ipt_IMQ.h 2008-04-18 14:54:49.594372600 +0300
f4f8379a 588@@ -0,0 +1,8 @@
589+#ifndef _IPT_IMQ_H
590+#define _IPT_IMQ_H
591+
592+struct ipt_imq_info {
593+ unsigned int todev; /* target imq device */
594+};
595+
596+#endif /* _IPT_IMQ_H */
d6ad3303 597diff -U 6 -Nr linux-2.6.25/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.25+imq/include/linux/netfilter_ipv6/ip6t_IMQ.h
598--- linux-2.6.25/include/linux/netfilter_ipv6/ip6t_IMQ.h 1970-01-01 02:00:00.000000000 +0200
599+++ linux-2.6.25+imq/include/linux/netfilter_ipv6/ip6t_IMQ.h 2008-04-18 14:54:49.594372600 +0300
f4f8379a 600@@ -0,0 +1,8 @@
601+#ifndef _IP6T_IMQ_H
602+#define _IP6T_IMQ_H
603+
604+struct ip6t_imq_info {
605+ unsigned int todev; /* target imq device */
606+};
607+
608+#endif /* _IP6T_IMQ_H */
d6ad3303 609diff -U 6 -Nr linux-2.6.25/include/linux/skbuff.h linux-2.6.25+imq/include/linux/skbuff.h
610--- linux-2.6.25/include/linux/skbuff.h 2008-04-17 05:49:44.000000000 +0300
611+++ linux-2.6.25+imq/include/linux/skbuff.h 2008-04-18 18:59:44.607852013 +0300
612@@ -293,12 +293,16 @@
613
614 void (*destructor)(struct sk_buff *skb);
615 #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2437dee6 616 struct nf_conntrack *nfct;
f4f8379a 617 struct sk_buff *nfct_reasm;
618 #endif
619+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
620+ unsigned char imq_flags;
d6ad3303 621+ struct nf_queue_entry *nf_queue_entry;
f4f8379a 622+#endif
623 #ifdef CONFIG_BRIDGE_NETFILTER
624 struct nf_bridge_info *nf_bridge;
625 #endif
d6ad3303 626
627 int iif;
628 #ifdef CONFIG_NETDEVICES_MULTIQUEUE
629@@ -1733,12 +1737,16 @@
630 dst->nfct = src->nfct;
631 nf_conntrack_get(src->nfct);
632 dst->nfctinfo = src->nfctinfo;
2437dee6 633 dst->nfct_reasm = src->nfct_reasm;
634 nf_conntrack_get_reasm(src->nfct_reasm);
635 #endif
636+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
637+ dst->imq_flags = src->imq_flags;
d6ad3303 638+ dst->nf_queue_entry = src->nf_queue_entry;
2437dee6 639+#endif
640 #ifdef CONFIG_BRIDGE_NETFILTER
641 dst->nf_bridge = src->nf_bridge;
642 nf_bridge_get(src->nf_bridge);
d6ad3303 643 #endif
644 }
645
646diff -U 6 -Nr linux-2.6.25/net/core/dev.c linux-2.6.25+imq/net/core/dev.c
647--- linux-2.6.25/net/core/dev.c 2008-04-17 05:49:44.000000000 +0300
648+++ linux-2.6.25+imq/net/core/dev.c 2008-04-18 14:54:49.611042584 +0300
649@@ -92,12 +92,15 @@
650 #include <linux/etherdevice.h>
651 #include <linux/notifier.h>
652 #include <linux/skbuff.h>
2437dee6 653 #include <net/net_namespace.h>
654 #include <net/sock.h>
655 #include <linux/rtnetlink.h>
656+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
657+#include <linux/imq.h>
658+#endif
659 #include <linux/proc_fs.h>
660 #include <linux/seq_file.h>
661 #include <linux/stat.h>
d6ad3303 662 #include <linux/if_bridge.h>
663 #include <linux/if_macvlan.h>
664 #include <net/dst.h>
665@@ -1534,13 +1537,17 @@
666 return 0;
667 }
668
2437dee6 669 int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
670 {
671 if (likely(!skb->next)) {
672- if (!list_empty(&ptype_all))
673+ if (!list_empty(&ptype_all)
674+#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
675+ && !(skb->imq_flags & IMQ_F_ENQUEUE)
676+#endif
677+ )
678 dev_queue_xmit_nit(skb, dev);
f4f8379a 679
2437dee6 680 if (netif_needs_gso(dev, skb)) {
d6ad3303 681 if (unlikely(dev_gso_segment(skb)))
682 goto out_kfree_skb;
683 if (skb->next)
684diff -U 6 -Nr linux-2.6.25/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.25+imq/net/ipv4/netfilter/ipt_IMQ.c
685--- linux-2.6.25/net/ipv4/netfilter/ipt_IMQ.c 1970-01-01 02:00:00.000000000 +0200
686+++ linux-2.6.25+imq/net/ipv4/netfilter/ipt_IMQ.c 2008-04-18 14:54:49.614374346 +0300
2437dee6 687@@ -0,0 +1,69 @@
f4f8379a 688+/*
689+ * This target marks packets to be enqueued to an imq device
690+ */
691+#include <linux/module.h>
692+#include <linux/skbuff.h>
693+#include <linux/netfilter_ipv4/ip_tables.h>
694+#include <linux/netfilter_ipv4/ipt_IMQ.h>
695+#include <linux/imq.h>
696+
2437dee6 697+static unsigned int imq_target(struct sk_buff *pskb,
f4f8379a 698+ const struct net_device *in,
699+ const struct net_device *out,
700+ unsigned int hooknum,
701+ const struct xt_target *target,
702+ const void *targinfo)
703+{
704+ struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
705+
2437dee6 706+ pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
f4f8379a 707+
708+ return XT_CONTINUE;
709+}
710+
2437dee6 711+static bool imq_checkentry(const char *tablename,
f4f8379a 712+ const void *e,
713+ const struct xt_target *target,
714+ void *targinfo,
715+ unsigned int hook_mask)
716+{
717+ struct ipt_imq_info *mr;
718+
719+ mr = (struct ipt_imq_info*)targinfo;
720+
721+ if (mr->todev > IMQ_MAX_DEVS) {
722+ printk(KERN_WARNING
723+ "IMQ: invalid device specified, highest is %u\n",
724+ IMQ_MAX_DEVS);
725+ return 0;
726+ }
727+
728+ return 1;
729+}
730+
731+static struct xt_target ipt_imq_reg = {
732+ .name = "IMQ",
733+ .family = AF_INET,
734+ .target = imq_target,
735+ .targetsize = sizeof(struct ipt_imq_info),
736+ .checkentry = imq_checkentry,
737+ .me = THIS_MODULE,
738+ .table = "mangle"
739+};
740+
741+static int __init init(void)
742+{
743+ return xt_register_target(&ipt_imq_reg);
744+}
745+
746+static void __exit fini(void)
747+{
748+ xt_unregister_target(&ipt_imq_reg);
749+}
750+
751+module_init(init);
752+module_exit(fini);
753+
754+MODULE_AUTHOR("http://www.linuximq.net");
755+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
756+MODULE_LICENSE("GPL");
d6ad3303 757diff -U 6 -Nr linux-2.6.25/net/ipv4/netfilter/Kconfig linux-2.6.25+imq/net/ipv4/netfilter/Kconfig
758--- linux-2.6.25/net/ipv4/netfilter/Kconfig 2008-04-17 05:49:44.000000000 +0300
759+++ linux-2.6.25+imq/net/ipv4/netfilter/Kconfig 2008-04-18 14:59:00.917678729 +0300
760@@ -305,12 +305,23 @@
761 an IP packet. This is particularly useful, if you need to work around
762 existing ECN blackholes on the internet, but don't want to disable
763 ECN support in general.
f4f8379a 764
765 To compile it as a module, choose M here. If unsure, say N.
766
2437dee6 767+config IP_NF_TARGET_IMQ
d6ad3303 768+ tristate "IMQ target support"
769+ depends on IP_NF_MANGLE
770+ help
771+ This option adds a `IMQ' target which is used to specify if and
772+ to which IMQ device packets should get enqueued/dequeued.
f4f8379a 773+
d6ad3303 774+ For more information visit: http://www.linuximq.net/
f4f8379a 775+
d6ad3303 776+ To compile it as a module, choose M here. If unsure, say N.
2437dee6 777+
d6ad3303 778 config IP_NF_TARGET_TTL
779 tristate 'TTL target support'
2437dee6 780 depends on IP_NF_MANGLE
d6ad3303 781 depends on NETFILTER_ADVANCED
782 help
783 This option adds a `TTL' target, which enables the user to modify
784diff -U 6 -Nr linux-2.6.25/net/ipv4/netfilter/Makefile linux-2.6.25+imq/net/ipv4/netfilter/Makefile
785--- linux-2.6.25/net/ipv4/netfilter/Makefile 2008-04-17 05:49:44.000000000 +0300
786+++ linux-2.6.25+imq/net/ipv4/netfilter/Makefile 2008-04-18 14:54:49.692406744 +0300
0c420048 787@@ -0,0 +0,1 @@
2437dee6 788+obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
d6ad3303 789diff -U 6 -Nr linux-2.6.25/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.25+imq/net/ipv6/netfilter/ip6t_IMQ.c
790--- linux-2.6.25/net/ipv6/netfilter/ip6t_IMQ.c 1970-01-01 02:00:00.000000000 +0200
791+++ linux-2.6.25+imq/net/ipv6/netfilter/ip6t_IMQ.c 2008-04-18 14:54:49.694398090 +0300
2437dee6 792@@ -0,0 +1,69 @@
f4f8379a 793+/*
794+ * This target marks packets to be enqueued to an imq device
795+ */
796+#include <linux/module.h>
797+#include <linux/skbuff.h>
798+#include <linux/netfilter_ipv6/ip6_tables.h>
799+#include <linux/netfilter_ipv6/ip6t_IMQ.h>
800+#include <linux/imq.h>
801+
2437dee6 802+static unsigned int imq_target(struct sk_buff *pskb,
f4f8379a 803+ const struct net_device *in,
804+ const struct net_device *out,
805+ unsigned int hooknum,
806+ const struct xt_target *target,
807+ const void *targinfo)
808+{
809+ struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
810+
2437dee6 811+ pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
f4f8379a 812+
813+ return XT_CONTINUE;
814+}
815+
2437dee6 816+static bool imq_checkentry(const char *tablename,
f4f8379a 817+ const void *entry,
818+ const struct xt_target *target,
819+ void *targinfo,
820+ unsigned int hook_mask)
821+{
822+ struct ip6t_imq_info *mr;
823+
824+ mr = (struct ip6t_imq_info*)targinfo;
825+
826+ if (mr->todev > IMQ_MAX_DEVS) {
827+ printk(KERN_WARNING
828+ "IMQ: invalid device specified, highest is %u\n",
829+ IMQ_MAX_DEVS);
830+ return 0;
831+ }
832+
833+ return 1;
834+}
835+
836+static struct xt_target ip6t_imq_reg = {
837+ .name = "IMQ",
2437dee6 838+ .family = AF_INET6,
f4f8379a 839+ .target = imq_target,
840+ .targetsize = sizeof(struct ip6t_imq_info),
841+ .table = "mangle",
842+ .checkentry = imq_checkentry,
843+ .me = THIS_MODULE
844+};
845+
846+static int __init init(void)
847+{
848+ return xt_register_target(&ip6t_imq_reg);
849+}
850+
851+static void __exit fini(void)
852+{
853+ xt_unregister_target(&ip6t_imq_reg);
854+}
855+
856+module_init(init);
857+module_exit(fini);
858+
859+MODULE_AUTHOR("http://www.linuximq.net");
860+MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
861+MODULE_LICENSE("GPL");
d6ad3303 862diff -U 6 -Nr linux-2.6.25/net/ipv6/netfilter/Kconfig linux-2.6.25+imq/net/ipv6/netfilter/Kconfig
863--- linux-2.6.25/net/ipv6/netfilter/Kconfig 2008-04-17 05:49:44.000000000 +0300
864+++ linux-2.6.25+imq/net/ipv6/netfilter/Kconfig 2008-04-18 14:54:49.771062974 +0300
865@@ -176,12 +176,21 @@
866 This option adds a `mangle' table to iptables: see the man page for
867 iptables(8). This table is used for various packet alterations
868 which can effect how the packet is routed.
2437dee6 869
870 To compile it as a module, choose M here. If unsure, say N.
871
872+config IP6_NF_TARGET_IMQ
873+ tristate "IMQ target support"
874+ depends on IP6_NF_MANGLE
875+ help
876+ This option adds a `IMQ' target which is used to specify if and
877+ to which imq device packets should get enqueued/dequeued.
878+
879+ To compile it as a module, choose M here. If unsure, say N.
f4f8379a 880+
2437dee6 881 config IP6_NF_TARGET_HL
882 tristate 'HL (hoplimit) target support'
883 depends on IP6_NF_MANGLE
d6ad3303 884 depends on NETFILTER_ADVANCED
885 help
886 This option adds a `HL' target, which enables the user to decrement
887diff -U 6 -Nr linux-2.6.25/net/ipv6/netfilter/Makefile linux-2.6.25+imq/net/ipv6/netfilter/Makefile
888--- linux-2.6.25/net/ipv6/netfilter/Makefile 2008-04-17 05:49:44.000000000 +0300
889+++ linux-2.6.25+imq/net/ipv6/netfilter/Makefile 2008-04-18 14:54:49.771062974 +0300
890@@ -3,12 +3,13 @@
891 #
892
893 # Link order matters here.
894 obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
895 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
896 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
2437dee6 897+obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
d6ad3303 898 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
899 obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
900
901 # objects for l3 independent conntrack
902 nf_conntrack_ipv6-objs := nf_conntrack_l3proto_ipv6.o nf_conntrack_proto_icmpv6.o nf_conntrack_reasm.o
903
904diff -U 6 -Nr linux-2.6.25/net/sched/sch_generic.c linux-2.6.25+imq/net/sched/sch_generic.c
905--- linux-2.6.25/net/sched/sch_generic.c 2008-04-17 05:49:44.000000000 +0300
906+++ linux-2.6.25+imq/net/sched/sch_generic.c 2008-04-18 14:56:21.977691013 +0300
907@@ -179,12 +179,18 @@
908 break;
909 }
910
2437dee6 911 return ret;
f4f8379a 912 }
913
914+int qdisc_restart1(struct net_device *dev)
915+{
916+ return qdisc_restart(dev);
917+}
d6ad3303 918+EXPORT_SYMBOL(qdisc_restart1);
f4f8379a 919+
920 void __qdisc_run(struct net_device *dev)
921 {
d6ad3303 922 unsigned long start_time = jiffies;
923
924 while (qdisc_restart(dev)) {
925 if (netif_queue_stopped(dev))
This page took 0.260275 seconds and 4 git commands to generate.