]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-imq.patch
- updated for 2.6.27.26
[packages/kernel.git] / kernel-imq.patch
1 diff -urN linux-2.6.27.org/drivers/net/imq.c linux-2.6.27/drivers/net/imq.c
2 --- linux-2.6.27.org/drivers/net/imq.c  1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.27/drivers/net/imq.c      2009-01-11 17:16:26.608878570 +0100
4 @@ -0,0 +1,500 @@
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
29 + *             including 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 + *
54 + *             2008/06/17 - 2.6.25 - Changed imq.c to use qdisc_run() instead 
55 + *            of qdisc_restart() and moved qdisc_run() to tasklet to avoid
56 + *             recursive locking. New initialization routines to fix 'rmmod' not
57 + *             working anymore. Used code from ifb.c. (Jussi Kivilinna)
58 + *            
59 + *            Also, many thanks to pablo Sebastian Greco for making the initial
60 + *            patch and to those who helped the testing.
61 + *
62 + *             More info at: http://www.linuximq.net/ (Andre Correa)
63 + */
64 +
65 +#include <linux/module.h>
66 +#include <linux/kernel.h>
67 +#include <linux/moduleparam.h>
68 +#include <linux/skbuff.h>
69 +#include <linux/netdevice.h>
70 +#include <linux/rtnetlink.h>
71 +#include <linux/if_arp.h>
72 +#include <linux/netfilter.h>
73 +#include <linux/netfilter_ipv4.h>
74 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
75 +       #include <linux/netfilter_ipv6.h>
76 +#endif
77 +#include <linux/imq.h>
78 +#include <net/pkt_sched.h>
79 +#include <net/netfilter/nf_queue.h>
80 +
81 +struct imq_private {
82 +       struct tasklet_struct tasklet;
83 +       long tasklet_pending[1];
84 +};
85 +
86 +static nf_hookfn imq_nf_hook;
87 +
88 +static struct nf_hook_ops imq_ingress_ipv4 = {
89 +       .hook           = imq_nf_hook,
90 +       .owner          = THIS_MODULE,
91 +       .pf             = PF_INET,
92 +       .hooknum        = NF_INET_PRE_ROUTING,
93 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
94 +       .priority       = NF_IP_PRI_MANGLE + 1
95 +#else
96 +       .priority       = NF_IP_PRI_NAT_DST + 1
97 +#endif
98 +};
99 +
100 +static struct nf_hook_ops imq_egress_ipv4 = {
101 +       .hook           = imq_nf_hook,
102 +       .owner          = THIS_MODULE,
103 +       .pf             = PF_INET,
104 +       .hooknum        = NF_INET_POST_ROUTING,
105 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
106 +       .priority       = NF_IP_PRI_LAST
107 +#else
108 +       .priority       = NF_IP_PRI_NAT_SRC - 1
109 +#endif
110 +};
111 +
112 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
113 +static struct nf_hook_ops imq_ingress_ipv6 = {
114 +       .hook           = imq_nf_hook,
115 +       .owner          = THIS_MODULE,
116 +       .pf             = PF_INET6,
117 +       .hooknum        = NF_INET_PRE_ROUTING,
118 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
119 +       .priority       = NF_IP6_PRI_MANGLE + 1
120 +#else
121 +       .priority       = NF_IP6_PRI_NAT_DST + 1
122 +#endif
123 +};
124 +
125 +static struct nf_hook_ops imq_egress_ipv6 = {
126 +       .hook           = imq_nf_hook,
127 +       .owner          = THIS_MODULE,
128 +       .pf             = PF_INET6,
129 +       .hooknum        = NF_INET_POST_ROUTING,
130 +#if defined(CONFIG_IMQ_BEHAVIOR_AA) || defined(CONFIG_IMQ_BEHAVIOR_BA)
131 +       .priority       = NF_IP6_PRI_LAST
132 +#else
133 +       .priority       = NF_IP6_PRI_NAT_SRC - 1
134 +#endif
135 +};
136 +#endif
137 +
138 +#if defined(CONFIG_IMQ_NUM_DEVS)
139 +static unsigned int numdevs = CONFIG_IMQ_NUM_DEVS;
140 +#else
141 +static unsigned int numdevs = IMQ_MAX_DEVS;
142 +#endif
143 +
144 +static struct net_device *imq_devs_cache[IMQ_MAX_DEVS];
145 +static struct lock_class_key imq_netdev_xmit_lock_key[IMQ_MAX_DEVS];
146 +static struct lock_class_key imq_netdev_addr_lock_key[IMQ_MAX_DEVS];
147 +
148 +static void imq_set_lockdep_class_one(struct net_device *dev,
149 +                                     struct netdev_queue *txq,
150 +                                     void *data)
151 +{
152 +       int *index=(int*)data;
153 +       lockdep_set_class(&txq->_xmit_lock, &imq_netdev_xmit_lock_key[*index]);
154 +}
155 +
156 +static void imq_set_lockdep_class(struct net_device *dev, int index)
157 +{
158 +       lockdep_set_class(&dev->addr_list_lock, &imq_netdev_addr_lock_key[index]);
159 +       netdev_for_each_tx_queue(dev, imq_set_lockdep_class_one, &index);
160 +}
161 +
162 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
163 +{
164 +       return &dev->stats;
165 +}
166 +
167 +/* called for packets kfree'd in qdiscs at places other than enqueue */
168 +static void imq_skb_destructor(struct sk_buff *skb)
169 +{
170 +       struct nf_queue_entry *entry = skb->nf_queue_entry;
171 +
172 +       if (entry) {
173 +               if (entry->indev)
174 +                       dev_put(entry->indev);
175 +               if (entry->outdev)
176 +                       dev_put(entry->outdev);
177 +               kfree(entry);
178 +       }
179 +}
180 +
181 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
182 +{
183 +       dev->stats.tx_bytes += skb->len;
184 +       dev->stats.tx_packets++;
185 +
186 +       skb->imq_flags = 0;
187 +       skb->destructor = NULL;
188 +
189 +       dev->trans_start = jiffies;
190 +       nf_reinject(skb->nf_queue_entry, NF_ACCEPT);
191 +       return 0;
192 +}
193 +
194 +static int imq_nf_queue(struct nf_queue_entry *entry, unsigned queue_num)
195 +{
196 +       struct net_device *dev;
197 +       struct imq_private *priv;
198 +       struct sk_buff *skb2 = NULL;
199 +       struct netdev_queue *txq;
200 +       struct Qdisc *q;
201 +       spinlock_t *root_lock;
202 +
203 +       unsigned int index = entry->skb->imq_flags & IMQ_F_IFMASK;
204 +       int ret = -1;
205 +
206 +       if (index > numdevs)
207 +               return -1;
208 +
209 +       /* check for imq device by index from cache */
210 +       dev = imq_devs_cache[index];
211 +       if (!dev) {
212 +               char buf[8];
213 +
214 +               /* get device by name and cache result */
215 +               snprintf(buf, sizeof(buf), "imq%d", index);
216 +               dev = dev_get_by_name(&init_net, buf);
217 +               if (!dev) {
218 +                       /* not found ?!*/
219 +                       BUG();
220 +                       return -1;
221 +               }
222 +
223 +               imq_devs_cache[index] = dev;
224 +       }
225 +
226 +       priv = netdev_priv(dev);
227 +       if (!(dev->flags & IFF_UP)) {
228 +               entry->skb->imq_flags = 0;
229 +               nf_reinject(entry, NF_ACCEPT);
230 +               return 0;
231 +       }
232 +       dev->last_rx = jiffies;
233 +
234 +       if (entry->skb->destructor) {
235 +               skb2 = entry->skb;
236 +               entry->skb = skb_clone(entry->skb, GFP_ATOMIC);
237 +               if (!entry->skb)
238 +                       return -1;
239 +       }
240 +       entry->skb->nf_queue_entry = entry;
241 +
242 +       dev->stats.rx_bytes += entry->skb->len;
243 +       dev->stats.rx_packets++;
244 +
245 +       txq = netdev_get_tx_queue(dev, queue_num);
246 +       q = txq->qdisc;
247 +       root_lock = qdisc_lock(q);
248 +       spin_lock_bh(root_lock);
249 +       if (q->enqueue) {
250 +               q->enqueue(skb_get(entry->skb), q);
251 +               if (skb_shared(entry->skb)) {
252 +                       entry->skb->destructor = imq_skb_destructor;
253 +                       kfree_skb(entry->skb);
254 +                       ret = 0;
255 +               }
256 +       }
257 +       if (!test_and_set_bit(1, &priv->tasklet_pending[queue_num]))
258 +               tasklet_schedule(&priv->tasklet);
259 +       spin_unlock_bh(root_lock);
260 +
261 +       if (skb2)
262 +               kfree_skb(ret ? entry->skb : skb2);
263 +
264 +       return ret;
265 +}
266 +
267 +static struct nf_queue_handler nfqh = {
268 +       .name  = "imq",
269 +       .outfn = imq_nf_queue,
270 +};
271 +
272 +static void qdisc_run_tasklet(unsigned long arg)
273 +{
274 +       struct net_device *dev = (struct net_device *)arg;
275 +       struct imq_private *priv = netdev_priv(dev);
276 +       struct netdev_queue *txq = netdev_get_tx_queue(dev, 0);
277 +       struct Qdisc *q = txq->qdisc;
278 +       spinlock_t *root_lock = qdisc_lock(q);
279 +
280 +       spin_lock(root_lock);
281 +       qdisc_run(q);
282 +       clear_bit(1, &priv->tasklet_pending[0]);
283 +       spin_unlock(root_lock);
284 +}
285 +
286 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff *pskb,
287 +                               const struct net_device *indev,
288 +                               const struct net_device *outdev,
289 +                               int (*okfn)(struct sk_buff *))
290 +{
291 +       if (pskb->imq_flags & IMQ_F_ENQUEUE)
292 +               return NF_QUEUE;
293 +
294 +       return NF_ACCEPT;
295 +}
296 +
297 +static int imq_close(struct net_device *dev)
298 +{
299 +       struct imq_private *priv = netdev_priv(dev);
300 +
301 +       tasklet_kill(&priv->tasklet);
302 +       netif_stop_queue(dev);
303 +
304 +       return 0;
305 +}
306 +
307 +static int imq_open(struct net_device *dev)
308 +{
309 +       struct imq_private *priv = netdev_priv(dev);
310 +
311 +       tasklet_init(&priv->tasklet, qdisc_run_tasklet, (unsigned long)dev);
312 +       netif_start_queue(dev);
313 +
314 +       return 0;
315 +}
316 +
317 +static void imq_setup(struct net_device *dev)
318 +{
319 +       dev->hard_start_xmit    = imq_dev_xmit;
320 +       dev->open               = imq_open;
321 +       dev->get_stats          = imq_get_stats;
322 +       dev->stop               = imq_close;
323 +       dev->type               = ARPHRD_VOID;
324 +       dev->mtu                = 16000;
325 +       dev->tx_queue_len       = 11000;
326 +       dev->flags              = IFF_NOARP;
327 +}
328 +
329 +static struct rtnl_link_ops imq_link_ops __read_mostly = {
330 +       .kind           = "imq",
331 +       .priv_size      = sizeof(struct imq_private),
332 +       .setup          = imq_setup,
333 +};
334 +
335 +static int __init imq_init_hooks(void)
336 +{
337 +       int err;
338 +
339 +       err = nf_register_queue_handler(PF_INET, &nfqh);
340 +       if (err)
341 +               goto err1;
342 +
343 +       err = nf_register_hook(&imq_ingress_ipv4);
344 +       if (err)
345 +               goto err2;
346 +
347 +       err = nf_register_hook(&imq_egress_ipv4);
348 +       if (err)
349 +               goto err3;
350 +
351 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
352 +       err = nf_register_queue_handler(PF_INET6, &nfqh);
353 +       if (err)
354 +               goto err4;
355 +
356 +       err = nf_register_hook(&imq_ingress_ipv6);
357 +       if (err)
358 +               goto err5;
359 +
360 +       err = nf_register_hook(&imq_egress_ipv6);
361 +       if (err)
362 +               goto err6;
363 +#endif
364 +
365 +       return 0;
366 +
367 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
368 +err6:
369 +       nf_unregister_hook(&imq_ingress_ipv6);
370 +err5:
371 +       nf_unregister_queue_handler(PF_INET6, &nfqh);
372 +err4:
373 +       nf_unregister_hook(&imq_egress_ipv4);
374 +#endif
375 +err3:
376 +       nf_unregister_hook(&imq_ingress_ipv4);
377 +err2:
378 +       nf_unregister_queue_handler(PF_INET, &nfqh);
379 +err1:
380 +       return err;
381 +}
382 +
383 +static int __init imq_init_one(int index)
384 +{
385 +       struct net_device *dev;
386 +       int ret;
387 +
388 +       dev = alloc_netdev(sizeof(struct imq_private), "imq%d", imq_setup);
389 +       if (!dev)
390 +               return -ENOMEM;
391 +
392 +       ret = dev_alloc_name(dev, dev->name);
393 +       dev->num_tx_queues=1;
394 +       imq_set_lockdep_class(dev, index);      
395 +       if (ret < 0)
396 +               goto fail;
397 +
398 +       dev->rtnl_link_ops = &imq_link_ops;
399 +       ret = register_netdevice(dev);
400 +       if (ret < 0)
401 +               goto fail;
402 +
403 +       return 0;
404 +fail:
405 +       free_netdev(dev);
406 +       return ret;
407 +}
408 +
409 +static int __init imq_init_devs(void)
410 +{
411 +       int err, i;
412 +
413 +       if (!numdevs || numdevs > IMQ_MAX_DEVS) {
414 +               printk(KERN_ERR "IMQ: numdevs has to be betweed 1 and %u\n",
415 +                      IMQ_MAX_DEVS);
416 +               return -EINVAL;
417 +       }
418 +
419 +       rtnl_lock();
420 +       err = __rtnl_link_register(&imq_link_ops);
421 +
422 +       for (i = 0; i < numdevs && !err; i++)
423 +               err = imq_init_one(i);
424 +
425 +       if (err) {
426 +               __rtnl_link_unregister(&imq_link_ops);
427 +               memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
428 +       }
429 +       rtnl_unlock();
430 +
431 +       return err;
432 +}
433 +
434 +static int __init imq_init_module(void)
435 +{
436 +       int err;
437 +
438 +       err = imq_init_devs();
439 +       if (err) {
440 +               printk(KERN_ERR "IMQ: Error trying imq_init_devs(net)\n");
441 +               return err;
442 +       }
443 +
444 +       err = imq_init_hooks();
445 +       if (err) {
446 +               printk(KERN_ERR "IMQ: Error trying imq_init_hooks()\n");
447 +               rtnl_link_unregister(&imq_link_ops);
448 +               memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
449 +               return err;
450 +       }
451 +
452 +       printk(KERN_INFO "IMQ driver loaded successfully.\n");
453 +
454 +#if defined(CONFIG_IMQ_BEHAVIOR_BA) || defined(CONFIG_IMQ_BEHAVIOR_BB)
455 +       printk(KERN_INFO "\tHooking IMQ before NAT on PREROUTING.\n");
456 +#else
457 +       printk(KERN_INFO "\tHooking IMQ after NAT on PREROUTING.\n");
458 +#endif
459 +#if defined(CONFIG_IMQ_BEHAVIOR_AB) || defined(CONFIG_IMQ_BEHAVIOR_BB)
460 +       printk(KERN_INFO "\tHooking IMQ before NAT on POSTROUTING.\n");
461 +#else
462 +       printk(KERN_INFO "\tHooking IMQ after NAT on POSTROUTING.\n");
463 +#endif
464 +
465 +       return 0;
466 +}
467 +
468 +static void __exit imq_unhook(void)
469 +{
470 +#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
471 +       nf_unregister_hook(&imq_ingress_ipv6);
472 +       nf_unregister_hook(&imq_egress_ipv6);
473 +       nf_unregister_queue_handler(PF_INET6, &nfqh);
474 +#endif
475 +       nf_unregister_hook(&imq_ingress_ipv4);
476 +       nf_unregister_hook(&imq_egress_ipv4);
477 +       nf_unregister_queue_handler(PF_INET, &nfqh);
478 +}
479 +
480 +static void __exit imq_cleanup_devs(void)
481 +{
482 +       rtnl_link_unregister(&imq_link_ops);
483 +       memset(imq_devs_cache, 0, sizeof(imq_devs_cache));
484 +}
485 +
486 +static void __exit imq_exit_module(void)
487 +{
488 +       imq_unhook();
489 +       imq_cleanup_devs();
490 +       printk(KERN_INFO "IMQ driver unloaded successfully.\n");
491 +}
492 +
493 +module_init(imq_init_module);
494 +module_exit(imq_exit_module);
495 +
496 +module_param(numdevs, int, 0);
497 +MODULE_PARM_DESC(numdevs, "number of IMQ devices (how many imq* devices will "
498 +                       "be created)");
499 +MODULE_AUTHOR("http://www.linuximq.net");
500 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See "
501 +                       "http://www.linuximq.net/ for more information.");
502 +MODULE_LICENSE("GPL");
503 +MODULE_ALIAS_RTNL_LINK("imq");
504 +
505 diff -urN linux-2.6.27.org/drivers/net/Kconfig linux-2.6.27/drivers/net/Kconfig
506 --- linux-2.6.27.org/drivers/net/Kconfig        2009-01-11 17:08:24.201024820 +0100
507 +++ linux-2.6.27/drivers/net/Kconfig    2009-01-11 17:16:26.605321939 +0100
508 @@ -109,6 +109,129 @@
509           To compile this driver as a module, choose M here: the module
510           will be called eql.  If unsure, say N.
511  
512 +config IMQ
513 +       tristate "IMQ (intermediate queueing device) support"
514 +       depends on NETDEVICES && NETFILTER
515 +       ---help---
516 +         The IMQ device(s) is used as placeholder for QoS queueing
517 +         disciplines. Every packet entering/leaving the IP stack can be
518 +         directed through the IMQ device where it's enqueued/dequeued to the
519 +         attached qdisc. This allows you to treat network devices as classes
520 +         and distribute bandwidth among them. Iptables is used to specify
521 +         through which IMQ device, if any, packets travel.
522 +
523 +         More information at: http://www.linuximq.net/
524 +
525 +         To compile this driver as a module, choose M here: the module
526 +         will be called imq.  If unsure, say N.
527 +
528 +choice
529 +       prompt "IMQ behavior (PRE/POSTROUTING)"
530 +       depends on IMQ
531 +       default IMQ_BEHAVIOR_AB
532 +       help
533 +
534 +               This settings defines how IMQ behaves in respect to its
535 +               hooking in PREROUTING and POSTROUTING.
536 +
537 +               IMQ can work in any of the following ways:
538 +
539 +                   PREROUTING   |      POSTROUTING
540 +               -----------------|-------------------
541 +               #1  After NAT    |      After NAT
542 +               #2  After NAT    |      Before NAT
543 +               #3  Before NAT   |      After NAT
544 +               #4  Before NAT   |      Before NAT
545 +
546 +               The default behavior is to hook before NAT on PREROUTING
547 +               and after NAT on POSTROUTING (#3).
548 +
549 +               This settings are specially usefull when trying to use IMQ
550 +               to shape NATed clients.
551 +
552 +               More information can be found at: www.linuximq.net
553 +
554 +               If not sure leave the default settings alone.
555 +
556 +config IMQ_BEHAVIOR_AA
557 +       bool "IMQ AA"
558 +       help
559 +               This settings defines how IMQ behaves in respect to its
560 +               hooking in PREROUTING and POSTROUTING.
561 +
562 +               Choosing this option will make IMQ hook like this:
563 +
564 +               PREROUTING:   After NAT
565 +               POSTROUTING:  After NAT
566 +
567 +               More information can be found at: www.linuximq.net
568 +
569 +               If not sure leave the default settings alone.
570 +
571 +config IMQ_BEHAVIOR_AB
572 +       bool "IMQ AB"
573 +       help
574 +               This settings defines how IMQ behaves in respect to its
575 +               hooking in PREROUTING and POSTROUTING.
576 +
577 +               Choosing this option will make IMQ hook like this:
578 +
579 +               PREROUTING:   After NAT
580 +               POSTROUTING:  Before NAT
581 +
582 +               More information can be found at: www.linuximq.net
583 +
584 +               If not sure leave the default settings alone.
585 +
586 +config IMQ_BEHAVIOR_BA
587 +       bool "IMQ BA"
588 +       help
589 +               This settings defines how IMQ behaves in respect to its
590 +               hooking in PREROUTING and POSTROUTING.
591 +
592 +               Choosing this option will make IMQ hook like this:
593 +
594 +               PREROUTING:   Before NAT
595 +               POSTROUTING:  After NAT
596 +
597 +               More information can be found at: www.linuximq.net
598 +
599 +               If not sure leave the default settings alone.
600 +
601 +config IMQ_BEHAVIOR_BB
602 +       bool "IMQ BB"
603 +       help
604 +               This settings defines how IMQ behaves in respect to its
605 +               hooking in PREROUTING and POSTROUTING.
606 +
607 +               Choosing this option will make IMQ hook like this:
608 +
609 +               PREROUTING:   Before NAT
610 +               POSTROUTING:  Before NAT
611 +
612 +               More information can be found at: www.linuximq.net
613 +
614 +               If not sure leave the default settings alone.
615 +
616 +endchoice
617 +
618 +config IMQ_NUM_DEVS
619 +
620 +       int "Number of IMQ devices"
621 +       range 2 16
622 +       depends on IMQ
623 +       default "16"
624 +       help
625 +
626 +               This settings defines how many IMQ devices will be
627 +               created.
628 +
629 +               The default value is 16.
630 +
631 +               More information can be found at: www.linuximq.net
632 +
633 +               If not sure leave the default settings alone.
634 +
635  config TUN
636         tristate "Universal TUN/TAP device driver support"
637         select CRC32
638 diff -urN linux-2.6.27.org/drivers/net/Makefile linux-2.6.27/drivers/net/Makefile
639 --- linux-2.6.27.org/drivers/net/Makefile       2008-10-10 00:13:53.000000000 +0200
640 +++ linux-2.6.27/drivers/net/Makefile   2009-01-11 17:16:26.608878570 +0100
641 @@ -144,6 +144,7 @@
642  obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o
643  
644  obj-$(CONFIG_DUMMY) += dummy.o
645 +obj-$(CONFIG_IMQ) += imq.o
646  obj-$(CONFIG_IFB) += ifb.o
647  obj-$(CONFIG_MACVLAN) += macvlan.o
648  obj-$(CONFIG_DE600) += de600.o
649 diff -urN linux-2.6.27.org/include/linux/imq.h linux-2.6.27/include/linux/imq.h
650 --- linux-2.6.27.org/include/linux/imq.h        1970-01-01 01:00:00.000000000 +0100
651 +++ linux-2.6.27/include/linux/imq.h    2009-01-11 17:16:26.624402721 +0100
652 @@ -0,0 +1,9 @@
653 +#ifndef _IMQ_H
654 +#define _IMQ_H
655 +
656 +#define IMQ_MAX_DEVS   16
657 +
658 +#define IMQ_F_IFMASK   0x7f
659 +#define IMQ_F_ENQUEUE  0x80
660 +
661 +#endif /* _IMQ_H */
662 diff -urN linux-2.6.27.org/include/linux/netfilter_ipv4/ipt_IMQ.h linux-2.6.27/include/linux/netfilter_ipv4/ipt_IMQ.h
663 --- linux-2.6.27.org/include/linux/netfilter_ipv4/ipt_IMQ.h     1970-01-01 01:00:00.000000000 +0100
664 +++ linux-2.6.27/include/linux/netfilter_ipv4/ipt_IMQ.h 2009-01-11 17:16:26.624402721 +0100
665 @@ -0,0 +1,8 @@
666 +#ifndef _IPT_IMQ_H
667 +#define _IPT_IMQ_H
668 +
669 +struct ipt_imq_info {
670 +       unsigned int todev;     /* target imq device */
671 +};
672 +
673 +#endif /* _IPT_IMQ_H */
674 diff -urN linux-2.6.27.org/include/linux/netfilter_ipv6/ip6t_IMQ.h linux-2.6.27/include/linux/netfilter_ipv6/ip6t_IMQ.h
675 --- linux-2.6.27.org/include/linux/netfilter_ipv6/ip6t_IMQ.h    1970-01-01 01:00:00.000000000 +0100
676 +++ linux-2.6.27/include/linux/netfilter_ipv6/ip6t_IMQ.h        2009-01-11 17:16:26.624402721 +0100
677 @@ -0,0 +1,8 @@
678 +#ifndef _IP6T_IMQ_H
679 +#define _IP6T_IMQ_H
680 +
681 +struct ip6t_imq_info {
682 +       unsigned int todev;     /* target imq device */
683 +};
684 +
685 +#endif /* _IP6T_IMQ_H */
686 diff -urN linux-2.6.27.org/include/linux/skbuff.h linux-2.6.27/include/linux/skbuff.h
687 --- linux-2.6.27.org/include/linux/skbuff.h     2008-10-10 00:13:53.000000000 +0200
688 +++ linux-2.6.27/include/linux/skbuff.h 2009-01-11 17:16:26.624402721 +0100
689 @@ -302,6 +302,10 @@
690         struct nf_conntrack     *nfct;
691         struct sk_buff          *nfct_reasm;
692  #endif
693 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
694 +       unsigned char                   imq_flags;
695 +       struct nf_queue_entry   *nf_queue_entry;
696 +#endif
697  #ifdef CONFIG_BRIDGE_NETFILTER
698         struct nf_bridge_info   *nf_bridge;
699  #endif
700 @@ -1642,6 +1646,10 @@
701         dst->nfct_reasm = src->nfct_reasm;
702         nf_conntrack_get_reasm(src->nfct_reasm);
703  #endif
704 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
705 +       dst->imq_flags = src->imq_flags;
706 +       dst->nf_queue_entry = src->nf_queue_entry;
707 +#endif
708  #ifdef CONFIG_BRIDGE_NETFILTER
709         dst->nf_bridge  = src->nf_bridge;
710         nf_bridge_get(src->nf_bridge);
711 diff -urN linux-2.6.27.org/net/core/dev.c linux-2.6.27/net/core/dev.c
712 --- linux-2.6.27.org/net/core/dev.c     2009-01-11 17:08:24.484360310 +0100
713 +++ linux-2.6.27/net/core/dev.c 2009-01-11 17:16:26.628877583 +0100
714 @@ -96,6 +96,9 @@
715  #include <net/net_namespace.h>
716  #include <net/sock.h>
717  #include <linux/rtnetlink.h>
718 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
719 +#include <linux/imq.h>
720 +#endif
721  #include <linux/proc_fs.h>
722  #include <linux/seq_file.h>
723  #include <linux/stat.h>
724 @@ -1624,7 +1627,11 @@
725                         struct netdev_queue *txq)
726  {
727         if (likely(!skb->next)) {
728 -               if (!list_empty(&ptype_all))
729 +               if (!list_empty(&ptype_all)
730 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
731 +                   && !(skb->imq_flags & IMQ_F_ENQUEUE)
732 +#endif
733 +                   )
734                         dev_queue_xmit_nit(skb, dev);
735  
736                 if (netif_needs_gso(dev, skb)) {
737 diff -urN linux-2.6.27.org/net/ipv4/netfilter/ipt_IMQ.c linux-2.6.27/net/ipv4/netfilter/ipt_IMQ.c
738 --- linux-2.6.27.org/net/ipv4/netfilter/ipt_IMQ.c       1970-01-01 01:00:00.000000000 +0100
739 +++ linux-2.6.27/net/ipv4/netfilter/ipt_IMQ.c   2009-01-11 17:16:26.631246773 +0100
740 @@ -0,0 +1,58 @@
741 +/*
742 + * This target marks packets to be enqueued to an imq device
743 + */
744 +#include <linux/module.h>
745 +#include <linux/skbuff.h>
746 +#include <linux/netfilter_ipv4/ip_tables.h>
747 +#include <linux/netfilter_ipv4/ipt_IMQ.h>
748 +#include <linux/imq.h>
749 +
750 +static unsigned int imq_target(struct sk_buff *pskb, const struct xt_target_param *target)
751 +{
752 +       struct ipt_imq_info *mr = (struct ipt_imq_info *)target->targinfo;
753 +
754 +       pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
755 +
756 +       return XT_CONTINUE;
757 +}
758 +
759 +static bool imq_checkentry(const struct xt_tgchk_param *target)
760 +{
761 +       struct ipt_imq_info *mr = (struct ipt_imq_info *)target->targinfo;
762 +
763 +       if (mr->todev > IMQ_MAX_DEVS) {
764 +               printk(KERN_WARNING
765 +                      "IMQ: invalid device specified, highest is %u\n",
766 +                      IMQ_MAX_DEVS);
767 +               return 0;
768 +       }
769 +
770 +       return 1;
771 +}
772 +
773 +static struct xt_target ipt_imq_reg = {
774 +       .name           = "IMQ",
775 +       .family         = AF_INET,
776 +       .target         = imq_target,
777 +       .targetsize     = sizeof(struct ipt_imq_info),
778 +       .checkentry     = imq_checkentry,
779 +       .me             = THIS_MODULE,
780 +       .table          = "mangle"
781 +};
782 +
783 +static int __init init(void)
784 +{
785 +       return xt_register_target(&ipt_imq_reg);
786 +}
787 +
788 +static void __exit fini(void)
789 +{
790 +       xt_unregister_target(&ipt_imq_reg);
791 +}
792 +
793 +module_init(init);
794 +module_exit(fini);
795 +
796 +MODULE_AUTHOR("http://www.linuximq.net");
797 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
798 +MODULE_LICENSE("GPL");
799 diff -urN linux-2.6.27.org/net/ipv4/netfilter/Kconfig linux-2.6.27/net/ipv4/netfilter/Kconfig
800 --- linux-2.6.27.org/net/ipv4/netfilter/Kconfig 2009-01-11 17:08:24.774134145 +0100
801 +++ linux-2.6.27/net/ipv4/netfilter/Kconfig     2009-01-11 17:16:26.628877583 +0100
802 @@ -123,6 +123,17 @@
803  
804           To compile it as a module, choose M here.  If unsure, say N.
805  
806 +config IP_NF_TARGET_IMQ
807 +       tristate "IMQ target support"
808 +       depends on IP_NF_MANGLE
809 +       help
810 +         This option adds a `IMQ' target which is used to specify if and
811 +         to which IMQ device packets should get enqueued/dequeued.
812 +
813 +        For more information visit: http://www.linuximq.net/
814 +
815 +         To compile it as a module, choose M here.  If unsure, say N.
816 +
817  config IP_NF_TARGET_REJECT
818         tristate "REJECT target support"
819         depends on IP_NF_FILTER
820 diff -urN linux-2.6.27.org/net/ipv4/netfilter/Makefile linux-2.6.27/net/ipv4/netfilter/Makefile
821 --- linux-2.6.27.org/net/ipv4/netfilter/Makefile        2009-01-11 17:08:24.774134145 +0100
822 +++ linux-2.6.27/net/ipv4/netfilter/Makefile    2009-01-11 17:16:46.727417283 +0100
823 @@ -60,6 +60,7 @@
824  obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o
825  obj-$(CONFIG_IP_NF_TARGET_ECN) += ipt_ECN.o
826  obj-$(CONFIG_IP_NF_TARGET_LOG) += ipt_LOG.o
827 +obj-$(CONFIG_IP_NF_TARGET_IMQ) += ipt_IMQ.o
828  obj-$(CONFIG_IP_NF_TARGET_IPV4OPTSSTRIP) += ipt_IPV4OPTSSTRIP.o
829  obj-$(CONFIG_IP_NF_TARGET_MASQUERADE) += ipt_MASQUERADE.o
830  obj-$(CONFIG_IP_NF_TARGET_NETMAP) += ipt_NETMAP.o
831 diff -urN linux-2.6.27.org/net/ipv6/netfilter/ip6t_IMQ.c linux-2.6.27/net/ipv6/netfilter/ip6t_IMQ.c
832 --- linux-2.6.27.org/net/ipv6/netfilter/ip6t_IMQ.c      1970-01-01 01:00:00.000000000 +0100
833 +++ linux-2.6.27/net/ipv6/netfilter/ip6t_IMQ.c  2009-01-11 17:16:26.631246773 +0100
834 @@ -0,0 +1,58 @@
835 +/*
836 + * This target marks packets to be enqueued to an imq device
837 + */
838 +#include <linux/module.h>
839 +#include <linux/skbuff.h>
840 +#include <linux/netfilter_ipv6/ip6_tables.h>
841 +#include <linux/netfilter_ipv6/ip6t_IMQ.h>
842 +#include <linux/imq.h>
843 +
844 +static unsigned int imq_target(struct sk_buff *pskb, const struct xt_target_param *target)
845 +{
846 +       struct ip6t_imq_info *mr = (struct ip6t_imq_info *)target->targinfo;
847 +
848 +       pskb->imq_flags = mr->todev | IMQ_F_ENQUEUE;
849 +
850 +       return XT_CONTINUE;
851 +}
852 +
853 +static bool imq_checkentry(const struct xt_tgchk_param *target)
854 +{
855 +       struct ip6t_imq_info *mr = (struct ip6t_imq_info *)target->targinfo;
856 +
857 +       if (mr->todev > IMQ_MAX_DEVS) {
858 +               printk(KERN_WARNING
859 +                      "IMQ: invalid device specified, highest is %u\n",
860 +                      IMQ_MAX_DEVS);
861 +               return 0;
862 +       }
863 +
864 +       return 1;
865 +}
866 +
867 +static struct xt_target ip6t_imq_reg = {
868 +       .name           = "IMQ",
869 +       .family         = AF_INET6,
870 +       .target         = imq_target,
871 +       .targetsize     = sizeof(struct ip6t_imq_info),
872 +       .table          = "mangle",
873 +       .checkentry     = imq_checkentry,
874 +       .me             = THIS_MODULE
875 +};
876 +
877 +static int __init init(void)
878 +{
879 +       return xt_register_target(&ip6t_imq_reg);
880 +}
881 +
882 +static void __exit fini(void)
883 +{
884 +       xt_unregister_target(&ip6t_imq_reg);
885 +}
886 +
887 +module_init(init);
888 +module_exit(fini);
889 +
890 +MODULE_AUTHOR("http://www.linuximq.net");
891 +MODULE_DESCRIPTION("Pseudo-driver for the intermediate queue device. See http://www.linuximq.net/ for more information.");
892 +MODULE_LICENSE("GPL");
893 diff -urN linux-2.6.27.org/net/ipv6/netfilter/Kconfig linux-2.6.27/net/ipv6/netfilter/Kconfig
894 --- linux-2.6.27.org/net/ipv6/netfilter/Kconfig 2009-01-11 17:08:24.720800755 +0100
895 +++ linux-2.6.27/net/ipv6/netfilter/Kconfig     2009-01-11 17:16:26.631246773 +0100
896 @@ -179,6 +179,15 @@
897  
898           To compile it as a module, choose M here.  If unsure, say N.
899  
900 +config IP6_NF_TARGET_IMQ
901 +       tristate "IMQ target support"
902 +       depends on IP6_NF_MANGLE
903 +       help
904 +          This option adds a `IMQ' target which is used to specify if and
905 +          to which imq device packets should get enqueued/dequeued.
906 +
907 +          To compile it as a module, choose M here.  If unsure, say N.
908 +
909  config IP6_NF_TARGET_HL
910         tristate  'HL (hoplimit) target support'
911         depends on IP6_NF_MANGLE
912 diff -urN linux-2.6.27.org/net/ipv6/netfilter/Makefile linux-2.6.27/net/ipv6/netfilter/Makefile
913 --- linux-2.6.27.org/net/ipv6/netfilter/Makefile        2009-01-11 17:08:24.720800755 +0100
914 +++ linux-2.6.27/net/ipv6/netfilter/Makefile    2009-01-11 17:16:26.631246773 +0100
915 @@ -6,6 +6,7 @@
916  obj-$(CONFIG_IP6_NF_IPTABLES) += ip6_tables.o
917  obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o
918  obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o
919 +obj-$(CONFIG_IP6_NF_TARGET_IMQ) += ip6t_IMQ.o
920  obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o
921  obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o
922  obj-$(CONFIG_IP6_NF_SECURITY) += ip6table_security.o
923 diff -urN linux-2.6.27.org/net/sched/sch_generic.c linux-2.6.27/net/sched/sch_generic.c
924 --- linux-2.6.27.org/net/sched/sch_generic.c    2009-01-11 17:08:24.498092451 +0100
925 +++ linux-2.6.27/net/sched/sch_generic.c        2009-01-11 17:16:26.631246773 +0100
926 @@ -188,6 +188,7 @@
927  
928         clear_bit(__QDISC_STATE_RUNNING, &q->state);
929  }
930 +EXPORT_SYMBOL(__qdisc_run);
931  
932  static void dev_watchdog(unsigned long arg)
933  {
This page took 0.086539 seconds and 3 git commands to generate.