mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-02 19:57:35 +03:00
check for WSAEMSGSIZE errors when receiving UDP packets on Windows (#3982)
* check for WSAEMSGSIZE errors when receiving UDP packets on Windows * check EMSGSIZE error on macOS
This commit is contained in:
parent
2183283622
commit
2bcfe5bc4b
6 changed files with 23 additions and 5 deletions
|
@ -82,7 +82,7 @@ func (h *sendQueue) Run() error {
|
||||||
// 1. Checking for "datagram too large" message from the kernel, as such,
|
// 1. Checking for "datagram too large" message from the kernel, as such,
|
||||||
// 2. Path MTU discovery,and
|
// 2. Path MTU discovery,and
|
||||||
// 3. Eventual detection of loss PingFrame.
|
// 3. Eventual detection of loss PingFrame.
|
||||||
if !isMsgSizeErr(err) {
|
if !isSendMsgSizeErr(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,12 @@ func setDF(syscall.RawConn) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMsgSizeErr(err error) bool {
|
func isSendMsgSizeErr(err error) bool {
|
||||||
|
// to be implemented for more specific platforms
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func isRecvMsgSizeErr(err error) bool {
|
||||||
// to be implemented for more specific platforms
|
// to be implemented for more specific platforms
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,10 +47,12 @@ func setDF(rawConn syscall.RawConn) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMsgSizeErr(err error) bool {
|
func isSendMsgSizeErr(err error) bool {
|
||||||
return errors.Is(err, unix.EMSGSIZE)
|
return errors.Is(err, unix.EMSGSIZE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isRecvMsgSizeErr(error) bool { return false }
|
||||||
|
|
||||||
func isAtLeastMacOS11() (bool, error) {
|
func isAtLeastMacOS11() (bool, error) {
|
||||||
uname := &unix.Utsname{}
|
uname := &unix.Utsname{}
|
||||||
err := unix.Uname(uname)
|
err := unix.Uname(uname)
|
||||||
|
|
|
@ -57,11 +57,13 @@ func maybeSetGSO(rawConn syscall.RawConn) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMsgSizeErr(err error) bool {
|
func isSendMsgSizeErr(err error) bool {
|
||||||
// https://man7.org/linux/man-pages/man7/udp.7.html
|
// https://man7.org/linux/man-pages/man7/udp.7.html
|
||||||
return errors.Is(err, unix.EMSGSIZE)
|
return errors.Is(err, unix.EMSGSIZE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isRecvMsgSizeErr(err error) bool { return false }
|
||||||
|
|
||||||
func appendUDPSegmentSizeMsg(b []byte, size uint16) []byte {
|
func appendUDPSegmentSizeMsg(b []byte, size uint16) []byte {
|
||||||
startLen := len(b)
|
startLen := len(b)
|
||||||
const dataLen = 2 // payload is a uint16
|
const dataLen = 2 // payload is a uint16
|
||||||
|
|
|
@ -43,7 +43,12 @@ func setDF(rawConn syscall.RawConn) (bool, error) {
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isMsgSizeErr(err error) bool {
|
func isSendMsgSizeErr(err error) bool {
|
||||||
|
// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
|
||||||
|
return errors.Is(err, windows.WSAEMSGSIZE)
|
||||||
|
}
|
||||||
|
|
||||||
|
func isRecvMsgSizeErr(err error) bool {
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
|
// https://docs.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
|
||||||
return errors.Is(err, windows.WSAEMSGSIZE)
|
return errors.Is(err, windows.WSAEMSGSIZE)
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,6 +330,10 @@ func (t *Transport) listen(conn rawConn) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Windows returns an error when receiving a UDP datagram that doesn't fit into the provided buffer.
|
||||||
|
if isRecvMsgSizeErr(err) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
t.close(err)
|
t.close(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue