diff mbox series

net: helper function for skb_shift

Message ID 20220616122617.GA2237@debian (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: helper function for skb_shift | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 2 this patch: 5
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang fail Errors and warnings before: 6 this patch: 9
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 2 this patch: 5
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/kdoc fail Errors and warnings before: 0 this patch: 3
netdev/source_inline fail Was 0 now: 1

Commit Message

Richard Gobert June 16, 2022, 12:26 p.m. UTC
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(-)

Comments

Jakub Kicinski June 16, 2022, 4:54 p.m. UTC | #1
On Thu, 16 Jun 2022 14:26:29 +0200 Richard Gobert wrote:
> 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.
> + */

1) this is not a valid kdoc
2) I don't see the point unless we have another user of this helper

> +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;
>  }
>
diff mbox series

Patch

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;
 }