netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: helper function for skb_shift
@ 2022-06-16 12:26 Richard Gobert
  2022-06-16 16:54 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Gobert @ 2022-06-16 12:26 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, brouer, imagedong, vasily.averin,
	talalahmad, luiz.von.dentz, jk, netdev

Move the len fields manipulation in the skbs to a helper function.
There is a comment specifically requesting this. This improves the
readability of skb_shift.

Signed-off-by: Richard Gobert <richardbgobert@gmail.com>
---
 net/core/skbuff.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 30b523fa4ad2..8a0a941915e8 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3508,6 +3508,19 @@ static int skb_prepare_for_shift(struct sk_buff *skb)
 }
 
 /**
+ * skb_shift_len - Update length fields of skbs when shifting.
+ */
+static inline void skb_shift_len(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
+{
+	skb->len -= shiftlen;
+	skb->data_len -= shiftlen;
+	skb->truesize -= shiftlen;
+	tgt->len += shiftlen;
+	tgt->data_len += shiftlen;
+	tgt->truesize += shiftlen;
+}
+
+/**
  * skb_shift - Shifts paged data partially from skb to another
  * @tgt: buffer into which tail data gets added
  * @skb: buffer from which the paged data comes from
@@ -3634,14 +3647,7 @@ int skb_shift(struct sk_buff *tgt, struct sk_buff *skb, int shiftlen)
 	tgt->ip_summed = CHECKSUM_PARTIAL;
 	skb->ip_summed = CHECKSUM_PARTIAL;
 
-	/* Yak, is it really working this way? Some helper please? */
-	skb->len -= shiftlen;
-	skb->data_len -= shiftlen;
-	skb->truesize -= shiftlen;
-	tgt->len += shiftlen;
-	tgt->data_len += shiftlen;
-	tgt->truesize += shiftlen;
-
+	skb_shift_len(tgt, skb, shiftlen);
 	return shiftlen;
 }
 
-- 
2.36.1


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

end of thread, other threads:[~2022-06-16 16:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-16 12:26 [PATCH] net: helper function for skb_shift Richard Gobert
2022-06-16 16:54 ` Jakub Kicinski

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