mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Merge pull request #7703 from avagin:raw-mtu
PiperOrigin-RevId: 453993215
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user