VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / net / core / skbuff.c
1 /*
2  *      Routines having to do with the 'struct sk_buff' memory handlers.
3  *
4  *      Authors:        Alan Cox <iiitac@pyr.swan.ac.uk>
5  *                      Florian La Roche <rzsfl@rz.uni-sb.de>
6  *
7  *      Version:        $Id: skbuff.c,v 1.90 2001/11/07 05:56:19 davem Exp $
8  *
9  *      Fixes:
10  *              Alan Cox        :       Fixed the worst of the load
11  *                                      balancer bugs.
12  *              Dave Platt      :       Interrupt stacking fix.
13  *      Richard Kooijman        :       Timestamp fixes.
14  *              Alan Cox        :       Changed buffer format.
15  *              Alan Cox        :       destructor hook for AF_UNIX etc.
16  *              Linus Torvalds  :       Better skb_clone.
17  *              Alan Cox        :       Added skb_copy.
18  *              Alan Cox        :       Added all the changed routines Linus
19  *                                      only put in the headers
20  *              Ray VanTassle   :       Fixed --skb->lock in free
21  *              Alan Cox        :       skb_copy copy arp field
22  *              Andi Kleen      :       slabified it.
23  *              Robert Olsson   :       Removed skb_head_pool
24  *
25  *      NOTE:
26  *              The __skb_ routines should be called with interrupts
27  *      disabled, or you better be *real* sure that the operation is atomic
28  *      with respect to whatever list is being frobbed (e.g. via lock_sock()
29  *      or via disabling bottom half handlers, etc).
30  *
31  *      This program is free software; you can redistribute it and/or
32  *      modify it under the terms of the GNU General Public License
33  *      as published by the Free Software Foundation; either version
34  *      2 of the License, or (at your option) any later version.
35  */
36
37 /*
38  *      The functions in this file will not compile correctly with gcc 2.4.x
39  */
40
41 #include <linux/config.h>
42 #include <linux/module.h>
43 #include <linux/types.h>
44 #include <linux/kernel.h>
45 #include <linux/sched.h>
46 #include <linux/mm.h>
47 #include <linux/interrupt.h>
48 #include <linux/in.h>
49 #include <linux/inet.h>
50 #include <linux/slab.h>
51 #include <linux/netdevice.h>
52 #ifdef CONFIG_NET_CLS_ACT
53 #include <net/pkt_sched.h>
54 #endif
55 #include <linux/string.h>
56 #include <linux/skbuff.h>
57 #include <linux/cache.h>
58 #include <linux/rtnetlink.h>
59 #include <linux/init.h>
60 #include <linux/highmem.h>
61
62 #include <net/protocol.h>
63 #include <net/dst.h>
64 #include <net/sock.h>
65 #include <net/checksum.h>
66 #include <net/xfrm.h>
67
68 #include <asm/uaccess.h>
69 #include <asm/system.h>
70
71 static kmem_cache_t *skbuff_head_cache;
72
73 /*
74  *      Keep out-of-line to prevent kernel bloat.
75  *      __builtin_return_address is not used because it is not always
76  *      reliable.
77  */
78
79 /**
80  *      skb_over_panic  -       private function
81  *      @skb: buffer
82  *      @sz: size
83  *      @here: address
84  *
85  *      Out of line support code for skb_put(). Not user callable.
86  */
87 void skb_over_panic(struct sk_buff *skb, int sz, void *here)
88 {
89         printk(KERN_INFO "skput:over: %p:%d put:%d dev:%s",
90                 here, skb->len, sz, skb->dev ? skb->dev->name : "<NULL>");
91         BUG();
92 }
93
94 /**
95  *      skb_under_panic -       private function
96  *      @skb: buffer
97  *      @sz: size
98  *      @here: address
99  *
100  *      Out of line support code for skb_push(). Not user callable.
101  */
102
103 void skb_under_panic(struct sk_buff *skb, int sz, void *here)
104 {
105         printk(KERN_INFO "skput:under: %p:%d put:%d dev:%s",
106                here, skb->len, sz, skb->dev ? skb->dev->name : "<NULL>");
107         BUG();
108 }
109
110 /*      Allocate a new skbuff. We do this ourselves so we can fill in a few
111  *      'private' fields and also do memory statistics to find all the
112  *      [BEEP] leaks.
113  *
114  */
115
116 /**
117  *      alloc_skb       -       allocate a network buffer
118  *      @size: size to allocate
119  *      @gfp_mask: allocation mask
120  *
121  *      Allocate a new &sk_buff. The returned buffer has no headroom and a
122  *      tail room of size bytes. The object has a reference count of one.
123  *      The return is the buffer. On a failure the return is %NULL.
124  *
125  *      Buffers may only be allocated from interrupts using a @gfp_mask of
126  *      %GFP_ATOMIC.
127  */
128 struct sk_buff *alloc_skb(unsigned int size, int gfp_mask)
129 {
130         struct sk_buff *skb;
131         u8 *data;
132
133         /* Get the HEAD */
134         skb = kmem_cache_alloc(skbuff_head_cache,
135                                gfp_mask & ~__GFP_DMA);
136         if (!skb)
137                 goto out;
138
139         /* Get the DATA. Size must match skb_add_mtu(). */
140         size = SKB_DATA_ALIGN(size);
141         data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
142         if (!data)
143                 goto nodata;
144
145         memset(skb, 0, offsetof(struct sk_buff, truesize));
146         skb->truesize = size + sizeof(struct sk_buff);
147         atomic_set(&skb->users, 1);
148         skb->head = data;
149         skb->data = data;
150         skb->tail = data;
151         skb->end  = data + size;
152
153         atomic_set(&(skb_shinfo(skb)->dataref), 1);
154         skb_shinfo(skb)->nr_frags  = 0;
155         skb_shinfo(skb)->tso_size = 0;
156         skb_shinfo(skb)->tso_segs = 0;
157         skb_shinfo(skb)->frag_list = NULL;
158 out:
159         return skb;
160 nodata:
161         kmem_cache_free(skbuff_head_cache, skb);
162         skb = NULL;
163         goto out;
164 }
165
166
167 static void skb_drop_fraglist(struct sk_buff *skb)
168 {
169         struct sk_buff *list = skb_shinfo(skb)->frag_list;
170
171         skb_shinfo(skb)->frag_list = NULL;
172
173         do {
174                 struct sk_buff *this = list;
175                 list = list->next;
176                 kfree_skb(this);
177         } while (list);
178 }
179
180 static void skb_clone_fraglist(struct sk_buff *skb)
181 {
182         struct sk_buff *list;
183
184         for (list = skb_shinfo(skb)->frag_list; list; list = list->next)
185                 skb_get(list);
186 }
187
188 void skb_release_data(struct sk_buff *skb)
189 {
190         if (!skb->cloned ||
191             atomic_dec_and_test(&(skb_shinfo(skb)->dataref))) {
192                 if (skb_shinfo(skb)->nr_frags) {
193                         int i;
194                         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
195                                 put_page(skb_shinfo(skb)->frags[i].page);
196                 }
197
198                 if (skb_shinfo(skb)->frag_list)
199                         skb_drop_fraglist(skb);
200
201                 kfree(skb->head);
202         }
203 }
204
205 /*
206  *      Free an skbuff by memory without cleaning the state.
207  */
208 void kfree_skbmem(struct sk_buff *skb)
209 {
210         skb_release_data(skb);
211         kmem_cache_free(skbuff_head_cache, skb);
212 }
213
214 /**
215  *      __kfree_skb - private function
216  *      @skb: buffer
217  *
218  *      Free an sk_buff. Release anything attached to the buffer.
219  *      Clean the state. This is an internal helper function. Users should
220  *      always call kfree_skb
221  */
222
223 void __kfree_skb(struct sk_buff *skb)
224 {
225         if (skb->list) {
226                 printk(KERN_WARNING "Warning: kfree_skb passed an skb still "
227                        "on a list (from %p).\n", NET_CALLER(skb));
228                 BUG();
229         }
230
231         dst_release(skb->dst);
232 #ifdef CONFIG_XFRM
233         secpath_put(skb->sp);
234 #endif
235         if(skb->destructor) {
236                 if (in_irq())
237                         printk(KERN_WARNING "Warning: kfree_skb on "
238                                             "hard IRQ %p\n", NET_CALLER(skb));
239                 skb->destructor(skb);
240         }
241 #ifdef CONFIG_NETFILTER
242         nf_conntrack_put(skb->nfct);
243 #ifdef CONFIG_BRIDGE_NETFILTER
244         nf_bridge_put(skb->nf_bridge);
245 #endif
246 #endif
247 /* XXX: IS this still necessary? - JHS */
248 #ifdef CONFIG_NET_SCHED
249         skb->tc_index = 0;
250 #ifdef CONFIG_NET_CLS_ACT
251         skb->tc_verd = 0;
252         skb->tc_classid = 0;
253 #endif
254 #endif
255
256         kfree_skbmem(skb);
257 }
258
259 /**
260  *      skb_clone       -       duplicate an sk_buff
261  *      @skb: buffer to clone
262  *      @gfp_mask: allocation priority
263  *
264  *      Duplicate an &sk_buff. The new one is not owned by a socket. Both
265  *      copies share the same packet data but not structure. The new
266  *      buffer has a reference count of 1. If the allocation fails the
267  *      function returns %NULL otherwise the new buffer is returned.
268  *
269  *      If this function is called from an interrupt gfp_mask() must be
270  *      %GFP_ATOMIC.
271  */
272
273 struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
274 {
275         struct sk_buff *n = kmem_cache_alloc(skbuff_head_cache, gfp_mask);
276
277         if (!n) 
278                 return NULL;
279
280 #define C(x) n->x = skb->x
281
282         n->next = n->prev = NULL;
283         n->list = NULL;
284         n->sk = NULL;
285         C(stamp);
286         C(dev);
287         C(real_dev);
288         C(h);
289         C(nh);
290         C(mac);
291         C(dst);
292         dst_clone(skb->dst);
293         C(sp);
294 #ifdef CONFIG_INET
295         secpath_get(skb->sp);
296 #endif
297         memcpy(n->cb, skb->cb, sizeof(skb->cb));
298         C(len);
299         C(data_len);
300         C(csum);
301         C(local_df);
302         n->cloned = 1;
303         C(pkt_type);
304         C(ip_summed);
305         C(priority);
306         C(protocol);
307         C(security);
308         n->destructor = NULL;
309 #ifdef CONFIG_NETFILTER
310         C(nfmark);
311         C(nfcache);
312         C(nfct);
313         nf_conntrack_get(skb->nfct);
314 #ifdef CONFIG_NETFILTER_DEBUG
315         C(nf_debug);
316 #endif
317 #ifdef CONFIG_BRIDGE_NETFILTER
318         C(nf_bridge);
319         nf_bridge_get(skb->nf_bridge);
320 #endif
321 #endif /*CONFIG_NETFILTER*/
322 #if defined(CONFIG_HIPPI)
323         C(private);
324 #endif
325 #ifdef CONFIG_NET_SCHED
326         C(tc_index);
327 #ifdef CONFIG_NET_CLS_ACT
328         n->tc_verd = SET_TC_VERD(skb->tc_verd,0);
329         n->tc_verd = CLR_TC_OK2MUNGE(skb->tc_verd);
330         n->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
331         C(input_dev);
332         C(tc_classid);
333 #endif
334
335 #endif
336         C(truesize);
337         atomic_set(&n->users, 1);
338         C(head);
339         C(data);
340         C(tail);
341         C(end);
342
343         atomic_inc(&(skb_shinfo(skb)->dataref));
344         skb->cloned = 1;
345
346         return n;
347 }
348
349 static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
350 {
351         /*
352          *      Shift between the two data areas in bytes
353          */
354         unsigned long offset = new->data - old->data;
355
356         new->list       = NULL;
357         new->sk         = NULL;
358         new->dev        = old->dev;
359         new->real_dev   = old->real_dev;
360         new->priority   = old->priority;
361         new->protocol   = old->protocol;
362         new->dst        = dst_clone(old->dst);
363 #ifdef CONFIG_INET
364         new->sp         = secpath_get(old->sp);
365 #endif
366         new->h.raw      = old->h.raw + offset;
367         new->nh.raw     = old->nh.raw + offset;
368         new->mac.raw    = old->mac.raw + offset;
369         memcpy(new->cb, old->cb, sizeof(old->cb));
370         new->local_df   = old->local_df;
371         new->pkt_type   = old->pkt_type;
372         new->stamp      = old->stamp;
373         new->destructor = NULL;
374         new->security   = old->security;
375 #ifdef CONFIG_NETFILTER
376         new->nfmark     = old->nfmark;
377         new->nfcache    = old->nfcache;
378         new->nfct       = old->nfct;
379         nf_conntrack_get(old->nfct);
380 #ifdef CONFIG_NETFILTER_DEBUG
381         new->nf_debug   = old->nf_debug;
382 #endif
383 #ifdef CONFIG_BRIDGE_NETFILTER
384         new->nf_bridge  = old->nf_bridge;
385         nf_bridge_get(old->nf_bridge);
386 #endif
387 #endif
388 #ifdef CONFIG_NET_SCHED
389 #ifdef CONFIG_NET_CLS_ACT
390         new->tc_verd = old->tc_verd;
391 #endif
392         new->tc_index   = old->tc_index;
393 #endif
394         atomic_set(&new->users, 1);
395 }
396
397 /**
398  *      skb_copy        -       create private copy of an sk_buff
399  *      @skb: buffer to copy
400  *      @gfp_mask: allocation priority
401  *
402  *      Make a copy of both an &sk_buff and its data. This is used when the
403  *      caller wishes to modify the data and needs a private copy of the
404  *      data to alter. Returns %NULL on failure or the pointer to the buffer
405  *      on success. The returned buffer has a reference count of 1.
406  *
407  *      As by-product this function converts non-linear &sk_buff to linear
408  *      one, so that &sk_buff becomes completely private and caller is allowed
409  *      to modify all the data of returned buffer. This means that this
410  *      function is not recommended for use in circumstances when only
411  *      header is going to be modified. Use pskb_copy() instead.
412  */
413
414 struct sk_buff *skb_copy(const struct sk_buff *skb, int gfp_mask)
415 {
416         int headerlen = skb->data - skb->head;
417         /*
418          *      Allocate the copy buffer
419          */
420         struct sk_buff *n = alloc_skb(skb->end - skb->head + skb->data_len,
421                                       gfp_mask);
422         if (!n)
423                 return NULL;
424
425         /* Set the data pointer */
426         skb_reserve(n, headerlen);
427         /* Set the tail pointer and length */
428         skb_put(n, skb->len);
429         n->csum      = skb->csum;
430         n->ip_summed = skb->ip_summed;
431
432         if (skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len))
433                 BUG();
434
435         copy_skb_header(n, skb);
436         return n;
437 }
438
439
440 /**
441  *      pskb_copy       -       create copy of an sk_buff with private head.
442  *      @skb: buffer to copy
443  *      @gfp_mask: allocation priority
444  *
445  *      Make a copy of both an &sk_buff and part of its data, located
446  *      in header. Fragmented data remain shared. This is used when
447  *      the caller wishes to modify only header of &sk_buff and needs
448  *      private copy of the header to alter. Returns %NULL on failure
449  *      or the pointer to the buffer on success.
450  *      The returned buffer has a reference count of 1.
451  */
452
453 struct sk_buff *pskb_copy(struct sk_buff *skb, int gfp_mask)
454 {
455         /*
456          *      Allocate the copy buffer
457          */
458         struct sk_buff *n = alloc_skb(skb->end - skb->head, gfp_mask);
459
460         if (!n)
461                 goto out;
462
463         /* Set the data pointer */
464         skb_reserve(n, skb->data - skb->head);
465         /* Set the tail pointer and length */
466         skb_put(n, skb_headlen(skb));
467         /* Copy the bytes */
468         memcpy(n->data, skb->data, n->len);
469         n->csum      = skb->csum;
470         n->ip_summed = skb->ip_summed;
471
472         n->data_len  = skb->data_len;
473         n->len       = skb->len;
474
475         if (skb_shinfo(skb)->nr_frags) {
476                 int i;
477
478                 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
479                         skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i];
480                         get_page(skb_shinfo(n)->frags[i].page);
481                 }
482                 skb_shinfo(n)->nr_frags = i;
483         }
484         skb_shinfo(n)->tso_size = skb_shinfo(skb)->tso_size;
485         skb_shinfo(n)->tso_segs = skb_shinfo(skb)->tso_segs;
486
487         if (skb_shinfo(skb)->frag_list) {
488                 skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list;
489                 skb_clone_fraglist(n);
490         }
491
492         copy_skb_header(n, skb);
493 out:
494         return n;
495 }
496
497 /**
498  *      pskb_expand_head - reallocate header of &sk_buff
499  *      @skb: buffer to reallocate
500  *      @nhead: room to add at head
501  *      @ntail: room to add at tail
502  *      @gfp_mask: allocation priority
503  *
504  *      Expands (or creates identical copy, if &nhead and &ntail are zero)
505  *      header of skb. &sk_buff itself is not changed. &sk_buff MUST have
506  *      reference count of 1. Returns zero in the case of success or error,
507  *      if expansion failed. In the last case, &sk_buff is not changed.
508  *
509  *      All the pointers pointing into skb header may change and must be
510  *      reloaded after call to this function.
511  */
512
513 int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, int gfp_mask)
514 {
515         int i;
516         u8 *data;
517         int size = nhead + (skb->end - skb->head) + ntail;
518         long off;
519
520         if (skb_shared(skb))
521                 BUG();
522
523         size = SKB_DATA_ALIGN(size);
524
525         data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
526         if (!data)
527                 goto nodata;
528
529         /* Copy only real data... and, alas, header. This should be
530          * optimized for the cases when header is void. */
531         memcpy(data + nhead, skb->head, skb->tail - skb->head);
532         memcpy(data + size, skb->end, sizeof(struct skb_shared_info));
533
534         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
535                 get_page(skb_shinfo(skb)->frags[i].page);
536
537         if (skb_shinfo(skb)->frag_list)
538                 skb_clone_fraglist(skb);
539
540         skb_release_data(skb);
541
542         off = (data + nhead) - skb->head;
543
544         skb->head     = data;
545         skb->end      = data + size;
546         skb->data    += off;
547         skb->tail    += off;
548         skb->mac.raw += off;
549         skb->h.raw   += off;
550         skb->nh.raw  += off;
551         skb->cloned   = 0;
552         atomic_set(&skb_shinfo(skb)->dataref, 1);
553         return 0;
554
555 nodata:
556         return -ENOMEM;
557 }
558
559 /* Make private copy of skb with writable head and some headroom */
560
561 struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom)
562 {
563         struct sk_buff *skb2;
564         int delta = headroom - skb_headroom(skb);
565
566         if (delta <= 0)
567                 skb2 = pskb_copy(skb, GFP_ATOMIC);
568         else {
569                 skb2 = skb_clone(skb, GFP_ATOMIC);
570                 if (skb2 && pskb_expand_head(skb2, SKB_DATA_ALIGN(delta), 0,
571                                              GFP_ATOMIC)) {
572                         kfree_skb(skb2);
573                         skb2 = NULL;
574                 }
575         }
576         return skb2;
577 }
578
579
580 /**
581  *      skb_copy_expand -       copy and expand sk_buff
582  *      @skb: buffer to copy
583  *      @newheadroom: new free bytes at head
584  *      @newtailroom: new free bytes at tail
585  *      @gfp_mask: allocation priority
586  *
587  *      Make a copy of both an &sk_buff and its data and while doing so
588  *      allocate additional space.
589  *
590  *      This is used when the caller wishes to modify the data and needs a
591  *      private copy of the data to alter as well as more space for new fields.
592  *      Returns %NULL on failure or the pointer to the buffer
593  *      on success. The returned buffer has a reference count of 1.
594  *
595  *      You must pass %GFP_ATOMIC as the allocation priority if this function
596  *      is called from an interrupt.
597  *
598  *      BUG ALERT: ip_summed is not copied. Why does this work? Is it used
599  *      only by netfilter in the cases when checksum is recalculated? --ANK
600  */
601 struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
602                                 int newheadroom, int newtailroom, int gfp_mask)
603 {
604         /*
605          *      Allocate the copy buffer
606          */
607         struct sk_buff *n = alloc_skb(newheadroom + skb->len + newtailroom,
608                                       gfp_mask);
609         int head_copy_len, head_copy_off;
610
611         if (!n)
612                 return NULL;
613
614         skb_reserve(n, newheadroom);
615
616         /* Set the tail pointer and length */
617         skb_put(n, skb->len);
618
619         head_copy_len = skb_headroom(skb);
620         head_copy_off = 0;
621         if (newheadroom <= head_copy_len)
622                 head_copy_len = newheadroom;
623         else
624                 head_copy_off = newheadroom - head_copy_len;
625
626         /* Copy the linear header and data. */
627         if (skb_copy_bits(skb, -head_copy_len, n->head + head_copy_off,
628                           skb->len + head_copy_len))
629                 BUG();
630
631         copy_skb_header(n, skb);
632         skb_shinfo(n)->tso_size = skb_shinfo(skb)->tso_size;
633         skb_shinfo(n)->tso_segs = skb_shinfo(skb)->tso_segs;
634
635         return n;
636 }
637
638 /**
639  *      skb_pad                 -       zero pad the tail of an skb
640  *      @skb: buffer to pad
641  *      @pad: space to pad
642  *
643  *      Ensure that a buffer is followed by a padding area that is zero
644  *      filled. Used by network drivers which may DMA or transfer data
645  *      beyond the buffer end onto the wire.
646  *
647  *      May return NULL in out of memory cases.
648  */
649  
650 struct sk_buff *skb_pad(struct sk_buff *skb, int pad)
651 {
652         struct sk_buff *nskb;
653         
654         /* If the skbuff is non linear tailroom is always zero.. */
655         if (skb_tailroom(skb) >= pad) {
656                 memset(skb->data+skb->len, 0, pad);
657                 return skb;
658         }
659         
660         nskb = skb_copy_expand(skb, skb_headroom(skb), skb_tailroom(skb) + pad, GFP_ATOMIC);
661         kfree_skb(skb);
662         if (nskb)
663                 memset(nskb->data+nskb->len, 0, pad);
664         return nskb;
665 }       
666  
667 /* Trims skb to length len. It can change skb pointers, if "realloc" is 1.
668  * If realloc==0 and trimming is impossible without change of data,
669  * it is BUG().
670  */
671
672 int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
673 {
674         int offset = skb_headlen(skb);
675         int nfrags = skb_shinfo(skb)->nr_frags;
676         int i;
677
678         for (i = 0; i < nfrags; i++) {
679                 int end = offset + skb_shinfo(skb)->frags[i].size;
680                 if (end > len) {
681                         if (skb_cloned(skb)) {
682                                 if (!realloc)
683                                         BUG();
684                                 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
685                                         return -ENOMEM;
686                         }
687                         if (len <= offset) {
688                                 put_page(skb_shinfo(skb)->frags[i].page);
689                                 skb_shinfo(skb)->nr_frags--;
690                         } else {
691                                 skb_shinfo(skb)->frags[i].size = len - offset;
692                         }
693                 }
694                 offset = end;
695         }
696
697         if (offset < len) {
698                 skb->data_len -= skb->len - len;
699                 skb->len       = len;
700         } else {
701                 if (len <= skb_headlen(skb)) {
702                         skb->len      = len;
703                         skb->data_len = 0;
704                         skb->tail     = skb->data + len;
705                         if (skb_shinfo(skb)->frag_list && !skb_cloned(skb))
706                                 skb_drop_fraglist(skb);
707                 } else {
708                         skb->data_len -= skb->len - len;
709                         skb->len       = len;
710                 }
711         }
712
713         return 0;
714 }
715
716 /**
717  *      __pskb_pull_tail - advance tail of skb header
718  *      @skb: buffer to reallocate
719  *      @delta: number of bytes to advance tail
720  *
721  *      The function makes a sense only on a fragmented &sk_buff,
722  *      it expands header moving its tail forward and copying necessary
723  *      data from fragmented part.
724  *
725  *      &sk_buff MUST have reference count of 1.
726  *
727  *      Returns %NULL (and &sk_buff does not change) if pull failed
728  *      or value of new tail of skb in the case of success.
729  *
730  *      All the pointers pointing into skb header may change and must be
731  *      reloaded after call to this function.
732  */
733
734 /* Moves tail of skb head forward, copying data from fragmented part,
735  * when it is necessary.
736  * 1. It may fail due to malloc failure.
737  * 2. It may change skb pointers.
738  *
739  * It is pretty complicated. Luckily, it is called only in exceptional cases.
740  */
741 unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta)
742 {
743         /* If skb has not enough free space at tail, get new one
744          * plus 128 bytes for future expansions. If we have enough
745          * room at tail, reallocate without expansion only if skb is cloned.
746          */
747         int i, k, eat = (skb->tail + delta) - skb->end;
748
749         if (eat > 0 || skb_cloned(skb)) {
750                 if (pskb_expand_head(skb, 0, eat > 0 ? eat + 128 : 0,
751                                      GFP_ATOMIC))
752                         return NULL;
753         }
754
755         if (skb_copy_bits(skb, skb_headlen(skb), skb->tail, delta))
756                 BUG();
757
758         /* Optimization: no fragments, no reasons to preestimate
759          * size of pulled pages. Superb.
760          */
761         if (!skb_shinfo(skb)->frag_list)
762                 goto pull_pages;
763
764         /* Estimate size of pulled pages. */
765         eat = delta;
766         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
767                 if (skb_shinfo(skb)->frags[i].size >= eat)
768                         goto pull_pages;
769                 eat -= skb_shinfo(skb)->frags[i].size;
770         }
771
772         /* If we need update frag list, we are in troubles.
773          * Certainly, it possible to add an offset to skb data,
774          * but taking into account that pulling is expected to
775          * be very rare operation, it is worth to fight against
776          * further bloating skb head and crucify ourselves here instead.
777          * Pure masohism, indeed. 8)8)
778          */
779         if (eat) {
780                 struct sk_buff *list = skb_shinfo(skb)->frag_list;
781                 struct sk_buff *clone = NULL;
782                 struct sk_buff *insp = NULL;
783
784                 do {
785                         if (!list)
786                                 BUG();
787
788                         if (list->len <= eat) {
789                                 /* Eaten as whole. */
790                                 eat -= list->len;
791                                 list = list->next;
792                                 insp = list;
793                         } else {
794                                 /* Eaten partially. */
795
796                                 if (skb_shared(list)) {
797                                         /* Sucks! We need to fork list. :-( */
798                                         clone = skb_clone(list, GFP_ATOMIC);
799                                         if (!clone)
800                                                 return NULL;
801                                         insp = list->next;
802                                         list = clone;
803                                 } else {
804                                         /* This may be pulled without
805                                          * problems. */
806                                         insp = list;
807                                 }
808                                 if (!pskb_pull(list, eat)) {
809                                         if (clone)
810                                                 kfree_skb(clone);
811                                         return NULL;
812                                 }
813                                 break;
814                         }
815                 } while (eat);
816
817                 /* Free pulled out fragments. */
818                 while ((list = skb_shinfo(skb)->frag_list) != insp) {
819                         skb_shinfo(skb)->frag_list = list->next;
820                         kfree_skb(list);
821                 }
822                 /* And insert new clone at head. */
823                 if (clone) {
824                         clone->next = list;
825                         skb_shinfo(skb)->frag_list = clone;
826                 }
827         }
828         /* Success! Now we may commit changes to skb data. */
829
830 pull_pages:
831         eat = delta;
832         k = 0;
833         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
834                 if (skb_shinfo(skb)->frags[i].size <= eat) {
835                         put_page(skb_shinfo(skb)->frags[i].page);
836                         eat -= skb_shinfo(skb)->frags[i].size;
837                 } else {
838                         skb_shinfo(skb)->frags[k] = skb_shinfo(skb)->frags[i];
839                         if (eat) {
840                                 skb_shinfo(skb)->frags[k].page_offset += eat;
841                                 skb_shinfo(skb)->frags[k].size -= eat;
842                                 eat = 0;
843                         }
844                         k++;
845                 }
846         }
847         skb_shinfo(skb)->nr_frags = k;
848
849         skb->tail     += delta;
850         skb->data_len -= delta;
851
852         return skb->tail;
853 }
854
855 /* Copy some data bits from skb to kernel buffer. */
856
857 int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
858 {
859         int i, copy;
860         int start = skb_headlen(skb);
861
862         if (offset > (int)skb->len - len)
863                 goto fault;
864
865         /* Copy header. */
866         if ((copy = start - offset) > 0) {
867                 if (copy > len)
868                         copy = len;
869                 memcpy(to, skb->data + offset, copy);
870                 if ((len -= copy) == 0)
871                         return 0;
872                 offset += copy;
873                 to     += copy;
874         }
875
876         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
877                 int end;
878
879                 BUG_TRAP(start <= offset + len);
880
881                 end = start + skb_shinfo(skb)->frags[i].size;
882                 if ((copy = end - offset) > 0) {
883                         u8 *vaddr;
884
885                         if (copy > len)
886                                 copy = len;
887
888                         vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]);
889                         memcpy(to,
890                                vaddr + skb_shinfo(skb)->frags[i].page_offset+
891                                offset - start, copy);
892                         kunmap_skb_frag(vaddr);
893
894                         if ((len -= copy) == 0)
895                                 return 0;
896                         offset += copy;
897                         to     += copy;
898                 }
899                 start = end;
900         }
901
902         if (skb_shinfo(skb)->frag_list) {
903                 struct sk_buff *list = skb_shinfo(skb)->frag_list;
904
905                 for (; list; list = list->next) {
906                         int end;
907
908                         BUG_TRAP(start <= offset + len);
909
910                         end = start + list->len;
911                         if ((copy = end - offset) > 0) {
912                                 if (copy > len)
913                                         copy = len;
914                                 if (skb_copy_bits(list, offset - start,
915                                                   to, copy))
916                                         goto fault;
917                                 if ((len -= copy) == 0)
918                                         return 0;
919                                 offset += copy;
920                                 to     += copy;
921                         }
922                         start = end;
923                 }
924         }
925         if (!len)
926                 return 0;
927
928 fault:
929         return -EFAULT;
930 }
931
932 /* Keep iterating until skb_iter_next returns false. */
933 void skb_iter_first(const struct sk_buff *skb, struct skb_iter *i)
934 {
935         i->len = skb_headlen(skb);
936         i->data = (unsigned char *)skb->data;
937         i->nextfrag = 0;
938         i->fraglist = NULL;
939 }
940
941 int skb_iter_next(const struct sk_buff *skb, struct skb_iter *i)
942 {
943         /* Unmap previous, if not head fragment. */
944         if (i->nextfrag)
945                 kunmap_skb_frag(i->data);
946
947         if (i->fraglist) {
948         fraglist:
949                 /* We're iterating through fraglist. */
950                 if (i->nextfrag < skb_shinfo(i->fraglist)->nr_frags) {
951                         i->data = kmap_skb_frag(&skb_shinfo(i->fraglist)
952                                                 ->frags[i->nextfrag]);
953                         i->len = skb_shinfo(i->fraglist)->frags[i->nextfrag]
954                                 .size;
955                         i->nextfrag++;
956                         return 1;
957                 }
958                 /* Fragments with fragments?  Too hard! */
959                 BUG_ON(skb_shinfo(i->fraglist)->frag_list);
960                 i->fraglist = i->fraglist->next;
961                 if (!i->fraglist)
962                         goto end;
963
964                 i->len = skb_headlen(i->fraglist);
965                 i->data = i->fraglist->data;
966                 i->nextfrag = 0;
967                 return 1;
968         }
969
970         if (i->nextfrag < skb_shinfo(skb)->nr_frags) {
971                 i->data = kmap_skb_frag(&skb_shinfo(skb)->frags[i->nextfrag]);
972                 i->len = skb_shinfo(skb)->frags[i->nextfrag].size;
973                 i->nextfrag++;
974                 return 1;
975         }
976
977         i->fraglist = skb_shinfo(skb)->frag_list;
978         if (i->fraglist)
979                 goto fraglist;
980
981 end:
982         /* Bug trap for callers */
983         i->data = NULL;
984         return 0;
985 }
986
987 void skb_iter_abort(const struct sk_buff *skb, struct skb_iter *i)
988 {
989         /* Unmap previous, if not head fragment. */
990         if (i->data && i->nextfrag)
991                 kunmap_skb_frag(i->data);
992         /* Bug trap for callers */
993         i->data = NULL;
994 }
995
996 /* Checksum skb data. */
997
998 unsigned int skb_checksum(const struct sk_buff *skb, int offset,
999                           int len, unsigned int csum)
1000 {
1001         int start = skb_headlen(skb);
1002         int i, copy = start - offset;
1003         int pos = 0;
1004
1005         /* Checksum header. */
1006         if (copy > 0) {
1007                 if (copy > len)
1008                         copy = len;
1009                 csum = csum_partial(skb->data + offset, copy, csum);
1010                 if ((len -= copy) == 0)
1011                         return csum;
1012                 offset += copy;
1013                 pos     = copy;
1014         }
1015
1016         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1017                 int end;
1018
1019                 BUG_TRAP(start <= offset + len);
1020
1021                 end = start + skb_shinfo(skb)->frags[i].size;
1022                 if ((copy = end - offset) > 0) {
1023                         unsigned int csum2;
1024                         u8 *vaddr;
1025                         skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1026
1027                         if (copy > len)
1028                                 copy = len;
1029                         vaddr = kmap_skb_frag(frag);
1030                         csum2 = csum_partial(vaddr + frag->page_offset +
1031                                              offset - start, copy, 0);
1032                         kunmap_skb_frag(vaddr);
1033                         csum = csum_block_add(csum, csum2, pos);
1034                         if (!(len -= copy))
1035                                 return csum;
1036                         offset += copy;
1037                         pos    += copy;
1038                 }
1039                 start = end;
1040         }
1041
1042         if (skb_shinfo(skb)->frag_list) {
1043                 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1044
1045                 for (; list; list = list->next) {
1046                         int end;
1047
1048                         BUG_TRAP(start <= offset + len);
1049
1050                         end = start + list->len;
1051                         if ((copy = end - offset) > 0) {
1052                                 unsigned int csum2;
1053                                 if (copy > len)
1054                                         copy = len;
1055                                 csum2 = skb_checksum(list, offset - start,
1056                                                      copy, 0);
1057                                 csum = csum_block_add(csum, csum2, pos);
1058                                 if ((len -= copy) == 0)
1059                                         return csum;
1060                                 offset += copy;
1061                                 pos    += copy;
1062                         }
1063                         start = end;
1064                 }
1065         }
1066         if (len)
1067                 BUG();
1068
1069         return csum;
1070 }
1071
1072 /* Both of above in one bottle. */
1073
1074 unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1075                                     u8 *to, int len, unsigned int csum)
1076 {
1077         int start = skb_headlen(skb);
1078         int i, copy = start - offset;
1079         int pos = 0;
1080
1081         /* Copy header. */
1082         if (copy > 0) {
1083                 if (copy > len)
1084                         copy = len;
1085                 csum = csum_partial_copy_nocheck(skb->data + offset, to,
1086                                                  copy, csum);
1087                 if ((len -= copy) == 0)
1088                         return csum;
1089                 offset += copy;
1090                 to     += copy;
1091                 pos     = copy;
1092         }
1093
1094         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1095                 int end;
1096
1097                 BUG_TRAP(start <= offset + len);
1098
1099                 end = start + skb_shinfo(skb)->frags[i].size;
1100                 if ((copy = end - offset) > 0) {
1101                         unsigned int csum2;
1102                         u8 *vaddr;
1103                         skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1104
1105                         if (copy > len)
1106                                 copy = len;
1107                         vaddr = kmap_skb_frag(frag);
1108                         csum2 = csum_partial_copy_nocheck(vaddr +
1109                                                           frag->page_offset +
1110                                                           offset - start, to,
1111                                                           copy, 0);
1112                         kunmap_skb_frag(vaddr);
1113                         csum = csum_block_add(csum, csum2, pos);
1114                         if (!(len -= copy))
1115                                 return csum;
1116                         offset += copy;
1117                         to     += copy;
1118                         pos    += copy;
1119                 }
1120                 start = end;
1121         }
1122
1123         if (skb_shinfo(skb)->frag_list) {
1124                 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1125
1126                 for (; list; list = list->next) {
1127                         unsigned int csum2;
1128                         int end;
1129
1130                         BUG_TRAP(start <= offset + len);
1131
1132                         end = start + list->len;
1133                         if ((copy = end - offset) > 0) {
1134                                 if (copy > len)
1135                                         copy = len;
1136                                 csum2 = skb_copy_and_csum_bits(list,
1137                                                                offset - start,
1138                                                                to, copy, 0);
1139                                 csum = csum_block_add(csum, csum2, pos);
1140                                 if ((len -= copy) == 0)
1141                                         return csum;
1142                                 offset += copy;
1143                                 to     += copy;
1144                                 pos    += copy;
1145                         }
1146                         start = end;
1147                 }
1148         }
1149         if (len)
1150                 BUG();
1151         return csum;
1152 }
1153
1154 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
1155 {
1156         unsigned int csum;
1157         long csstart;
1158
1159         if (skb->ip_summed == CHECKSUM_HW)
1160                 csstart = skb->h.raw - skb->data;
1161         else
1162                 csstart = skb_headlen(skb);
1163
1164         if (csstart > skb_headlen(skb))
1165                 BUG();
1166
1167         memcpy(to, skb->data, csstart);
1168
1169         csum = 0;
1170         if (csstart != skb->len)
1171                 csum = skb_copy_and_csum_bits(skb, csstart, to + csstart,
1172                                               skb->len - csstart, 0);
1173
1174         if (skb->ip_summed == CHECKSUM_HW) {
1175                 long csstuff = csstart + skb->csum;
1176
1177                 *((unsigned short *)(to + csstuff)) = csum_fold(csum);
1178         }
1179 }
1180
1181 /**
1182  *      skb_dequeue - remove from the head of the queue
1183  *      @list: list to dequeue from
1184  *
1185  *      Remove the head of the list. The list lock is taken so the function
1186  *      may be used safely with other locking list functions. The head item is
1187  *      returned or %NULL if the list is empty.
1188  */
1189
1190 struct sk_buff *skb_dequeue(struct sk_buff_head *list)
1191 {
1192         unsigned long flags;
1193         struct sk_buff *result;
1194
1195         spin_lock_irqsave(&list->lock, flags);
1196         result = __skb_dequeue(list);
1197         spin_unlock_irqrestore(&list->lock, flags);
1198         return result;
1199 }
1200
1201 /**
1202  *      skb_dequeue_tail - remove from the tail of the queue
1203  *      @list: list to dequeue from
1204  *
1205  *      Remove the tail of the list. The list lock is taken so the function
1206  *      may be used safely with other locking list functions. The tail item is
1207  *      returned or %NULL if the list is empty.
1208  */
1209 struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list)
1210 {
1211         unsigned long flags;
1212         struct sk_buff *result;
1213
1214         spin_lock_irqsave(&list->lock, flags);
1215         result = __skb_dequeue_tail(list);
1216         spin_unlock_irqrestore(&list->lock, flags);
1217         return result;
1218 }
1219
1220 /**
1221  *      skb_queue_purge - empty a list
1222  *      @list: list to empty
1223  *
1224  *      Delete all buffers on an &sk_buff list. Each buffer is removed from
1225  *      the list and one reference dropped. This function takes the list
1226  *      lock and is atomic with respect to other list locking functions.
1227  */
1228 void skb_queue_purge(struct sk_buff_head *list)
1229 {
1230         struct sk_buff *skb;
1231         while ((skb = skb_dequeue(list)) != NULL)
1232                 kfree_skb(skb);
1233 }
1234
1235 /**
1236  *      skb_queue_head - queue a buffer at the list head
1237  *      @list: list to use
1238  *      @newsk: buffer to queue
1239  *
1240  *      Queue a buffer at the start of the list. This function takes the
1241  *      list lock and can be used safely with other locking &sk_buff functions
1242  *      safely.
1243  *
1244  *      A buffer cannot be placed on two lists at the same time.
1245  */
1246 void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
1247 {
1248         unsigned long flags;
1249
1250         spin_lock_irqsave(&list->lock, flags);
1251         __skb_queue_head(list, newsk);
1252         spin_unlock_irqrestore(&list->lock, flags);
1253 }
1254
1255 /**
1256  *      skb_queue_tail - queue a buffer at the list tail
1257  *      @list: list to use
1258  *      @newsk: buffer to queue
1259  *
1260  *      Queue a buffer at the tail of the list. This function takes the
1261  *      list lock and can be used safely with other locking &sk_buff functions
1262  *      safely.
1263  *
1264  *      A buffer cannot be placed on two lists at the same time.
1265  */
1266 void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
1267 {
1268         unsigned long flags;
1269
1270         spin_lock_irqsave(&list->lock, flags);
1271         __skb_queue_tail(list, newsk);
1272         spin_unlock_irqrestore(&list->lock, flags);
1273 }
1274 /**
1275  *      skb_unlink      -       remove a buffer from a list
1276  *      @skb: buffer to remove
1277  *
1278  *      Place a packet after a given packet in a list. The list locks are taken
1279  *      and this function is atomic with respect to other list locked calls
1280  *
1281  *      Works even without knowing the list it is sitting on, which can be
1282  *      handy at times. It also means that THE LIST MUST EXIST when you
1283  *      unlink. Thus a list must have its contents unlinked before it is
1284  *      destroyed.
1285  */
1286 void skb_unlink(struct sk_buff *skb)
1287 {
1288         struct sk_buff_head *list = skb->list;
1289
1290         if (list) {
1291                 unsigned long flags;
1292
1293                 spin_lock_irqsave(&list->lock, flags);
1294                 if (skb->list == list)
1295                         __skb_unlink(skb, skb->list);
1296                 spin_unlock_irqrestore(&list->lock, flags);
1297         }
1298 }
1299
1300
1301 /**
1302  *      skb_append      -       append a buffer
1303  *      @old: buffer to insert after
1304  *      @newsk: buffer to insert
1305  *
1306  *      Place a packet after a given packet in a list. The list locks are taken
1307  *      and this function is atomic with respect to other list locked calls.
1308  *      A buffer cannot be placed on two lists at the same time.
1309  */
1310
1311 void skb_append(struct sk_buff *old, struct sk_buff *newsk)
1312 {
1313         unsigned long flags;
1314
1315         spin_lock_irqsave(&old->list->lock, flags);
1316         __skb_append(old, newsk);
1317         spin_unlock_irqrestore(&old->list->lock, flags);
1318 }
1319
1320
1321 /**
1322  *      skb_insert      -       insert a buffer
1323  *      @old: buffer to insert before
1324  *      @newsk: buffer to insert
1325  *
1326  *      Place a packet before a given packet in a list. The list locks are taken
1327  *      and this function is atomic with respect to other list locked calls
1328  *      A buffer cannot be placed on two lists at the same time.
1329  */
1330
1331 void skb_insert(struct sk_buff *old, struct sk_buff *newsk)
1332 {
1333         unsigned long flags;
1334
1335         spin_lock_irqsave(&old->list->lock, flags);
1336         __skb_insert(newsk, old->prev, old, old->list);
1337         spin_unlock_irqrestore(&old->list->lock, flags);
1338 }
1339
1340 #if 0
1341 /*
1342  *      Tune the memory allocator for a new MTU size.
1343  */
1344 void skb_add_mtu(int mtu)
1345 {
1346         /* Must match allocation in alloc_skb */
1347         mtu = SKB_DATA_ALIGN(mtu) + sizeof(struct skb_shared_info);
1348
1349         kmem_add_cache_size(mtu);
1350 }
1351 #endif
1352
1353 static void inline skb_split_inside_header(struct sk_buff *skb,
1354                                            struct sk_buff* skb1,
1355                                            const u32 len, const int pos)
1356 {
1357         int i;
1358
1359         memcpy(skb_put(skb1, pos - len), skb->data + len, pos - len);
1360
1361         /* And move data appendix as is. */
1362         for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1363                 skb_shinfo(skb1)->frags[i] = skb_shinfo(skb)->frags[i];
1364
1365         skb_shinfo(skb1)->nr_frags = skb_shinfo(skb)->nr_frags;
1366         skb_shinfo(skb)->nr_frags  = 0;
1367         skb1->data_len             = skb->data_len;
1368         skb1->len                  += skb1->data_len;
1369         skb->data_len              = 0;
1370         skb->len                   = len;
1371         skb->tail                  = skb->data + len;
1372 }
1373
1374 static void inline skb_split_no_header(struct sk_buff *skb,
1375                                        struct sk_buff* skb1,
1376                                        const u32 len, int pos)
1377 {
1378         int i, k = 0;
1379         const int nfrags = skb_shinfo(skb)->nr_frags;
1380
1381         skb_shinfo(skb)->nr_frags = 0;
1382         skb1->len                 = skb1->data_len = skb->len - len;
1383         skb->len                  = len;
1384         skb->data_len             = len - pos;
1385
1386         for (i = 0; i < nfrags; i++) {
1387                 int size = skb_shinfo(skb)->frags[i].size;
1388
1389                 if (pos + size > len) {
1390                         skb_shinfo(skb1)->frags[k] = skb_shinfo(skb)->frags[i];
1391
1392                         if (pos < len) {
1393                                 /* Split frag.
1394                                  * We have to variants in this case:
1395                                  * 1. Move all the frag to the second
1396                                  *    part, if it is possible. F.e.
1397                                  *    this approach is mandatory for TUX,
1398                                  *    where splitting is expensive.
1399                                  * 2. Split is accurately. We make this.
1400                                  */
1401                                 get_page(skb_shinfo(skb)->frags[i].page);
1402                                 skb_shinfo(skb1)->frags[0].page_offset += len - pos;
1403                                 skb_shinfo(skb1)->frags[0].size -= len - pos;
1404                                 skb_shinfo(skb)->frags[i].size  = len - pos;
1405                                 skb_shinfo(skb)->nr_frags++;
1406                         }
1407                         k++;
1408                 } else
1409                         skb_shinfo(skb)->nr_frags++;
1410                 pos += size;
1411         }
1412         skb_shinfo(skb1)->nr_frags = k;
1413 }
1414
1415 /**
1416  * skb_split - Split fragmented skb to two parts at length len.
1417  */
1418 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
1419 {
1420         int pos = skb_headlen(skb);
1421
1422         if (len < pos)  /* Split line is inside header. */
1423                 skb_split_inside_header(skb, skb1, len, pos);
1424         else            /* Second chunk has no header, nothing to copy. */
1425                 skb_split_no_header(skb, skb1, len, pos);
1426 }
1427
1428 void __init skb_init(void)
1429 {
1430         skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
1431                                               sizeof(struct sk_buff),
1432                                               0,
1433                                               SLAB_HWCACHE_ALIGN,
1434                                               NULL, NULL);
1435         if (!skbuff_head_cache)
1436                 panic("cannot create skbuff cache");
1437 }
1438
1439 EXPORT_SYMBOL(___pskb_trim);
1440 EXPORT_SYMBOL(__kfree_skb);
1441 EXPORT_SYMBOL(__pskb_pull_tail);
1442 EXPORT_SYMBOL(alloc_skb);
1443 EXPORT_SYMBOL(pskb_copy);
1444 EXPORT_SYMBOL(pskb_expand_head);
1445 EXPORT_SYMBOL(skb_checksum);
1446 EXPORT_SYMBOL(skb_clone);
1447 EXPORT_SYMBOL(skb_clone_fraglist);
1448 EXPORT_SYMBOL(skb_copy);
1449 EXPORT_SYMBOL(skb_copy_and_csum_bits);
1450 EXPORT_SYMBOL(skb_copy_and_csum_dev);
1451 EXPORT_SYMBOL(skb_copy_bits);
1452 EXPORT_SYMBOL(skb_copy_expand);
1453 EXPORT_SYMBOL(skb_over_panic);
1454 EXPORT_SYMBOL(skb_pad);
1455 EXPORT_SYMBOL(skb_realloc_headroom);
1456 EXPORT_SYMBOL(skb_under_panic);
1457 EXPORT_SYMBOL(skb_dequeue);
1458 EXPORT_SYMBOL(skb_dequeue_tail);
1459 EXPORT_SYMBOL(skb_insert);
1460 EXPORT_SYMBOL(skb_queue_purge);
1461 EXPORT_SYMBOL(skb_queue_head);
1462 EXPORT_SYMBOL(skb_queue_tail);
1463 EXPORT_SYMBOL(skb_unlink);
1464 EXPORT_SYMBOL(skb_append);
1465 EXPORT_SYMBOL(skb_split);
1466 EXPORT_SYMBOL(skb_iter_first);
1467 EXPORT_SYMBOL(skb_iter_next);
1468 EXPORT_SYMBOL(skb_iter_abort);