[PR #2840] fix(linux): preserve IPv4 interface host and prefix #2973

Open
opened 2026-10-14 21:06:36 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/2840
Author: @AI-andreevilay
Created: 7/17/2026
Status: 🔄 Open

Base: dev ← Head: fix/linux-ipv4-interface-address


📝 Commits (3)

  • 4d7ef1e fix(linux): preserve IPv4 interface host and prefix
  • 15bb0a6 fix(linux): avoid unchecked netlink attribute copy
  • 9ac9d45 test(linux): cover combined WireGuard addresses

📊 Changes

7 files changed (+217 additions, -22 deletions)

View changed files

📝 CMakeLists.txt (+2 -0)
📝 client/platforms/linux/daemon/iputilslinux.cpp (+110 -22)
➕ client/platforms/linux/daemon/ipv4interfaceaddress.cpp (+27 -0)
➕ client/platforms/linux/daemon/ipv4interfaceaddress.h (+21 -0)
📝 service/server/CMakeLists.txt (+6 -0)
➕ service/server/tests/CMakeLists.txt (+18 -0)
➕ service/server/tests/ipv4interfaceaddress_test.cpp (+33 -0)

📄 Description

Summary

  • preserve the configured IPv4 host address and prefix when configuring the Linux WireGuard interface
  • use an RTM_NEWADDR netlink request to set both IFA_LOCAL and IFA_ADDRESS
  • accept a comma-separated IPv4/IPv6 Address value and select the IPv4 entry

Problem

QHostAddress::parseSubnet() normalizes a host address to its network address, while the previous SIOCSIFADDR call did not set the configured prefix. This can leave amn0 with the wrong IPv4 address/prefix and require an external helper to repair it.

Validation

  • added a QtTest regression test proving that 10.8.0.4/24, 2001:db8::9e/128 preserves the IPv4 host 10.8.0.4 and prefix 24
  • built the Linux service with Ninja
  • exercised the netlink address operation in an isolated network namespace: 10.8.0.4/24 was retained as the interface address
  • manually connected a real WireGuard profile on Ubuntu 24.04 with Docker network interfaces present, with the helper disabled; the VPN connected and external egress was verified

Fixes #2048


🔄 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/amnezia-vpn/amnezia-client/pull/2840 **Author:** [@AI-andreevilay](https://github.com/AI-andreevilay) **Created:** 7/17/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/linux-ipv4-interface-address` --- ### 📝 Commits (3) - [`4d7ef1e`](https://github.com/amnezia-vpn/amnezia-client/commit/4d7ef1e98625e1f7d13f3565959646f979ec2740) fix(linux): preserve IPv4 interface host and prefix - [`15bb0a6`](https://github.com/amnezia-vpn/amnezia-client/commit/15bb0a64343f3bd72807fef86e9b5133135f8c1a) fix(linux): avoid unchecked netlink attribute copy - [`9ac9d45`](https://github.com/amnezia-vpn/amnezia-client/commit/9ac9d45f185ccc268e96073713be1735d2ea620a) test(linux): cover combined WireGuard addresses ### 📊 Changes **7 files changed** (+217 additions, -22 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+2 -0) 📝 `client/platforms/linux/daemon/iputilslinux.cpp` (+110 -22) ➕ `client/platforms/linux/daemon/ipv4interfaceaddress.cpp` (+27 -0) ➕ `client/platforms/linux/daemon/ipv4interfaceaddress.h` (+21 -0) 📝 `service/server/CMakeLists.txt` (+6 -0) ➕ `service/server/tests/CMakeLists.txt` (+18 -0) ➕ `service/server/tests/ipv4interfaceaddress_test.cpp` (+33 -0) </details> ### 📄 Description ## Summary - preserve the configured IPv4 host address and prefix when configuring the Linux WireGuard interface - use an RTM_NEWADDR netlink request to set both IFA_LOCAL and IFA_ADDRESS - accept a comma-separated IPv4/IPv6 Address value and select the IPv4 entry ## Problem QHostAddress::parseSubnet() normalizes a host address to its network address, while the previous SIOCSIFADDR call did not set the configured prefix. This can leave amn0 with the wrong IPv4 address/prefix and require an external helper to repair it. ## Validation - added a QtTest regression test proving that `10.8.0.4/24, 2001:db8::9e/128` preserves the IPv4 host `10.8.0.4` and prefix `24` - built the Linux service with Ninja - exercised the netlink address operation in an isolated network namespace: 10.8.0.4/24 was retained as the interface address - manually connected a real WireGuard profile on Ubuntu 24.04 with Docker network interfaces present, with the helper disabled; the VPN connected and external egress was verified Fixes #2048 --- <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
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
amnezia-vpn/amnezia-client#2973
No description provided.