Page MenuHomeFreeBSD

if_tuntap: add support for receive side checksum offloading
ClosedPublic

Authored by tuexen on Nov 6 2023, 12:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 14, 7:51 PM
Unknown Object (File)
Fri, Dec 13, 8:48 PM
Unknown Object (File)
Wed, Nov 20, 7:40 AM
Unknown Object (File)
Nov 15 2024, 6:21 AM
Unknown Object (File)
Nov 14 2024, 4:37 AM
Unknown Object (File)
Sep 29 2024, 4:52 AM
Unknown Object (File)
Sep 28 2024, 7:18 PM
Unknown Object (File)
Sep 24 2024, 5:18 PM

Details

Summary

Add support for receive checksum offloading. When enabled, pretend that the IPv4 and transport layer checksum is correct.
This is a prerequisite to add LRO support, which will be added after this. Then tap interfaces can be used by packetdrill to test the LRO code even in local mode.

Diff Detail

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

Event Timeline

tuexen updated this revision to Diff 129763.

Make IPv4 and IPv6 consistent by explicitly handling SCTP in both cases.

This revision is now accepted and ready to land.Nov 6 2023, 12:26 PM
zlei added inline comments.
sys/net/if_tuntap.c
1826

CSUM_SCTP_VALID == CSUM_SCTP_VALID.

Is it a historical reason we maintains a CSUM_SCTP_VALID ?

sys/net/if_tuntap.c
1782

The NULL check for eh seems to be redundant. It should never be NULL.

tuexen added inline comments.
sys/net/if_tuntap.c
1782

I found that also when integrating the change. I agree that it can't be NULL, that is why I'm not checking for it.

However, removing the check here should be done in a separate small cleanup commit. I was planing to do that after this is in.

1826

I guess you want to say that CSUM_DATA_VALID and CSUM_SCTP_VALID both map to CSUM_L4_VALID. So they are the same and the compiler can simplify the statement. However, there is no reason why thy must be mapped to the same value. That is why I added both.

sys/net/if_tuntap.c
980

Only tap devices are going to have LRO then should we check TUN_L2 ?

1826

I guess you want to say that CSUM_DATA_VALID and CSUM_SCTP_VALID both map to CSUM_L4_VALID.

Yes, CSUM_DATA_VALID and CSUM_SCTP_VALID .

However, there is no reason why thy must be mapped to the same value. That is why I added both.

From the layer perspective, both TCP and SCTP are layer 4. For incoming packets, if the HW can do SCTP checksum offload, then set the flag CSUM_DATA_VALID should be enough. That's why I guess CSUM_SCTP_VALID is maintained for historical reason.

tuexen added inline comments.
sys/net/if_tuntap.c
980

Right now both the tun and tap interfaces can enable receive checksum offloading. LRO will only work for the tap device, since the LRO code requires an ethernet header to be present.
If you prefer, we can restrict the receive checksum offloading capability to the tap interfaces. Do you prefer that?

1826

Some ethernet drivers prefer the information separately. So CSUM_SCTP_VALID is used. If you prefer, you can do an overall cleanup, but I would prefer to keep focussed in this commit.

sys/net/if_tuntap.c
980

If you prefer, we can restrict the receive checksum offloading capability to the tap interfaces. Do you prefer that?

I'd prefer consistency.

I'm seeing inconsistency for tun and tap (of the feature RXSUM / RXCSUM_IPV6).
If tun is going to do receive checksum offloading, then tunwrite_l3() should be adjust accordingly. Correct me if wrong.

1826

OK.

tuexen marked 2 inline comments as done.

Restrict receive checksum offloading capabilities to tap devices.

This revision now requires review to proceed.Nov 8 2023, 1:53 PM
tuexen added inline comments.
sys/net/if_tuntap.c
980

Good point, thanks for catching that. I restricted setting the capabilities to the L2 device. I discussed this also with rgrimes.

tuexen marked an inline comment as done and an inline comment as not done.Nov 8 2023, 1:55 PM

Avoid interfering with virtio.

Looks good to me.

sys/net/if_tuntap.c
1796

The last bits to check.

#ifdef INET
	case ETHERTYPE_IP:
#endif

#ifdef INET6
	case ETHERTYPE_IPV6
#endif
This revision is now accepted and ready to land.Nov 9 2023, 1:06 AM
tuexen added inline comments.
sys/net/if_tuntap.c
1796

Done. Thanks for the review!