lxd

Comment 24 for bug 1991552

Revision history for this message
Thomas Parrott (tomparrott) wrote :

I've been looking into this today and have come across some relevant links which I suspect explain the issue.

I suspect it is the change to systemd-networkd that adds a default link policy of:

`MACAddressPolicy=persistent`

Which would apply to new veth interfaces created.

See:

https://bugzilla.suse.com/show_bug.cgi?id=1136600
https://github.com/systemd/systemd/issues/25555
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/15#note_162509
https://github.com/moby/libnetwork/pull/2380

Specifically the last one was key:

> We set the address before udev gets to the networking rules, so udev
sees /sys/devices/virtual/net/docker0/addr_assign_type = 3
(NET_ADDR_SET). This means there's no need to assign a different
address and everything is fine.

This got me thinking that if we can set the MAC address at the same time the interface is created (in one operation) then this might prevent systemd-udevd from thinking it needs to generate and apply a persistent MAC address.

I've figured out how to update LXD's use of `ip link add` command to apply the MAC, MTU, and other settings directly in a single execution rather than calling `ip link add` first to create the veth pairs, and then subsequently calling `ip link set` afterwards.

Hopefully this should be sufficient to ensure that systemd-udevd always sees the veth interfaces created by LXD as having a manually set MAC address and will leave them alone.

https://github.com/lxc/lxd/pull/11399