only run DPLPMTUD if the connection can send packets with the DF bit set (#3879)

This commit is contained in:
Marten Seemann
2023-06-02 16:54:34 +03:00
committed by GitHub
parent 0438eada95
commit 614fdb3271
15 changed files with 67 additions and 26 deletions

View File

@@ -61,11 +61,13 @@ type oobConn struct {
// Packets received from the kernel, but not yet returned by ReadPacket().
messages []ipv4.Message
buffers [batchSize]*packetBuffer
supportsDF bool
}
var _ rawConn = &oobConn{}
func newConn(c OOBCapablePacketConn) (*oobConn, error) {
func newConn(c OOBCapablePacketConn, supportsDF bool) (*oobConn, error) {
rawConn, err := c.SyscallConn()
if err != nil {
return nil, err
@@ -132,6 +134,7 @@ func newConn(c OOBCapablePacketConn) (*oobConn, error) {
batchConn: bc,
messages: msgs,
readPos: batchSize,
supportsDF: supportsDF,
}
for i := 0; i < batchSize; i++ {
oobConn.messages[i].OOB = make([]byte, oobBufferSize)
@@ -234,6 +237,10 @@ func (c *oobConn) WritePacket(b []byte, addr net.Addr, oob []byte) (n int, err e
return n, err
}
func (c *oobConn) capabilities() connCapabilities {
return connCapabilities{DF: c.supportsDF}
}
func (info *packetInfo) OOB() []byte {
if info == nil {
return nil