[PR #2241] ws2_offline: let connect dissolve a UDP association (WS2-UDP-DISCONNECT) #2245

Open
opened 2026-11-26 21:20:32 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2241
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/ws2-udp-disconnect


📝 Commits (2)

  • 55dfd6b ws2_offline: let connect dissolve a UDP association (WS2-UDP-DISCONNECT)
  • 1c6f552 docs: runtime_imports describes the WS2-UDP-DISCONNECT behaviour

📊 Changes

3 files changed (+126 additions, -4 deletions)

View changed files

📝 docs/runtime_imports.md (+7 -2)
📝 runtime/shims/ws2_offline.cpp (+26 -2)
📝 runtime/test/ws2_offline_test.cpp (+93 -0)

📄 Description

Claimed in the coordination issue as: WS2-UDP-DISCONNECT (claim comment to follow)

What and why

runtime/shims/ws2_offline.cpp lets connect and WSAConnect through only for loopback addresses and fails everything else with WSAENETUNREACH. connect's remarks give an all-zero address a second meaning on a connectionless socket: it dissolves the association, after which send/recv fail with WSAENOTCONN and datagrams from any address arrive again. The shim refused that address like any external one, so a UDP socket connected once to a loopback peer stayed tied to it: the title's disconnect failed, and datagrams from every other loopback port kept being dropped.

Measured with a small probe on Windows 11 (loopback only):

call UDP socket connected to 127.0.0.1:A TCP socket
connect(0.0.0.0:0) 0, association gone (getpeername → WSAENOTCONN) WSAEADDRNOTAVAIL
connect([::]:0) (IPv6 socket) 0, association gone WSAEADDRNOTAVAIL ([::]:80)
connect(AF_UNSPEC) 0, association gone WSAEAFNOSUPPORT
WSAConnect(0.0.0.0:0) 0, association gone
connect(0.0.0.0:4321) WSAEADDRNOTAVAIL, still connected WSAEADDRNOTAVAIL

None of these reaches a peer. connect and WSAConnect now pass the disconnect forms (an AF_UNSPEC address, and 0.0.0.0 or :: with port 0) to the host. 0.0.0.0 with a port stays refused before the host, as before.

Tested

Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:

  • ws2_offline_test gets a section 5b: a loopback UDP socket connected to A is disconnected with connect(0.0.0.0:0), after which getpeername and send fail with WSAENOTCONN and a datagram from a second socket B arrives; the same through WSAConnect and with an AF_UNSPEC address and, on an IPv6 socket, with [::]:0. 0.0.0.0:4321 stays refused with WSAENETUNREACH, and on a TCP socket both forms fail with the host's error.
    • main: 9 of the 12 new checks fail.
    • this branch: 83 of 83 checks pass, in 3 of 3 runs.
  • ctest -j 8 over the 168 CPU tests, with this branch and WS2-CONNECT-BY-NAME-V6 merged: all pass except xmem_no_write_watch, whose split-reader check is the start race #2131 fixes (it passes on its own).
  • scripts/check_no_game_data.py on both files.

Not tested under Wine.

This and WS2-CONNECT-BY-NAME-V6 both change ws2_offline.cpp and its test, in different places; they merge cleanly in either order.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2241 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ws2-udp-disconnect` --- ### 📝 Commits (2) - [`55dfd6b`](https://github.com/ubiquitarianism/leonida/commit/55dfd6bc3266b8c3fd343a74499e258fbdcf299b) ws2_offline: let connect dissolve a UDP association (WS2-UDP-DISCONNECT) - [`1c6f552`](https://github.com/ubiquitarianism/leonida/commit/1c6f552cc110fe6cddb6fa5f719f3b20bb10ff6a) docs: runtime_imports describes the WS2-UDP-DISCONNECT behaviour ### 📊 Changes **3 files changed** (+126 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `docs/runtime_imports.md` (+7 -2) 📝 `runtime/shims/ws2_offline.cpp` (+26 -2) 📝 `runtime/test/ws2_offline_test.cpp` (+93 -0) </details> ### 📄 Description Claimed in the coordination issue as: WS2-UDP-DISCONNECT (claim comment to follow) ### What and why `runtime/shims/ws2_offline.cpp` lets `connect` and `WSAConnect` through only for loopback addresses and fails everything else with `WSAENETUNREACH`. connect's remarks give an all-zero address a second meaning on a connectionless socket: it dissolves the association, after which `send`/`recv` fail with `WSAENOTCONN` and datagrams from any address arrive again. The shim refused that address like any external one, so a UDP socket connected once to a loopback peer stayed tied to it: the title's disconnect failed, and datagrams from every other loopback port kept being dropped. Measured with a small probe on Windows 11 (loopback only): | call | UDP socket connected to 127.0.0.1:A | TCP socket | |---|---|---| | `connect(0.0.0.0:0)` | `0`, association gone (`getpeername` → `WSAENOTCONN`) | `WSAEADDRNOTAVAIL` | | `connect([::]:0)` (IPv6 socket) | `0`, association gone | `WSAEADDRNOTAVAIL` (`[::]:80`) | | `connect(AF_UNSPEC)` | `0`, association gone | `WSAEAFNOSUPPORT` | | `WSAConnect(0.0.0.0:0)` | `0`, association gone | | | `connect(0.0.0.0:4321)` | `WSAEADDRNOTAVAIL`, still connected | `WSAEADDRNOTAVAIL` | None of these reaches a peer. `connect` and `WSAConnect` now pass the disconnect forms (an `AF_UNSPEC` address, and `0.0.0.0` or `::` with port 0) to the host. `0.0.0.0` with a port stays refused before the host, as before. ### Tested Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo: - `ws2_offline_test` gets a section 5b: a loopback UDP socket connected to A is disconnected with `connect(0.0.0.0:0)`, after which `getpeername` and `send` fail with `WSAENOTCONN` and a datagram from a second socket B arrives; the same through `WSAConnect` and with an `AF_UNSPEC` address and, on an IPv6 socket, with `[::]:0`. `0.0.0.0:4321` stays refused with `WSAENETUNREACH`, and on a TCP socket both forms fail with the host's error. - `main`: 9 of the 12 new checks fail. - this branch: 83 of 83 checks pass, in 3 of 3 runs. - `ctest -j 8` over the 168 CPU tests, with this branch and WS2-CONNECT-BY-NAME-V6 merged: all pass except `xmem_no_write_watch`, whose split-reader check is the start race #2131 fixes (it passes on its own). - `scripts/check_no_game_data.py` on both files. Not tested under Wine. This and WS2-CONNECT-BY-NAME-V6 both change `ws2_offline.cpp` and its test, in different places; they merge cleanly in either order. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
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.

Dependencies

No dependencies set

Reference
starred/leonida#2245
No description provided.