move pskb_put (was: IPsec improvements)
Subsystems (3)
v2 cover 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)
Mathias Krause (3):
net: move pskb_put() to core code
caif: use pskb_put() instead of reimplementing its functionality
net: skbuff - kernel-doc fixes
include/linux/skbuff.h | 3 ++- include/net/esp.h | 2 -- net/caif/cfpkt_skbuff.c | 12 +----------- net/core/skbuff.c | 33 ++++++++++++++++++++++++++++----- net/xfrm/xfrm_algo.c | 13 ------------- 5 files changed, 31 insertions(+), 32 deletions(-)
Signature · 1 line
1.7.2.3
PATCH v2 1/3 net: move pskb_put() to core code
This function has usage beside IPsec so move it to the core skbuff code. While doing so, give it some documentation and change its return type to 'unsigned char *' to be in line with skb_put().
---
v2: kernel-doc fixes, as noticed by Ben
include/linux/skbuff.h | 1 + include/net/esp.h | 2 -- net/core/skbuff.c | 23 +++++++++++++++++++++++ net/xfrm/xfrm_algo.c | 13 ------------- 4 files changed, 24 insertions(+), 15 deletions(-)
include/linux/skbuff.h +1 -0
@@ -1417,6 +1417,7 @@ static inline void skb_set_tail_pointer(struct sk_buff *skb, const int offset)/* * 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);static inline unsigned char *__skb_put (struct sk_buff *skb,unsigned int len) {
include/net/esp.h +0 -2
@@ -3,8 +3,6 @@#include <linux/skbuff.h> -void *pskb_put (struct sk_buff *skb,struct sk_buff *tail,int len); -struct ip_esp_hdr ;static inline struct ip_esp_hdr *ip_esp_hdr (const struct sk_buff *skb)
net/core/skbuff.c +23 -0
@@ -1264,6 +1264,29 @@ free_skb: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: buffer to use * @len: amount of data to add
net/xfrm/xfrm_algo.c +0 -13
@@ -802,17 +802,4 @@ int xfrm_count_pfkey_enc_supported(void) }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" );
Signature · 1 line
1.7.2.3
PATCH v2 2/3 caif: use pskb_put() instead of reimplementing its functionality
In reply to Mathias KrauseAlso remove the warning for fragmented packets -- skb_cow_data() will linearize the buffer, removing all fragments.
--- net/caif/cfpkt_skbuff.c | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
net/caif/cfpkt_skbuff.c +1 -11
@@ -203,20 +203,10 @@ int cfpkt_add_body(struct cfpkt *pkt, const void *data, u16 len)PKT_ERROR (pkt,"cow failed\n" );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. */ - to =skb_put (lastskb, len); + to =pskb_put (skb, lastskb, len);if (likely (data))memcpy (to, data, len);return 0 ;
Signature · 1 line
1.7.2.3
PATCH v2 3/3 net: skbuff - kernel-doc fixes
In reply to Mathias KrauseUse "@" to refer to parameters in the kernel-doc description. According to Documentation/kernel-doc-nano-HOWTO.txt "&" shall be used to refer to structures only.
--- include/linux/skbuff.h | 2 +- net/core/skbuff.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
include/linux/skbuff.h +1 -1
@@ -1357,7 +1357,7 @@ static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,* @size: the length of the data * * 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. * * Does not take any additional reference on the fragment.
net/core/skbuff.c +5 -5
@@ -1051,8 +1051,8 @@ EXPORT_SYMBOL(__pskb_copy);* @ntail: room to add at tail * @gfp_mask: allocation priority * -* Expands (or creates identical copy, if &nhead and &ntail are zero) -* header of skb. &sk_buff itself is not changed. &sk_buff MUST have +* Expands (or creates identical copy, if @nhead and @ntail are zero) +* 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, * if expansion failed. In the last case, &sk_buff is not changed. *
@@ -2563,14 +2563,14 @@ EXPORT_SYMBOL(skb_prepare_seq_read);* @data: destination pointer for data to be returned * @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 -* 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 * offset has been reached. * * 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 * skb_seq_read() will return the remaining part of the block. *
Signature · 1 line
1.7.2.3
David Miller
maintainerRe: [PATCHv2 next-next 0/3] move pskb_put
In reply to Mathias KrauseFrom: Mathias Krause <[email protected]>
Date: Thu, 7 Nov 2013 14:18:23 +0100
Quoted 9 lines
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!
Series applied, thanks!