netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements)
@ 2013-11-07 13:18 Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 1/3] net: move pskb_put() to core code Mathias Krause
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Mathias Krause @ 2013-11-07 13:18 UTC (permalink / raw)
  To: David S. Miller, Steffen Klassert, Herbert Xu
  Cc: Dmitry Tarnyagin, Ben Hutchings, Eric Dumazet, netdev,
	Mathias Krause

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(-)

-- 
1.7.2.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCHv2 next-next 1/3] net: move pskb_put() to core code
  2013-11-07 13:18 [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements) Mathias Krause
@ 2013-11-07 13:18 ` Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 2/3] caif: use pskb_put() instead of reimplementing its functionality Mathias Krause
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-11-07 13:18 UTC (permalink / raw)
  To: David S. Miller, Steffen Klassert, Herbert Xu
  Cc: Dmitry Tarnyagin, Ben Hutchings, Eric Dumazet, netdev,
	Mathias Krause, Steffen Klassert, David S. Miller, Herbert Xu

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().

Signed-off-by: Mathias Krause <mathias.krause@secunet.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
---
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(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 2e153b6..491dd6c 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -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)
 {
diff --git a/include/net/esp.h b/include/net/esp.h
index c92213c..a43be85 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -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)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3735fad..2fbea08 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -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
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index ab4ef72..debe733 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -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");
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCHv2 next-next 2/3] caif: use pskb_put() instead of reimplementing its functionality
  2013-11-07 13:18 [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements) Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 1/3] net: move pskb_put() to core code Mathias Krause
@ 2013-11-07 13:18 ` Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 3/3] net: skbuff - kernel-doc fixes Mathias Krause
  2013-11-08  0:29 ` [PATCHv2 next-next 0/3] move pskb_put David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-11-07 13:18 UTC (permalink / raw)
  To: David S. Miller, Steffen Klassert, Herbert Xu
  Cc: Dmitry Tarnyagin, Ben Hutchings, Eric Dumazet, netdev,
	Mathias Krause, David S. Miller

Also remove the warning for fragmented packets -- skb_cow_data() will
linearize the buffer, removing all fragments.

Signed-off-by: Mathias Krause <mathias.krause@secunet.com>
Cc: Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
Cc: "David S. Miller" <davem@davemloft.net>
---
 net/caif/cfpkt_skbuff.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c
index 6493351..1be0b52 100644
--- a/net/caif/cfpkt_skbuff.c
+++ b/net/caif/cfpkt_skbuff.c
@@ -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;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCHv2 next-next 3/3] net: skbuff - kernel-doc fixes
  2013-11-07 13:18 [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements) Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 1/3] net: move pskb_put() to core code Mathias Krause
  2013-11-07 13:18 ` [PATCHv2 next-next 2/3] caif: use pskb_put() instead of reimplementing its functionality Mathias Krause
@ 2013-11-07 13:18 ` Mathias Krause
  2013-11-08  0:29 ` [PATCHv2 next-next 0/3] move pskb_put David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-11-07 13:18 UTC (permalink / raw)
  To: David S. Miller, Steffen Klassert, Herbert Xu
  Cc: Dmitry Tarnyagin, Ben Hutchings, Eric Dumazet, netdev,
	Mathias Krause, David S. Miller

Use "@" 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.

Signed-off-by: Mathias Krause <mathias.krause@secunet.com>
Cc: "David S. Miller" <davem@davemloft.net>
---
 include/linux/skbuff.h |    2 +-
 net/core/skbuff.c      |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 491dd6c..036ec7d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -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.
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2fbea08..8c5197f 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -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.
  *
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCHv2 next-next 0/3] move pskb_put
  2013-11-07 13:18 [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements) Mathias Krause
                   ` (2 preceding siblings ...)
  2013-11-07 13:18 ` [PATCHv2 next-next 3/3] net: skbuff - kernel-doc fixes Mathias Krause
@ 2013-11-08  0:29 ` David Miller
  3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-11-08  0:29 UTC (permalink / raw)
  To: mathias.krause
  Cc: steffen.klassert, herbert, dmitry.tarnyagin, bhutchings, edumazet,
	netdev

From: Mathias Krause <mathias.krause@secunet.com>
Date: Thu,  7 Nov 2013 14:18:23 +0100

> 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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-08  0:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07 13:18 [PATCHv2 next-next 0/3] move pskb_put (was: IPsec improvements) Mathias Krause
2013-11-07 13:18 ` [PATCHv2 next-next 1/3] net: move pskb_put() to core code Mathias Krause
2013-11-07 13:18 ` [PATCHv2 next-next 2/3] caif: use pskb_put() instead of reimplementing its functionality Mathias Krause
2013-11-07 13:18 ` [PATCHv2 next-next 3/3] net: skbuff - kernel-doc fixes Mathias Krause
2013-11-08  0:29 ` [PATCHv2 next-next 0/3] move pskb_put David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).