34 wireguard peers result in invalid peer configuration
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
systemd (Ubuntu) |
Invalid
|
Undecided
|
Unassigned |
Bug Description
ubuntu server 18.04.3 LTS
systemd 237-3ubuntu10.31
wireguard 0.0.20191012-
We're using systemd-networkd to configure wireguard via wireguard.netdev and wireguard.network files in /etc/systemd/
When we include 34, 35, or 36 [WireGuardPeer] entries in the netdev file some peers are configured incorrectly. The affected peers seem to be related to the total number of peers (counting from 0 here):
33 peers: No issue
34 peers: Peer 1 and 2 fail
35 peers: Peer 2 and 3 fail
36 peers: Peer 3 and 4 fail
37 peers: No issue
In all cases peer 0 is functional. For an affected pair of peers A and B, peer A ends up with the allowed IP address range of peer B. Peer B ends up with no allowed IP addresses. This can be seen in the output of wg. The connections to both peers fail because of incorrect address range assignments.
We first encountered this issue in a production environment when we moved from 33 to 34 unique peers on each server. The issue was reproduced on 3 different physical servers with similar configuration by adding and removing peer 34.
The [WireGuardPeer] entries do not need to be unique to reproduce the issue. In my testing I used 6 distinct peers and then used 28 or more identical copies of a 7th peer. The results were the same.
In January 2019 a bug was reported that was also related to the number of wireguard peers, but the description seems sufficiently different from our case that I felt I should file a distinct bug report. Here's a link to that report in case I'm wrong about that:
https:/
On two systems with 33 peers I noticed that this shows up in dmesg after a reboot:
netlink: 'systemd-network': attribute type 5 has an invalid length.
These lines also show up whenever I run `sudo systemctl restart systemd-networkd` now. They didn't show up before the reboot.
This suggests that there may be issues I haven't noticed yet even with fewer than 34 peers. In our production environment not all of our peers are online all the time, so an issue affecting a few of them could go unnoticed.