Merge pull request #7703 from avagin:raw-mtu

PiperOrigin-RevId: 453993215
This commit is contained in:
gVisor bot
2022-06-09 13:04:35 -07:00
2 changed files with 8 additions and 0 deletions
@@ -235,6 +235,10 @@ type WriteContext struct {
tos uint8
}
func (c *WriteContext) MTU() uint32 {
return c.route.MTU()
}
// Release releases held resources.
func (c *WriteContext) Release() {
c.route.Release()
+4
View File
@@ -345,6 +345,10 @@ func (e *endpoint) write(p tcpip.Payloader, opts tcpip.WriteOptions) (int64, tcp
return 0, err
}
if p.Len() > int(ctx.MTU()) {
return 0, &tcpip.ErrMessageTooLong{}
}
// TODO(https://gvisor.dev/issue/6538): Avoid this allocation.
payloadBytes := make([]byte, p.Len())
if _, err := io.ReadFull(p, payloadBytes); err != nil {