diff options
author | Eric Dumazet <edumazet@google.com> | 2021-11-24 12:24:46 -0800 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-11-25 21:03:31 -0800 |
commit | 29c3002644bdd653f6ec6407d25135d0a4f7cefb (patch) | |
tree | 7f17a01eb6164d66c713a0d18fde1ffa231707e4 | |
parent | 0bd28476f6363c7ccc841fe6a0ab0dd1fdb822f6 (diff) | |
download | linux-29c3002644bdd653f6ec6407d25135d0a4f7cefb.tar.bz2 |
net: optimize skb_postpull_rcsum()
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);
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r-- | include/linux/skbuff.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index eba256af64a5..eae4bd3237a4 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 |