Re: [PATCH net-next 2/2] net: optimize skb_postpull_rcsum()
flat view
From: Eric Dumazet <hidden>
Date: 2021-11-25 13:40:49
On Thu, Nov 25, 2021 at 1:41 AM David Laight [off-list ref] wrote:
From: Eric Dumazetquoted
Sent: 24 November 2021 20:25 From: Eric Dumazet <redacted> Remove one pair of add/adc instructions and their dependency against carry flag. We can leverage third argument to csum_partial(): X = csum_block_sub(X, csum_partial(start, len, 0), 0); --> X = csum_block_add(X, ~csum_partial(start, len, 0), 0); --> X = ~csum_partial(start, len, ~X);That doesn't seem to refer to the change in this file.
It is describing the change. The first step, of copying first the __skb_postpull_rcsum(skb, start, len, 0) content into __skb_postpull_rcsum() was kind of obvious.
Davidquoted
Signed-off-by: Eric Dumazet <redacted> --- include/linux/skbuff.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index eba256af64a577b458998845f2dc01a5ec80745a..eae4bd3237a41cc1b60b44c91fbfe21dfdd8f117 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h@@ -3485,7 +3485,11 @@ __skb_postpull_rcsum(struct sk_buff *skb, const void *start, unsigned int len, static inline void skb_postpull_rcsum(struct sk_buff *skb, const void *start, unsigned int len) { - __skb_postpull_rcsum(skb, start, len, 0); + if (skb->ip_summed == CHECKSUM_COMPLETE) + skb->csum = ~csum_partial(start, len, ~skb->csum); + else if (skb->ip_summed == CHECKSUM_PARTIAL && + skb_checksum_start_offset(skb) < 0) + skb->ip_summed = CHECKSUM_NONE; } static __always_inline void --2.34.0.rc2.393.gf8c9666880-goog- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)