vmnet: Support offloading for krunkit

libkrun virtio-net driver enables TSO offloading and checksum
offloading by default, so we must use vment-helper --enable-tso and
--enable-checksum-offload with krunkit. These options do not work with
vfkit.
pull/20831/head
Nir Soffer 2025-05-22 02:00:33 +03:00 committed by Nir Soffer
parent da0839e79d
commit b634d8fe12
1 changed files with 13 additions and 3 deletions

View File

@ -55,6 +55,11 @@ type Helper struct {
// will obtain the same MAC address from vmnet. // will obtain the same MAC address from vmnet.
InterfaceID string InterfaceID string
// Offloading is required for krunkit, doss not work with vfkit.
// We must use this until libkrun add support for disabling offloading:
// https://github.com/containers/libkrun/issues/264
Offloading bool
// Set when vmnet interface is started. // Set when vmnet interface is started.
macAddress string macAddress string
} }
@ -115,13 +120,18 @@ func ValidateHelper() error {
// machine. The helper will create a unix datagram socket at the specfied path. // machine. The helper will create a unix datagram socket at the specfied path.
// The client (e.g. vfkit) will connect to this socket. // The client (e.g. vfkit) will connect to this socket.
func (h *Helper) Start(socketPath string) error { func (h *Helper) Start(socketPath string) error {
cmd := exec.Command( args := []string{
"sudo",
"--non-interactive", "--non-interactive",
executablePath, executablePath,
"--socket", socketPath, "--socket", socketPath,
"--interface-id", h.InterfaceID, "--interface-id", h.InterfaceID,
) }
if h.Offloading {
args = append(args, "--enable-tso", "--enable-checksum-offload")
}
cmd := exec.Command("sudo", args...)
// Create vmnet-helper in a new process group so it is not harmed when // Create vmnet-helper in a new process group so it is not harmed when
// terminating the minikube process group. // terminating the minikube process group.