]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.4.21-imq-1.diff
- fix unresolved symbols in ipv6 netfilter
[packages/kernel.git] / linux-2.4.21-imq-1.diff
1 diff -urN a/Documentation/Configure.help b/Documentation/Configure.help
2 --- a/Documentation/Configure.help      2003-06-25 00:18:32.000000000 +0200
3 +++ b/Documentation/Configure.help      2003-06-25 00:19:01.000000000 +0200
4 @@ -8821,6 +8821,20 @@
5    say M here and read <file:Documentation/modules.txt>.  The module
6    will be called bonding.o.
7  
8 +Intermediate queueing device support
9 +CONFIG_IMQ
10 +  The imq device(s) is used as placeholder for QoS queueing disciplines.
11 +  Every packet entering/leaving the ip stack can be directed through
12 +  the imq device where it's enqueued/dequeued to the attached qdisc.
13 +  This allows you to treat network devices as classes and distribute
14 +  bandwidth among them. Iptables is used to specify through which imq
15 +  device, if any, packets travel.
16 +
17 +  If you want to compile this as a module ( = code which ca be
18 +  inserted in and removed from the running kernel whenever you want),
19 +  say M here and read <file:Documentation/modules.txt>.  The module
20 +  will be called imq.o
21 +
22  SLIP (serial line) support
23  CONFIG_SLIP
24    Say Y if you intend to use SLIP or CSLIP (compressed SLIP) to
25 diff -urN a/drivers/net/Config.in b/drivers/net/Config.in
26 --- a/drivers/net/Config.in     2003-06-25 00:18:32.000000000 +0200
27 +++ b/drivers/net/Config.in     2003-06-25 00:19:02.000000000 +0200
28 @@ -7,6 +7,11 @@
29  tristate 'Dummy net driver support' CONFIG_DUMMY
30  tristate 'Bonding driver support' CONFIG_BONDING
31  tristate 'EQL (serial line load balancing) support' CONFIG_EQUALIZER
32 +if [ "$CONFIG_NETFILTER" = "y" ]; then
33 +  tristate 'IMQ (intermediate queueing device) support' CONFIG_IMQ
34 +else
35 +  comment 'IMQ needs CONFIG_NETFILTER enabled'
36 +fi
37  tristate 'Universal TUN/TAP device driver support' CONFIG_TUN
38  if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
39     tristate 'Ethertap network tap (OBSOLETE)' CONFIG_ETHERTAP
40 diff -urN a/drivers/net/imq.c b/drivers/net/imq.c
41 --- a/drivers/net/imq.c 1970-01-01 01:00:00.000000000 +0100
42 +++ b/drivers/net/imq.c 2003-06-25 00:20:38.000000000 +0200
43 @@ -0,0 +1,321 @@
44 +/*
45 + *             Pseudo-driver for the intermediate queue device.
46 + *
47 + *             This program is free software; you can redistribute it and/or
48 + *             modify it under the terms of the GNU General Public License
49 + *             as published by the Free Software Foundation; either version
50 + *             2 of the License, or (at your option) any later version.
51 + *
52 + * Authors:    Patrick McHardy, <kaber@trash.net>
53 + *
54 + *            The first version was written by Martin Devera, <devik@cdi.cz>
55 + *
56 + * Credits:    Jan Rafaj <imq2t@cedric.vabo.cz>
57 + *              - Update patch to 2.4.21
58 + *             Sebastian Strollo <sstrollo@nortelnetworks.com>
59 + *              - Fix "Dead-loop on netdevice imq"-issue
60 + */
61 +
62 +#include <linux/kernel.h>
63 +#include <linux/module.h>
64 +#include <linux/config.h>
65 +#include <linux/skbuff.h>
66 +#include <linux/netdevice.h>
67 +#include <linux/rtnetlink.h>
68 +#include <linux/if_arp.h>
69 +#include <linux/netfilter.h>
70 +#include <linux/netfilter_ipv4.h>
71 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
72 +#include <linux/netfilter_ipv6.h>
73 +#endif
74 +#include <linux/imq.h>
75 +#include <net/pkt_sched.h>
76 +
77 +static nf_hookfn imq_nf_hook;
78 +
79 +static struct nf_hook_ops imq_ingress_ipv4 = {
80 +       { NULL, NULL},
81 +       imq_nf_hook,
82 +       PF_INET,
83 +       NF_IP_PRE_ROUTING,
84 +       NF_IP_PRI_MANGLE + 1
85 +};
86 +
87 +static struct nf_hook_ops imq_egress_ipv4 = {
88 +       { NULL, NULL},
89 +       imq_nf_hook,
90 +       PF_INET,
91 +       NF_IP_POST_ROUTING,
92 +       NF_IP_PRI_LAST
93 +};
94 +
95 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
96 +static struct nf_hook_ops imq_ingress_ipv6 = {
97 +       { NULL, NULL},
98 +       imq_nf_hook,
99 +       PF_INET6,
100 +       NF_IP6_PRE_ROUTING,
101 +       NF_IP6_PRI_MANGLE + 1
102 +};
103 +
104 +static struct nf_hook_ops imq_egress_ipv6 = {
105 +       { NULL, NULL},
106 +       imq_nf_hook,
107 +       PF_INET6,
108 +       NF_IP6_POST_ROUTING,
109 +       NF_IP6_PRI_LAST
110 +};
111 +#endif
112 +
113 +static unsigned int numdevs = 2;
114 +
115 +MODULE_PARM(numdevs, "i");
116 +MODULE_PARM_DESC(numdevs, "number of imq devices");
117 +
118 +static struct net_device *imq_devs;
119 +
120 +
121 +static struct net_device_stats *imq_get_stats(struct net_device *dev)
122 +{
123 +       return (struct net_device_stats *)dev->priv;
124 +}
125 +
126 +/* called for packets kfree'd in qdiscs at places other than enqueue */
127 +static void imq_skb_destructor(struct sk_buff *skb)
128 +{
129 +       struct nf_info *info = skb->nf_info;
130 +
131 +       if (info) {
132 +               if (info->indev)
133 +                       dev_put(info->indev);
134 +               if (info->outdev)
135 +                       dev_put(info->outdev);
136 +               kfree(info);
137 +       }
138 +}
139 +
140 +static int imq_dev_xmit(struct sk_buff *skb, struct net_device *dev)
141 +{
142 +       struct net_device_stats *stats = (struct net_device_stats*) dev->priv;
143 +       
144 +       stats->tx_bytes += skb->len;
145 +       stats->tx_packets++;
146 +
147 +       skb->imq_flags = 0;
148 +       skb->destructor = NULL;
149 +       
150 +       dev->trans_start = jiffies;
151 +       nf_reinject(skb, skb->nf_info, NF_ACCEPT);
152 +       return 0;
153 +}
154 +
155 +static int imq_nf_queue(struct sk_buff *skb, struct nf_info *info,
156 +                       void *data)
157 +{
158 +       struct net_device *dev;
159 +       struct net_device_stats *stats;
160 +       struct sk_buff *skb2 = NULL;
161 +       struct Qdisc *q;
162 +       unsigned int index = skb->imq_flags&IMQ_F_IFMASK;
163 +       int ret = -1;
164 +
165 +       if (index > numdevs) 
166 +               return -1;
167 +       
168 +       dev = imq_devs + index;
169 +       if (!(dev->flags & IFF_UP)) {
170 +               skb->imq_flags = 0;
171 +               nf_reinject(skb, info, NF_ACCEPT);
172 +               return 0;
173 +       }
174 +       dev->last_rx = jiffies;
175 +
176 +       if (skb->destructor) {
177 +               skb2 = skb;
178 +               skb = skb_clone(skb, GFP_ATOMIC);
179 +               if (!skb)
180 +                       return -1;
181 +       }
182 +       skb->nf_info = info;
183 +
184 +       stats = (struct net_device_stats *)dev->priv;
185 +       stats->rx_bytes+= skb->len;
186 +       stats->rx_packets++;
187 +       
188 +       spin_lock_bh(&dev->queue_lock);
189 +       q = dev->qdisc;
190 +       if (q->enqueue) {
191 +               q->enqueue(skb_get(skb), q);
192 +               if (skb_shared(skb)) {
193 +                       skb->destructor = imq_skb_destructor;
194 +                       kfree_skb(skb);
195 +                       ret = 0;
196 +               }
197 +       }
198 +       if (spin_is_locked(&dev->xmit_lock))
199 +               netif_schedule(dev);
200 +       else
201 +               qdisc_run(dev);
202 +       spin_unlock_bh(&dev->queue_lock);
203 +
204 +       if (skb2)
205 +               kfree_skb(ret ? skb : skb2);
206 +
207 +       return ret;
208 +}
209 +
210 +static unsigned int imq_nf_hook(unsigned int hook, struct sk_buff **pskb,
211 +                  const struct net_device *indev,
212 +                  const struct net_device *outdev,
213 +                  int (*okfn)(struct sk_buff *))
214 +{
215 +       if ((*pskb)->imq_flags & IMQ_F_ENQUEUE)
216 +               return NF_QUEUE;
217 +
218 +       return NF_ACCEPT;
219 +}
220 +
221 +
222 +static int __init imq_init_hooks(void)
223 +{
224 +       int err;
225 +
226 +       if ((err = nf_register_queue_handler(PF_INET, imq_nf_queue, NULL)))
227 +               goto err1;
228 +       if ((err = nf_register_hook(&imq_ingress_ipv4)))
229 +               goto err2;
230 +       if ((err = nf_register_hook(&imq_egress_ipv4)))
231 +               goto err3;
232 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
233 +       if ((err = nf_register_queue_handler(PF_INET6, imq_nf_queue, NULL)))
234 +               goto err4;
235 +       if ((err = nf_register_hook(&imq_ingress_ipv6)))
236 +               goto err5;
237 +       if ((err = nf_register_hook(&imq_egress_ipv6)))
238 +               goto err6;
239 +#endif
240 +       
241 +       return 0;
242 +       
243 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
244 +err6:
245 +       nf_unregister_hook(&imq_ingress_ipv6);
246 +err5:
247 +       nf_unregister_queue_handler(PF_INET6);
248 +err4:
249 +       nf_unregister_hook(&imq_egress_ipv4);
250 +#endif
251 +err3:
252 +       nf_unregister_hook(&imq_ingress_ipv4);
253 +err2:
254 +       nf_unregister_queue_handler(PF_INET);
255 +err1:
256 +       return err;
257 +}
258 +
259 +static void __exit imq_unhook(void)
260 +{
261 +       nf_unregister_hook(&imq_ingress_ipv4);
262 +       nf_unregister_hook(&imq_egress_ipv4);
263 +       nf_unregister_queue_handler(PF_INET);
264 +#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
265 +       nf_unregister_hook(&imq_ingress_ipv6);
266 +       nf_unregister_hook(&imq_egress_ipv6);
267 +       nf_unregister_queue_handler(PF_INET6);
268 +#endif
269 +}
270 +
271 +static int __init imq_dev_init(struct net_device *dev)
272 +{
273 +       dev->hard_start_xmit    = imq_dev_xmit;
274 +       dev->type               = ARPHRD_VOID;
275 +       dev->mtu                = 1500;
276 +       dev->tx_queue_len       = 30;
277 +       dev->flags              = IFF_NOARP;
278 +       dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
279 +       if (dev->priv == NULL)
280 +               return -ENOMEM;
281 +       memset(dev->priv, 0, sizeof(struct net_device_stats));
282 +       dev->get_stats          = imq_get_stats;
283 +
284 +       return 0;
285 +}
286 +
287 +static void imq_dev_uninit(struct net_device *dev)
288 +{
289 +       kfree(dev->priv);
290 +}
291 +
292 +static int __init imq_init_devs(void)
293 +{
294 +       struct net_device *dev;
295 +       int i;
296 +
297 +       if (!numdevs || numdevs > IMQ_MAX_DEVS) {
298 +               printk(KERN_ERR "numdevs has to be betweed 1 and %u\n",
299 +                      IMQ_MAX_DEVS);
300 +               return -EINVAL;
301 +       }
302 +
303 +       imq_devs = kmalloc(sizeof(struct net_device) * numdevs, GFP_KERNEL);
304 +       if (!imq_devs)
305 +               return -ENOMEM;
306 +       memset(imq_devs, 0, sizeof(struct net_device) * numdevs);
307 +
308 +       /* we start counting at zero */
309 +       numdevs--;
310 +
311 +       for (i = 0, dev = imq_devs; i <= numdevs; i++, dev++) {
312 +               SET_MODULE_OWNER(dev);
313 +               strcpy(dev->name, "imq%d");
314 +               dev->init   = imq_dev_init;
315 +               dev->uninit = imq_dev_uninit;
316 +
317 +               if (register_netdev(dev) < 0)
318 +                       goto err_register;
319 +       }
320 +       return 0;
321 +
322 +err_register:
323 +       for (; i; i--)
324 +               unregister_netdev(--dev);
325 +       kfree(imq_devs);
326 +       return -EIO;
327 +}
328 +
329 +static void imq_cleanup_devs(void)
330 +{
331 +       int i;
332 +       struct net_device *dev = imq_devs;
333 +       
334 +       for (i = 0; i <= numdevs; i++)
335 +               unregister_netdev(dev++);
336 +
337 +       kfree(imq_devs);
338 +}
339 +
340 +static int __init imq_init_module(void)
341 +{
342 +       int err;
343 +
344 +       if ((err = imq_init_devs()))
345 +               return err;
346 +       if ((err = imq_init_hooks())) {
347 +               imq_cleanup_devs();
348 +               return err;
349 +       }
350 +
351 +       printk(KERN_INFO "imq driver loaded.\n");
352 +
353 +       return 0;
354 +}
355 +
356 +static void __exit imq_cleanup_module(void)
357 +{
358 +       imq_unhook();
359 +       imq_cleanup_devs();
360 +}
361 +
362 +module_init(imq_init_module);
363 +module_exit(imq_cleanup_module);
364 +MODULE_LICENSE("GPL");
365 diff -urN a/drivers/net/Makefile b/drivers/net/Makefile
366 --- a/drivers/net/Makefile      2003-06-25 00:18:32.000000000 +0200
367 +++ b/drivers/net/Makefile      2003-06-25 00:19:02.000000000 +0200
368 @@ -159,5 +159,6 @@
369  obj-$(CONFIG_STRIP) += strip.o
370  obj-$(CONFIG_DUMMY) += dummy.o
371 +obj-$(CONFIG_IMQ) += imq.o
372  obj-$(CONFIG_DE600) += de600.o
373  obj-$(CONFIG_DE620) += de620.o
374  obj-$(CONFIG_AT1500) += lance.o
375 diff -urN a/include/linux/imq.h b/include/linux/imq.h
376 --- a/include/linux/imq.h       1970-01-01 01:00:00.000000000 +0100
377 +++ b/include/linux/imq.h       2003-06-25 00:19:02.000000000 +0200
378 @@ -0,0 +1,9 @@
379 +#ifndef _IMQ_H
380 +#define _IMQ_H
381 +
382 +#define IMQ_MAX_DEVS   16
383 +
384 +#define IMQ_F_IFMASK   0x7f
385 +#define IMQ_F_ENQUEUE  0x80
386 +
387 +#endif /* _IMQ_H */
388 diff -urN a/include/linux/skbuff.h b/include/linux/skbuff.h
389 --- a/include/linux/skbuff.h    2003-06-25 00:18:32.000000000 +0200
390 +++ b/include/linux/skbuff.h    2003-06-25 00:19:02.000000000 +0200
391 @@ -93,6 +93,9 @@
392         struct nf_conntrack *master;
393  };
394  #endif
395 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
396 +struct nf_info;
397 +#endif
398  
399  struct sk_buff_head {
400         /* These two members must be first. */
401 @@ -178,7 +181,7 @@
402         unsigned int    len;                    /* Length of actual data                        */
403         unsigned int    data_len;
404         unsigned int    csum;                   /* Checksum                                     */
405 -       unsigned char   __unused,               /* Dead field, may be reused                    */
406 +       unsigned char   imq_flags,              /* intermediate queueing device */
407                         cloned,                 /* head may be cloned (check refcnt to be sure). */
408                         pkt_type,               /* Packet class                                 */
409                         ip_summed;              /* Driver fed us an IP checksum                 */
410 @@ -215,6 +218,9 @@
411  #ifdef CONFIG_NET_SCHED
412         __u32           tc_index;               /* traffic control index */
413  #endif
414 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
415 +       struct nf_info  *nf_info;
416 +#endif
417  };
418  
419  #define SK_WMEM_MAX    65535
420 diff -urN a/net/core/skbuff.c b/net/core/skbuff.c
421 --- a/net/core/skbuff.c 2003-06-25 00:18:32.000000000 +0200
422 +++ b/net/core/skbuff.c 2003-06-25 00:19:03.000000000 +0200
423 @@ -202,6 +202,10 @@
424         /* Set up other state */
425         skb->len = 0;
426         skb->cloned = 0;
427 +#if defined(CONFIG_IMQ) || defined (CONFIG_IMQ_MODULE)
428 +       skb->imq_flags = 0;
429 +       skb->nf_info = NULL;
430 +#endif
431         skb->data_len = 0;
432  
433         atomic_set(&skb->users, 1); 
434 @@ -249,6 +253,10 @@
435  #ifdef CONFIG_NET_SCHED
436         skb->tc_index = 0;
437  #endif
438 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
439 +       skb->imq_flags = 0;
440 +       skb->nf_info = NULL;
441 +#endif
442  }
443  
444  static void skb_drop_fraglist(struct sk_buff *skb)
445 @@ -398,6 +406,10 @@
446  #ifdef CONFIG_NET_SCHED
447         C(tc_index);
448  #endif
449 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
450 +       C(imq_flags);
451 +       C(nf_info);
452 +#endif
453  
454         atomic_inc(&(skb_shinfo(skb)->dataref));
455         skb->cloned = 1;
456 @@ -441,6 +453,10 @@
457  #ifdef CONFIG_NET_SCHED
458         new->tc_index = old->tc_index;
459  #endif
460 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
461 +       new->imq_flags=old->imq_flags;
462 +       new->nf_info=old->nf_info;
463 +#endif
464  }
465  
466  /**
467 diff -urN a/net/sched/sch_generic.c b/net/sched/sch_generic.c
468 --- a/net/sched/sch_generic.c   2003-06-25 00:18:32.000000000 +0200
469 +++ b/net/sched/sch_generic.c   2003-06-25 00:19:03.000000000 +0200
470 @@ -29,6 +29,9 @@
471  #include <linux/skbuff.h>
472  #include <linux/rtnetlink.h>
473  #include <linux/init.h>
474 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
475 +#include <linux/imq.h>
476 +#endif
477  #include <net/sock.h>
478  #include <net/pkt_sched.h>
479  
480 @@ -89,7 +92,11 @@
481                         spin_unlock(&dev->queue_lock);
482  
483                         if (!netif_queue_stopped(dev)) {
484 -                               if (netdev_nit)
485 +                               if (netdev_nit
486 +#if defined(CONFIG_IMQ) || defined(CONFIG_IMQ_MODULE)
487 +                                   && !(skb->imq_flags & IMQ_F_ENQUEUE)
488 +#endif
489 +                                   )
490                                         dev_queue_xmit_nit(skb, dev);
491  
492                                 if (dev->hard_start_xmit(skb, dev) == 0) {
This page took 0.069505 seconds and 3 git commands to generate.