diff --git a/pkg/tcpip/header/eth.go b/pkg/tcpip/header/eth.go index c29d930bf..d45757308 100644 --- a/pkg/tcpip/header/eth.go +++ b/pkg/tcpip/header/eth.go @@ -46,6 +46,9 @@ const ( // EthernetMinimumSize is the minimum size of a valid ethernet frame. EthernetMinimumSize = 14 + // EthernetMaximumSize is the maximum size of a valid ethernet frame. + EthernetMaximumSize = 18 + // EthernetAddressSize is the size, in bytes, of an ethernet address. EthernetAddressSize = 6 diff --git a/pkg/tcpip/header/tcp.go b/pkg/tcpip/header/tcp.go index 709a43d1e..cb9257ad6 100644 --- a/pkg/tcpip/header/tcp.go +++ b/pkg/tcpip/header/tcp.go @@ -216,6 +216,11 @@ const ( // TCPHeaderMaximumSize is the maximum header size of a TCP packet. TCPHeaderMaximumSize = TCPMinimumSize + TCPOptionsMaximumSize + // TCPTotalHeaderMaximumSize is the maximum size of headers from all layers in + // a TCP packet. This will need to be updated if we decide to support more + // layer 2 protocols or features like IP tunneling. + TCPTotalHeaderMaximumSize = TCPHeaderMaximumSize + IPv4MaximumHeaderSize + EthernetMaximumSize + // TCPProtocolNumber is TCP's transport protocol number. TCPProtocolNumber tcpip.TransportProtocolNumber = 6 diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go index 891c1bed9..78abc07d4 100644 --- a/pkg/tcpip/transport/tcp/snd.go +++ b/pkg/tcpip/transport/tcp/snd.go @@ -953,7 +953,7 @@ func (s *sender) postXmit(dataSent bool, shouldScheduleProbe bool) { func (s *sender) sendData() { limit := s.MaxPayloadSize if s.gso { - limit = int(s.ep.gso.MaxSize - header.TCPHeaderMaximumSize) + limit = int(s.ep.gso.MaxSize - header.TCPTotalHeaderMaximumSize - 1) } end := s.SndUna.Add(s.SndWnd)