|
@@ -280,13 +280,14 @@ nodata:
|
|
|
EXPORT_SYMBOL(__alloc_skb);
|
|
|
|
|
|
/**
|
|
|
- * build_skb - build a network buffer
|
|
|
+ * __build_skb - build a network buffer
|
|
|
* @data: data buffer provided by caller
|
|
|
- * @frag_size: size of fragment, or 0 if head was kmalloced
|
|
|
+ * @frag_size: size of data, or 0 if head was kmalloced
|
|
|
*
|
|
|
* Allocate a new &sk_buff. Caller provides space holding head and
|
|
|
* skb_shared_info. @data must have been allocated by kmalloc() only if
|
|
|
- * @frag_size is 0, otherwise data should come from the page allocator.
|
|
|
+ * @frag_size is 0, otherwise data should come from the page allocator
|
|
|
+ * or vmalloc()
|
|
|
* The return is the new skb buffer.
|
|
|
* On a failure the return is %NULL, and @data is not freed.
|
|
|
* Notes :
|
|
@@ -297,7 +298,7 @@ EXPORT_SYMBOL(__alloc_skb);
|
|
|
* before giving packet to stack.
|
|
|
* RX rings only contains data buffers, not full skbs.
|
|
|
*/
|
|
|
-struct sk_buff *build_skb(void *data, unsigned int frag_size)
|
|
|
+struct sk_buff *__build_skb(void *data, unsigned int frag_size)
|
|
|
{
|
|
|
struct skb_shared_info *shinfo;
|
|
|
struct sk_buff *skb;
|
|
@@ -311,11 +312,6 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
|
|
|
|
|
|
memset(skb, 0, offsetof(struct sk_buff, tail));
|
|
|
skb->truesize = SKB_TRUESIZE(size);
|
|
|
- if (frag_size) {
|
|
|
- skb->head_frag = 1;
|
|
|
- if (virt_to_head_page(data)->pfmemalloc)
|
|
|
- skb->pfmemalloc = 1;
|
|
|
- }
|
|
|
atomic_set(&skb->users, 1);
|
|
|
skb->head = data;
|
|
|
skb->data = data;
|
|
@@ -332,6 +328,23 @@ struct sk_buff *build_skb(void *data, unsigned int frag_size)
|
|
|
|
|
|
return skb;
|
|
|
}
|
|
|
+
|
|
|
+/* build_skb() is wrapper over __build_skb(), that specifically
|
|
|
+ * takes care of skb->head and skb->pfmemalloc
|
|
|
+ * This means that if @frag_size is not zero, then @data must be backed
|
|
|
+ * by a page fragment, not kmalloc() or vmalloc()
|
|
|
+ */
|
|
|
+struct sk_buff *build_skb(void *data, unsigned int frag_size)
|
|
|
+{
|
|
|
+ struct sk_buff *skb = __build_skb(data, frag_size);
|
|
|
+
|
|
|
+ if (skb && frag_size) {
|
|
|
+ skb->head_frag = 1;
|
|
|
+ if (virt_to_head_page(data)->pfmemalloc)
|
|
|
+ skb->pfmemalloc = 1;
|
|
|
+ }
|
|
|
+ return skb;
|
|
|
+}
|
|
|
EXPORT_SYMBOL(build_skb);
|
|
|
|
|
|
struct netdev_alloc_cache {
|