Properly account for all lower level headers when setting GSO limit.

Tested on gVNIC VM, PUT 10MB to GCS (3 run mean):
```
--gso=false: 1.05s
--gso=true: 0.45s
```

Fixes #9816

PiperOrigin-RevId: 597304748
This commit is contained in:
Lucas Manning
2024-01-10 11:20:09 -08:00
committed by gVisor bot
parent 9e364f4c23
commit 94e83c674e
3 changed files with 9 additions and 1 deletions
+3
View File
@@ -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
+5
View File
@@ -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
+1 -1
View File
@@ -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)