add generic 2.6.23 patches and config
[openwrt/svn-archive/archive.git] / target / linux / generic-2.6 / patches-2.6.23 / 150-netfilter_imq.patch
1 Index: linux-2.6.23-rc6/drivers/net/imq.c
2 ===================================================================
3 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4 +++ linux-2.6.23-rc6/drivers/net/imq.c 2007-09-21 16:24:02.000000000 +0800
5 @@ -0,0 +1,402 @@
6 +/*
7 + * Pseudo-driver for the intermediate queue device.
8 + *
9 + * This program is free software; you can redistribute it and/or
10 + * modify it under the terms of the GNU General Public License
11 + * as published by the Free Software Foundation; either version
12 + * 2 of the License, or (at your option) any later version.
13 + *
14 + * Authors: Patrick McHardy, <kaber@trash.net>
15 + *
16 + * The first version was written by Martin Devera, <devik@cdi.cz>
17 + *
18 + * Credits: Jan Rafaj <imq2t@cedric.vabo.cz>
19 + * - Update patch to 2.4.21
20 + * Sebastian Strollo <sstrollo@nortelnetworks.com>
21 + * - Fix "Dead-loop on netdevice imq"-issue
22 + * Marcel Sebek <sebek64@post.cz>
23 + * - Update to 2.6.2-rc1
24 + *
25 + * After some time of inactivity there is a group taking care
26 + * of IMQ again: http://www.linuximq.net
27 + *
28 + *
29 + * 2004/06/30 - New version of IMQ patch to kernels <=2.6.7 including
30 + * the following changes:
31 + *
32 + * - Correction of ipv6 support "+"s issue (Hasso Tepper)
33 + * - Correction of imq_init_devs() issue that resulted in
34 + * kernel OOPS unloading IMQ as module (Norbert Buchmuller)
35 + * - Addition of functionality to choose number of IMQ devices
36 + * during kernel config (Andre Correa)
37 + * - Addition of functionality to choose how IMQ hooks on
38 + * PRE and POSTROUTING (after or before NAT) (Andre Correa)
39 + * - Cosmetic corrections (Norbert Buchmuller) (Andre Correa)
40 + *
41 + *
42 + * 2005/12/16 - IMQ versions between 2.6.7 and 2.6.13 were
43 + * released with almost no problems. 2.6.14-x was released
44 + * with some important changes: nfcache was removed; After
45 + * some weeks of trouble we figured out that some IMQ fields
46 + * in skb were missing in skbuff.c - skb_clone and copy_skb_header.
47 + * These functions are correctly patched by this new patch version.
48 + *
49 + * Thanks for all who helped to figure out all the problems with
50 + * 2.6.14.x: Patrick McHardy, Rune Kock, VeNoMouS, Max CtRiX,
51 + * Kevin Shanahan, Richard Lucassen, Valery Dachev (hopefully
52 + * I didn't forget anybody). I apologize again for my lack of time.
53 + *
54 + * More info at: http://www.linuximq.net/ (Andre Correa)
55 + */
56 +
57 +#include <linux/module.h>
58 +#include <linux/kernel.h>
59 +#include <linux/moduleparam.h>
60 +#include <linux/skbuff.h>
61 +#include <linux/netdevice.h>
62 +#include <linux/rtnetlink.h>
63 +#include <linux/if_arp.h>
64 +#include <linux/netfilter.h>
65 +#include <linux/netfilter_ipv4.h>
66 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
67 + #include <linux/netfilter_ipv6.h>
68 +#endif
69 +#include <linux/imq.h>
70 +#include <net/pkt_sched.h>
71 +
72 +extern int qdisc_restart1(struct net_device *dev);
73 +
74 +static nf_hookfn imq_nf_hook;
75 +
76 +static struct nf_hook_ops imq_ingress_ipv4 = {
77 + .hook = imq_nf_hook,
78 + .owner = THIS_MODULE,
79 + .pf = PF_INET,
80 + .hooknum = NF_IP_PRE_ROUTING,
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,
92 + .hooknum = NF_IP_POST_ROUTING,
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,
105 + .hooknum = NF_IP6_PRE_ROUTING,
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,
117 + .hooknum = NF_IP6_POST_ROUTING,
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
129 +static unsigned int numdevs = 2;
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 +{
142 + struct nf_info *info = skb->nf_info;
143 +
144 + if (info) {
145 + if (info->indev)
146 + dev_put(info->indev);
147 + if (info->outdev)
148 + dev_put(info->outdev);
149 + kfree(info);
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;
164 + nf_reinject(skb, skb->nf_info, NF_ACCEPT);
165 + return 0;
166 +}
167 +
168 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info, unsigned queue_num, void *data)
169 +{
170 + struct net_device *dev;
171 + struct net_device_stats *stats;
172 + struct sk_buff *skb2 = NULL;
173 + struct Qdisc *q;
174 + unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
175 + int ret = -1;
176 +
177 + if (index > numdevs)
178 + return -1;
179 +
180 + dev = imq_devs + index;
181 + if (!(dev->flags & IFF_UP)) {
182 + skb->imq_flags = 0;
183 + nf_reinject(skb, info, NF_ACCEPT);
184 + return 0;
185 + }
186 + dev->last_rx = jiffies;
187 +
188 + if (skb->destructor) {
189 + skb2 = skb;
190 + skb = skb_clone(skb, GFP_ATOMIC);
191 + if (!skb)
192 + return -1;
193 + }
194 + skb->nf_info = info;
195 +
196 + stats = (struct net_device_stats *)dev->priv;
197 + stats->rx_bytes+= skb->len;
198 + stats->rx_packets++;
199 +
200 + spin_lock_bh(&dev->queue_lock);
201 + q = dev->qdisc;
202 + if (q->enqueue) {
203 + q->enqueue(skb_get(skb), q);
204 + if (skb_shared(skb)) {
205 + skb->destructor = imq_skb_destructor;
206 + kfree_skb(skb);
207 + ret = 0;
208 + }
209 + }
210 + if (spin_is_locked(&dev->_xmit_lock))
211 + netif_schedule(dev);
212 + else
213 + while (!netif_queue_stopped(dev) && qdisc_restart1(dev) < 0)
214 + /* NOTHING */;
215 +
216 + spin_unlock_bh(&dev->queue_lock);
217 +
218 + if (skb2)
219 + kfree_skb(ret ? skb : skb2);
220 +
221 + return ret;
222 +}
223 +
224 +static struct nf_queue_handler nfqh = {
225 + .name = "imq",
226 + .outfn = imq_nf_queue,
227 +};
228 +
229 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
230 + const struct net_device *indev,
231 + const struct net_device *outdev,
232 + int (*okfn)(struct sk_buff *))
233 +{
234 + if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
235 + return NF_QUEUE;
236 +
237 + return NF_ACCEPT;
238 +}
239 +
240 +
241 +static int __init imq_init_hooks(void)
242 +{
243 + int err;
244 +
245 + err = nf_register_queue_handler(PF_INET, &nfqh);
246 + if (err > 0)
247 + goto err1;
248 + if ((err = nf_register_hook(&imq_ingress_ipv4)))
249 + goto err2;
250 + if ((err = nf_register_hook(&imq_egress_ipv4)))
251 + goto err3;
252 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
253 + if ((err = nf_register_queue_handler(PF_INET6, &nfqh)))
254 + goto err4;
255 + if ((err = nf_register_hook(&imq_ingress_ipv6)))
256 + goto err5;
257 + if ((err = nf_register_hook(&imq_egress_ipv6)))
258 + goto err6;
259 +#endif
260 +
261 + return 0;
262 +
263 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
264 +err6:
265 + nf_unregister_hook(&imq_ingress_ipv6);
266 +err5:
267 + nf_unregister_queue_handler(PF_INET6, &nfqh);
268 +err4:
269 + nf_unregister_hook(&imq_egress_ipv4);
270 +#endif
271 +err3:
272 + nf_unregister_hook(&imq_ingress_ipv4);
273 +err2:
274 + nf_unregister_queue_handler(PF_INET, &nfqh);
275 +err1:
276 + return err;
277 +}
278 +
279 +static void __exit imq_unhook(void)
280 +{
281 + nf_unregister_hook(&imq_ingress_ipv4);
282 + nf_unregister_hook(&imq_egress_ipv4);
283 + nf_unregister_queue_handler(PF_INET, &nfqh);
284 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
285 + nf_unregister_hook(&imq_ingress_ipv6);
286 + nf_unregister_hook(&imq_egress_ipv6);
287 + nf_unregister_queue_handler(PF_INET6, &nfqh);
288 +#endif
289 +}
290 +
291 +static int __init imq_dev_init(struct net_device *dev)
292 +{
293 + dev->hard_start_xmit = imq_dev_xmit;
294 + dev->type = ARPHRD_VOID;
295 + dev->mtu = 1500;
296 + dev->tx_queue_len = 30;
297 + dev->flags = IFF_NOARP;
298 + dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
299 + if (dev->priv == NULL)
300 + return -ENOMEM;
301 + memset(dev->priv, 0, sizeof(struct net_device_stats));
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 +
312 +static int __init imq_init_devs(void)
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 +
324 + imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
325 + if (!imq_devs)
326 + return -ENOMEM;
327 + memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
328 +
329 + /* we start counting at zero */
330 + numdevs--;
331 +
332 + for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
333 + SET_MODULE_OWNER(dev);
334 + strcpy(dev->name, "imq%d");
335 + dev->init = imq_dev_init;
336 + dev->uninit = imq_dev_uninit;
337 +
338 + if (register_netdev(dev) < 0)
339 + goto err_register;
340 + }
341 + printk(KERN_INFO "IMQ starting with %u devices...\n", j);
342 + return 0;
343 +
344 +err_register:
345 + for (; i; i--)
346 + unregister_netdev(--dev);
347 + kfree(imq_devs);
348 + return -EIO;
349 +}
350 +
351 +static void imq_cleanup_devs(void)
352 +{
353 + int i;
354 + struct net_device *dev = imq_devs;
355 +
356 + for (i = 0; i <= numdevs; i++)
357 + unregister_netdev(dev++);
358 +
359 + kfree(imq_devs);
360 +}
361 +
362 +static int __init imq_init_module(void)
363 +{
364 + int err;
365 +
366 + if ((err = imq_init_devs())) {
367 + printk(KERN_ERR "IMQ: Error trying imq_init_devs()\n");
368 + return err;
369 + }
370 + if ((err = imq_init_hooks())) {
371 + printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
372 + imq_cleanup_devs();
373 + return err;
374 + }
375 +
376 + printk(KERN_INFO "IMQ driver loaded successfully.\n");
377 +
378 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
379 + printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
380 +#else
381 + printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
382 +#endif
383 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
384 + printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
385 +#else
386 + printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
387 +#endif
388 +
389 + return 0;
390 +}
391 +
392 +static void __exit imq_cleanup_module(void)
393 +{
394 + imq_unhook();
395 + imq_cleanup_devs();
396 + printk(KERN_INFO "IMQ driver unloaded successfully.\n");
397 +}
398 +
399 +
400 +module_init(imq_init_module);
401 +module_exit(imq_cleanup_module);
402 +
403 +module_param(numdevs, int, 0);
404 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will be created)");
405 +MODULE_AUTHOR("http://www.linuximq.net");
406 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
407 +MODULE_LICENSE("GPL");
408 Index: linux-2.6.23-rc6/drivers/net/Kconfig
409 ===================================================================
410 --- linux-2.6.23-rc6.orig/drivers/net/Kconfig 2007-09-21 16:23:53.000000000 +0800
411 +++ linux-2.6.23-rc6/drivers/net/Kconfig 2007-09-21 16:24:02.000000000 +0800
412 @@ -112,6 +112,129 @@
413 To compile this driver as a module, choose M here: the module
414 will be called eql. If unsure, say N.
415
416 +config IMQ
417 + tristate "IMQ (intermediate queueing device) support"
418 + depends on NETDEVICES && NETFILTER
419 + ---help---
420 + The IMQ device(s) is used as placeholder for QoS queueing
421 + disciplines. Every packet entering/leaving the IP stack can be
422 + directed through the IMQ device where it's enqueued/dequeued to the
423 + attached qdisc. This allows you to treat network devices as classes
424 + and distribute bandwidth among them. Iptables is used to specify
425 + through which IMQ device, if any, packets travel.
426 +
427 + More information at: http://www.linuximq.net/
428 +
429 + To compile this driver as a module, choose M here: the module
430 + will be called imq. If unsure, say N.
431 +
432 +choice
433 + prompt "IMQ behavior (PRE/POSTROUTING)"
434 + depends on IMQ
435 + default IMQ_BEHAVIOR_BA
436 + help
437 +
438 + This settings defines how IMQ behaves in respect to its
439 + hooking in PREROUTING and POSTROUTING.
440 +
441 + IMQ can work in any of the following ways:
442 +
443 + PREROUTING | POSTROUTING
444 + -----------------|-------------------
445 + #1 After NAT | After NAT
446 + #2 After NAT | Before NAT
447 + #3 Before NAT | After NAT
448 + #4 Before NAT | Before NAT
449 +
450 + The default behavior is to hook before NAT on PREROUTING
451 + and after NAT on POSTROUTING (#3).
452 +
453 + This settings are specially usefull when trying to use IMQ
454 + to shape NATed clients.
455 +
456 + More information can be found at: www.linuximq.net
457 +
458 + If not sure leave the default settings alone.
459 +
460 +config IMQ_BEHAVIOR_AA
461 + bool "IMQ AA"
462 + help
463 + This settings defines how IMQ behaves in respect to its
464 + hooking in PREROUTING and POSTROUTING.
465 +
466 + Choosing this option will make IMQ hook like this:
467 +
468 + PREROUTING: After NAT
469 + POSTROUTING: After NAT
470 +
471 + More information can be found at: www.linuximq.net
472 +
473 + If not sure leave the default settings alone.
474 +
475 +config IMQ_BEHAVIOR_AB
476 + bool "IMQ AB"
477 + help
478 + This settings defines how IMQ behaves in respect to its
479 + hooking in PREROUTING and POSTROUTING.
480 +
481 + Choosing this option will make IMQ hook like this:
482 +
483 + PREROUTING: After NAT
484 + POSTROUTING: Before NAT
485 +
486 + More information can be found at: www.linuximq.net
487 +
488 + If not sure leave the default settings alone.
489 +
490 +config IMQ_BEHAVIOR_BA
491 + bool "IMQ BA"
492 + help
493 + This settings defines how IMQ behaves in respect to its
494 + hooking in PREROUTING and POSTROUTING.
495 +
496 + Choosing this option will make IMQ hook like this:
497 +
498 + PREROUTING: Before NAT
499 + POSTROUTING: After NAT
500 +
501 + More information can be found at: www.linuximq.net
502 +
503 + If not sure leave the default settings alone.
504 +
505 +config IMQ_BEHAVIOR_BB
506 + bool "IMQ BB"
507 + help
508 + This settings defines how IMQ behaves in respect to its
509 + hooking in PREROUTING and POSTROUTING.
510 +
511 + Choosing this option will make IMQ hook like this:
512 +
513 + PREROUTING: Before NAT
514 + POSTROUTING: Before NAT
515 +
516 + More information can be found at: www.linuximq.net
517 +
518 + If not sure leave the default settings alone.
519 +
520 +endchoice
521 +
522 +config IMQ_NUM_DEVS
523 +
524 + int "Number of IMQ devices"
525 + range 2 8
526 + depends on IMQ
527 + default "2"
528 + help
529 +
530 + This settings defines how many IMQ devices will be
531 + created.
532 +
533 + The default value is 2.
534 +
535 + More information can be found at: www.linuximq.net
536 +
537 + If not sure leave the default settings alone.
538 +
539 config TUN
540 tristate "Universal TUN/TAP device driver support"
541 select CRC32
542 Index: linux-2.6.23-rc6/drivers/net/Makefile
543 ===================================================================
544 --- linux-2.6.23-rc6.orig/drivers/net/Makefile 2007-09-21 16:23:53.000000000 +0800
545 +++ linux-2.6.23-rc6/drivers/net/Makefile 2007-09-21 16:24:02.000000000 +0800
546 @@ -130,6 +130,7 @@
547 obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
548
549 obj-$(CONFIG_DUMMY) += dummy.o
550 +obj-$(CONFIG_IMQ) += imq.o
551 obj-$(CONFIG_IFB) += ifb.o
552 obj-$(CONFIG_MACVLAN) += macvlan.o
553 obj-$(CONFIG_DE600) += de600.o
554 Index: linux-2.6.23-rc6/include/linux/imq.h
555 ===================================================================
556 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
557 +++ linux-2.6.23-rc6/include/linux/imq.h 2007-09-21 16:24:02.000000000 +0800
558 @@ -0,0 +1,9 @@
559 +#ifndef _IMQ_H
560 +#define _IMQ_H
561 +
562 +#define IMQ_MAX_DEVS 16
563 +
564 +#define IMQ_F_IFMASK 0x7f
565 +#define IMQ_F_ENQUEUE 0x80
566 +
567 +#endif /* _IMQ_H */
568 Index: linux-2.6.23-rc6/include/linux/netfilter_ipv4/ipt_IMQ.h
569 ===================================================================
570 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
571 +++ linux-2.6.23-rc6/include/linux/netfilter_ipv4/ipt_IMQ.h 2007-09-21 16:24:02.000000000 +0800
572 @@ -0,0 +1,8 @@
573 +#ifndef _IPT_IMQ_H
574 +#define _IPT_IMQ_H
575 +
576 +struct ipt_imq_info {
577 + unsigned int todev; /* target imq device */
578 +};
579 +
580 +#endif /* _IPT_IMQ_H */
581 Index: linux-2.6.23-rc6/include/linux/netfilter_ipv6/ip6t_IMQ.h
582 ===================================================================
583 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
584 +++ linux-2.6.23-rc6/include/linux/netfilter_ipv6/ip6t_IMQ.h 2007-09-21 16:24:02.000000000 +0800
585 @@ -0,0 +1,8 @@
586 +#ifndef _IP6T_IMQ_H
587 +#define _IP6T_IMQ_H
588 +
589 +struct ip6t_imq_info {
590 + unsigned int todev; /* target imq device */
591 +};
592 +
593 +#endif /* _IP6T_IMQ_H */
594 Index: linux-2.6.23-rc6/include/linux/skbuff.h
595 ===================================================================
596 --- linux-2.6.23-rc6.orig/include/linux/skbuff.h 2007-09-21 16:23:53.000000000 +0800
597 +++ linux-2.6.23-rc6/include/linux/skbuff.h 2007-09-21 16:24:02.000000000 +0800
598 @@ -296,6 +296,10 @@
599 struct nf_conntrack *nfct;
600 struct sk_buff *nfct_reasm;
601 #endif
602 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
603 + unsigned char imq_flags;
604 + struct nf_info *nf_info;
605 +#endif
606 #ifdef CONFIG_BRIDGE_NETFILTER
607 struct nf_bridge_info *nf_bridge;
608 #endif
609 Index: linux-2.6.23-rc6/net/core/dev.c
610 ===================================================================
611 --- linux-2.6.23-rc6.orig/net/core/dev.c 2007-09-21 16:23:53.000000000 +0800
612 +++ linux-2.6.23-rc6/net/core/dev.c 2007-09-21 16:24:02.000000000 +0800
613 @@ -94,6 +94,9 @@
614 #include <linux/skbuff.h>
615 #include <net/sock.h>
616 #include <linux/rtnetlink.h>
617 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
618 +#include <linux/imq.h>
619 +#endif
620 #include <linux/proc_fs.h>
621 #include <linux/seq_file.h>
622 #include <linux/stat.h>
623 @@ -1463,6 +1466,9 @@
624 {
625 if (likely(!skb->next)) {
626 if (!list_empty(&ptype_all))
627 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
628 + if (!(skb->imq_flags & IMQ_F_ENQUEUE))
629 +#endif
630 dev_queue_xmit_nit(skb, dev);
631
632 if (netif_needs_gso(dev, skb)) {
633 Index: linux-2.6.23-rc6/net/core/skbuff.c
634 ===================================================================
635 --- linux-2.6.23-rc6.orig/net/core/skbuff.c 2007-09-21 16:23:53.000000000 +0800
636 +++ linux-2.6.23-rc6/net/core/skbuff.c 2007-09-21 16:24:02.000000000 +0800
637 @@ -421,6 +421,10 @@
638 C(ip_summed);
639 skb_copy_queue_mapping(n, skb);
640 C(priority);
641 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
642 + C(imq_flags);
643 + C(nf_info);
644 +#endif /*CONFIG_IMQ*/
645 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
646 C(ipvs_property);
647 #endif
648 @@ -496,6 +500,10 @@
649 #if defined(CONFIG_IP_VS) || defined(CONFIG_IP_VS_MODULE)
650 new->ipvs_property = old->ipvs_property;
651 #endif
652 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
653 + new->imq_flags = old->imq_flags;
654 + new->nf_info = old->nf_info;
655 +#endif /*CONFIG_IMQ*/
656 #ifdef CONFIG_NET_SCHED
657 #ifdef CONFIG_NET_CLS_ACT
658 new->tc_verd = old->tc_verd;
659 Index: linux-2.6.23-rc6/net/ipv4/netfilter/ipt_IMQ.c
660 ===================================================================
661 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
662 +++ linux-2.6.23-rc6/net/ipv4/netfilter/ipt_IMQ.c 2007-09-21 16:24:02.000000000 +0800
663 @@ -0,0 +1,69 @@
664 +/*
665 + * This target marks packets to be enqueued to an imq device
666 + */
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>
672 +
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 struct xt_target *target,
678 + const void *targinfo)
679 +{
680 + struct ipt_imq_info *mr = (struct ipt_imq_info*)targinfo;
681 +
682 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
683 +
684 + return XT_CONTINUE;
685 +}
686 +
687 +static bool imq_checkentry(const char *tablename,
688 + const void *e,
689 + const struct xt_target *target,
690 + void *targinfo,
691 + unsigned int hook_mask)
692 +{
693 + struct ipt_imq_info *mr;
694 +
695 + mr = (struct ipt_imq_info*)targinfo;
696 +
697 + if (mr->todev > IMQ_MAX_DEVS) {
698 + printk(KERN_WARNING
699 + "IMQ: invalid device specified, highest is %u\n",
700 + IMQ_MAX_DEVS);
701 + return 0;
702 + }
703 +
704 + return 1;
705 +}
706 +
707 +static struct xt_target ipt_imq_reg = {
708 + .name = "IMQ",
709 + .family = AF_INET,
710 + .target = imq_target,
711 + .targetsize = sizeof(struct ipt_imq_info),
712 + .checkentry = imq_checkentry,
713 + .me = THIS_MODULE,
714 + .table = "mangle"
715 +};
716 +
717 +static int __init init(void)
718 +{
719 + return xt_register_target(&ipt_imq_reg);
720 +}
721 +
722 +static void __exit fini(void)
723 +{
724 + xt_unregister_target(&ipt_imq_reg);
725 +}
726 +
727 +module_init(init);
728 +module_exit(fini);
729 +
730 +MODULE_AUTHOR("http://www.linuximq.net");
731 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
732 +MODULE_LICENSE("GPL");
733 Index: linux-2.6.23-rc6/net/ipv4/netfilter/Kconfig
734 ===================================================================
735 --- linux-2.6.23-rc6.orig/net/ipv4/netfilter/Kconfig 2007-09-21 16:24:02.000000000 +0800
736 +++ linux-2.6.23-rc6/net/ipv4/netfilter/Kconfig 2007-09-21 16:24:02.000000000 +0800
737 @@ -351,6 +351,17 @@
738
739 To compile it as a module, choose M here. If unsure, say N.
740
741 +config IP_NF_TARGET_IMQ
742 + tristate "IMQ target support"
743 + depends on IP_NF_MANGLE
744 + help
745 + This option adds a `IMQ' target which is used to specify if and
746 + to which IMQ device packets should get enqueued/dequeued.
747 +
748 + For more information visit: http://www.linuximq.net/
749 +
750 + To compile it as a module, choose M here. If unsure, say N.
751 +
752 config IP_NF_TARGET_TOS
753 tristate "TOS target support"
754 depends on IP_NF_MANGLE
755 Index: linux-2.6.23-rc6/net/ipv4/netfilter/Makefile
756 ===================================================================
757 --- linux-2.6.23-rc6.orig/net/ipv4/netfilter/Makefile 2007-09-21 16:24:02.000000000 +0800
758 +++ linux-2.6.23-rc6/net/ipv4/netfilter/Makefile 2007-09-21 16:24:02.000000000 +0800
759 @@ -58,6 +58,7 @@
760 obj-$(CONFIG_IP_NF_TARGET_REJECT) += ipt_REJECT.o
761 obj-$(CONFIG_IP_NF_TARGET_TOS) += ipt_TOS.o
762 obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
763 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
764 obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
765 obj-$(CONFIG_IP_NF_TARGET_REDIRECT) += ipt_REDIRECT.o
766 obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
767 Index: linux-2.6.23-rc6/net/ipv6/netfilter/ip6t_IMQ.c
768 ===================================================================
769 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
770 +++ linux-2.6.23-rc6/net/ipv6/netfilter/ip6t_IMQ.c 2007-09-21 16:24:02.000000000 +0800
771 @@ -0,0 +1,69 @@
772 +/*
773 + * This target marks packets to be enqueued to an imq device
774 + */
775 +#include <linux/module.h>
776 +#include <linux/skbuff.h>
777 +#include <linux/netfilter_ipv6/ip6_tables.h>
778 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
779 +#include <linux/imq.h>
780 +
781 +static unsigned int imq_target(struct sk_buff **pskb,
782 + const struct net_device *in,
783 + const struct net_device *out,
784 + unsigned int hooknum,
785 + const struct xt_target *target,
786 + const void *targinfo)
787 +{
788 + struct ip6t_imq_info *mr = (struct ip6t_imq_info*)targinfo;
789 +
790 + (*pskb)->imq_flags = mr->todev | IMQ_F_ENQUEUE;
791 +
792 + return XT_CONTINUE;
793 +}
794 +
795 +static int imq_checkentry(const char *tablename,
796 + const void *entry,
797 + const struct xt_target *target,
798 + void *targinfo,
799 + unsigned int hook_mask)
800 +{
801 + struct ip6t_imq_info *mr;
802 +
803 + mr = (struct ip6t_imq_info*)targinfo;
804 +
805 + if (mr->todev > IMQ_MAX_DEVS) {
806 + printk(KERN_WARNING
807 + "IMQ: invalid device specified, highest is %u\n",
808 + IMQ_MAX_DEVS);
809 + return 0;
810 + }
811 +
812 + return 1;
813 +}
814 +
815 +static struct xt_target ip6t_imq_reg = {
816 + .name = "IMQ",
817 + .family = AF_INET6,
818 + .target = imq_target,
819 + .targetsize = sizeof(struct ip6t_imq_info),
820 + .table = "mangle",
821 + .checkentry = imq_checkentry,
822 + .me = THIS_MODULE
823 +};
824 +
825 +static int __init init(void)
826 +{
827 + return xt_register_target(&ip6t_imq_reg);
828 +}
829 +
830 +static void __exit fini(void)
831 +{
832 + xt_unregister_target(&ip6t_imq_reg);
833 +}
834 +
835 +module_init(init);
836 +module_exit(fini);
837 +
838 +MODULE_AUTHOR("http://www.linuximq.net");
839 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
840 +MODULE_LICENSE("GPL");
841 Index: linux-2.6.23-rc6/net/ipv6/netfilter/Kconfig
842 ===================================================================
843 --- linux-2.6.23-rc6.orig/net/ipv6/netfilter/Kconfig 2007-09-21 16:23:53.000000000 +0800
844 +++ linux-2.6.23-rc6/net/ipv6/netfilter/Kconfig 2007-09-21 16:24:02.000000000 +0800
845 @@ -173,6 +173,15 @@
846
847 To compile it as a module, choose M here. If unsure, say N.
848
849 +config IP6_NF_TARGET_IMQ
850 + tristate "IMQ target support"
851 + depends on IP6_NF_MANGLE
852 + help
853 + This option adds a `IMQ' target which is used to specify if and
854 + to which imq device packets should get enqueued/dequeued.
855 +
856 + To compile it as a module, choose M here. If unsure, say N.
857 +
858 config IP6_NF_TARGET_HL
859 tristate 'HL (hoplimit) target support'
860 depends on IP6_NF_MANGLE
861 Index: linux-2.6.23-rc6/net/ipv6/netfilter/Makefile
862 ===================================================================
863 --- linux-2.6.23-rc6.orig/net/ipv6/netfilter/Makefile 2007-09-21 16:23:53.000000000 +0800
864 +++ linux-2.6.23-rc6/net/ipv6/netfilter/Makefile 2007-09-21 16:24:02.000000000 +0800
865 @@ -13,6 +13,7 @@
866 obj-$(CONFIG_IP6_NF_MATCH_OWNER) += ip6t_owner.o
867 obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
868 obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
869 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
870 obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o
871 obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
872 obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o
873 Index: linux-2.6.23-rc6/net/sched/sch_generic.c
874 ===================================================================
875 --- linux-2.6.23-rc6.orig/net/sched/sch_generic.c 2007-09-21 16:23:53.000000000 +0800
876 +++ linux-2.6.23-rc6/net/sched/sch_generic.c 2007-09-21 16:24:02.000000000 +0800
877 @@ -190,6 +190,11 @@
878 return ret;
879 }
880
881 +int qdisc_restart1(struct net_device *dev)
882 +{
883 + return qdisc_restart(dev);
884 +}
885 +
886 void __qdisc_run(struct net_device *dev)
887 {
888 do {
889 @@ -619,3 +624,4 @@
890 EXPORT_SYMBOL(qdisc_reset);
891 EXPORT_SYMBOL(qdisc_lock_tree);
892 EXPORT_SYMBOL(qdisc_unlock_tree);
893 +EXPORT_SYMBOL(qdisc_restart1);