diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-06-30 00:59:09 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-30 00:59:09 +0000 |
commit | 372b12e34442e4064b9b9597445275f0555fab40 (patch) | |
tree | 81cc87badc20b6bca54417e0326afbbf9cf1b567 /pkg/tcpip/link/tun | |
parent | 1360966003efafa2af6a6816dfaf37b69d2d7f67 (diff) | |
parent | 3e5a6981d65c5e658bc4e8ed3b01aa9b6d2adfb7 (diff) |
Merge release-20210628.0-12-g3e5a6981d (automated)
Diffstat (limited to 'pkg/tcpip/link/tun')
-rw-r--r-- | pkg/tcpip/link/tun/device.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/pkg/tcpip/link/tun/device.go b/pkg/tcpip/link/tun/device.go index 575a084e2..59ac5cb8c 100644 --- a/pkg/tcpip/link/tun/device.go +++ b/pkg/tcpip/link/tun/device.go @@ -208,6 +208,15 @@ func (d *Device) Write(data []byte) (int64, error) { protocol = pktInfoHdr.Protocol() case ethHdr != nil: protocol = ethHdr.Type() + case d.flags.TUN: + // TUN interface with IFF_NO_PI enabled, thus + // we need to determine protocol from version field + version := data[0] >> 4 + if version == 4 { + protocol = header.IPv4ProtocolNumber + } else if version == 6 { + protocol = header.IPv6ProtocolNumber + } } // Try to determine remote link address, default zero. @@ -265,13 +274,6 @@ func (d *Device) encodePkt(info *channel.PacketInfo) (buffer.View, bool) { vv.AppendView(buffer.View(hdr)) } - // If the packet does not already have link layer header, and the route - // does not exist, we can't compute it. This is possibly a raw packet, tun - // device doesn't support this at the moment. - if info.Pkt.LinkHeader().View().IsEmpty() && len(info.Route.RemoteLinkAddress) == 0 { - return nil, false - } - // Ethernet header (TAP only). if d.flags.TAP { // Add ethernet header if not provided. |