Re: git: bcb298fa9e23 - main - sctp, tcp, udp: improve deferred computation of checksums
Date: Thu, 07 Aug 2025 03:00:23 UTC
> On Aug 7, 2025, at 6:35 AM, Gleb Smirnoff <glebius@freebsd.org> wrote: > > Michael, > > On Fri, Aug 01, 2025 at 08:17:35AM +0000, Michael Tuexen wrote: > M> When the SCTP, TCP, or UDP implementation send a packet, it does not > M> compute the corresponding checksum but defers that. The network layer > M> will determine whether the network interface selected for the packet > M> has the requested capability and computes the checksum in software, > M> if the selected network interface doesn't have the requested > M> capability. > M> Do this not only for packets being sent by the local SCTP, TCP, > M> and UDP stack, but also when forwarding packets. Furthermore, when > M> such packets are delivered to a local SCTP, TCP, or UDP stack, do not > M> compute or validate the checksum, since such packets never have been on > M> the wire. > M> This allows to support checksum offloading also in the case of local > M> virtual machines or jails. > M> Support for epair, vtnet, and tap interfaces will be added in > M> separate commits. > > Not a request for any action, but a general comment on the topic. > > Imagine we are developing an IP stack from scratch for modern computers. Most > NICs do hardware checksumming, large fraction of installations run in > containers/VMs and communicate via virtual interfaces. With modern reality we > would probably do not do any checksumming in the stack at all, just completely > ignore the checksum field. It would always be obligation of the NIC driver to > care about the checksums. The existing software checksumming code would be > just a library that drivers for legacy hardware call. Local traffic won't set > and won't check checksums neither any related flags. I have ever had the same idea, but that requires lots of modification to in-tree drivers and I finally abort. Think it twice, maybe a new driver flag say `IFF_CSUM_OFFLOAD` is needed to indicate the driver is capable to delay calculating the checksums, and eventually all drivers are converted and tested. > > -- > Gleb Smirnoff Best regards, Zhenlei