Commit 0b2e2d36 authored by David S. Miller's avatar David S. Miller

Merge branch 'pskb_put'

Mathias Krause says:

====================
move pskb_put (was: IPsec improvements)

This series moves pskb_put() to the core code, making the code
duplication in caif obsolete (patches 1 and 2).
Patch 3 fixes a few kernel-doc issues.

v2 of this series does no longer contain the skb_cow_data() patch and
therefore no performance improvements for IPsec. The change is still
under discussion, but otherwise independent from the above changes.

Please apply!

v2:
- kernel-doc fixes for pskb_put, as noticed by Ben
- dropped skb_cow_data patch as it's still discussed
- added a kernel-doc fixes patch (patch 3)
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b5ad795e bc32383c
...@@ -1357,7 +1357,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i, ...@@ -1357,7 +1357,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
* @size: the length of the data * @size: the length of the data
* *
* As per __skb_fill_page_desc() -- initialises the @i'th fragment of * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
* @skb to point to &size bytes at offset @off within @page. In * @skb to point to @size bytes at offset @off within @page. In
* addition updates @skb such that @i is the last fragment. * addition updates @skb such that @i is the last fragment.
* *
* Does not take any additional reference on the fragment. * Does not take any additional reference on the fragment.
...@@ -1417,6 +1417,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset) ...@@ -1417,6 +1417,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)
/* /*
* Add data to an sk_buff * Add data to an sk_buff
*/ */
unsigned char *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
unsigned char *skb_put(struct sk_buff *skb, unsigned int len); unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len) static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len)
{ {
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
struct ip_esp_hdr; struct ip_esp_hdr;
static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb) static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
......
...@@ -203,20 +203,10 @@ int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len) ...@@ -203,20 +203,10 @@ int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len)
PKT_ERROR(pkt, "cow failed\n"); PKT_ERROR(pkt, "cow failed\n");
return -EPROTO; return -EPROTO;
} }
/*
* Is the SKB non-linear after skb_cow_data()? If so, we are
* going to add data to the last SKB, so we need to adjust
* lengths of the top SKB.
*/
if (lastskb != skb) {
pr_warn("Packet is non-linear\n");
skb->len += len;
skb->data_len += len;
}
} }
/* All set to put the last SKB and optionally write data there. */ /* All set to put the last SKB and optionally write data there. */
to = skb_put(lastskb, len); to = pskb_put(skb, lastskb, len);
if (likely(data)) if (likely(data))
memcpy(to, data, len); memcpy(to, data, len);
return 0; return 0;
......
...@@ -1051,8 +1051,8 @@ EXPORT_SYMBOL(__pskb_copy); ...@@ -1051,8 +1051,8 @@ EXPORT_SYMBOL(__pskb_copy);
* @ntail: room to add at tail * @ntail: room to add at tail
* @gfp_mask: allocation priority * @gfp_mask: allocation priority
* *
* Expands (or creates identical copy, if &nhead and &ntail are zero) * Expands (or creates identical copy, if @nhead and @ntail are zero)
* header of skb. &sk_buff itself is not changed. &sk_buff MUST have * header of @skb. &sk_buff itself is not changed. &sk_buff MUST have
* reference count of 1. Returns zero in the case of success or error, * reference count of 1. Returns zero in the case of success or error,
* if expansion failed. In the last case, &sk_buff is not changed. * if expansion failed. In the last case, &sk_buff is not changed.
* *
...@@ -1263,6 +1263,29 @@ int skb_pad(struct sk_buff *skb, int pad) ...@@ -1263,6 +1263,29 @@ int skb_pad(struct sk_buff *skb, int pad)
} }
EXPORT_SYMBOL(skb_pad); EXPORT_SYMBOL(skb_pad);
/**
* pskb_put - add data to the tail of a potentially fragmented buffer
* @skb: start of the buffer to use
* @tail: tail fragment of the buffer to use
* @len: amount of data to add
*
* This function extends the used data area of the potentially
* fragmented buffer. @tail must be the last fragment of @skb -- or
* @skb itself. If this would exceed the total buffer size the kernel
* will panic. A pointer to the first byte of the extra data is
* returned.
*/
unsigned char *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
{
if (tail != skb) {
skb->data_len += len;
skb->len += len;
}
return skb_put(tail, len);
}
EXPORT_SYMBOL_GPL(pskb_put);
/** /**
* skb_put - add data to a buffer * skb_put - add data to a buffer
* @skb: buffer to use * @skb: buffer to use
...@@ -2540,14 +2563,14 @@ EXPORT_SYMBOL(skb_prepare_seq_read); ...@@ -2540,14 +2563,14 @@ EXPORT_SYMBOL(skb_prepare_seq_read);
* @data: destination pointer for data to be returned * @data: destination pointer for data to be returned
* @st: state variable * @st: state variable
* *
* Reads a block of skb data at &consumed relative to the * Reads a block of skb data at @consumed relative to the
* lower offset specified to skb_prepare_seq_read(). Assigns * lower offset specified to skb_prepare_seq_read(). Assigns
* the head of the data block to &data and returns the length * the head of the data block to @data and returns the length
* of the block or 0 if the end of the skb data or the upper * of the block or 0 if the end of the skb data or the upper
* offset has been reached. * offset has been reached.
* *
* The caller is not required to consume all of the data * The caller is not required to consume all of the data
* returned, i.e. &consumed is typically set to the number * returned, i.e. @consumed is typically set to the number
* of bytes already consumed and the next call to * of bytes already consumed and the next call to
* skb_seq_read() will return the remaining part of the block. * skb_seq_read() will return the remaining part of the block.
* *
......
...@@ -802,17 +802,4 @@ int xfrm_count_pfkey_enc_supported(void) ...@@ -802,17 +802,4 @@ int xfrm_count_pfkey_enc_supported(void)
} }
EXPORT_SYMBOL_GPL(xfrm_count_pfkey_enc_supported); EXPORT_SYMBOL_GPL(xfrm_count_pfkey_enc_supported);
#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
{
if (tail != skb) {
skb->data_len += len;
skb->len += len;
}
return skb_put(tail, len);
}
EXPORT_SYMBOL_GPL(pskb_put);
#endif
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment