Page MenuHomeFreeBSD

tests: fix checksum computation
ClosedPublic

Authored by tuexen on Wed, Jul 1, 7:11 AM.
Tags
None
Referenced Files
F161739807: D57988.id181174.diff
Mon, Jul 6, 10:25 AM
F161708253: D57988.id181211.diff
Mon, Jul 6, 3:37 AM
F161703484: D57988.id181154.diff
Mon, Jul 6, 2:38 AM
F161696677: D57988.id181152.diff
Mon, Jul 6, 1:03 AM
F161687614: D57988.id181211.diff
Sun, Jul 5, 11:18 PM
F161656552: D57988.id181174.diff
Sun, Jul 5, 4:16 PM
Unknown Object (File)
Sun, Jul 5, 4:55 AM
Unknown Object (File)
Sat, Jul 4, 11:50 AM

Details

Summary

This fixes an endianness bug in sys/netinet/ip_reass_test. Just use the code from RFC 1071.

Test Plan

kyua test ip_reass_test

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

tuexen requested review of this revision.Wed, Jul 1, 7:11 AM

It seems this bug shows only after D57518 because, before that change, the loopback interface with IFCAP_RXCSUM enabled just told IP for each packet that the checksum has been checked and is valid. After that change, the loopback interface does not pretend that anymore, and IP validates the checksum.

This fix looks good to me.

This revision is now accepted and ready to land.Wed, Jul 1, 7:30 AM
tuexen edited the summary of this revision. (Show Details)

More cleaner version.

This revision now requires review to proceed.Wed, Jul 1, 7:37 AM

Thanks! Stupid question: how did that happen that after Timo's change the loopback actually does check checksums?

This revision is now accepted and ready to land.Wed, Jul 1, 2:40 PM

Cause we actually plan in the opposite direction: packets known to be valid (never went over a wire) shall not be checked.

Thanks! Stupid question: how did that happen that after Timo's change the loopback actually does check checksums?

It is not the loopback that does checksum validation. It has never validated the checksum.

Before my change (D57518), loopback lied. For each packet, loopback just indicated that it has validated the checksum and that the checksum is correct. In consequence, IP skipped checksum validation.

In general, this kind of lying for a packet received is problematic. If the packet is not for the host and the host sends it out (e.g., due to IP routing), the packet goes on the wire without a valid checksum.

When using loopback, the checksum does not need to be computed at all. If IP sends a packet, it uses transmit checksum offloading (for IP, by setting the CSUM_IP flag), and loopback leaves the offloading flags set. When IP receives a packet with CSUM_IP set, it skips validation.

For the test, BPF is used. It could set CSUM_IP when creating the mbuf. However, I've never used BPF and don't know if that's a good idea.

After applying this patch, the ip_reass_test tests pass on my system.

This revision was automatically updated to reflect the committed changes.

I still can't understand :(

It is not the loopback that does checksum validation. It has never validated the checksum.
Before my change (D57518), loopback lied. For each packet, loopback just indicated that it has validated the checksum and that the checksum is correct. In consequence, IP skipped checksum validation.
In general, this kind of lying for a packet received is problematic. If the packet is not for the host and the host sends it out (e.g., due to IP routing), the packet goes on the wire without a valid checksum.

How is it possible that a packet received on loopback would go outside? I can imagine only policy routing by ipfw/pf.

When using loopback, the checksum does not need to be computed at all. If IP sends a packet, it uses transmit checksum offloading (for IP, by setting the CSUM_IP flag), and loopback leaves the offloading flags set. When IP receives a packet with CSUM_IP set, it skips validation.
For the test, BPF is used. It could set CSUM_IP when creating the mbuf. However, I've never used BPF and don't know if that's a good idea.

Definitely not a correct idea in general! The bpf is supposed to send on the wire exactly what application has written.

I still can't understand :(

It is not the loopback that does checksum validation. It has never validated the checksum.
Before my change (D57518), loopback lied. For each packet, loopback just indicated that it has validated the checksum and that the checksum is correct. In consequence, IP skipped checksum validation.
In general, this kind of lying for a packet received is problematic. If the packet is not for the host and the host sends it out (e.g., due to IP routing), the packet goes on the wire without a valid checksum.

How is it possible that a packet received on loopback would go outside? I can imagine only policy routing by ipfw/pf.

It's hard to imagine a use case with loopback but vtnet, for example, did this kind of lying too. It did set checksum validated and checksum correct when it received a packet with transmit checksum offloading flag set. So, if a VM that uses vtnet received a packet with transmit checksum offloading flag set, it set the flags checksum validated and checksum correct. If that VM does IP routing and the host sends that packet out, it would be on the wire with an incorrect checksum. This was fixed by D51686.

The tap interface is another example. It still does this kind of lying because it uses an old version of the vtnet implementation. This is what D57299 fixes.

This is what I meant with In general. Even though, for loopback, this kind of lying is an issue only in a very special case, I don't think pretending something that hasn't been done is a good way. Here, it hides a bug.

When using loopback, the checksum does not need to be computed at all. If IP sends a packet, it uses transmit checksum offloading (for IP, by setting the CSUM_IP flag), and loopback leaves the offloading flags set. When IP receives a packet with CSUM_IP set, it skips validation.
For the test, BPF is used. It could set CSUM_IP when creating the mbuf. However, I've never used BPF and don't know if that's a good idea.

Definitely not a correct idea in general! The bpf is supposed to send on the wire exactly what application has written.