forked from quic-go/quic-go
send and track packets with ECN markings
This commit is contained in:
15
send_conn.go
15
send_conn.go
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// A sendConn allows sending using a simple Write() on a non-connected packet conn.
|
||||
type sendConn interface {
|
||||
Write(b []byte, gsoSize uint16) error
|
||||
Write(b []byte, gsoSize uint16, ecn protocol.ECN) error
|
||||
Close() error
|
||||
LocalAddr() net.Addr
|
||||
RemoteAddr() net.Addr
|
||||
@@ -43,13 +43,6 @@ func newSendConn(c rawConn, remote net.Addr, info packetInfo, logger utils.Logge
|
||||
}
|
||||
|
||||
oob := info.OOB()
|
||||
if remoteUDPAddr, ok := remote.(*net.UDPAddr); ok {
|
||||
if remoteUDPAddr.IP.To4() != nil {
|
||||
oob = appendIPv4ECNMsg(oob, protocol.ECT1)
|
||||
} else {
|
||||
oob = appendIPv6ECNMsg(oob, protocol.ECT1)
|
||||
}
|
||||
}
|
||||
// increase oob slice capacity, so we can add the UDP_SEGMENT and ECN control messages without allocating
|
||||
l := len(oob)
|
||||
oob = append(oob, make([]byte, 64)...)[:l]
|
||||
@@ -62,8 +55,8 @@ func newSendConn(c rawConn, remote net.Addr, info packetInfo, logger utils.Logge
|
||||
}
|
||||
}
|
||||
|
||||
func (c *sconn) Write(p []byte, gsoSize uint16) error {
|
||||
_, err := c.WritePacket(p, c.remoteAddr, c.packetInfoOOB, gsoSize)
|
||||
func (c *sconn) Write(p []byte, gsoSize uint16, ecn protocol.ECN) error {
|
||||
_, err := c.WritePacket(p, c.remoteAddr, c.packetInfoOOB, gsoSize, ecn)
|
||||
if err != nil && isGSOError(err) {
|
||||
// disable GSO for future calls
|
||||
c.gotGSOError = true
|
||||
@@ -76,7 +69,7 @@ func (c *sconn) Write(p []byte, gsoSize uint16) error {
|
||||
if l > int(gsoSize) {
|
||||
l = int(gsoSize)
|
||||
}
|
||||
if _, err := c.WritePacket(p[:l], c.remoteAddr, c.packetInfoOOB, 0); err != nil {
|
||||
if _, err := c.WritePacket(p[:l], c.remoteAddr, c.packetInfoOOB, 0, ecn); err != nil {
|
||||
return err
|
||||
}
|
||||
p = p[l:]
|
||||
|
||||
Reference in New Issue
Block a user