Repository navigation
Commit bbde467
committed
net: macb: fix zero UDPv4 checksum on transmit
The GEM checksum engine writes its raw result into the UDP checksum
field, so a UDPv4 checksum that computes to zero goes out as 0x0000.
RFC 768 requires:
If the computed checksum is zero, it is transmitted as all ones
(the equivalent in one's complement arithmetic). An all zero
transmitted checksum value means that the transmitter generated
no checksum (for debugging or for higher level protocols that
don't care).
So these packets lose their integrity check and peers treat
them as sent without a checksum. Raspberry Pi confirmed in a
simulation of the Cadence IP [1] that the engine skips the final
substitution exactly for UDP over IPv4. UDPv6 and TCP come out
correct. The IP changelog shows no related change, so probably all
GEM revisions have the same bug.
Clear the checksum offload features for UDPv4 frames in
macb_features_check(), the core then completes the checksum in
software before handing the frame over. With ip_summed cleared,
macb_pad_and_fcs() appends the FCS and the TX_NOCRC descriptor bit
keeps the hardware off the frame. TCP and UDPv6 keep the offload.
One-step PTP sync packets keep the hardware path because the MAC
rewrites their timestamp during transmit, which would invalidate a
software checksum. Leave their existing checksum handling unchanged.
[1] #7550 (comment)
Fixes: 85ff3d8 ("net/macb: add TX checksum offload feature")
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>1 parent 2ce9f9d commit bbde467
1 file changed
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
2442 | 2443 | | |
2443 | 2444 | | |
2444 | 2445 | | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
2445 | 2457 | | |
2446 | 2458 | | |
2447 | 2459 | | |
| |||
0 commit comments