correctness

This commit is contained in:
JackDoan committed 2026-04-28 17:29:25 -05:00
1 parent 8fdd98f639
commit d1ea33659a
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -80,7 +80,7 @@ func newOffload(fd int, shutdownFd int) (*Offload, error) {
fd: fd, fd: fd,
shutdownFd: shutdownFd, shutdownFd: shutdownFd,
closed: atomic.Bool{}, closed: atomic.Bool{},
readBuf: make([]byte, tunReadBufSize), readBuf: make([]byte, virtioNetHdrLen+tunReadBufSize),
readPoll: [2]unix.PollFd{ readPoll: [2]unix.PollFd{
{Fd: int32(fd), Events: unix.POLLIN}, {Fd: int32(fd), Events: unix.POLLIN},
{Fd: int32(shutdownFd), Events: unix.POLLIN}, {Fd: int32(shutdownFd), Events: unix.POLLIN},
+3
View File
@@ -56,6 +56,9 @@ func checkVirtioValid(pkt []byte, hdr VirtioNetHdr) error {
if hdr.Flags&unix.VIRTIO_NET_HDR_F_RSC_INFO != 0 { if hdr.Flags&unix.VIRTIO_NET_HDR_F_RSC_INFO != 0 {
return fmt.Errorf("virtio RSC_INFO flag not supported on TUN reads") return fmt.Errorf("virtio RSC_INFO flag not supported on TUN reads")
} }
if len(pkt) < ipv4HeaderMinLen {
return fmt.Errorf("packet too short")
}
ipVersion := pkt[0] >> 4 ipVersion := pkt[0] >> 4
switch hdr.GSOType { switch hdr.GSOType {
case unix.VIRTIO_NET_HDR_GSO_TCPV4: case unix.VIRTIO_NET_HDR_GSO_TCPV4: