Restarting `systemd-networkd` looses unmanaged bridged parents

Bug #2036127 reported by Simon Déziel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

My home network comprises many VLANs managed by `systemd-networkd`/`netplan`. Those VLANs are then used as parent interfaces for LXD networks. Whenever `systemd-networkd` is restarted (i.e: post-update), my whole network breaks because all the unmanaged bridges lose their parent devices. Another way to see it is that `systemd-networkd` undoes the `master` setting of those VLAN devices.

Here is a simplified reproducer:

1. Create a `vlan1` device

$ lxc launch ubuntu:22.04 networkd-bug
Creating networkd-bug
Starting networkd-bug

$ lxc file push - networkd-bug/etc/netplan/99-vlan1.yaml << EOF
network:
  version: 2
  vlans:
    vlan1:
      id: 1
      link: eth0
EOF

$ lxc exec networkd-bug -- netplan apply

2. Manually create a bridge and join `vlan1` to it

$ lxc exec networkd-bug -- ip link add br0 type bridge
$ lxc exec networkd-bug -- ip link set vlan1 master br0
$ lxc exec networkd-bug -- ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: vlan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:16:3e:94:6e:47 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 42:b6:31:01:47:9a brd ff:ff:ff:ff:ff:ff
164: eth0@if165: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:16:3e:94:6e:47 brd ff:ff:ff:ff:ff:ff link-netnsid 0

3. Restart `systemd-networkd`

$ lxc exec networkd-bug -- systemctl restart systemd-networkd

4. Notice `vlan1` lost it's master config

$ lxc exec networkd-bug -- ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: vlan1@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:16:3e:94:6e:47 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 42:b6:31:01:47:9a brd ff:ff:ff:ff:ff:ff
164: eth0@if165: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:16:3e:94:6e:47 brd ff:ff:ff:ff:ff:ff link-netnsid 0

Ideally, `vlan1` should retain it's `master` setting and I wouldn't loose connectivity :)

Additional information:

# apt-cache policy systemd netplan.io iproute2
systemd:
  Installed: 249.11-0ubuntu3.9
  Candidate: 249.11-0ubuntu3.9
  Version table:
 *** 249.11-0ubuntu3.9 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     249.11-0ubuntu3.7 500
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
     249.11-0ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
netplan.io:
  Installed: 0.105-0ubuntu2~22.04.3
  Candidate: 0.105-0ubuntu2~22.04.3
  Version table:
 *** 0.105-0ubuntu2~22.04.3 500
        500 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     0.104-0ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
iproute2:
  Installed: 5.15.0-1ubuntu2
  Candidate: 5.15.0-1ubuntu2
  Version table:
 *** 5.15.0-1ubuntu2 500
        500 http://archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status

# lsb_release -rd
Description: Ubuntu 22.04.3 LTS
Release: 22.04
# uname -a
Linux networkd-bug 6.2.0-32-generic #32~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 18 10:40:13 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Revision history for this message
Nick Rosbrook (enr0n) wrote :

You have a couple options here. I think simplest would be to just add:

bridges:
  br0:
    interfaces: [vlan1]

to your netplan config. This will generate /run/systemd/network/10-netplan-vlan1.network with:

[Match]
Name=vlan1

[Network]
LinkLocalAddressing=no
ConfigureWithoutCarrier=yes
Bridge=br0

so the master will be configured correctly. Otherwise, you could add a drop-in configuration for vlan1 to set KeepMaster=true (I don't know if netplan has something for this)[1].

Either way, I do not think this is a bug.

[1] https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html#KeepMaster=

Changed in systemd (Ubuntu):
status: New → Invalid
Revision history for this message
Nick Rosbrook (enr0n) wrote :

The drop-in would apply to vlan1, e.g.:

$ mkdir -p /etc/systemd/network/10-netplan-vlan1.network.d
$ cat > /etc/systemd/network/10-netplan-vlan1.network.d/keep_master.conf << EOF
[Network]
KeepMaster=true
EOF

Again, if netplan has a setting equivalent to KeepMaster=, that would be simpler. I just don't know netplan well enough.

Revision history for this message
Simon Déziel (sdeziel) wrote :

@enr0n, the proposal to add:

bridges:
  br0:
    interfaces: [vlan1]

To the network config defeats the purpose. The goal is to not have to do double configuration. The bridge is define in LXD, the vlan1 only in netplan.

The other proposed fix of `KeepMaster=true` snippet in /etc/systemd/network/10-netplan-vlan1.network.d/keep_master.conf didn't work for me. I also tried putting it in 99-netplan-vlan1.network.d to match the name of my netplan .yaml but still didn't work.

root@networkd-bug:~# cat /etc/netplan/99-vlan1.yaml
network:
  version: 2
  vlans:
    vlan1:
      id: 1
      link: eth0

root@networkd-bug:~# cat /etc/systemd/network/99-netplan-vlan1.network.d/keep_master.conf
[Network]
KeepMaster=true

root@networkd-bug:~# grep -n . /run/systemd/network/*vlan1*
/run/systemd/network/10-netplan-vlan1.netdev:1:[NetDev]
/run/systemd/network/10-netplan-vlan1.netdev:2:Name=vlan1
/run/systemd/network/10-netplan-vlan1.netdev:3:Kind=vlan
/run/systemd/network/10-netplan-vlan1.netdev:5:[VLAN]
/run/systemd/network/10-netplan-vlan1.netdev:6:Id=1
/run/systemd/network/10-netplan-vlan1.network:1:[Match]
/run/systemd/network/10-netplan-vlan1.network:2:Name=vlan1
/run/systemd/network/10-netplan-vlan1.network:4:[Network]
/run/systemd/network/10-netplan-vlan1.network:5:LinkLocalAddressing=ipv6
/run/systemd/network/10-netplan-vlan1.network:6:ConfigureWithoutCarrier=yes

Revision history for this message
Nick Rosbrook (enr0n) wrote :

This path is wrong: /etc/systemd/network/99-netplan-vlan1.network.d/keep_master.conf. It should in fact be etc/systemd/network/10-netplan-vlan1.network.d/keep_master.conf.

Did you restart systemd-networkd afterward?

Revision history for this message
Simon Déziel (sdeziel) wrote (last edit ):

@enr0n, yes, I did restart systemd-networkd after creating /etc/systemd/network/10-netplan-vlan1.network.d/keep_master.conf.

If you want to reproduce, the steps outlined in the bug description should provide you with a simple reproducer.

Revision history for this message
Nick Rosbrook (enr0n) wrote :

Ah I'm sorry - KeepMaster= was not added until v250. I must have tested that on Noble.

For jammy, I think the best solution is to add the snippet I suggested to your netplan config. Your opposition to it sounds mostly ideological. I'm sorry it's not ideal, but it seems like a valid workaround to me.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.