[lxc-devel] [lxc/master] network: don't delete net devs we didn't create
brauner on Github
lxc-bot at linuxcontainers.org
Tue May 30 08:48:11 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 542 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170530/8b65711d/attachment.bin>
-------------- next part --------------
From 0d5fbdbba5b3ca471495ce1ffbced0aef3680167 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 30 May 2017 10:46:02 +0200
Subject: [PATCH] network: don't delete net devs we didn't create
When we didn't delete a net dev we should make sure that we don't delete it. We
can simply check whether we have index for it. If not, we didn't create it.
Closes #1600.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/conf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 85805f975..b65c4add8 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2873,7 +2873,8 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
return 0;
out_delete:
- lxc_netdev_delete_by_name(veth1);
+ if (netdev->ifindex != 0)
+ lxc_netdev_delete_by_name(veth1);
if (!netdev->priv.veth_attr.pair)
free(veth1);
free(veth2);
@@ -3201,7 +3202,7 @@ bool lxc_delete_network(struct lxc_handler *handler)
/* Explicitly delete host veth device to prevent lingering
* devices. We had issues in LXD around this.
*/
- if (netdev->type == LXC_NET_VETH && !am_unpriv()) {
+ if (netdev->ifindex != 0 && netdev->type == LXC_NET_VETH && !am_unpriv()) {
char *hostveth;
if (netdev->priv.veth_attr.pair) {
hostveth = netdev->priv.veth_attr.pair;
More information about the lxc-devel
mailing list