Skip to content

Changing network address fails with "Network address space cannot fit all devices" even when possible #2176

@jakub-tldr

Description

@jakub-tldr

Description

Attempting to change the address of a WireGuard network results in error even though the new address is the same prefix length as the previous one and should accommodate the same number of devices.

Screen.Recording.2026-03-03.at.20.40.47.mov

Steps to Reproduce

  1. Create a WireGuard network with address 10.1.1.0/29 (8 addresses, 5 usable
    host slots)
  2. Connect a gateway to the network
  3. Create a user and add 5 devices to them — the network is now completely
    full
  4. Try to change the network address to another /29, e.g. 12.1.1.0/29

Cause (?)

let mut allowed_devices = location.get_allowed_devices(&mut *conn).await?;  // 5 user devices
let network_devices =
    Device::find_by_type_and_network(&mut *conn, DeviceType::Network, location.id).await?;
allowed_devices.extend(network_devices);  // + 1 gateway device = 6

let count = allowed_devices.len() + 3;   // 6 + 3 = 9
location.validate_network_size(count)?;  // 9 > 8 (size of /29) -> error

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Task.

Projects

Status

Ready to release

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions