Page MenuHomeFreeBSD

bhyve: add checksum offloading for tap
Needs ReviewPublic

Authored by timo.voelker_fh-muenster.de on Aug 1 2025, 8:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jun 5, 1:40 AM
Unknown Object (File)
Sun, May 17, 12:47 PM
Unknown Object (File)
Sun, May 17, 11:24 AM
Unknown Object (File)
May 14 2026, 2:51 AM
Unknown Object (File)
May 14 2026, 2:50 AM
Unknown Object (File)
Apr 25 2026, 5:00 AM
Unknown Object (File)
Apr 18 2026, 8:58 PM
Unknown Object (File)
Apr 18 2026, 8:13 PM

Details

Reviewers
tuexen
kevans
markj
jhb
vmaffione
Group Reviewers
bhyve
Summary

To allow the use of checksum offloading for packets to and from a VM, this patch changes the following.

  • Set the vnet_hdr_len > 0 for tap.
  • Report that the tap backend supports receiving packets with partial checksum (VIRTIO_NET_F_CSUM) and that the guest can get packets with partial checksum (VIRTIO_NET_F_GUEST_CSUM).
  • Enable transmission checksum offloading (IFCAP_TXCSUM and IFCAP_TXCSUM) on the tap interface if the feature VIRTIO_NET_F_GUEST_CSUM has been negotiated.

Note that if the VM sends a packet with partial checksum and the host sends it out over an interface that does not support checksum offloading, the packet go out with an incorrect checksum. D56564 moves the check of whether an interface supports checksum offloading close to the driver and prevents this issue.

Test Plan

Create a tap interface.

ifconfig tap0 create

Start a FreeBSD VM with bhyve using this tap interface. The tap0 interface on the host and the vtnet0 interface in the VM should have txcsum and txcsum6 enabled. Configure an IP address on both interfaces.

Host

ifconfig tap0 inet 192.168.0.1/24

VM

ifconfig vtnet0 inet 192.168.0.2/24

Use nc for a test with TCP packets. In the VM run

nc -l 1234

On the host, run

nc 192.168.0.2 1234

Result: Both the host and the VM offload the computation of the TCP checksum. Host and VM can communicate without computing the TCP checksum.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

usr.sbin/bhyve/net_backends.c
93

This value causes the assertion on lines 429-430 to fail if the frontend negotiates mergeable rx buffers with the guest virtio driver.

timo.voelker_fh-muenster.de edited the summary of this revision. (Show Details)
timo.voelker_fh-muenster.de edited the test plan for this revision. (Show Details)

Update the vnet_hdr_len in tap_set_cap().

Change the way of enabling transmission checksum offloading (see new summary).

timo.voelker_fh-muenster.de added inline comments.
usr.sbin/bhyve/net_backends.c
93

Thanks, that helped. Now, I update the vnet_hdr_len in tap_set_cap().