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