On Windows, an ICMP "port unreachable" no longer surfaces as a UDP receive error #17

Closed
opened 2026-10-31 12:41:50 -04:00 by claude · 1 comment
Owner
  • Draft: REL-11
  • Priority: low (verify first; a Warning per stray ICMP message on a Windows DNS server)
  • Agent: protocol-coder
  • Depends on: none
  • Decisions: none

Why

On Windows a UDP socket reports an ICMP port-unreachable for an earlier send as
SocketException ConnectionReset (10054) on the next receive. The RP-4 DHCP live tests hit this
("An existing connection was forcibly closed by the remote host" at ReceiveFromAsync).
UdpDnsListener (src/dotnet/src/Ninlil.Dns.Protocol.Plain/UdpDnsListener.cs:155-170) and
DnsCryptUdpListener log each such exception as a Warning and continue, so a client that sends a
query and closes its port turns into a Warning line on Windows, which an off-path sender can
provoke at will.

What changes

First reproduce on Lofnheim (query, close the client socket before the reply, check the log).
If confirmed: on Windows, turn the behaviour off on every UDP listening socket with
socket.IOControl(SIO_UDP_CONNRESET, false) (Winsock SIO_UDP_CONNRESET, documented by
Microsoft) at bind time, in the shared listen-socket code
(src/dotnet/src/Ninlil.Dns.Server.Core/Transport/) if the DNS UDP listeners share it.

Acceptance

  • Windows test (git bundle on Lofnheim) that sends to the listener from a socket it closes
    before the reply, then sends a second query from another socket: no Warning logged, the
    second query answered. Red without the fix.
  • Linux: guard test passes; whole solution if Server.Core changes.

Source

RP-4 report finding 3 ("the UDP ICMP-reset behaviour"); inference from the product code, not yet
observed on a product listener.

- **Draft:** REL-11 - **Priority:** low (verify first; a Warning per stray ICMP message on a Windows DNS server) - **Agent:** protocol-coder - **Depends on:** none - **Decisions:** none ### Why On Windows a UDP socket reports an ICMP port-unreachable for an earlier send as `SocketException` ConnectionReset (10054) on the next receive. The RP-4 DHCP live tests hit this ("An existing connection was forcibly closed by the remote host" at `ReceiveFromAsync`). `UdpDnsListener` (`src/dotnet/src/Ninlil.Dns.Protocol.Plain/UdpDnsListener.cs:155-170`) and `DnsCryptUdpListener` log each such exception as a Warning and continue, so a client that sends a query and closes its port turns into a Warning line on Windows, which an off-path sender can provoke at will. ### What changes First reproduce on Lofnheim (query, close the client socket before the reply, check the log). If confirmed: on Windows, turn the behaviour off on every UDP listening socket with `socket.IOControl(SIO_UDP_CONNRESET, false)` (Winsock `SIO_UDP_CONNRESET`, documented by Microsoft) at bind time, in the shared listen-socket code (`src/dotnet/src/Ninlil.Dns.Server.Core/Transport/`) if the DNS UDP listeners share it. ### Acceptance - [ ] Windows test (git bundle on Lofnheim) that sends to the listener from a socket it closes before the reply, then sends a second query from another socket: no Warning logged, the second query answered. Red without the fix. - [ ] Linux: guard test passes; whole solution if Server.Core changes. ### Source RP-4 report finding 3 ("the UDP ICMP-reset behaviour"); inference from the product code, not yet observed on a product listener.
Author
Owner

Owner decision Q-ARCH-1 (#260): Ninlil.Dhcp.Common referencing Ninlil.Common.Extension for the shared IgnoreIcmpPortUnreachable helper is accepted. Shared helpers live once in Ninlil.Common.*; do not copy them.

Owner decision Q-ARCH-1 (#260): `Ninlil.Dhcp.Common` referencing `Ninlil.Common.Extension` for the shared `IgnoreIcmpPortUnreachable` helper is accepted. Shared helpers live once in `Ninlil.Common.*`; do not copy them.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#17
No description provided.