[libvirt] [RFC PATCH] lxc: Up back the veth interfaces by default

Benjamin Cama b.cama at kerlink.fr
Thu Jan 11 17:08:58 UTC 2018

Upping an interface without configuring it is not a “cardinal sin” but a
sensible way to achieve auto-configuration, e.g. with IPv6 SLAAC (RFC
4862). If NetworkManager has troube with interfaces having only a
link-local address, this is a bug in NetworkManager, not in libvirt; it
should listen for router advertisements to decide if some interface has
global connectivity or not.

With network interfaces up by default, stateless containers can be
easily auto-configured through the network with SLAAC, without any
specific configuration from the host system.

This reverts commit c3cf3c43a0bb2e0e4909c32821e20f607635ec85.

Signed-off-by: Benjamin Cama <b.cama at kerlink.fr>

The patch that I propose to revert basically broke my workflow for light
stateless containers, where they could be auto-configured on IPv6-only network
through SLAAC. Of course, fully-fledged containers can bring up the interface
themselves, but this behavior had previously been the default for quite some
time, and is even indicated as default in src/conf/domain_conf.h ("Default link
state (up)").

I cannot find any real justification for the patch I am reverting, and the
bugzilla looks private so I can not comment on the NetworkManager behavior,
which looks very buggy to me.

Please tell me if you think this is wrong. Also, please Cc me, I am not


 .mailmap                |  1 +
 src/lxc/lxc_container.c |  7 +------
 src/lxc/lxc_native.c    | 10 ++++++----
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/.mailmap b/.mailmap
index 2f0fc901e..9dc3bff85 100644
--- a/.mailmap
+++ b/.mailmap
@@ -36,6 +36,7 @@
 <gerd at egidy.de> <lists at egidy.de>
 <gerd at egidy.de> <gerd.von.egidy at intra2net.com>
 <benoar at dolka.fr> <benjamin.cama at telecom-bretagne.eu>
+<benoar at dolka.fr> <b.cama at kerlink.fr>
 <zhlcindy at linux.vnet.ibm.com> <zhlcindy at gmail.com>
 <serge.hallyn at canonical.com> <serue at us.ibm.com>
 <pritesh.kothari at sun.com> <Pritesh.Kothari at Sun.COM>
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 96fceaf1b..e546f0aaf 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -517,12 +517,7 @@ lxcContainerRenameAndEnableInterfaces(virDomainDefPtr vmDef,
         if (virNetDevSetName(veths[i], newname) < 0)
             goto cleanup;
-        /* Only enable this device if there is a reason to do so (either
-         * at least one IP was specified, or link state was set to up in
-         * the config)
-         */
-        if (netDef->guestIP.nips ||
-            netDef->linkstate == VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP) {
+        if (netDef->linkstate != VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN) {
             VIR_DEBUG("Enabling %s", newname);
             if (virNetDevSetOnline(newname, true) < 0)
                 goto cleanup;
diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c
index fdc03a57e..f77a2a910 100644
--- a/src/lxc/lxc_native.c
+++ b/src/lxc/lxc_native.c
@@ -349,10 +349,12 @@ lxcCreateNetDef(const char *type,
     if (VIR_ALLOC(net) < 0)
         goto error;
-    if (STREQ_NULLABLE(flag, "up"))
-        net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
-    else
+    if (flag) {
+        if (STREQ(flag, "up"))
+            net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP;
+        else
+            net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN;
+    }
     if (VIR_STRDUP(net->ifname_guest, name) < 0)
         goto error;

More information about the libvir-list mailing list