ia64/xen-unstable

view linux-2.6-xen-sparse/net/core/skbuff.c @ 6726:0c7379b702e5

common/kernel.o contains changeset/compiler info.
Blow away on every build.
author kaf24@firebug.cl.cam.ac.uk
date Fri Sep 09 16:26:20 2005 +0000 (2005-09-09)
parents dd668f7527cb
children b2f4823b6ff0 b35215021b32 9af349b055e5 3233e7ecfa9f
line source
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 */
37 /*
38 * The functions in this file will not compile correctly with gcc 2.4.x
39 */
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>
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>
68 #include <asm/uaccess.h>
69 #include <asm/system.h>
71 static kmem_cache_t *skbuff_head_cache;
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 */
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_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
90 "data:%p tail:%p end:%p dev:%s\n",
91 here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
92 skb->dev ? skb->dev->name : "<NULL>");
93 BUG();
94 }
96 /**
97 * skb_under_panic - private function
98 * @skb: buffer
99 * @sz: size
100 * @here: address
101 *
102 * Out of line support code for skb_push(). Not user callable.
103 */
105 void skb_under_panic(struct sk_buff *skb, int sz, void *here)
106 {
107 printk(KERN_EMERG "skb_under_panic: text:%p len:%d put:%d head:%p "
108 "data:%p tail:%p end:%p dev:%s\n",
109 here, skb->len, sz, skb->head, skb->data, skb->tail, skb->end,
110 skb->dev ? skb->dev->name : "<NULL>");
111 BUG();
112 }
114 /* Allocate a new skbuff. We do this ourselves so we can fill in a few
115 * 'private' fields and also do memory statistics to find all the
116 * [BEEP] leaks.
117 *
118 */
120 /**
121 * alloc_skb - allocate a network buffer
122 * @size: size to allocate
123 * @gfp_mask: allocation mask
124 *
125 * Allocate a new &sk_buff. The returned buffer has no headroom and a
126 * tail room of size bytes. The object has a reference count of one.
127 * The return is the buffer. On a failure the return is %NULL.
128 *
129 * Buffers may only be allocated from interrupts using a @gfp_mask of
130 * %GFP_ATOMIC.
131 */
132 struct sk_buff *alloc_skb(unsigned int size, int gfp_mask)
133 {
134 struct sk_buff *skb;
135 u8 *data;
137 /* Get the HEAD */
138 skb = kmem_cache_alloc(skbuff_head_cache,
139 gfp_mask & ~__GFP_DMA);
140 if (!skb)
141 goto out;
143 /* Get the DATA. Size must match skb_add_mtu(). */
144 size = SKB_DATA_ALIGN(size);
145 data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
146 if (!data)
147 goto nodata;
149 memset(skb, 0, offsetof(struct sk_buff, truesize));
150 skb->truesize = size + sizeof(struct sk_buff);
151 atomic_set(&skb->users, 1);
152 skb->head = data;
153 skb->data = data;
154 skb->tail = data;
155 skb->end = data + size;
157 atomic_set(&(skb_shinfo(skb)->dataref), 1);
158 skb_shinfo(skb)->nr_frags = 0;
159 skb_shinfo(skb)->tso_size = 0;
160 skb_shinfo(skb)->tso_segs = 0;
161 skb_shinfo(skb)->frag_list = NULL;
162 out:
163 return skb;
164 nodata:
165 kmem_cache_free(skbuff_head_cache, skb);
166 skb = NULL;
167 goto out;
168 }
170 /**
171 * alloc_skb_from_cache - allocate a network buffer
172 * @cp: kmem_cache from which to allocate the data area
173 * (object size must be big enough for @size bytes + skb overheads)
174 * @size: size to allocate
175 * @gfp_mask: allocation mask
176 *
177 * Allocate a new &sk_buff. The returned buffer has no headroom and
178 * tail room of size bytes. The object has a reference count of one.
179 * The return is the buffer. On a failure the return is %NULL.
180 *
181 * Buffers may only be allocated from interrupts using a @gfp_mask of
182 * %GFP_ATOMIC.
183 */
184 struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
185 unsigned int size, int gfp_mask)
186 {
187 struct sk_buff *skb;
188 u8 *data;
190 /* Get the HEAD */
191 skb = kmem_cache_alloc(skbuff_head_cache,
192 gfp_mask & ~__GFP_DMA);
193 if (!skb)
194 goto out;
196 /* Get the DATA. */
197 size = SKB_DATA_ALIGN(size);
198 data = kmem_cache_alloc(cp, gfp_mask);
199 if (!data)
200 goto nodata;
202 memset(skb, 0, offsetof(struct sk_buff, truesize));
203 skb->truesize = size + sizeof(struct sk_buff);
204 atomic_set(&skb->users, 1);
205 skb->head = data;
206 skb->data = data;
207 skb->tail = data;
208 skb->end = data + size;
210 atomic_set(&(skb_shinfo(skb)->dataref), 1);
211 skb_shinfo(skb)->nr_frags = 0;
212 skb_shinfo(skb)->tso_size = 0;
213 skb_shinfo(skb)->tso_segs = 0;
214 skb_shinfo(skb)->frag_list = NULL;
215 out:
216 return skb;
217 nodata:
218 kmem_cache_free(skbuff_head_cache, skb);
219 skb = NULL;
220 goto out;
221 }
224 static void skb_drop_fraglist(struct sk_buff *skb)
225 {
226 struct sk_buff *list = skb_shinfo(skb)->frag_list;
228 skb_shinfo(skb)->frag_list = NULL;
230 do {
231 struct sk_buff *this = list;
232 list = list->next;
233 kfree_skb(this);
234 } while (list);
235 }
237 static void skb_clone_fraglist(struct sk_buff *skb)
238 {
239 struct sk_buff *list;
241 for (list = skb_shinfo(skb)->frag_list; list; list = list->next)
242 skb_get(list);
243 }
245 void skb_release_data(struct sk_buff *skb)
246 {
247 if (!skb->cloned ||
248 !atomic_sub_return(skb->nohdr ? (1 << SKB_DATAREF_SHIFT) + 1 : 1,
249 &skb_shinfo(skb)->dataref)) {
250 if (skb_shinfo(skb)->nr_frags) {
251 int i;
252 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
253 put_page(skb_shinfo(skb)->frags[i].page);
254 }
256 if (skb_shinfo(skb)->frag_list)
257 skb_drop_fraglist(skb);
259 kfree(skb->head);
260 }
261 }
263 /*
264 * Free an skbuff by memory without cleaning the state.
265 */
266 void kfree_skbmem(struct sk_buff *skb)
267 {
268 skb_release_data(skb);
269 kmem_cache_free(skbuff_head_cache, skb);
270 }
272 /**
273 * __kfree_skb - private function
274 * @skb: buffer
275 *
276 * Free an sk_buff. Release anything attached to the buffer.
277 * Clean the state. This is an internal helper function. Users should
278 * always call kfree_skb
279 */
281 void __kfree_skb(struct sk_buff *skb)
282 {
283 BUG_ON(skb->list != NULL);
285 dst_release(skb->dst);
286 #ifdef CONFIG_XFRM
287 secpath_put(skb->sp);
288 #endif
289 if (skb->destructor) {
290 WARN_ON(in_irq());
291 skb->destructor(skb);
292 }
293 #ifdef CONFIG_NETFILTER
294 nf_conntrack_put(skb->nfct);
295 #ifdef CONFIG_BRIDGE_NETFILTER
296 nf_bridge_put(skb->nf_bridge);
297 #endif
298 #endif
299 /* XXX: IS this still necessary? - JHS */
300 #ifdef CONFIG_NET_SCHED
301 skb->tc_index = 0;
302 #ifdef CONFIG_NET_CLS_ACT
303 skb->tc_verd = 0;
304 skb->tc_classid = 0;
305 #endif
306 #endif
308 kfree_skbmem(skb);
309 }
311 /**
312 * skb_clone - duplicate an sk_buff
313 * @skb: buffer to clone
314 * @gfp_mask: allocation priority
315 *
316 * Duplicate an &sk_buff. The new one is not owned by a socket. Both
317 * copies share the same packet data but not structure. The new
318 * buffer has a reference count of 1. If the allocation fails the
319 * function returns %NULL otherwise the new buffer is returned.
320 *
321 * If this function is called from an interrupt gfp_mask() must be
322 * %GFP_ATOMIC.
323 */
325 struct sk_buff *skb_clone(struct sk_buff *skb, int gfp_mask)
326 {
327 struct sk_buff *n = kmem_cache_alloc(skbuff_head_cache, gfp_mask);
329 if (!n)
330 return NULL;
332 #define C(x) n->x = skb->x
334 n->next = n->prev = NULL;
335 n->list = NULL;
336 n->sk = NULL;
337 C(stamp);
338 C(dev);
339 C(real_dev);
340 C(h);
341 C(nh);
342 C(mac);
343 C(dst);
344 dst_clone(skb->dst);
345 C(sp);
346 #ifdef CONFIG_INET
347 secpath_get(skb->sp);
348 #endif
349 memcpy(n->cb, skb->cb, sizeof(skb->cb));
350 C(len);
351 C(data_len);
352 C(csum);
353 C(local_df);
354 n->cloned = 1;
355 n->nohdr = 0;
356 C(proto_csum_valid);
357 C(proto_csum_blank);
358 C(pkt_type);
359 C(ip_summed);
360 C(priority);
361 C(protocol);
362 C(security);
363 n->destructor = NULL;
364 #ifdef CONFIG_NETFILTER
365 C(nfmark);
366 C(nfcache);
367 C(nfct);
368 nf_conntrack_get(skb->nfct);
369 C(nfctinfo);
370 #ifdef CONFIG_NETFILTER_DEBUG
371 C(nf_debug);
372 #endif
373 #ifdef CONFIG_BRIDGE_NETFILTER
374 C(nf_bridge);
375 nf_bridge_get(skb->nf_bridge);
376 #endif
377 #endif /*CONFIG_NETFILTER*/
378 #if defined(CONFIG_HIPPI)
379 C(private);
380 #endif
381 #ifdef CONFIG_NET_SCHED
382 C(tc_index);
383 #ifdef CONFIG_NET_CLS_ACT
384 n->tc_verd = SET_TC_VERD(skb->tc_verd,0);
385 n->tc_verd = CLR_TC_OK2MUNGE(skb->tc_verd);
386 n->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
387 C(input_dev);
388 C(tc_classid);
389 #endif
391 #endif
392 C(truesize);
393 atomic_set(&n->users, 1);
394 C(head);
395 C(data);
396 C(tail);
397 C(end);
399 atomic_inc(&(skb_shinfo(skb)->dataref));
400 skb->cloned = 1;
402 return n;
403 }
405 static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
406 {
407 /*
408 * Shift between the two data areas in bytes
409 */
410 unsigned long offset = new->data - old->data;
412 new->list = NULL;
413 new->sk = NULL;
414 new->dev = old->dev;
415 new->real_dev = old->real_dev;
416 new->priority = old->priority;
417 new->protocol = old->protocol;
418 new->dst = dst_clone(old->dst);
419 #ifdef CONFIG_INET
420 new->sp = secpath_get(old->sp);
421 #endif
422 new->h.raw = old->h.raw + offset;
423 new->nh.raw = old->nh.raw + offset;
424 new->mac.raw = old->mac.raw + offset;
425 memcpy(new->cb, old->cb, sizeof(old->cb));
426 new->local_df = old->local_df;
427 new->pkt_type = old->pkt_type;
428 new->stamp = old->stamp;
429 new->destructor = NULL;
430 new->security = old->security;
431 #ifdef CONFIG_NETFILTER
432 new->nfmark = old->nfmark;
433 new->nfcache = old->nfcache;
434 new->nfct = old->nfct;
435 nf_conntrack_get(old->nfct);
436 new->nfctinfo = old->nfctinfo;
437 #ifdef CONFIG_NETFILTER_DEBUG
438 new->nf_debug = old->nf_debug;
439 #endif
440 #ifdef CONFIG_BRIDGE_NETFILTER
441 new->nf_bridge = old->nf_bridge;
442 nf_bridge_get(old->nf_bridge);
443 #endif
444 #endif
445 #ifdef CONFIG_NET_SCHED
446 #ifdef CONFIG_NET_CLS_ACT
447 new->tc_verd = old->tc_verd;
448 #endif
449 new->tc_index = old->tc_index;
450 #endif
451 atomic_set(&new->users, 1);
452 skb_shinfo(new)->tso_size = skb_shinfo(old)->tso_size;
453 skb_shinfo(new)->tso_segs = skb_shinfo(old)->tso_segs;
454 }
456 /**
457 * skb_copy - create private copy of an sk_buff
458 * @skb: buffer to copy
459 * @gfp_mask: allocation priority
460 *
461 * Make a copy of both an &sk_buff and its data. This is used when the
462 * caller wishes to modify the data and needs a private copy of the
463 * data to alter. Returns %NULL on failure or the pointer to the buffer
464 * on success. The returned buffer has a reference count of 1.
465 *
466 * As by-product this function converts non-linear &sk_buff to linear
467 * one, so that &sk_buff becomes completely private and caller is allowed
468 * to modify all the data of returned buffer. This means that this
469 * function is not recommended for use in circumstances when only
470 * header is going to be modified. Use pskb_copy() instead.
471 */
473 struct sk_buff *skb_copy(const struct sk_buff *skb, int gfp_mask)
474 {
475 int headerlen = skb->data - skb->head;
476 /*
477 * Allocate the copy buffer
478 */
479 struct sk_buff *n = alloc_skb(skb->end - skb->head + skb->data_len,
480 gfp_mask);
481 if (!n)
482 return NULL;
484 /* Set the data pointer */
485 skb_reserve(n, headerlen);
486 /* Set the tail pointer and length */
487 skb_put(n, skb->len);
488 n->csum = skb->csum;
489 n->ip_summed = skb->ip_summed;
491 if (skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len))
492 BUG();
494 copy_skb_header(n, skb);
495 return n;
496 }
499 /**
500 * pskb_copy - create copy of an sk_buff with private head.
501 * @skb: buffer to copy
502 * @gfp_mask: allocation priority
503 *
504 * Make a copy of both an &sk_buff and part of its data, located
505 * in header. Fragmented data remain shared. This is used when
506 * the caller wishes to modify only header of &sk_buff and needs
507 * private copy of the header to alter. Returns %NULL on failure
508 * or the pointer to the buffer on success.
509 * The returned buffer has a reference count of 1.
510 */
512 struct sk_buff *pskb_copy(struct sk_buff *skb, int gfp_mask)
513 {
514 /*
515 * Allocate the copy buffer
516 */
517 struct sk_buff *n = alloc_skb(skb->end - skb->head, gfp_mask);
519 if (!n)
520 goto out;
522 /* Set the data pointer */
523 skb_reserve(n, skb->data - skb->head);
524 /* Set the tail pointer and length */
525 skb_put(n, skb_headlen(skb));
526 /* Copy the bytes */
527 memcpy(n->data, skb->data, n->len);
528 n->csum = skb->csum;
529 n->ip_summed = skb->ip_summed;
531 n->data_len = skb->data_len;
532 n->len = skb->len;
534 if (skb_shinfo(skb)->nr_frags) {
535 int i;
537 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
538 skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i];
539 get_page(skb_shinfo(n)->frags[i].page);
540 }
541 skb_shinfo(n)->nr_frags = i;
542 }
544 if (skb_shinfo(skb)->frag_list) {
545 skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list;
546 skb_clone_fraglist(n);
547 }
549 copy_skb_header(n, skb);
550 out:
551 return n;
552 }
554 /**
555 * pskb_expand_head - reallocate header of &sk_buff
556 * @skb: buffer to reallocate
557 * @nhead: room to add at head
558 * @ntail: room to add at tail
559 * @gfp_mask: allocation priority
560 *
561 * Expands (or creates identical copy, if &nhead and &ntail are zero)
562 * header of skb. &sk_buff itself is not changed. &sk_buff MUST have
563 * reference count of 1. Returns zero in the case of success or error,
564 * if expansion failed. In the last case, &sk_buff is not changed.
565 *
566 * All the pointers pointing into skb header may change and must be
567 * reloaded after call to this function.
568 */
570 int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, int gfp_mask)
571 {
572 int i;
573 u8 *data;
574 int size = nhead + (skb->end - skb->head) + ntail;
575 long off;
577 if (skb_shared(skb))
578 BUG();
580 size = SKB_DATA_ALIGN(size);
582 data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
583 if (!data)
584 goto nodata;
586 /* Copy only real data... and, alas, header. This should be
587 * optimized for the cases when header is void. */
588 memcpy(data + nhead, skb->head, skb->tail - skb->head);
589 memcpy(data + size, skb->end, sizeof(struct skb_shared_info));
591 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
592 get_page(skb_shinfo(skb)->frags[i].page);
594 if (skb_shinfo(skb)->frag_list)
595 skb_clone_fraglist(skb);
597 skb_release_data(skb);
599 off = (data + nhead) - skb->head;
601 skb->head = data;
602 skb->end = data + size;
603 skb->data += off;
604 skb->tail += off;
605 skb->mac.raw += off;
606 skb->h.raw += off;
607 skb->nh.raw += off;
608 skb->cloned = 0;
609 skb->nohdr = 0;
610 atomic_set(&skb_shinfo(skb)->dataref, 1);
611 return 0;
613 nodata:
614 return -ENOMEM;
615 }
617 /* Make private copy of skb with writable head and some headroom */
619 struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom)
620 {
621 struct sk_buff *skb2;
622 int delta = headroom - skb_headroom(skb);
624 if (delta <= 0)
625 skb2 = pskb_copy(skb, GFP_ATOMIC);
626 else {
627 skb2 = skb_clone(skb, GFP_ATOMIC);
628 if (skb2 && pskb_expand_head(skb2, SKB_DATA_ALIGN(delta), 0,
629 GFP_ATOMIC)) {
630 kfree_skb(skb2);
631 skb2 = NULL;
632 }
633 }
634 return skb2;
635 }
638 /**
639 * skb_copy_expand - copy and expand sk_buff
640 * @skb: buffer to copy
641 * @newheadroom: new free bytes at head
642 * @newtailroom: new free bytes at tail
643 * @gfp_mask: allocation priority
644 *
645 * Make a copy of both an &sk_buff and its data and while doing so
646 * allocate additional space.
647 *
648 * This is used when the caller wishes to modify the data and needs a
649 * private copy of the data to alter as well as more space for new fields.
650 * Returns %NULL on failure or the pointer to the buffer
651 * on success. The returned buffer has a reference count of 1.
652 *
653 * You must pass %GFP_ATOMIC as the allocation priority if this function
654 * is called from an interrupt.
655 *
656 * BUG ALERT: ip_summed is not copied. Why does this work? Is it used
657 * only by netfilter in the cases when checksum is recalculated? --ANK
658 */
659 struct sk_buff *skb_copy_expand(const struct sk_buff *skb,
660 int newheadroom, int newtailroom, int gfp_mask)
661 {
662 /*
663 * Allocate the copy buffer
664 */
665 struct sk_buff *n = alloc_skb(newheadroom + skb->len + newtailroom,
666 gfp_mask);
667 int head_copy_len, head_copy_off;
669 if (!n)
670 return NULL;
672 skb_reserve(n, newheadroom);
674 /* Set the tail pointer and length */
675 skb_put(n, skb->len);
677 head_copy_len = skb_headroom(skb);
678 head_copy_off = 0;
679 if (newheadroom <= head_copy_len)
680 head_copy_len = newheadroom;
681 else
682 head_copy_off = newheadroom - head_copy_len;
684 /* Copy the linear header and data. */
685 if (skb_copy_bits(skb, -head_copy_len, n->head + head_copy_off,
686 skb->len + head_copy_len))
687 BUG();
689 copy_skb_header(n, skb);
691 return n;
692 }
694 /**
695 * skb_pad - zero pad the tail of an skb
696 * @skb: buffer to pad
697 * @pad: space to pad
698 *
699 * Ensure that a buffer is followed by a padding area that is zero
700 * filled. Used by network drivers which may DMA or transfer data
701 * beyond the buffer end onto the wire.
702 *
703 * May return NULL in out of memory cases.
704 */
706 struct sk_buff *skb_pad(struct sk_buff *skb, int pad)
707 {
708 struct sk_buff *nskb;
710 /* If the skbuff is non linear tailroom is always zero.. */
711 if (skb_tailroom(skb) >= pad) {
712 memset(skb->data+skb->len, 0, pad);
713 return skb;
714 }
716 nskb = skb_copy_expand(skb, skb_headroom(skb), skb_tailroom(skb) + pad, GFP_ATOMIC);
717 kfree_skb(skb);
718 if (nskb)
719 memset(nskb->data+nskb->len, 0, pad);
720 return nskb;
721 }
723 /* Trims skb to length len. It can change skb pointers, if "realloc" is 1.
724 * If realloc==0 and trimming is impossible without change of data,
725 * it is BUG().
726 */
728 int ___pskb_trim(struct sk_buff *skb, unsigned int len, int realloc)
729 {
730 int offset = skb_headlen(skb);
731 int nfrags = skb_shinfo(skb)->nr_frags;
732 int i;
734 for (i = 0; i < nfrags; i++) {
735 int end = offset + skb_shinfo(skb)->frags[i].size;
736 if (end > len) {
737 if (skb_cloned(skb)) {
738 if (!realloc)
739 BUG();
740 if (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
741 return -ENOMEM;
742 }
743 if (len <= offset) {
744 put_page(skb_shinfo(skb)->frags[i].page);
745 skb_shinfo(skb)->nr_frags--;
746 } else {
747 skb_shinfo(skb)->frags[i].size = len - offset;
748 }
749 }
750 offset = end;
751 }
753 if (offset < len) {
754 skb->data_len -= skb->len - len;
755 skb->len = len;
756 } else {
757 if (len <= skb_headlen(skb)) {
758 skb->len = len;
759 skb->data_len = 0;
760 skb->tail = skb->data + len;
761 if (skb_shinfo(skb)->frag_list && !skb_cloned(skb))
762 skb_drop_fraglist(skb);
763 } else {
764 skb->data_len -= skb->len - len;
765 skb->len = len;
766 }
767 }
769 return 0;
770 }
772 /**
773 * __pskb_pull_tail - advance tail of skb header
774 * @skb: buffer to reallocate
775 * @delta: number of bytes to advance tail
776 *
777 * The function makes a sense only on a fragmented &sk_buff,
778 * it expands header moving its tail forward and copying necessary
779 * data from fragmented part.
780 *
781 * &sk_buff MUST have reference count of 1.
782 *
783 * Returns %NULL (and &sk_buff does not change) if pull failed
784 * or value of new tail of skb in the case of success.
785 *
786 * All the pointers pointing into skb header may change and must be
787 * reloaded after call to this function.
788 */
790 /* Moves tail of skb head forward, copying data from fragmented part,
791 * when it is necessary.
792 * 1. It may fail due to malloc failure.
793 * 2. It may change skb pointers.
794 *
795 * It is pretty complicated. Luckily, it is called only in exceptional cases.
796 */
797 unsigned char *__pskb_pull_tail(struct sk_buff *skb, int delta)
798 {
799 /* If skb has not enough free space at tail, get new one
800 * plus 128 bytes for future expansions. If we have enough
801 * room at tail, reallocate without expansion only if skb is cloned.
802 */
803 int i, k, eat = (skb->tail + delta) - skb->end;
805 if (eat > 0 || skb_cloned(skb)) {
806 if (pskb_expand_head(skb, 0, eat > 0 ? eat + 128 : 0,
807 GFP_ATOMIC))
808 return NULL;
809 }
811 if (skb_copy_bits(skb, skb_headlen(skb), skb->tail, delta))
812 BUG();
814 /* Optimization: no fragments, no reasons to preestimate
815 * size of pulled pages. Superb.
816 */
817 if (!skb_shinfo(skb)->frag_list)
818 goto pull_pages;
820 /* Estimate size of pulled pages. */
821 eat = delta;
822 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
823 if (skb_shinfo(skb)->frags[i].size >= eat)
824 goto pull_pages;
825 eat -= skb_shinfo(skb)->frags[i].size;
826 }
828 /* If we need update frag list, we are in troubles.
829 * Certainly, it possible to add an offset to skb data,
830 * but taking into account that pulling is expected to
831 * be very rare operation, it is worth to fight against
832 * further bloating skb head and crucify ourselves here instead.
833 * Pure masohism, indeed. 8)8)
834 */
835 if (eat) {
836 struct sk_buff *list = skb_shinfo(skb)->frag_list;
837 struct sk_buff *clone = NULL;
838 struct sk_buff *insp = NULL;
840 do {
841 if (!list)
842 BUG();
844 if (list->len <= eat) {
845 /* Eaten as whole. */
846 eat -= list->len;
847 list = list->next;
848 insp = list;
849 } else {
850 /* Eaten partially. */
852 if (skb_shared(list)) {
853 /* Sucks! We need to fork list. :-( */
854 clone = skb_clone(list, GFP_ATOMIC);
855 if (!clone)
856 return NULL;
857 insp = list->next;
858 list = clone;
859 } else {
860 /* This may be pulled without
861 * problems. */
862 insp = list;
863 }
864 if (!pskb_pull(list, eat)) {
865 if (clone)
866 kfree_skb(clone);
867 return NULL;
868 }
869 break;
870 }
871 } while (eat);
873 /* Free pulled out fragments. */
874 while ((list = skb_shinfo(skb)->frag_list) != insp) {
875 skb_shinfo(skb)->frag_list = list->next;
876 kfree_skb(list);
877 }
878 /* And insert new clone at head. */
879 if (clone) {
880 clone->next = list;
881 skb_shinfo(skb)->frag_list = clone;
882 }
883 }
884 /* Success! Now we may commit changes to skb data. */
886 pull_pages:
887 eat = delta;
888 k = 0;
889 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
890 if (skb_shinfo(skb)->frags[i].size <= eat) {
891 put_page(skb_shinfo(skb)->frags[i].page);
892 eat -= skb_shinfo(skb)->frags[i].size;
893 } else {
894 skb_shinfo(skb)->frags[k] = skb_shinfo(skb)->frags[i];
895 if (eat) {
896 skb_shinfo(skb)->frags[k].page_offset += eat;
897 skb_shinfo(skb)->frags[k].size -= eat;
898 eat = 0;
899 }
900 k++;
901 }
902 }
903 skb_shinfo(skb)->nr_frags = k;
905 skb->tail += delta;
906 skb->data_len -= delta;
908 return skb->tail;
909 }
911 /* Copy some data bits from skb to kernel buffer. */
913 int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len)
914 {
915 int i, copy;
916 int start = skb_headlen(skb);
918 if (offset > (int)skb->len - len)
919 goto fault;
921 /* Copy header. */
922 if ((copy = start - offset) > 0) {
923 if (copy > len)
924 copy = len;
925 memcpy(to, skb->data + offset, copy);
926 if ((len -= copy) == 0)
927 return 0;
928 offset += copy;
929 to += copy;
930 }
932 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
933 int end;
935 BUG_TRAP(start <= offset + len);
937 end = start + skb_shinfo(skb)->frags[i].size;
938 if ((copy = end - offset) > 0) {
939 u8 *vaddr;
941 if (copy > len)
942 copy = len;
944 vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[i]);
945 memcpy(to,
946 vaddr + skb_shinfo(skb)->frags[i].page_offset+
947 offset - start, copy);
948 kunmap_skb_frag(vaddr);
950 if ((len -= copy) == 0)
951 return 0;
952 offset += copy;
953 to += copy;
954 }
955 start = end;
956 }
958 if (skb_shinfo(skb)->frag_list) {
959 struct sk_buff *list = skb_shinfo(skb)->frag_list;
961 for (; list; list = list->next) {
962 int end;
964 BUG_TRAP(start <= offset + len);
966 end = start + list->len;
967 if ((copy = end - offset) > 0) {
968 if (copy > len)
969 copy = len;
970 if (skb_copy_bits(list, offset - start,
971 to, copy))
972 goto fault;
973 if ((len -= copy) == 0)
974 return 0;
975 offset += copy;
976 to += copy;
977 }
978 start = end;
979 }
980 }
981 if (!len)
982 return 0;
984 fault:
985 return -EFAULT;
986 }
988 /**
989 * skb_store_bits - store bits from kernel buffer to skb
990 * @skb: destination buffer
991 * @offset: offset in destination
992 * @from: source buffer
993 * @len: number of bytes to copy
994 *
995 * Copy the specified number of bytes from the source buffer to the
996 * destination skb. This function handles all the messy bits of
997 * traversing fragment lists and such.
998 */
1000 int skb_store_bits(const struct sk_buff *skb, int offset, void *from, int len)
1002 int i, copy;
1003 int start = skb_headlen(skb);
1005 if (offset > (int)skb->len - len)
1006 goto fault;
1008 if ((copy = start - offset) > 0) {
1009 if (copy > len)
1010 copy = len;
1011 memcpy(skb->data + offset, from, copy);
1012 if ((len -= copy) == 0)
1013 return 0;
1014 offset += copy;
1015 from += copy;
1018 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1019 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1020 int end;
1022 BUG_TRAP(start <= offset + len);
1024 end = start + frag->size;
1025 if ((copy = end - offset) > 0) {
1026 u8 *vaddr;
1028 if (copy > len)
1029 copy = len;
1031 vaddr = kmap_skb_frag(frag);
1032 memcpy(vaddr + frag->page_offset + offset - start,
1033 from, copy);
1034 kunmap_skb_frag(vaddr);
1036 if ((len -= copy) == 0)
1037 return 0;
1038 offset += copy;
1039 from += copy;
1041 start = end;
1044 if (skb_shinfo(skb)->frag_list) {
1045 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1047 for (; list; list = list->next) {
1048 int end;
1050 BUG_TRAP(start <= offset + len);
1052 end = start + list->len;
1053 if ((copy = end - offset) > 0) {
1054 if (copy > len)
1055 copy = len;
1056 if (skb_store_bits(list, offset - start,
1057 from, copy))
1058 goto fault;
1059 if ((len -= copy) == 0)
1060 return 0;
1061 offset += copy;
1062 from += copy;
1064 start = end;
1067 if (!len)
1068 return 0;
1070 fault:
1071 return -EFAULT;
1074 EXPORT_SYMBOL(skb_store_bits);
1076 /* Checksum skb data. */
1078 unsigned int skb_checksum(const struct sk_buff *skb, int offset,
1079 int len, unsigned int csum)
1081 int start = skb_headlen(skb);
1082 int i, copy = start - offset;
1083 int pos = 0;
1085 /* Checksum header. */
1086 if (copy > 0) {
1087 if (copy > len)
1088 copy = len;
1089 csum = csum_partial(skb->data + offset, copy, csum);
1090 if ((len -= copy) == 0)
1091 return csum;
1092 offset += copy;
1093 pos = copy;
1096 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1097 int end;
1099 BUG_TRAP(start <= offset + len);
1101 end = start + skb_shinfo(skb)->frags[i].size;
1102 if ((copy = end - offset) > 0) {
1103 unsigned int csum2;
1104 u8 *vaddr;
1105 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1107 if (copy > len)
1108 copy = len;
1109 vaddr = kmap_skb_frag(frag);
1110 csum2 = csum_partial(vaddr + frag->page_offset +
1111 offset - start, 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 pos += copy;
1119 start = end;
1122 if (skb_shinfo(skb)->frag_list) {
1123 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1125 for (; list; list = list->next) {
1126 int end;
1128 BUG_TRAP(start <= offset + len);
1130 end = start + list->len;
1131 if ((copy = end - offset) > 0) {
1132 unsigned int csum2;
1133 if (copy > len)
1134 copy = len;
1135 csum2 = skb_checksum(list, offset - start,
1136 copy, 0);
1137 csum = csum_block_add(csum, csum2, pos);
1138 if ((len -= copy) == 0)
1139 return csum;
1140 offset += copy;
1141 pos += copy;
1143 start = end;
1146 if (len)
1147 BUG();
1149 return csum;
1152 /* Both of above in one bottle. */
1154 unsigned int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
1155 u8 *to, int len, unsigned int csum)
1157 int start = skb_headlen(skb);
1158 int i, copy = start - offset;
1159 int pos = 0;
1161 /* Copy header. */
1162 if (copy > 0) {
1163 if (copy > len)
1164 copy = len;
1165 csum = csum_partial_copy_nocheck(skb->data + offset, to,
1166 copy, csum);
1167 if ((len -= copy) == 0)
1168 return csum;
1169 offset += copy;
1170 to += copy;
1171 pos = copy;
1174 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1175 int end;
1177 BUG_TRAP(start <= offset + len);
1179 end = start + skb_shinfo(skb)->frags[i].size;
1180 if ((copy = end - offset) > 0) {
1181 unsigned int csum2;
1182 u8 *vaddr;
1183 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1185 if (copy > len)
1186 copy = len;
1187 vaddr = kmap_skb_frag(frag);
1188 csum2 = csum_partial_copy_nocheck(vaddr +
1189 frag->page_offset +
1190 offset - start, to,
1191 copy, 0);
1192 kunmap_skb_frag(vaddr);
1193 csum = csum_block_add(csum, csum2, pos);
1194 if (!(len -= copy))
1195 return csum;
1196 offset += copy;
1197 to += copy;
1198 pos += copy;
1200 start = end;
1203 if (skb_shinfo(skb)->frag_list) {
1204 struct sk_buff *list = skb_shinfo(skb)->frag_list;
1206 for (; list; list = list->next) {
1207 unsigned int csum2;
1208 int end;
1210 BUG_TRAP(start <= offset + len);
1212 end = start + list->len;
1213 if ((copy = end - offset) > 0) {
1214 if (copy > len)
1215 copy = len;
1216 csum2 = skb_copy_and_csum_bits(list,
1217 offset - start,
1218 to, copy, 0);
1219 csum = csum_block_add(csum, csum2, pos);
1220 if ((len -= copy) == 0)
1221 return csum;
1222 offset += copy;
1223 to += copy;
1224 pos += copy;
1226 start = end;
1229 if (len)
1230 BUG();
1231 return csum;
1234 void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
1236 unsigned int csum;
1237 long csstart;
1239 if (skb->ip_summed == CHECKSUM_HW)
1240 csstart = skb->h.raw - skb->data;
1241 else
1242 csstart = skb_headlen(skb);
1244 if (csstart > skb_headlen(skb))
1245 BUG();
1247 memcpy(to, skb->data, csstart);
1249 csum = 0;
1250 if (csstart != skb->len)
1251 csum = skb_copy_and_csum_bits(skb, csstart, to + csstart,
1252 skb->len - csstart, 0);
1254 if (skb->ip_summed == CHECKSUM_HW) {
1255 long csstuff = csstart + skb->csum;
1257 *((unsigned short *)(to + csstuff)) = csum_fold(csum);
1261 /**
1262 * skb_dequeue - remove from the head of the queue
1263 * @list: list to dequeue from
1265 * Remove the head of the list. The list lock is taken so the function
1266 * may be used safely with other locking list functions. The head item is
1267 * returned or %NULL if the list is empty.
1268 */
1270 struct sk_buff *skb_dequeue(struct sk_buff_head *list)
1272 unsigned long flags;
1273 struct sk_buff *result;
1275 spin_lock_irqsave(&list->lock, flags);
1276 result = __skb_dequeue(list);
1277 spin_unlock_irqrestore(&list->lock, flags);
1278 return result;
1281 /**
1282 * skb_dequeue_tail - remove from the tail of the queue
1283 * @list: list to dequeue from
1285 * Remove the tail of the list. The list lock is taken so the function
1286 * may be used safely with other locking list functions. The tail item is
1287 * returned or %NULL if the list is empty.
1288 */
1289 struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list)
1291 unsigned long flags;
1292 struct sk_buff *result;
1294 spin_lock_irqsave(&list->lock, flags);
1295 result = __skb_dequeue_tail(list);
1296 spin_unlock_irqrestore(&list->lock, flags);
1297 return result;
1300 /**
1301 * skb_queue_purge - empty a list
1302 * @list: list to empty
1304 * Delete all buffers on an &sk_buff list. Each buffer is removed from
1305 * the list and one reference dropped. This function takes the list
1306 * lock and is atomic with respect to other list locking functions.
1307 */
1308 void skb_queue_purge(struct sk_buff_head *list)
1310 struct sk_buff *skb;
1311 while ((skb = skb_dequeue(list)) != NULL)
1312 kfree_skb(skb);
1315 /**
1316 * skb_queue_head - queue a buffer at the list head
1317 * @list: list to use
1318 * @newsk: buffer to queue
1320 * Queue a buffer at the start of the list. This function takes the
1321 * list lock and can be used safely with other locking &sk_buff functions
1322 * safely.
1324 * A buffer cannot be placed on two lists at the same time.
1325 */
1326 void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk)
1328 unsigned long flags;
1330 spin_lock_irqsave(&list->lock, flags);
1331 __skb_queue_head(list, newsk);
1332 spin_unlock_irqrestore(&list->lock, flags);
1335 /**
1336 * skb_queue_tail - queue a buffer at the list tail
1337 * @list: list to use
1338 * @newsk: buffer to queue
1340 * Queue a buffer at the tail of the list. This function takes the
1341 * list lock and can be used safely with other locking &sk_buff functions
1342 * safely.
1344 * A buffer cannot be placed on two lists at the same time.
1345 */
1346 void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk)
1348 unsigned long flags;
1350 spin_lock_irqsave(&list->lock, flags);
1351 __skb_queue_tail(list, newsk);
1352 spin_unlock_irqrestore(&list->lock, flags);
1354 /**
1355 * skb_unlink - remove a buffer from a list
1356 * @skb: buffer to remove
1358 * Place a packet after a given packet in a list. The list locks are taken
1359 * and this function is atomic with respect to other list locked calls
1361 * Works even without knowing the list it is sitting on, which can be
1362 * handy at times. It also means that THE LIST MUST EXIST when you
1363 * unlink. Thus a list must have its contents unlinked before it is
1364 * destroyed.
1365 */
1366 void skb_unlink(struct sk_buff *skb)
1368 struct sk_buff_head *list = skb->list;
1370 if (list) {
1371 unsigned long flags;
1373 spin_lock_irqsave(&list->lock, flags);
1374 if (skb->list == list)
1375 __skb_unlink(skb, skb->list);
1376 spin_unlock_irqrestore(&list->lock, flags);
1381 /**
1382 * skb_append - append a buffer
1383 * @old: buffer to insert after
1384 * @newsk: buffer to insert
1386 * Place a packet after a given packet in a list. The list locks are taken
1387 * and this function is atomic with respect to other list locked calls.
1388 * A buffer cannot be placed on two lists at the same time.
1389 */
1391 void skb_append(struct sk_buff *old, struct sk_buff *newsk)
1393 unsigned long flags;
1395 spin_lock_irqsave(&old->list->lock, flags);
1396 __skb_append(old, newsk);
1397 spin_unlock_irqrestore(&old->list->lock, flags);
1401 /**
1402 * skb_insert - insert a buffer
1403 * @old: buffer to insert before
1404 * @newsk: buffer to insert
1406 * Place a packet before a given packet in a list. The list locks are taken
1407 * and this function is atomic with respect to other list locked calls
1408 * A buffer cannot be placed on two lists at the same time.
1409 */
1411 void skb_insert(struct sk_buff *old, struct sk_buff *newsk)
1413 unsigned long flags;
1415 spin_lock_irqsave(&old->list->lock, flags);
1416 __skb_insert(newsk, old->prev, old, old->list);
1417 spin_unlock_irqrestore(&old->list->lock, flags);
1420 #if 0
1421 /*
1422 * Tune the memory allocator for a new MTU size.
1423 */
1424 void skb_add_mtu(int mtu)
1426 /* Must match allocation in alloc_skb */
1427 mtu = SKB_DATA_ALIGN(mtu) + sizeof(struct skb_shared_info);
1429 kmem_add_cache_size(mtu);
1431 #endif
1433 static inline void skb_split_inside_header(struct sk_buff *skb,
1434 struct sk_buff* skb1,
1435 const u32 len, const int pos)
1437 int i;
1439 memcpy(skb_put(skb1, pos - len), skb->data + len, pos - len);
1441 /* And move data appendix as is. */
1442 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++)
1443 skb_shinfo(skb1)->frags[i] = skb_shinfo(skb)->frags[i];
1445 skb_shinfo(skb1)->nr_frags = skb_shinfo(skb)->nr_frags;
1446 skb_shinfo(skb)->nr_frags = 0;
1447 skb1->data_len = skb->data_len;
1448 skb1->len += skb1->data_len;
1449 skb->data_len = 0;
1450 skb->len = len;
1451 skb->tail = skb->data + len;
1454 static inline void skb_split_no_header(struct sk_buff *skb,
1455 struct sk_buff* skb1,
1456 const u32 len, int pos)
1458 int i, k = 0;
1459 const int nfrags = skb_shinfo(skb)->nr_frags;
1461 skb_shinfo(skb)->nr_frags = 0;
1462 skb1->len = skb1->data_len = skb->len - len;
1463 skb->len = len;
1464 skb->data_len = len - pos;
1466 for (i = 0; i < nfrags; i++) {
1467 int size = skb_shinfo(skb)->frags[i].size;
1469 if (pos + size > len) {
1470 skb_shinfo(skb1)->frags[k] = skb_shinfo(skb)->frags[i];
1472 if (pos < len) {
1473 /* Split frag.
1474 * We have two variants in this case:
1475 * 1. Move all the frag to the second
1476 * part, if it is possible. F.e.
1477 * this approach is mandatory for TUX,
1478 * where splitting is expensive.
1479 * 2. Split is accurately. We make this.
1480 */
1481 get_page(skb_shinfo(skb)->frags[i].page);
1482 skb_shinfo(skb1)->frags[0].page_offset += len - pos;
1483 skb_shinfo(skb1)->frags[0].size -= len - pos;
1484 skb_shinfo(skb)->frags[i].size = len - pos;
1485 skb_shinfo(skb)->nr_frags++;
1487 k++;
1488 } else
1489 skb_shinfo(skb)->nr_frags++;
1490 pos += size;
1492 skb_shinfo(skb1)->nr_frags = k;
1495 /**
1496 * skb_split - Split fragmented skb to two parts at length len.
1497 * @skb: the buffer to split
1498 * @skb1: the buffer to receive the second part
1499 * @len: new length for skb
1500 */
1501 void skb_split(struct sk_buff *skb, struct sk_buff *skb1, const u32 len)
1503 int pos = skb_headlen(skb);
1505 if (len < pos) /* Split line is inside header. */
1506 skb_split_inside_header(skb, skb1, len, pos);
1507 else /* Second chunk has no header, nothing to copy. */
1508 skb_split_no_header(skb, skb1, len, pos);
1511 void __init skb_init(void)
1513 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
1514 sizeof(struct sk_buff),
1515 0,
1516 SLAB_HWCACHE_ALIGN,
1517 NULL, NULL);
1518 if (!skbuff_head_cache)
1519 panic("cannot create skbuff cache");
1522 EXPORT_SYMBOL(___pskb_trim);
1523 EXPORT_SYMBOL(__kfree_skb);
1524 EXPORT_SYMBOL(__pskb_pull_tail);
1525 EXPORT_SYMBOL(alloc_skb);
1526 EXPORT_SYMBOL(pskb_copy);
1527 EXPORT_SYMBOL(pskb_expand_head);
1528 EXPORT_SYMBOL(skb_checksum);
1529 EXPORT_SYMBOL(skb_clone);
1530 EXPORT_SYMBOL(skb_clone_fraglist);
1531 EXPORT_SYMBOL(skb_copy);
1532 EXPORT_SYMBOL(skb_copy_and_csum_bits);
1533 EXPORT_SYMBOL(skb_copy_and_csum_dev);
1534 EXPORT_SYMBOL(skb_copy_bits);
1535 EXPORT_SYMBOL(skb_copy_expand);
1536 EXPORT_SYMBOL(skb_over_panic);
1537 EXPORT_SYMBOL(skb_pad);
1538 EXPORT_SYMBOL(skb_realloc_headroom);
1539 EXPORT_SYMBOL(skb_under_panic);
1540 EXPORT_SYMBOL(skb_dequeue);
1541 EXPORT_SYMBOL(skb_dequeue_tail);
1542 EXPORT_SYMBOL(skb_insert);
1543 EXPORT_SYMBOL(skb_queue_purge);
1544 EXPORT_SYMBOL(skb_queue_head);
1545 EXPORT_SYMBOL(skb_queue_tail);
1546 EXPORT_SYMBOL(skb_unlink);
1547 EXPORT_SYMBOL(skb_append);
1548 EXPORT_SYMBOL(skb_split);