Thread (26 messages) flat view 26 messages, 5 authors, 2021-12-03

Re: [PATCH net-next 2/2] net: optimize skb_postpull_rcsum()

From: Vladimir Oltean <olteanv@gmail.com>
Date: 2021-12-03 16:14:52

On Fri, Dec 03, 2021 at 02:57:04PM +0000, David Laight wrote:
From: Vladimir Oltean
quoted
Sent: 02 December 2021 21:40
...
quoted
quoted
Try replacing both ~ with -.
So replace:
		skb->csum = ~csum_partial(start, len, ~skb->csum);
with:
		skb->csum = -csum_partial(start, len, -skb->csum);

That should geneate ~0u instead 0 (if I've got my maths right).
Indeed, replacing both one's complement operations with two's complement
seems to produce correct results (consistent with old code) in all cases
that I am testing with (ICMP, TCP, UDP). Thanks!
You need to generate (or persuade Eric to generate) a patch.
I don't have the right source tree.

Any code that does ~csum_partial() is 'dubious' unless followed
by a check for 0.
The two's compliment negate save the conditional - provided the
offset of 1 can be added in earlier.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Eric, could you please send a patch with this change?
If you want and if it helps, I can also help you reproduce this locally
using the dsa_loop mockup driver.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help