feat(libwebrtc): implement four rtc::NetworkManagerBase address helpers #24668

Merged
Callimann8 merged 3 commits from upstream-pr/24668 into main 2026-11-24 14:12:36 +00:00
Callimann8 commented 2026-11-20 22:53:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Callimann8 on 2026-11-20T22:53:46Z.


What

Implements four rtc::NetworkManagerBase exports of libwebrtc that threw NotImplemented:

  • enumeration_permission() const (McIeA-8x1V0)
  • set_default_local_addresses(const IPAddress&, const IPAddress&) (YasEM+qA8is)
  • GetDefaultLocalAddress(int, IPAddress*) const (0Y6e9BZKB6Y)
  • GetNetworkFromAddress(const IPAddress&) const (O1-Pt00dDLQ)

They follow network.cc at M134. The new include/NetworkManager.hpp gives the layouts from network.h, with libc++ containers and the bundled sigslot.h, whose default policy is single_threaded (56-byte signals): NetworkManagerBase is 272 bytes with enumeration_permission_ at 128, networks_ at 136 and the default IPv4/IPv6 addresses at 200 and 232. Network has prefix_ at 176 and ips_ at 240, and InterfaceAddress keeps ipv6_flags_ in the tail padding of IPAddress at 28.

  • set_default_local_addresses stores each address only when its family matches (AF_INET, AF_INET6).
  • GetDefaultLocalAddress returns false for a nil default. For IPv6 it returns the best address of the network that holds the default one, following Network::GetBestIP (skips deprecated addresses, prefers a temporary global, then link-local, then ULA), or the default itself when no network holds it.
  • GetNetworkFromAddress walks networks_ and their ips_ with the existing IPAddress::operator==.

Address copies write the family and address and leave the destination vtable alone, as IPAddress::operator= does. A null manager, or a null address that upstream would read or write, throws. A debt fragment records the layout assumptions.

Tested

  • guest_webrtc_network_manager gains TestDefaultLocalAddresses and TestNetworkFromAddress: permission read, family filtering, untouched vtables, nil defaults, network lookup (IPv4 bytes that match an IPv6 entry don't match), each GetBestIP branch (temporary, global, link-local, ULA, IPv4 prefix, all deprecated), the unknown-network fallback and the null-argument throws.
  • Linux, GCC 13: guest_webrtc_network_manager passes in a Release build and in an ASan + UBSan build (ANYPS5_ENABLE_ASAN=ON, -fsanitize=undefined).
  • Not tested on a title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5421437306 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24668). Originally posted by [Callimann8](https://github.com/Callimann8) on 2026-11-20T22:53:46Z. --- ### What Implements four `rtc::NetworkManagerBase` exports of libwebrtc that threw `NotImplemented`: - `enumeration_permission() const` (`McIeA-8x1V0`) - `set_default_local_addresses(const IPAddress&, const IPAddress&)` (`YasEM+qA8is`) - `GetDefaultLocalAddress(int, IPAddress*) const` (`0Y6e9BZKB6Y`) - `GetNetworkFromAddress(const IPAddress&) const` (`O1-Pt00dDLQ`) They follow [network.cc](https://webrtc.googlesource.com/src/+/8d78f5de6c27b2c793039989ea381f1428fb0100/rtc_base/network.cc) at M134. The new `include/NetworkManager.hpp` gives the layouts from `network.h`, with libc++ containers and the bundled `sigslot.h`, whose default policy is `single_threaded` (56-byte signals): `NetworkManagerBase` is 272 bytes with `enumeration_permission_` at 128, `networks_` at 136 and the default IPv4/IPv6 addresses at 200 and 232. `Network` has `prefix_` at 176 and `ips_` at 240, and `InterfaceAddress` keeps `ipv6_flags_` in the tail padding of `IPAddress` at 28. - `set_default_local_addresses` stores each address only when its family matches (`AF_INET`, `AF_INET6`). - `GetDefaultLocalAddress` returns false for a nil default. For IPv6 it returns the best address of the network that holds the default one, following `Network::GetBestIP` (skips deprecated addresses, prefers a temporary global, then link-local, then ULA), or the default itself when no network holds it. - `GetNetworkFromAddress` walks `networks_` and their `ips_` with the existing `IPAddress::operator==`. Address copies write the family and address and leave the destination vtable alone, as `IPAddress::operator=` does. A null manager, or a null address that upstream would read or write, throws. A debt fragment records the layout assumptions. ### Tested - `guest_webrtc_network_manager` gains `TestDefaultLocalAddresses` and `TestNetworkFromAddress`: permission read, family filtering, untouched vtables, nil defaults, network lookup (IPv4 bytes that match an IPv6 entry don't match), each `GetBestIP` branch (temporary, global, link-local, ULA, IPv4 prefix, all deprecated), the unknown-network fallback and the null-argument throws. - Linux, GCC 13: `guest_webrtc_network_manager` passes in a Release build and in an ASan + UBSan build (`ANYPS5_ENABLE_ASAN=ON`, `-fsanitize=undefined`). - Not tested on a title. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) and the licence notice of code adapted from upstream (see AGENTS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-20 23:47:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T23:47:16Z.

Review: APPROVED


Reviewed — looks good

No verified blocking defect was found in the six changed files; the console layout remains explicitly unverified.

What I ran

  • Reviewed head 4f5db69dc38149969c84b468eebe15fdb89ec39c using the prepared diff and reader repo_read.py.
  • No build or test command was run in this review; the reported Linux test runs are author-reported.
  • Read: core/libs/prx/libwebrtc/Export.cpp (diff only), core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/include/NetworkManager.hpp, core/libs/prx/libwebrtc/src/NetworkManager.cpp, core/libs/prx/libwebrtc/tests/NetworkManager.cpp (diff only), docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md (diff only), and core/libs/prx/libwebrtc/include/IpAddress.hpp, core/libs/prx/libwebrtc/src/IpAddress.cpp for context. All six changed files were included in the review bundle.

Results

Check Result Note
Diff and targeted source review passed Six changed files reviewed
Build and tests in this review not run Linux runs are author-reported
Console layout and title behavior not run Debt record says layout awaits console comparison

Findings

Blocking

None.

Non-blocking

  • The layout assumptions underpin every field access in NetworkManager.hpp; the debt record correctly tracks that they still need comparison against the console. Record that validation when available. This is a follow-up, not a verified defect in the reviewed code.

Not verified

  • I did not run the reported Linux Release or ASan/UBSan tests or validate their output.
  • Console ABI/layout and title behavior were not verified.
  • Export.cpp and the added tests were inspected through the diff only; unchanged surrounding lines were not read.

To get this to a good state

Nothing is required. Optional: compare the layout assumptions with the console and update the debt record with the result.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6000932667 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24668#pullrequestreview-6000932667). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T23:47:16Z. **Review:** APPROVED --- # Reviewed — looks good No verified blocking defect was found in the six changed files; the console layout remains explicitly unverified. ## What I ran - Reviewed head `4f5db69dc38149969c84b468eebe15fdb89ec39c` using the prepared diff and reader `repo_read.py`. - No build or test command was run in this review; the reported Linux test runs are author-reported. - Read: `core/libs/prx/libwebrtc/Export.cpp` (diff only), `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/include/NetworkManager.hpp`, `core/libs/prx/libwebrtc/src/NetworkManager.cpp`, `core/libs/prx/libwebrtc/tests/NetworkManager.cpp` (diff only), `docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md` (diff only), and `core/libs/prx/libwebrtc/include/IpAddress.hpp`, `core/libs/prx/libwebrtc/src/IpAddress.cpp` for context. All six changed files were included in the review bundle. ## Results | Check | Result | Note | |---|---|---| | Diff and targeted source review | passed | Six changed files reviewed | | Build and tests in this review | not run | Linux runs are author-reported | | Console layout and title behavior | not run | Debt record says layout awaits console comparison | ## Findings ### Blocking None. ### Non-blocking - The layout assumptions underpin every field access in `NetworkManager.hpp`; the debt record correctly tracks that they still need comparison against the console. Record that validation when available. This is a follow-up, not a verified defect in the reviewed code. ## Not verified - I did not run the reported Linux Release or ASan/UBSan tests or validate their output. - Console ABI/layout and title behavior were not verified. - `Export.cpp` and the added tests were inspected through the diff only; unchanged surrounding lines were not read. ## To get this to a good state Nothing is required. Optional: compare the layout assumptions with the console and update the debt record with the result.
MarcZX10 commented 2026-11-20 23:55:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T23:55:47Z.

Review: COMMENTED


Reviewed — comments

Changes are not ready for a formal decision because the IPv6 address selection logic does not match the documented upstream selection behavior.

What I ran

Reviewed head 9f16f5b9344b2426736012ac5e80423acfd62a34. No commands or tests were run; this review used the prepared diff and pinned repository reader.

Results

Check Result Note
Changed code review passed All six changed files read
Tests not run Author reports Linux GCC 13 runs
Console behavior not run Description says no title test

Findings

Blocking

None.

Non-blocking

  • BestIp can replace an earlier ULA with a later one, and returns the last matching link-local/ULA address. Upstream Network::GetBestIP retains the first candidate in each category, so a network with multiple candidate addresses can return a different result. Preserve the first link-local and ULA candidates (for example, assign them only when their stored pointer is null). core/libs/prx/libwebrtc/src/NetworkManager.cpp:93

Sources

Behavior is implemented in NetworkManager.cpp at the reviewed head; equality used for address lookup compares families and address bytes in IpAddress.cpp.

Not verified

No test commands, build, sanitizer run, or console/title behavior were verified. The description reports successful Linux GCC 13 Release and ASan/UBSan test runs, but those results were not independently checked. All six files marked reviewed in manifest.json were read: Export.cpp, include/Api.hpp, include/NetworkManager.hpp, src/NetworkManager.cpp, tests/NetworkManager.cpp, and docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md. No changed files were excluded.

To get this to a good state

Nothing is required. Optional: retain the first link-local and ULA candidates to match upstream selection behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6000998235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24668#pullrequestreview-6000998235). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T23:55:47Z. **Review:** COMMENTED --- # Reviewed — comments Changes are not ready for a formal decision because the IPv6 address selection logic does not match the documented upstream selection behavior. ## What I ran Reviewed head `9f16f5b9344b2426736012ac5e80423acfd62a34`. No commands or tests were run; this review used the prepared diff and pinned repository reader. ## Results | Check | Result | Note | |---|---|---| | Changed code review | passed | All six changed files read | | Tests | not run | Author reports Linux GCC 13 runs | | Console behavior | not run | Description says no title test | ## Findings ### Blocking None. ### Non-blocking - `BestIp` can replace an earlier ULA with a later one, and returns the last matching link-local/ULA address. Upstream `Network::GetBestIP` retains the first candidate in each category, so a network with multiple candidate addresses can return a different result. Preserve the first link-local and ULA candidates (for example, assign them only when their stored pointer is null). `core/libs/prx/libwebrtc/src/NetworkManager.cpp:93` ## Sources Behavior is implemented in `NetworkManager.cpp` at the reviewed head; equality used for address lookup compares families and address bytes in `IpAddress.cpp`. ## Not verified No test commands, build, sanitizer run, or console/title behavior were verified. The description reports successful Linux GCC 13 Release and ASan/UBSan test runs, but those results were not independently checked. All six files marked reviewed in `manifest.json` were read: `Export.cpp`, `include/Api.hpp`, `include/NetworkManager.hpp`, `src/NetworkManager.cpp`, `tests/NetworkManager.cpp`, and `docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md`. No changed files were excluded. ## To get this to a good state Nothing is required. Optional: retain the first link-local and ULA candidates to match upstream selection behavior.
PrivacyOnion commented 2026-11-21 01:13:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-21T01:13:13Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9f16f5b934:

  • Conventions: tools/check_conventions.py passed.
  • Build: guest_webrtc_network_manager_tests built cleanly.
  • CTest (guest_webrtc_network_manager):
    1/1 Test #6109: guest_webrtc_network_manager .....   Passed    0.01 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libwebrtc/Export.cpp, core/libs/prx/libwebrtc/include/Api.hpp, core/libs/prx/libwebrtc/src/NetworkManager.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • core/libs/prx/libwebrtc/src/NetworkManager.cpp: CheckedManager and pointer validation on all exports (enumeration_permission, set_default_local_addresses, GetDefaultLocalAddress, GetNetworkFromAddress) properly throw std::invalid_argument on null pointers
    • core/libs/prx/libwebrtc/src/NetworkManager.cpp: BestIp IPv6 candidate selection correctly filters Ipv6AddressFlagDeprecated, prioritizes temporary global IP, and falls back to link-local and ULA candidates
    • core/libs/prx/libwebrtc/include/NetworkManager.hpp: struct layouts and static_assert field offsets for WebRtcSigslotSignal, WebRtcInterfaceAddress, WebRtcNetwork, and WebRtcNetworkManagerBase match x86_64 ABI specifications
    • core/libs/prx/libwebrtc/src/NetworkManager.cpp: AssignAddress safely updates family and in6_addr payload without overwriting the guest vtable pointer
    • docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md: Debt fragment properly documents console layout verification status according to AGENTS.md

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6001664098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/24668#pullrequestreview-6001664098). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-21T01:13:13Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `9f16f5b934`: - **Conventions**: `tools/check_conventions.py` passed. - **Build**: `guest_webrtc_network_manager_tests` built cleanly. - **CTest** (`guest_webrtc_network_manager`): ``` 1/1 Test #6109: guest_webrtc_network_manager ..... Passed 0.01 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libwebrtc/Export.cpp`, `core/libs/prx/libwebrtc/include/Api.hpp`, `core/libs/prx/libwebrtc/src/NetworkManager.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - core/libs/prx/libwebrtc/src/NetworkManager.cpp: CheckedManager and pointer validation on all exports (enumeration_permission, set_default_local_addresses, GetDefaultLocalAddress, GetNetworkFromAddress) properly throw std::invalid_argument on null pointers - core/libs/prx/libwebrtc/src/NetworkManager.cpp: BestIp IPv6 candidate selection correctly filters Ipv6AddressFlagDeprecated, prioritizes temporary global IP, and falls back to link-local and ULA candidates - core/libs/prx/libwebrtc/include/NetworkManager.hpp: struct layouts and static_assert field offsets for WebRtcSigslotSignal, WebRtcInterfaceAddress, WebRtcNetwork, and WebRtcNetworkManagerBase match x86_64 ABI specifications - core/libs/prx/libwebrtc/src/NetworkManager.cpp: AssignAddress safely updates family and in6_addr payload without overwriting the guest vtable pointer - docs/dev/debt/changes/feat-libwebrtc-network-manager-base.md: Debt fragment properly documents console layout verification status according to AGENTS.md Looks Good To Me
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
boykopovar/AnyPS5!24668
No description provided.