Fix: tun issue with virtio_net_hdr (#254)

This commit is contained in:
xjasonlyu
2023-05-26 16:23:01 +08:00
parent 07a6a9f096
commit 46c04db29f
2 changed files with 25 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
//go:build linux && !(amd64 || arm64)
package tun
import (
"unsafe"
)
const (
virtioNetHdrLen = int(unsafe.Sizeof(virtioNetHdr{}))
offset = virtioNetHdrLen + 0 /* NO_PI */
defaultMTU = 1500
)
// virtioNetHdr is defined in the kernel in include/uapi/linux/virtio_net.h. The
// kernel symbol is virtio_net_hdr.
type virtioNetHdr struct {
flags uint8
gsoType uint8
hdrLen uint16
gsoSize uint16
csumStart uint16
csumOffset uint16
}

View File

@@ -1,8 +1,7 @@
//go:build unix //go:build unix && !linux
package tun package tun
//nolint:all
const ( const (
offset = 4 /* 4 bytes TUN_PI */ offset = 4 /* 4 bytes TUN_PI */
defaultMTU = 1500 defaultMTU = 1500