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, Oct 10, 11:17 PM
Unknown Object (File)
Fri, Oct 10, 11:17 PM
Unknown Object (File)
Fri, Oct 10, 5:00 PM
Unknown Object (File)
Mon, Oct 6, 5:49 AM
Unknown Object (File)
Thu, Oct 2, 11:57 AM
Unknown Object (File)
Sat, Sep 20, 2:17 AM
Unknown Object (File)
Wed, Sep 17, 5:22 PM
Unknown Object (File)
Sep 13 2025, 2:36 AM

Details

Reviewers
tuexen
kevans
markj
jhb
vmaffione
Group Reviewers
bhyve
Summary

Set the a vhdrlen > 0 for tap and report the VIRTIO_NET_F_CSUM feature if transmission checksum is enabled on the tap interface. This allows to use checksum offloading for packets to and from the VM.

To get the tap interface capabilities, the added code uses the ioctrl SIOCGIFCAP, which is added by D51289.

A user must enable txcsum on the tap interface before, which is possible with the code changes by D51291.

Once vhdrlen > 0, mbuf flags are translated in virtio network header flags and vice versa. D51686 fixes these translations.

Test Plan

With FreeBSD head and D51289, D51291, and D51686 applied, create a tap interface.

ifconfig tap0 create

Enable txcsum and txcsum6 on that interface and configure an ip address.

ifconfig tap0 txcsum txcsum6
ifconfig tap0 192.168.0.1/24

Start a FreeBSD VM with bhyve using this tap interface. The vtnet0 interface should have txcsum and txcsum6 enabled. Configure an ip address on that interface.

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