Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding

Open coded calculation can be avoided and replaced by the
equivalent csum_replace_by_diff() and csum_sub().

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Christophe Leroy and committed by
David S. Miller
0f6938eb adfb62db

+2 -2
+2 -2
net/core/utils.c
··· 476 476 __wsum diff, bool pseudohdr) 477 477 { 478 478 if (skb->ip_summed != CHECKSUM_PARTIAL) { 479 - *sum = csum_fold(csum_add(diff, ~csum_unfold(*sum))); 479 + csum_replace_by_diff(sum, diff); 480 480 if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) 481 - skb->csum = ~csum_add(diff, ~skb->csum); 481 + skb->csum = ~csum_sub(diff, skb->csum); 482 482 } else if (pseudohdr) { 483 483 *sum = ~csum_fold(csum_add(diff, csum_unfold(*sum))); 484 484 }