Skip to content

Commit 78f073b

Browse files
committed
internal/poll: disable SIO_UDP_NETRESET on Windows
Disable the reception of NET_UNREACHABLE (TTL expired) message reporting on UDP sockets to match the default behavior of sockets on other plaforms. See https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#sio_udp_netreset This is similar to, but a different case from the prior change 3114bd6 / https://golang.org/issue/5834 that disabled one of the two flags influencing behavior in response to the reception of related ICMP. Updates #5834 Updates #68614
1 parent 2c35900 commit 78f073b

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/internal/syscall/windows/types_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const (
1414
TCP_KEEPIDLE = 0x03
1515
TCP_KEEPCNT = 0x10
1616
TCP_KEEPINTVL = 0x11
17+
18+
SIO_UDP_NETRESET = syscall.IOC_IN | syscall.IOC_VENDOR | 15
1719
)
1820

1921
const (

src/net/fd_windows.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ func (fd *netFD) init() error {
6767
if err != nil {
6868
return wrapSyscallError("wsaioctl", err)
6969
}
70+
// Disable reporting of NET_UNREACHABLE errors.
71+
// See https://go.dev/issue/68614.
72+
ret = 0
73+
flag = 0
74+
size = uint32(unsafe.Sizeof(flag))
75+
err = syscall.WSAIoctl(fd.pfd.Sysfd, windows.SIO_UDP_NETRESET, (*byte)(unsafe.Pointer(&flag)), size, nil, 0, &ret, nil, 0)
76+
if err != nil {
77+
return wrapSyscallError("wsaioctl", err)
78+
}
7079
}
7180
return nil
7281
}

0 commit comments

Comments
 (0)