]> git.ipfire.org Git - thirdparty/lxc.git/commit
network: use two passes through networks 3699/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Feb 2021 13:05:09 +0000 (14:05 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Feb 2021 14:12:40 +0000 (15:12 +0100)
commit3a197a1b63d010943fbc88c31d63c05b73f81682
tree660132d7517df57e16efdf63be72b7ff2b2f980f
parentfdd6be55c1f58ddcfde3443a49ea6884878b343e
network: use two passes through networks

Consider the following network layout:

 lxc.net.0.type = phys
 lxc.net.0.link = eth2
 lxc.net.0.name = eth%d

 lxc.net.1.type = phys
 lxc.net.1.link = eth1
 lxc.net.1.name = eth0

If we simply follow this order and create the first network first the kernel
will allocate eth0 for the first network but the second network requests
that eth1 be renamed to eth0 in the container's network namespace which
would lead to a clash.

Note, we don't handle cases like:

 lxc.net.0.type = phys
 lxc.net.0.link = eth2
 lxc.net.0.name = eth0

 lxc.net.1.type = phys
 lxc.net.1.link = eth1
 lxc.net.1.name = eth0

That'll brutally fail of course but there's nothing we can do about it. But
this can happen when e.g. a has the following LXD configuration:

devices:
  eth2:
    name: eth0
    nictype: physical
    parent: eth2
    type: nic
  eth3:
    name: eth0
    nictype: physical
    parent: eth3
    type: nic

in the container's config and the default profile has:

devices:
  eth0:
    name: eth0
    network: lxdbr0
    type: nic

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/network.c