diff options
author | gVisor bot <gvisor-bot@google.com> | 2019-11-25 17:14:51 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2019-11-25 17:14:51 +0000 |
commit | 4fa69943460af8f1648d821778ef331589ac6558 (patch) | |
tree | 23afc9cc047a9853717750bbbfb38c69f049c7b4 /pkg | |
parent | 60cdc9c849ccc66243ce3d4c51b639517c17009a (diff) | |
parent | 2b1b51f1d7dd96f14b0af3b2663c33bc7ab67f63 (diff) |
Merge release-20191114.0-27-g2b1b51f (automated)
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/tcpip/link/sniffer/sniffer.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/tcpip/link/sniffer/sniffer.go b/pkg/tcpip/link/sniffer/sniffer.go index 767f14303..3392b7edd 100644 --- a/pkg/tcpip/link/sniffer/sniffer.go +++ b/pkg/tcpip/link/sniffer/sniffer.go @@ -49,6 +49,13 @@ var LogPackets uint32 = 1 // LogPacketsToFile must be accessed atomically. var LogPacketsToFile uint32 = 1 +var transportProtocolMinSizes map[tcpip.TransportProtocolNumber]int = map[tcpip.TransportProtocolNumber]int{ + header.ICMPv4ProtocolNumber: header.IPv4MinimumSize, + header.ICMPv6ProtocolNumber: header.IPv6MinimumSize, + header.UDPProtocolNumber: header.UDPMinimumSize, + header.TCPProtocolNumber: header.TCPMinimumSize, +} + type endpoint struct { dispatcher stack.NetworkDispatcher lower stack.LinkEndpoint @@ -333,6 +340,13 @@ func logPacket(prefix string, protocol tcpip.NetworkProtocolNumber, b buffer.Vie return } + // We aren't guaranteed to have a transport header - it's possible for + // writes via raw endpoints to contain only network headers. + if minSize, ok := transportProtocolMinSizes[tcpip.TransportProtocolNumber(transProto)]; ok && len(b) < minSize { + log.Infof("%s %v -> %v transport protocol: %d, but no transport header found (possible raw packet)", prefix, src, dst, transProto) + return + } + // Figure out the transport layer info. transName := "unknown" srcPort := uint16(0) |