ip: improve deferred computation of checksums

This patch adds the same functionality for the IPv4 header checksum
as was done erlier for the SCTP/TCP/UDP transport checksum.
When the IP implementation sends a packet, it does not compute the
corresponding checksum but defers that. It will determine whether the
network interface selected for the packet has the requested capability
and computes the checksum in software, if the selected network
interface does not have the requested capability.
Do this not only for packets being sent by the local IP stack, but
also when forwarding packets. Furthermore, when such packets are
delivered to a local IP stack, do not compute or validate the checksum,
since such packets have never been on the wire. This allows to support
checksum offloading also in the case of local virtual machines or
jails. Support for epair interfaces will be added in a separate commit.

Reviewed by:		pouria, tuexen
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D54455
This commit is contained in:
Timo Völker
2026-01-20 11:30:19 +01:00
committed by Michael Tuexen
parent 3d771e0db6
commit 6f15ba8004
3 changed files with 32 additions and 11 deletions
+3 -2
View File
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 1, 2025
.Dd January 20, 2026
.Dt MBUF 9
.Os
.\"
@@ -1216,13 +1216,14 @@ in
is not set, since SCTP does not use a pseudo header checksum.
.Pp
If IP delivers a packet with the flags
.Dv CSUM_IP ,
.Dv CSUM_SCTP ,
.Dv CSUM_TCP ,
or
.Dv CSUM_UDP
set in
.Va csum_flags
to a local SCTP, TCP, or UDP stack, the packet will be processed without
to a local IP, SCTP, TCP, or UDP stack, the packet will be processed without
computing or validating the checksum, since the packet has not been on the
wire.
This can happen if the packet was handled by a virtual interface such as