net: helper function for skb_shift
Subsystems (2)
PATCH 1/1 net: helper function for skb_shift
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 <[email protected]>
--- net/core/skbuff.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
net/core/skbuff.c +14 -8
@@ -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; }
Signature · 1 line
2.36.1
Jakub Kicinski
maintainerQuoted 14 lines · 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 <[email protected]>--- net/core/skbuff.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)net/core/skbuff.c +0
-0
net/core/skbuff.c static int skb_prepare_for_shift(struct sk_buff *skb) · line 3512
Quoted 5 lines
net/core/skbuff.c +2
-0@@ -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
Quoted 30 lines
net/core/skbuff.c +12
-8+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; }