]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
pass on reboot flag and delete old veth on reboot
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Jul 2015 05:33:08 +0000 (07:33 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 28 Aug 2015 22:05:37 +0000 (18:05 -0400)
When setting lxc.network.veth.pair to get a fixed interface
name the recreation of it after a reboot caused an EEXIST.
-) The reboot flag is now a three-state value. It's set to
1 to request a reboot, and 2 during a reboot until after
lxc_spawn where it is reset to 0.
-) If the reboot is set (!= 0) within instantiate_veth and
a fixed name is used, the interface is now deleted before
being recreated.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c
src/lxc/lxccontainer.c
src/lxc/start.c

index c69cd65c1be7a7ac92c3c290e37b2fb0b202ab1a..a7e0d7122fcd2ed28c46c2dc1e5b9bacd4e3c199 100644 (file)
@@ -2921,9 +2921,11 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
        char veth2buf[IFNAMSIZ], *veth2;
        int err;
 
-       if (netdev->priv.veth_attr.pair)
+       if (netdev->priv.veth_attr.pair) {
                veth1 = netdev->priv.veth_attr.pair;
-       else {
+               if (handler->conf->reboot)
+                       lxc_netdev_delete_by_name(veth1);
+       } else {
                err = snprintf(veth1buf, sizeof(veth1buf), "vethXXXXXX");
                if (err >= sizeof(veth1buf)) { /* can't *really* happen, but... */
                        ERROR("veth1 name too long");
index ec146eed4f640477d6b59fc15c39ca17eae31650..92523116dfd522f5e2f9add14a9af94d51ee900c 100644 (file)
@@ -661,14 +661,15 @@ static bool lxcapi_start(struct lxc_container *c, int useinit, char * const argv
                pid_fp = NULL;
        }
 
-reboot:
        conf->reboot = 0;
+
+reboot:
        ret = lxc_start(c->name, argv, conf, c->config_path);
        c->error_num = ret;
 
-       if (conf->reboot) {
+       if (conf->reboot == 1) {
                INFO("container requested reboot");
-               conf->reboot = 0;
+               conf->reboot = 2;
                goto reboot;
        }
 
index 64debc90c0c9657191a1a6a3e3a198c6bed1cb3a..3ac6409820ab86999f2733c9f640a5b68d61fb82 100644 (file)
@@ -1081,6 +1081,8 @@ int __lxc_start(const char *name, struct lxc_conf *conf,
                goto out_fini_nonet;
        }
 
+       handler->conf->reboot = 0;
+
        netnsfd = get_netns_fd(handler->pid);
 
        err = lxc_poll(name, handler);